blob: 90f10c1fccb1cb526c0cd7216a96ad7cf54409d0 [file] [log] [blame]
Chris Lattnerb26bcc52001-09-14 05:34:53 +00001//===-- TargetMachine.cpp - General Target Information ---------------------==//
Misha Brukmanf976c852005-04-21 22:55:34 +00002//
John Criswellb576c942003-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 Brukmanf976c852005-04-21 22:55:34 +00007//
John Criswellb576c942003-10-20 19:43:21 +00008//===----------------------------------------------------------------------===//
Chris Lattnerb26bcc52001-09-14 05:34:53 +00009//
10// This file describes the general parts of a Target machine.
11//
12//===----------------------------------------------------------------------===//
Vikram S. Advedaae6992001-07-21 12:42:08 +000013
Misha Brukmane67d5fb2004-06-21 21:20:23 +000014#include "llvm/Target/TargetMachine.h"
Chris Lattner93fa7052002-10-28 23:55:33 +000015#include "llvm/Type.h"
Chris Lattner30483732004-06-20 07:49:54 +000016#include "llvm/CodeGen/IntrinsicLowering.h"
Reid Spencer551ccae2004-09-01 22:55:40 +000017#include "llvm/Support/CommandLine.h"
Chris Lattnerf70e0c22003-12-28 21:23:38 +000018using namespace llvm;
Brian Gaeked0fde302003-11-11 22:41:34 +000019
Vikram S. Advee1f72802002-09-16 15:39:26 +000020//---------------------------------------------------------------------------
Brian Gaeke323819e2004-03-04 19:16:23 +000021// Command-line options that tend to be useful on more than one back-end.
22//
23
Misha Brukmanf90e4022004-06-21 21:44:12 +000024namespace llvm {
25 bool PrintMachineCode;
26 bool NoFramePointerElim;
Chris Lattner45554a62005-01-15 06:00:32 +000027 bool NoExcessFPPrecision;
Nate Begemanf8b02942005-04-15 22:12:16 +000028 int PatternISelTriState;
Chris Lattner34f74a62005-04-30 04:09:52 +000029 bool UnsafeFPMath;
Nate Begemanf63be7d2005-07-06 18:59:04 +000030 bool PICEnabled;
Misha Brukmanf90e4022004-06-21 21:44:12 +000031};
Brian Gaeke323819e2004-03-04 19:16:23 +000032namespace {
33 cl::opt<bool, true> PrintCode("print-machineinstrs",
34 cl::desc("Print generated machine code"),
35 cl::location(PrintMachineCode), cl::init(false));
Misha Brukman0fb5a662004-06-21 21:08:45 +000036
Misha Brukmanf976c852005-04-21 22:55:34 +000037 cl::opt<bool, true>
Misha Brukman0fb5a662004-06-21 21:08:45 +000038 DisableFPElim("disable-fp-elim",
39 cl::desc("Disable frame pointer elimination optimization"),
Misha Brukman66d6ee42004-06-21 21:17:44 +000040 cl::location(NoFramePointerElim),
41 cl::init(false));
Chris Lattner45554a62005-01-15 06:00:32 +000042 cl::opt<bool, true>
43 DisableExcessPrecision("disable-excess-fp-precision",
Nate Begemanf8b02942005-04-15 22:12:16 +000044 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",
Chris Lattner7d937272005-05-13 19:48:34 +000048 cl::desc("Turn the pattern ISel off(0), on(1), default(2)"),
Nate Begemanf8b02942005-04-15 22:12:16 +000049 cl::location(PatternISelTriState),
50 cl::init(2));
Chris Lattner34f74a62005-04-30 04:09:52 +000051 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));
Nate Begemanf63be7d2005-07-06 18:59:04 +000056 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));
Brian Gaeke323819e2004-03-04 19:16:23 +000061};
62
63//---------------------------------------------------------------------------
Chris Lattnerf70e0c22003-12-28 21:23:38 +000064// TargetMachine Class
65//
66TargetMachine::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,
Misha Brukmanc8e87642004-07-23 01:09:52 +000071 unsigned char ShortAl, unsigned char ByteAl,
72 unsigned char BoolAl)
Chris Lattnerf70e0c22003-12-28 21:23:38 +000073 : Name(name), DataLayout(name, LittleEndian,
74 PtrSize, PtrAl, DoubleAl, FloatAl, LongAl,
Misha Brukmanc8e87642004-07-23 01:09:52 +000075 IntAl, ShortAl, ByteAl, BoolAl) {
Chris Lattnerf70e0c22003-12-28 21:23:38 +000076 IL = il ? il : new DefaultIntrinsicLowering();
77}
Misha Brukman167deff2004-08-10 23:10:25 +000078
79TargetMachine::TargetMachine(const std::string &name, IntrinsicLowering *il,
80 const TargetData &TD)
81 : Name(name), DataLayout(TD) {
82 IL = il ? il : new DefaultIntrinsicLowering();
83}
84
Chris Lattner2bed9ec2004-03-03 02:12:47 +000085TargetMachine::TargetMachine(const std::string &name, IntrinsicLowering *il,
86 const Module &M)
87 : Name(name), DataLayout(name, &M) {
88 IL = il ? il : new DefaultIntrinsicLowering();
89}
Vikram S. Advedaae6992001-07-21 12:42:08 +000090
Chris Lattnerf70e0c22003-12-28 21:23:38 +000091TargetMachine::~TargetMachine() {
92 delete IL;
93}
94