summaryrefslogtreecommitdiff
path: root/lib/Target
diff options
context:
space:
mode:
authorAnton Korobeynikov <asl@math.spbu.ru>2009-07-16 14:36:52 +0000
committerAnton Korobeynikov <asl@math.spbu.ru>2009-07-16 14:36:52 +0000
commit7df8462038c4393771a0961c60a2686169e4fd9a (patch)
treef1772da62843e3dca4748ab533e1931bfa29abc0 /lib/Target
parentc9751806242a1e893f05cdbd3cc22c4685a971d4 (diff)
downloadllvm-7df8462038c4393771a0961c60a2686169e4fd9a.tar.gz
llvm-7df8462038c4393771a0961c60a2686169e4fd9a.tar.bz2
llvm-7df8462038c4393771a0961c60a2686169e4fd9a.tar.xz
Unbreak
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76064 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target')
-rw-r--r--lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp42
-rw-r--r--lib/Target/SystemZ/Makefile2
-rw-r--r--lib/Target/SystemZ/SystemZ.h9
-rw-r--r--lib/Target/SystemZ/SystemZISelDAGToDAG.cpp1
-rw-r--r--lib/Target/SystemZ/SystemZISelLowering.cpp9
-rw-r--r--lib/Target/SystemZ/SystemZISelLowering.h5
-rw-r--r--lib/Target/SystemZ/SystemZTargetMachine.cpp40
-rw-r--r--lib/Target/SystemZ/SystemZTargetMachine.h5
-rw-r--r--lib/Target/SystemZ/TargetInfo/CMakeLists.txt6
-rw-r--r--lib/Target/SystemZ/TargetInfo/Makefile15
-rw-r--r--lib/Target/SystemZ/TargetInfo/SystemZTargetInfo.cpp44
11 files changed, 122 insertions, 56 deletions
diff --git a/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp b/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp
index f778197be7..24f4114ebc 100644
--- a/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp
+++ b/lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp
@@ -27,10 +27,11 @@
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/Target/TargetAsmInfo.h"
#include "llvm/Target/TargetData.h"
+#include "llvm/Target/TargetRegistry.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Support/Compiler.h"
+#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/Mangler.h"
-#include "llvm/Support/raw_ostream.h"
using namespace llvm;
@@ -39,10 +40,9 @@ STATISTIC(EmittedInsts, "Number of machine instrs printed");
namespace {
class VISIBILITY_HIDDEN SystemZAsmPrinter : public AsmPrinter {
public:
- SystemZAsmPrinter(raw_ostream &O, SystemZTargetMachine &TM,
- const TargetAsmInfo *TAI,
- CodeGenOpt::Level OL, bool V)
- : AsmPrinter(O, TM, TAI, OL, V) {}
+ SystemZAsmPrinter(formatted_raw_ostream &O, TargetMachine &TM,
+ const TargetAsmInfo *TAI, bool V)
+ : AsmPrinter(O, TM, TAI, V) {}
virtual const char *getPassName() const {
return "SystemZ Assembly Printer";
@@ -85,11 +85,10 @@ namespace {
/// using the given target machine description. This should work
/// regardless of whether the function is in SSA form.
///
-FunctionPass *llvm::createSystemZCodePrinterPass(raw_ostream &o,
- SystemZTargetMachine &tm,
- CodeGenOpt::Level OptLevel,
- bool verbose) {
- return new SystemZAsmPrinter(o, tm, tm.getTargetAsmInfo(), OptLevel, verbose);
+FunctionPass *llvm::createSystemZCodePrinterPass(formatted_raw_ostream &o,
+ TargetMachine &tm,
+ bool verbose) {
+ return new SystemZAsmPrinter(o, tm, tm.getTargetAsmInfo(), verbose);
}
bool SystemZAsmPrinter::doInitialization(Module &M) {
@@ -108,14 +107,11 @@ bool SystemZAsmPrinter::doFinalization(Module &M) {
}
void SystemZAsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
+ unsigned FnAlign = MF.getAlignment();
const Function *F = MF.getFunction();
SwitchToSection(TAI->SectionForGlobal(F));
- unsigned FnAlign = 4;
- if (F->hasFnAttr(Attribute::OptimizeForSize))
- FnAlign = 1;
-
EmitAlignment(FnAlign, F);
switch (F->getLinkage()) {
@@ -201,7 +197,7 @@ void SystemZAsmPrinter::printPCRelImmOperand(const MachineInstr *MI, int OpNum)
return;
case MachineOperand::MO_GlobalAddress: {
const GlobalValue *GV = MO.getGlobal();
- std::string Name = Mang->getValueName(GV);
+ std::string Name = Mang->getMangledName(GV);
O << Name;
@@ -269,7 +265,7 @@ void SystemZAsmPrinter::printOperand(const MachineInstr *MI, int OpNum,
break;
case MachineOperand::MO_GlobalAddress: {
const GlobalValue *GV = MO.getGlobal();
- std::string Name = Mang->getValueName(GV);
+ std::string Name = Mang->getMangledName(GV);
O << Name;
break;
@@ -334,7 +330,7 @@ void SystemZAsmPrinter::printRRIAddrOperand(const MachineInstr *MI, int OpNum,
/// PrintUnmangledNameSafely - Print out the printable characters in the name.
/// Don't print things like \\n or \\0.
-static void PrintUnmangledNameSafely(const Value *V, raw_ostream &OS) {
+static void PrintUnmangledNameSafely(const Value *V, formatted_raw_ostream &OS) {
for (const char *Name = V->getNameStart(), *E = Name+V->getNameLen();
Name != E; ++Name)
if (isprint(*Name))
@@ -351,10 +347,9 @@ void SystemZAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
if (EmitSpecialLLVMGlobal(GVar))
return;
- std::string name = Mang->getValueName(GVar);
+ std::string name = Mang->getMangledName(GVar);
Constant *C = GVar->getInitializer();
- const Type *Type = C->getType();
- unsigned Size = TD->getTypeAllocSize(Type);
+ unsigned Size = TD->getTypeAllocSize(C->getType());
unsigned Align = std::max(1U, TD->getPreferredAlignmentLog(GVar));
printVisibility(name, GVar->getVisibility());
@@ -420,3 +415,10 @@ void SystemZAsmPrinter::printModuleLevelGV(const GlobalVariable* GVar) {
EmitGlobalConstant(C);
}
+
+// Force static initialization.
+extern "C" void LLVMInitializeSystemZAsmPrinter() {
+ extern Target TheSystemZTarget;
+ TargetRegistry::RegisterAsmPrinter(TheSystemZTarget,
+ createSystemZCodePrinterPass);
+}
diff --git a/lib/Target/SystemZ/Makefile b/lib/Target/SystemZ/Makefile
index c4574dc248..f1097ebcf3 100644
--- a/lib/Target/SystemZ/Makefile
+++ b/lib/Target/SystemZ/Makefile
@@ -16,7 +16,7 @@ BUILT_SOURCES = SystemZGenRegisterInfo.h.inc SystemZGenRegisterNames.inc \
SystemZGenInstrInfo.inc SystemZGenAsmWriter.inc \
SystemZGenDAGISel.inc SystemZGenSubtarget.inc SystemZGenCallingConv.inc
-DIRS = AsmPrinter
+DIRS = AsmPrinter TargetInfo
include $(LEVEL)/Makefile.common
diff --git a/lib/Target/SystemZ/SystemZ.h b/lib/Target/SystemZ/SystemZ.h
index e6a1707725..88b7b02db2 100644
--- a/lib/Target/SystemZ/SystemZ.h
+++ b/lib/Target/SystemZ/SystemZ.h
@@ -20,7 +20,7 @@
namespace llvm {
class SystemZTargetMachine;
class FunctionPass;
- class raw_ostream;
+ class formatted_raw_ostream;
namespace SystemZCC {
// SystemZ specific condition code. These correspond to SYSTEMZ_*_COND in
@@ -46,10 +46,9 @@ namespace llvm {
FunctionPass *createSystemZISelDag(SystemZTargetMachine &TM,
CodeGenOpt::Level OptLevel);
- FunctionPass *createSystemZCodePrinterPass(raw_ostream &o,
- SystemZTargetMachine &tm,
- CodeGenOpt::Level OptLevel,
- bool verbose);
+ FunctionPass *createSystemZCodePrinterPass(formatted_raw_ostream &o,
+ TargetMachine &tm,
+ bool verbose);
} // end namespace llvm;
diff --git a/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp b/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
index bc9c5ec7bf..cc77c6f578 100644
--- a/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
+++ b/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
@@ -28,6 +28,7 @@
#include "llvm/Target/TargetLowering.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/raw_ostream.h"
using namespace llvm;
static const unsigned subreg_even32 = 1;
diff --git a/lib/Target/SystemZ/SystemZISelLowering.cpp b/lib/Target/SystemZ/SystemZISelLowering.cpp
index 239a179e02..46e0459e4c 100644
--- a/lib/Target/SystemZ/SystemZISelLowering.cpp
+++ b/lib/Target/SystemZ/SystemZISelLowering.cpp
@@ -203,7 +203,7 @@ SDValue SystemZTargetLowering::LowerCCCArguments(SDValue Op,
// Assign locations to all of the incoming arguments.
SmallVector<CCValAssign, 16> ArgLocs;
- CCState CCInfo(CC, isVarArg, getTargetMachine(), ArgLocs);
+ CCState CCInfo(CC, isVarArg, getTargetMachine(), ArgLocs, DAG.getContext());
CCInfo.AnalyzeFormalArguments(Op.getNode(), CC_SystemZ);
assert(!isVarArg && "Varargs not supported yet");
@@ -292,7 +292,7 @@ SDValue SystemZTargetLowering::LowerCCCCallTo(SDValue Op, SelectionDAG &DAG,
// Analyze operands of the call, assigning locations to each operand.
SmallVector<CCValAssign, 16> ArgLocs;
- CCState CCInfo(CC, isVarArg, getTargetMachine(), ArgLocs);
+ CCState CCInfo(CC, isVarArg, getTargetMachine(), ArgLocs, DAG.getContext());
CCInfo.AnalyzeCallOperands(TheCall, CC_SystemZ);
@@ -422,7 +422,8 @@ SystemZTargetLowering::LowerCallResult(SDValue Chain, SDValue InFlag,
// Assign locations to each value returned by this call.
SmallVector<CCValAssign, 16> RVLocs;
- CCState CCInfo(CallingConv, isVarArg, getTargetMachine(), RVLocs);
+ CCState CCInfo(CallingConv, isVarArg, getTargetMachine(), RVLocs,
+ DAG.getContext());
CCInfo.AnalyzeCallResult(TheCall, RetCC_SystemZ);
SmallVector<SDValue, 8> ResultVals;
@@ -468,7 +469,7 @@ SDValue SystemZTargetLowering::LowerRET(SDValue Op, SelectionDAG &DAG) {
DebugLoc dl = Op.getDebugLoc();
// CCState - Info about the registers and stack slot.
- CCState CCInfo(CC, isVarArg, getTargetMachine(), RVLocs);
+ CCState CCInfo(CC, isVarArg, getTargetMachine(), RVLocs, DAG.getContext());
// Analize return values of ISD::RET
CCInfo.AnalyzeReturn(Op.getNode(), RetCC_SystemZ);
diff --git a/lib/Target/SystemZ/SystemZISelLowering.h b/lib/Target/SystemZ/SystemZISelLowering.h
index b6d5c605cd..33fa13f2cc 100644
--- a/lib/Target/SystemZ/SystemZISelLowering.h
+++ b/lib/Target/SystemZ/SystemZISelLowering.h
@@ -64,6 +64,11 @@ namespace llvm {
/// DAG node.
virtual const char *getTargetNodeName(unsigned Opcode) const;
+ /// getFunctionAlignment - Return the Log2 alignment of this function.
+ virtual unsigned getFunctionAlignment(const Function *F) const {
+ return 1;
+ }
+
SDValue LowerFORMAL_ARGUMENTS(SDValue Op, SelectionDAG &DAG);
SDValue LowerRET(SDValue Op, SelectionDAG &DAG);
SDValue LowerCALL(SDValue Op, SelectionDAG &DAG);
diff --git a/lib/Target/SystemZ/SystemZTargetMachine.cpp b/lib/Target/SystemZ/SystemZTargetMachine.cpp
index 4be8ea9936..01be4edf7d 100644
--- a/lib/Target/SystemZ/SystemZTargetMachine.cpp
+++ b/lib/Target/SystemZ/SystemZTargetMachine.cpp
@@ -18,17 +18,18 @@
#include "llvm/Target/TargetMachineRegistry.h"
using namespace llvm;
-/// SystemZTargetMachineModule - Note that this is used on hosts that
-/// cannot link in a library unless there are references into the
-/// library. In particular, it seems that it is not possible to get
-/// things to work on Win32 without this. Though it is unused, do not
-/// remove it.
-extern "C" int SystemZTargetMachineModule;
-int SystemZTargetMachineModule = 0;
+extern Target TheSystemZTarget;
+namespace {
+ // Register the target.
+ RegisterTarget<SystemZTargetMachine> X(TheSystemZTarget,
+ "systemz",
+ "SystemZ [experimental]");
+}
+
+// Force static initialization.
+extern "C" void LLVMInitializeSystemZTarget() {
-// Register the target.
-static RegisterTarget<SystemZTargetMachine>
-X("systemz", "SystemZ [experimental]");
+}
const TargetAsmInfo *SystemZTargetMachine::createTargetAsmInfo() const {
// FIXME: Handle Solaris subtarget someday :)
@@ -37,9 +38,13 @@ const TargetAsmInfo *SystemZTargetMachine::createTargetAsmInfo() const {
/// SystemZTargetMachine ctor - Create an ILP64 architecture model
///
-SystemZTargetMachine::SystemZTargetMachine(const Module &M, const std::string &FS)
- : Subtarget(*this, M, FS),
- DataLayout("E-p:64:64:64-i8:8:16-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-a0:16:16"),
+SystemZTargetMachine::SystemZTargetMachine(const Target &T,
+ const Module &M,
+ const std::string &FS)
+ : LLVMTargetMachine(T),
+ Subtarget(*this, M, FS),
+ DataLayout("E-p:64:64:64-i8:8:16-i16:16:16-i32:32:32-i64:64:64-f32:32:32"
+ "-f64:64:64-f128:128:128-a0:16:16"),
InstrInfo(*this), TLInfo(*this),
FrameInfo(TargetFrameInfo::StackGrowsDown, 8, -160) {
@@ -54,15 +59,6 @@ bool SystemZTargetMachine::addInstSelector(PassManagerBase &PM,
return false;
}
-bool SystemZTargetMachine::addAssemblyEmitter(PassManagerBase &PM,
- CodeGenOpt::Level OptLevel,
- bool Verbose,
- raw_ostream &Out) {
- // Output assembly language.
- PM.add(createSystemZCodePrinterPass(Out, *this, OptLevel, Verbose));
- return false;
-}
-
unsigned SystemZTargetMachine::getModuleMatchQuality(const Module &M) {
std::string TT = M.getTargetTriple();
diff --git a/lib/Target/SystemZ/SystemZTargetMachine.h b/lib/Target/SystemZ/SystemZTargetMachine.h
index 4862a99b4c..843399c2e4 100644
--- a/lib/Target/SystemZ/SystemZTargetMachine.h
+++ b/lib/Target/SystemZ/SystemZTargetMachine.h
@@ -41,7 +41,7 @@ protected:
virtual const TargetAsmInfo *createTargetAsmInfo() const;
public:
- SystemZTargetMachine(const Module &M, const std::string &FS);
+ SystemZTargetMachine(const Target &T, const Module &M, const std::string &FS);
virtual const TargetFrameInfo *getFrameInfo() const { return &FrameInfo; }
virtual const SystemZInstrInfo *getInstrInfo() const { return &InstrInfo; }
@@ -57,9 +57,6 @@ public:
}
virtual bool addInstSelector(PassManagerBase &PM, CodeGenOpt::Level OptLevel);
- virtual bool addAssemblyEmitter(PassManagerBase &PM,
- CodeGenOpt::Level OptLevel, bool Verbose,
- raw_ostream &Out);
static unsigned getModuleMatchQuality(const Module &M);
}; // SystemZTargetMachine.
diff --git a/lib/Target/SystemZ/TargetInfo/CMakeLists.txt b/lib/Target/SystemZ/TargetInfo/CMakeLists.txt
new file mode 100644
index 0000000000..6ac3738f62
--- /dev/null
+++ b/lib/Target/SystemZ/TargetInfo/CMakeLists.txt
@@ -0,0 +1,6 @@
+include_directories( ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/.. )
+
+add_llvm_library(LLVMSystemZInfo
+ SystemZTargetInfo.cpp
+ )
+
diff --git a/lib/Target/SystemZ/TargetInfo/Makefile b/lib/Target/SystemZ/TargetInfo/Makefile
new file mode 100644
index 0000000000..0be80eb4e6
--- /dev/null
+++ b/lib/Target/SystemZ/TargetInfo/Makefile
@@ -0,0 +1,15 @@
+##===- lib/Target/SystemZ/TargetInfo/Makefile --------------*- Makefile -*-===##
+#
+# The LLVM Compiler Infrastructure
+#
+# This file is distributed under the University of Illinois Open Source
+# License. See LICENSE.TXT for details.
+#
+##===----------------------------------------------------------------------===##
+LEVEL = ../../../..
+LIBRARYNAME = LLVMSystemZInfo
+
+# Hack: we need to include 'main' target directory to grab private headers
+CPPFLAGS = -I$(PROJ_OBJ_DIR)/.. -I$(PROJ_SRC_DIR)/..
+
+include $(LEVEL)/Makefile.common
diff --git a/lib/Target/SystemZ/TargetInfo/SystemZTargetInfo.cpp b/lib/Target/SystemZ/TargetInfo/SystemZTargetInfo.cpp
new file mode 100644
index 0000000000..c464039aac
--- /dev/null
+++ b/lib/Target/SystemZ/TargetInfo/SystemZTargetInfo.cpp
@@ -0,0 +1,44 @@
+//===-- SystemZTargetInfo.cpp - SystemZ Target Implementation -----------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Module.h"
+#include "llvm/Target/TargetRegistry.h"
+using namespace llvm;
+
+Target TheSystemZTarget;
+
+static unsigned SystemZ_JITMatchQuality() {
+ return 0;
+}
+
+static unsigned SystemZ_TripleMatchQuality(const std::string &TT) {
+ // We strongly match s390x
+ if (TT.size() >= 5 && TT[0] == 's' && TT[1] == '3' && TT[2] == '9' &&
+ TT[3] == '0' && TT[4] == 'x')
+ return 20;
+
+ return 0;
+}
+
+static unsigned SystemZ_ModuleMatchQuality(const Module &M) {
+ // Check for a triple match.
+ if (unsigned Q = SystemZ_TripleMatchQuality(M.getTargetTriple()))
+ return Q;
+
+ // Otherwise we don't match.
+ return 0;
+}
+
+extern "C" void LLVMInitializeSystemZTargetInfo() {
+ TargetRegistry::RegisterTarget(TheSystemZTarget, "systemz",
+ "SystemZ",
+ &SystemZ_TripleMatchQuality,
+ &SystemZ_ModuleMatchQuality,
+ &SystemZ_JITMatchQuality);
+}