blob: b6bab7297632ace1ccd88395ca8b51fac76fda82 [file] [log] [blame]
Chris Lattner22a6a902001-09-14 05:34:53 +00001//===-- TargetMachine.cpp - General Target Information ---------------------==//
Misha Brukman10468d82005-04-21 22:55:34 +00002//
John Criswell482202a2003-10-20 19:43:21 +00003// 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.
Misha Brukman10468d82005-04-21 22:55:34 +00007//
John Criswell482202a2003-10-20 19:43:21 +00008//===----------------------------------------------------------------------===//
Chris Lattner22a6a902001-09-14 05:34:53 +00009//
10// This file describes the general parts of a Target machine.
11//
12//===----------------------------------------------------------------------===//
Vikram S. Adve3414e782001-07-21 12:42:08 +000013
Misha Brukman0bfea682004-06-21 21:20:23 +000014#include "llvm/Target/TargetMachine.h"
Chris Lattner910b82f2002-10-28 23:55:33 +000015#include "llvm/Type.h"
Chris Lattnerbcdadf32004-06-20 07:49:54 +000016#include "llvm/CodeGen/IntrinsicLowering.h"
Reid Spencer7c16caa2004-09-01 22:55:40 +000017#include "llvm/Support/CommandLine.h"
Chris Lattner5d236002003-12-28 21:23:38 +000018using namespace llvm;
Brian Gaeke960707c2003-11-11 22:41:34 +000019
Vikram S. Adve36d3e032002-09-16 15:39:26 +000020//---------------------------------------------------------------------------
Brian Gaeke8351d8c2004-03-04 19:16:23 +000021// Command-line options that tend to be useful on more than one back-end.
22//
23
Misha Brukman96041e52004-06-21 21:44:12 +000024namespace llvm {
25 bool PrintMachineCode;
26 bool NoFramePointerElim;
Chris Lattner9de58902005-01-15 06:00:32 +000027 bool NoExcessFPPrecision;
Nate Begeman779c5cb2005-04-15 22:12:16 +000028 int PatternISelTriState;
Chris Lattner4a2cc662005-04-30 04:09:52 +000029 bool UnsafeFPMath;
Misha Brukman96041e52004-06-21 21:44:12 +000030};
Brian Gaeke8351d8c2004-03-04 19:16:23 +000031namespace {
32 cl::opt<bool, true> PrintCode("print-machineinstrs",
33 cl::desc("Print generated machine code"),
34 cl::location(PrintMachineCode), cl::init(false));
Misha Brukman069ca062004-06-21 21:08:45 +000035
Misha Brukman10468d82005-04-21 22:55:34 +000036 cl::opt<bool, true>
Misha Brukman069ca062004-06-21 21:08:45 +000037 DisableFPElim("disable-fp-elim",
38 cl::desc("Disable frame pointer elimination optimization"),
Misha Brukmanc22299d2004-06-21 21:17:44 +000039 cl::location(NoFramePointerElim),
40 cl::init(false));
Chris Lattner9de58902005-01-15 06:00:32 +000041 cl::opt<bool, true>
42 DisableExcessPrecision("disable-excess-fp-precision",
Nate Begeman779c5cb2005-04-15 22:12:16 +000043 cl::desc("Disable optimizations that may increase FP precision"),
44 cl::location(NoExcessFPPrecision),
45 cl::init(false));
46 cl::opt<int, true> PatternISel("enable-pattern-isel",
47 cl::desc("sets the pattern ISel off(0), on(1), default(2)"),
48 cl::location(PatternISelTriState),
49 cl::init(2));
Chris Lattner4a2cc662005-04-30 04:09:52 +000050 cl::opt<bool, true>
51 EnableUnsafeFPMath("enable-unsafe-fp-math",
52 cl::desc("Enable optimizations that may decrease FP precision"),
53 cl::location(UnsafeFPMath),
54 cl::init(false));
Brian Gaeke8351d8c2004-03-04 19:16:23 +000055};
56
57//---------------------------------------------------------------------------
Chris Lattner5d236002003-12-28 21:23:38 +000058// TargetMachine Class
59//
60TargetMachine::TargetMachine(const std::string &name, IntrinsicLowering *il,
61 bool LittleEndian,
62 unsigned char PtrSize, unsigned char PtrAl,
63 unsigned char DoubleAl, unsigned char FloatAl,
64 unsigned char LongAl, unsigned char IntAl,
Misha Brukman3faa8652004-07-23 01:09:52 +000065 unsigned char ShortAl, unsigned char ByteAl,
66 unsigned char BoolAl)
Chris Lattner5d236002003-12-28 21:23:38 +000067 : Name(name), DataLayout(name, LittleEndian,
68 PtrSize, PtrAl, DoubleAl, FloatAl, LongAl,
Misha Brukman3faa8652004-07-23 01:09:52 +000069 IntAl, ShortAl, ByteAl, BoolAl) {
Chris Lattner5d236002003-12-28 21:23:38 +000070 IL = il ? il : new DefaultIntrinsicLowering();
71}
Misha Brukman3decf862004-08-10 23:10:25 +000072
73TargetMachine::TargetMachine(const std::string &name, IntrinsicLowering *il,
74 const TargetData &TD)
75 : Name(name), DataLayout(TD) {
76 IL = il ? il : new DefaultIntrinsicLowering();
77}
78
Chris Lattner87ed2a42004-03-03 02:12:47 +000079TargetMachine::TargetMachine(const std::string &name, IntrinsicLowering *il,
80 const Module &M)
81 : Name(name), DataLayout(name, &M) {
82 IL = il ? il : new DefaultIntrinsicLowering();
83}
Vikram S. Adve3414e782001-07-21 12:42:08 +000084
Chris Lattner5d236002003-12-28 21:23:38 +000085TargetMachine::~TargetMachine() {
86 delete IL;
87}
88