2001-09-14 13:34:53 +08:00
|
|
|
//===-- TargetMachine.cpp - General Target Information ---------------------==//
|
2005-04-22 06:55:34 +08:00
|
|
|
//
|
2003-10-21 03:43:21 +08:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
2005-04-22 06:55:34 +08:00
|
|
|
//
|
2003-10-21 03:43:21 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2001-09-14 13:34:53 +08:00
|
|
|
//
|
|
|
|
// This file describes the general parts of a Target machine.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
2001-07-21 20:42:08 +08:00
|
|
|
|
2004-06-22 05:20:23 +08:00
|
|
|
#include "llvm/Target/TargetMachine.h"
|
2002-10-29 07:55:33 +08:00
|
|
|
#include "llvm/Type.h"
|
2004-06-20 15:49:54 +08:00
|
|
|
#include "llvm/CodeGen/IntrinsicLowering.h"
|
2004-09-02 06:55:40 +08:00
|
|
|
#include "llvm/Support/CommandLine.h"
|
2003-12-29 05:23:38 +08:00
|
|
|
using namespace llvm;
|
2003-11-12 06:41:34 +08:00
|
|
|
|
2004-03-05 03:16:23 +08:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// Command-line options that tend to be useful on more than one back-end.
|
|
|
|
//
|
|
|
|
|
2004-06-22 05:44:12 +08:00
|
|
|
namespace llvm {
|
|
|
|
bool PrintMachineCode;
|
|
|
|
bool NoFramePointerElim;
|
2005-01-15 14:00:32 +08:00
|
|
|
bool NoExcessFPPrecision;
|
2005-04-16 06:12:16 +08:00
|
|
|
int PatternISelTriState;
|
2005-04-30 12:09:52 +08:00
|
|
|
bool UnsafeFPMath;
|
2005-07-07 02:59:04 +08:00
|
|
|
bool PICEnabled;
|
2004-06-22 05:44:12 +08:00
|
|
|
};
|
2004-03-05 03:16:23 +08:00
|
|
|
namespace {
|
|
|
|
cl::opt<bool, true> PrintCode("print-machineinstrs",
|
|
|
|
cl::desc("Print generated machine code"),
|
|
|
|
cl::location(PrintMachineCode), cl::init(false));
|
2004-06-22 05:08:45 +08:00
|
|
|
|
2005-04-22 06:55:34 +08:00
|
|
|
cl::opt<bool, true>
|
2004-06-22 05:08:45 +08:00
|
|
|
DisableFPElim("disable-fp-elim",
|
|
|
|
cl::desc("Disable frame pointer elimination optimization"),
|
2004-06-22 05:17:44 +08:00
|
|
|
cl::location(NoFramePointerElim),
|
|
|
|
cl::init(false));
|
2005-01-15 14:00:32 +08:00
|
|
|
cl::opt<bool, true>
|
|
|
|
DisableExcessPrecision("disable-excess-fp-precision",
|
2005-04-16 06:12:16 +08:00
|
|
|
cl::desc("Disable optimizations that may increase FP precision"),
|
|
|
|
cl::location(NoExcessFPPrecision),
|
|
|
|
cl::init(false));
|
|
|
|
cl::opt<int, true> PatternISel("enable-pattern-isel",
|
2005-05-14 03:48:34 +08:00
|
|
|
cl::desc("Turn the pattern ISel off(0), on(1), default(2)"),
|
2005-04-16 06:12:16 +08:00
|
|
|
cl::location(PatternISelTriState),
|
|
|
|
cl::init(2));
|
2005-04-30 12:09:52 +08:00
|
|
|
cl::opt<bool, true>
|
|
|
|
EnableUnsafeFPMath("enable-unsafe-fp-math",
|
|
|
|
cl::desc("Enable optimizations that may decrease FP precision"),
|
|
|
|
cl::location(UnsafeFPMath),
|
|
|
|
cl::init(false));
|
2005-07-07 02:59:04 +08:00
|
|
|
cl::opt<bool, true>
|
|
|
|
EnablePIC("enable-pic",
|
|
|
|
cl::desc("Enable generation of position independant code"),
|
|
|
|
cl::location(PICEnabled),
|
|
|
|
cl::init(false));
|
2004-03-05 03:16:23 +08:00
|
|
|
};
|
|
|
|
|
2001-07-21 20:42:08 +08:00
|
|
|
//---------------------------------------------------------------------------
|
2003-12-29 05:23:38 +08:00
|
|
|
// TargetMachine Class
|
|
|
|
//
|
|
|
|
TargetMachine::TargetMachine(const std::string &name, IntrinsicLowering *il,
|
|
|
|
bool LittleEndian,
|
|
|
|
unsigned char PtrSize, unsigned char PtrAl,
|
|
|
|
unsigned char DoubleAl, unsigned char FloatAl,
|
|
|
|
unsigned char LongAl, unsigned char IntAl,
|
2004-07-23 09:09:52 +08:00
|
|
|
unsigned char ShortAl, unsigned char ByteAl,
|
|
|
|
unsigned char BoolAl)
|
2003-12-29 05:23:38 +08:00
|
|
|
: Name(name), DataLayout(name, LittleEndian,
|
|
|
|
PtrSize, PtrAl, DoubleAl, FloatAl, LongAl,
|
2004-07-23 09:09:52 +08:00
|
|
|
IntAl, ShortAl, ByteAl, BoolAl) {
|
2003-12-29 05:23:38 +08:00
|
|
|
IL = il ? il : new DefaultIntrinsicLowering();
|
|
|
|
}
|
2004-08-11 07:10:25 +08:00
|
|
|
|
|
|
|
TargetMachine::TargetMachine(const std::string &name, IntrinsicLowering *il,
|
|
|
|
const TargetData &TD)
|
|
|
|
: Name(name), DataLayout(TD) {
|
|
|
|
IL = il ? il : new DefaultIntrinsicLowering();
|
|
|
|
}
|
|
|
|
|
2004-03-03 10:12:47 +08:00
|
|
|
TargetMachine::TargetMachine(const std::string &name, IntrinsicLowering *il,
|
|
|
|
const Module &M)
|
|
|
|
: Name(name), DataLayout(name, &M) {
|
|
|
|
IL = il ? il : new DefaultIntrinsicLowering();
|
|
|
|
}
|
2003-12-29 05:23:38 +08:00
|
|
|
|
|
|
|
TargetMachine::~TargetMachine() {
|
|
|
|
delete IL;
|
|
|
|
}
|
|
|
|
|