Unbreak
authorAnton Korobeynikov <asl@math.spbu.ru>
Thu, 16 Jul 2009 14:36:52 +0000 (14:36 +0000)
committerAnton Korobeynikov <asl@math.spbu.ru>
Thu, 16 Jul 2009 14:36:52 +0000 (14:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76064 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/SystemZ/AsmPrinter/SystemZAsmPrinter.cpp
lib/Target/SystemZ/Makefile
lib/Target/SystemZ/SystemZ.h
lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
lib/Target/SystemZ/SystemZISelLowering.cpp
lib/Target/SystemZ/SystemZISelLowering.h
lib/Target/SystemZ/SystemZTargetMachine.cpp
lib/Target/SystemZ/SystemZTargetMachine.h
lib/Target/SystemZ/TargetInfo/CMakeLists.txt [new file with mode: 0644]
lib/Target/SystemZ/TargetInfo/Makefile [new file with mode: 0644]
lib/Target/SystemZ/TargetInfo/SystemZTargetInfo.cpp [new file with mode: 0644]

index f778197be70b1af32691acd6084eed8d1656985f..24f4114ebc78fcae32b2c44981645e6416125fb1 100644 (file)
 #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);
+}
index c4574dc2484e1d82746e65065ab0cd9572b9e771..f1097ebcf3b7ac19dd2322c1c8a0f55dfa1c3ba7 100644 (file)
@@ -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
 
index e6a1707725705df11a63de059e803f9aead1f758..88b7b02db2d1547ca7935d46fb13ed55aa649359 100644 (file)
@@ -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;
 
index bc9c5ec7bf8fdf2933392992e30a42afe8204104..cc77c6f578941df52a8a51c0f5e83e418bff9b72 100644 (file)
@@ -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;
index 239a179e02edf78daa1564f1a9e297a07856f3bc..46e0459e4c90dc6aabad9d98aadd0058cebe0311 100644 (file)
@@ -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);
index b6d5c605cd85cd802d1734ffffa6343e8541ac0e..33fa13f2cc67a1efbfcac7539a021ea725fc53e6 100644 (file)
@@ -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);
index 4be8ea9936499f4613975e99d3e69bf9cc766e55..01be4edf7d70f36cd20cf72a042ba25521059145 100644 (file)
 #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();
 
index 4862a99b4cc6b6531c07c76378b230a6cfa27308..843399c2e46bd31eb7c6f3759ed4833dd2a0a915 100644 (file)
@@ -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 (file)
index 0000000..6ac3738
--- /dev/null
@@ -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 (file)
index 0000000..0be80eb
--- /dev/null
@@ -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 (file)
index 0000000..c464039
--- /dev/null
@@ -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);
+}