Direct declaration of namespace-ified globals does not work, must enclose
[oota-llvm.git] / lib / Target / TargetMachine.cpp
index 30199be06ae08931d34b1702514ba064cdda7a57..d71bd3f9542f0bdbf0f710297c0d7720ff37eb49 100644 (file)
 
 #include "llvm/Target/TargetMachine.h"
 #include "llvm/Type.h"
-#include "llvm/IntrinsicLowering.h"
+#include "llvm/CodeGen/IntrinsicLowering.h"
+#include "Support/CommandLine.h"
 using namespace llvm;
 
+//---------------------------------------------------------------------------
+// Command-line options that tend to be useful on more than one back-end.
+//
+
+namespace llvm {
+  bool PrintMachineCode;
+  bool NoFramePointerElim;
+};
+namespace {
+  cl::opt<bool, true> PrintCode("print-machineinstrs",
+    cl::desc("Print generated machine code"),
+    cl::location(PrintMachineCode), cl::init(false));
+
+  cl::opt<bool, true> 
+    DisableFPElim("disable-fp-elim",
+                  cl::desc("Disable frame pointer elimination optimization"),
+                  cl::location(NoFramePointerElim),
+                  cl::init(false));
+};
+
 //---------------------------------------------------------------------------
 // TargetMachine Class
 //
@@ -30,15 +51,13 @@ TargetMachine::TargetMachine(const std::string &name, IntrinsicLowering *il,
                            IntAl, ShortAl, ByteAl) {
   IL = il ? il : new DefaultIntrinsicLowering();
 }
+TargetMachine::TargetMachine(const std::string &name, IntrinsicLowering *il,
+                             const Module &M)
+  : Name(name), DataLayout(name, &M) {
+  IL = il ? il : new DefaultIntrinsicLowering();
+}
 
 TargetMachine::~TargetMachine() {
   delete IL;
 }
 
-unsigned TargetMachine::findOptimalStorageSize(const Type *Ty) const {
-  // All integer types smaller than ints promote to 4 byte integers.
-  if (Ty->isIntegral() && Ty->getPrimitiveSize() < 4)
-    return 4;
-
-  return DataLayout.getTypeSize(Ty);
-}