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