First round of support for doing scalar FP using the SSE2 ISA extension and
[oota-llvm.git] / lib / Target / TargetMachine.cpp
1 //===-- TargetMachine.cpp - General Target Information ---------------------==//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file describes the general parts of a Target machine.
11 //
12 //===----------------------------------------------------------------------===//
13
14 #include "llvm/Target/TargetMachine.h"
15 #include "llvm/Type.h"
16 #include "llvm/CodeGen/IntrinsicLowering.h"
17 #include "llvm/Support/CommandLine.h"
18 using namespace llvm;
19
20 //---------------------------------------------------------------------------
21 // Command-line options that tend to be useful on more than one back-end.
22 //
23
24 namespace llvm {
25   bool PrintMachineCode;
26   bool NoFramePointerElim;
27   bool NoExcessFPPrecision;
28   int  PatternISelTriState;
29   bool UnsafeFPMath;
30   bool PICEnabled;
31 };
32 namespace {
33   cl::opt<bool, true> PrintCode("print-machineinstrs",
34     cl::desc("Print generated machine code"),
35     cl::location(PrintMachineCode), cl::init(false));
36
37   cl::opt<bool, true>
38     DisableFPElim("disable-fp-elim",
39                   cl::desc("Disable frame pointer elimination optimization"),
40                   cl::location(NoFramePointerElim),
41                   cl::init(false));
42   cl::opt<bool, true>
43   DisableExcessPrecision("disable-excess-fp-precision",
44                cl::desc("Disable optimizations that may increase FP precision"),
45                cl::location(NoExcessFPPrecision),
46                cl::init(false));
47   cl::opt<int, true> PatternISel("enable-pattern-isel",
48                     cl::desc("Turn the pattern ISel off(0), on(1), default(2)"),
49                     cl::location(PatternISelTriState),
50                     cl::init(2));
51   cl::opt<bool, true>
52   EnableUnsafeFPMath("enable-unsafe-fp-math",
53                cl::desc("Enable optimizations that may decrease FP precision"),
54                cl::location(UnsafeFPMath),
55                cl::init(false));
56   cl::opt<bool, true>
57   EnablePIC("enable-pic",
58                cl::desc("Enable generation of position independant code"),
59                cl::location(PICEnabled),
60                cl::init(false));
61 };
62
63 //---------------------------------------------------------------------------
64 // TargetMachine Class
65 //
66 TargetMachine::TargetMachine(const std::string &name, IntrinsicLowering *il,
67                              bool LittleEndian,
68                              unsigned char PtrSize, unsigned char PtrAl,
69                              unsigned char DoubleAl, unsigned char FloatAl,
70                              unsigned char LongAl, unsigned char IntAl,
71                              unsigned char ShortAl, unsigned char ByteAl,
72                              unsigned char BoolAl)
73   : Name(name), DataLayout(name, LittleEndian,
74                            PtrSize, PtrAl, DoubleAl, FloatAl, LongAl,
75                            IntAl, ShortAl, ByteAl, BoolAl) {
76   IL = il ? il : new DefaultIntrinsicLowering();
77 }
78
79 TargetMachine::TargetMachine(const std::string &name, IntrinsicLowering *il,
80                              const TargetData &TD)
81   : Name(name), DataLayout(TD) {
82   IL = il ? il : new DefaultIntrinsicLowering();
83 }
84
85 TargetMachine::TargetMachine(const std::string &name, IntrinsicLowering *il,
86                              const Module &M)
87   : Name(name), DataLayout(name, &M) {
88   IL = il ? il : new DefaultIntrinsicLowering();
89 }
90
91 TargetMachine::~TargetMachine() {
92   delete IL;
93 }
94