OSDN Git Service

Add MCTargetDesc library to Hexagon target
authorTony Linthicum <tlinth@codeaurora.org>
Thu, 15 Dec 2011 22:29:08 +0000 (22:29 +0000)
committerTony Linthicum <tlinth@codeaurora.org>
Thu, 15 Dec 2011 22:29:08 +0000 (22:29 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146692 91177308-0d34-0410-b5e6-96231b3b80d8

15 files changed:
lib/Target/Hexagon/CMakeLists.txt
lib/Target/Hexagon/Hexagon.h
lib/Target/Hexagon/HexagonInstrInfo.cpp
lib/Target/Hexagon/HexagonRegisterInfo.cpp
lib/Target/Hexagon/HexagonSubtarget.cpp
lib/Target/Hexagon/HexagonTargetMachine.cpp
lib/Target/Hexagon/LLVMBuild.txt
lib/Target/Hexagon/MCTargetDesc/CMakeLists.txt [new file with mode: 0644]
lib/Target/Hexagon/MCTargetDesc/HexagonMCAsmInfo.cpp [moved from lib/Target/Hexagon/HexagonMCAsmInfo.cpp with 100% similarity]
lib/Target/Hexagon/MCTargetDesc/HexagonMCAsmInfo.h [moved from lib/Target/Hexagon/HexagonMCAsmInfo.h with 100% similarity]
lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp [new file with mode: 0644]
lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.h [new file with mode: 0644]
lib/Target/Hexagon/MCTargetDesc/LLVMBuild.txt [new file with mode: 0644]
lib/Target/Hexagon/MCTargetDesc/Makefile [new file with mode: 0644]
lib/Target/Hexagon/Makefile

index ff917a2..f8705ee 100644 (file)
@@ -31,3 +31,5 @@ add_llvm_target(HexagonCodeGen
   )
 
 add_subdirectory(TargetInfo)
+add_subdirectory(MCTargetDesc)
+
index ced3e9f..a5f2279 100644 (file)
@@ -16,6 +16,7 @@
 #define TARGET_Hexagon_H
 
 #include <cassert>
+#include "MCTargetDesc/HexagonMCTargetDesc.h"
 #include "llvm/Target/TargetLowering.h"
 
 namespace llvm {
@@ -37,23 +38,8 @@ namespace llvm {
   FunctionPass *createHexagonOptimizeSZExtends();
   FunctionPass *createHexagonFixupHwLoops();
 
-  extern Target TheHexagonTarget;
-
 } // end namespace llvm;
 
-// Defines symbolic names for Hexagon instructions and registers.
-// This defines a mapping from register name to register number.
-//
-
-#define GET_REGINFO_ENUM
-#include "HexagonGenRegisterInfo.inc"
-
-#define GET_INSTRINFO_ENUM
-#include "HexagonGenInstrInfo.inc"
-
-#define GET_SUBTARGETINFO_ENUM
-#include "HexagonGenSubtargetInfo.inc"
-
 #define Hexagon_POINTER_SIZE 4
 
 #define Hexagon_PointerSize (Hexagon_POINTER_SIZE)
index 2b480a3..69a50d7 100644 (file)
@@ -23,7 +23,6 @@
 #include "llvm/CodeGen/MachineFrameInfo.h"
 #include "llvm/CodeGen/MachineMemOperand.h"
 #include "llvm/CodeGen/PseudoSourceValue.h"
-#define GET_INSTRINFO_MC_DESC
 #define GET_INSTRINFO_CTOR
 #include "HexagonGenInstrInfo.inc"
 
index 9fd9fd3..521e0c1 100644 (file)
@@ -319,4 +319,5 @@ unsigned HexagonRegisterInfo::getEHHandlerRegister() const {
   return 0;
 }
 
+#define GET_REGINFO_TARGET_DESC
 #include "HexagonGenRegisterInfo.inc"
index c0aa21b..83fb498 100644 (file)
@@ -17,7 +17,6 @@
 #include "llvm/Support/ErrorHandling.h"
 using namespace llvm;
 
-#define GET_SUBTARGETINFO_MC_DESC
 #define GET_SUBTARGETINFO_CTOR
 #define GET_SUBTARGETINFO_TARGET_DESC
 #include "HexagonGenSubtargetInfo.inc"
index 09b7dd5..b29e92c 100644 (file)
@@ -10,7 +10,6 @@
 //
 //===----------------------------------------------------------------------===//
 
-#include "HexagonMCAsmInfo.h"
 #include "HexagonTargetMachine.h"
 #include "Hexagon.h"
 #include "HexagonISelLowering.h"
 #include "llvm/Support/TargetRegistry.h"
 #include <iostream>
 
-#define GET_REGINFO_MC_DESC
-#define GET_REGINFO_TARGET_DESC
-#include "HexagonGenRegisterInfo.inc"
-
-extern "C" void LLVMInitializeHexagonTargetMC() {}
-
 using namespace llvm;
 
 static cl::
@@ -47,9 +40,6 @@ int HexagonTargetMachineModule = 0;
 extern "C" void LLVMInitializeHexagonTarget() {
   // Register the target.
   RegisterTargetMachine<HexagonTargetMachine> X(TheHexagonTarget);
-
-  // Register the target asm info.
-  RegisterMCAsmInfo<HexagonMCAsmInfo> A(TheHexagonTarget);
 }
 
 
index ed64aaa..84ea6a0 100644 (file)
@@ -16,7 +16,7 @@
 ;===------------------------------------------------------------------------===;
 
 [common]
-subdirectories = TargetInfo
+subdirectories = TargetInfo MCTargetDesc
 
 [component_0]
 type = TargetGroup
@@ -28,5 +28,5 @@ has_asmprinter = 1
 type = Library
 name = HexagonCodeGen
 parent = Hexagon
-required_libraries = AsmPrinter CodeGen Core HexagonInfo SelectionDAG Support Target MC
+required_libraries = AsmPrinter CodeGen Core HexagonInfo SelectionDAG Support Target MC HexagonDesc
 add_to_library_groups = Hexagon
diff --git a/lib/Target/Hexagon/MCTargetDesc/CMakeLists.txt b/lib/Target/Hexagon/MCTargetDesc/CMakeLists.txt
new file mode 100644 (file)
index 0000000..8e3da99
--- /dev/null
@@ -0,0 +1,6 @@
+add_llvm_library(LLVMHexagonDesc
+  HexagonMCTargetDesc.cpp
+  HexagonMCAsmInfo.cpp
+  )
+
+add_dependencies(LLVMHexagonDesc HexagonCommonTableGen)
diff --git a/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp b/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.cpp
new file mode 100644 (file)
index 0000000..625f07c
--- /dev/null
@@ -0,0 +1,94 @@
+//===-- HexagonMCTargetDesc.cpp - Cell Hexagon Target Descriptions -----*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file provides Cell Hexagon specific target descriptions.
+//
+//===----------------------------------------------------------------------===//
+
+#include "HexagonMCTargetDesc.h"
+#include "HexagonMCAsmInfo.h"
+#include "llvm/MC/MachineLocation.h"
+#include "llvm/MC/MCCodeGenInfo.h"
+#include "llvm/MC/MCInstrInfo.h"
+#include "llvm/MC/MCRegisterInfo.h"
+#include "llvm/MC/MCSubtargetInfo.h"
+#include "llvm/Support/TargetRegistry.h"
+
+#define GET_INSTRINFO_MC_DESC
+#include "HexagonGenInstrInfo.inc"
+
+#define GET_SUBTARGETINFO_MC_DESC
+#include "HexagonGenSubtargetInfo.inc"
+
+#define GET_REGINFO_MC_DESC
+#include "HexagonGenRegisterInfo.inc"
+
+using namespace llvm;
+
+static MCInstrInfo *createHexagonMCInstrInfo() {
+  MCInstrInfo *X = new MCInstrInfo();
+  InitHexagonMCInstrInfo(X);
+  return X;
+}
+
+static MCRegisterInfo *createHexagonMCRegisterInfo(StringRef TT) {
+  MCRegisterInfo *X = new MCRegisterInfo();
+  InitHexagonMCRegisterInfo(X, Hexagon::R0);
+  return X;
+}
+
+static MCSubtargetInfo *createHexagonMCSubtargetInfo(StringRef TT,
+                                                     StringRef CPU,
+                                                     StringRef FS) {
+  MCSubtargetInfo *X = new MCSubtargetInfo();
+  InitHexagonMCSubtargetInfo(X, TT, CPU, FS);
+  return X;
+}
+
+static MCAsmInfo *createHexagonMCAsmInfo(const Target &T, StringRef TT) {
+  MCAsmInfo *MAI = new HexagonMCAsmInfo(T, TT);
+
+  // VirtualFP = (R30 + #0).
+  MachineLocation Dst(MachineLocation::VirtualFP);
+  MachineLocation Src(Hexagon::R30, 0);
+  MAI->addInitialFrameState(0, Dst, Src);
+
+  return MAI;
+}
+
+static MCCodeGenInfo *createHexagonMCCodeGenInfo(StringRef TT, Reloc::Model RM,
+                                             CodeModel::Model CM,
+                                             CodeGenOpt::Level OL) {
+  MCCodeGenInfo *X = new MCCodeGenInfo();
+  // For the time being, use static relocations, since there's really no
+  // support for PIC yet.
+  X->InitMCCodeGenInfo(Reloc::Static, CM, OL);
+  return X;
+}
+
+// Force static initialization.
+extern "C" void LLVMInitializeHexagonTargetMC() {
+  // Register the MC asm info.
+  RegisterMCAsmInfoFn X(TheHexagonTarget, createHexagonMCAsmInfo);
+
+  // Register the MC codegen info.
+  TargetRegistry::RegisterMCCodeGenInfo(TheHexagonTarget,
+                                        createHexagonMCCodeGenInfo);
+
+  // Register the MC instruction info.
+  TargetRegistry::RegisterMCInstrInfo(TheHexagonTarget, createHexagonMCInstrInfo);
+
+  // Register the MC register info.
+  TargetRegistry::RegisterMCRegInfo(TheHexagonTarget,
+                                    createHexagonMCRegisterInfo);
+
+  // Register the MC subtarget info.
+  TargetRegistry::RegisterMCSubtargetInfo(TheHexagonTarget,
+                                          createHexagonMCSubtargetInfo);
+}
diff --git a/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.h b/lib/Target/Hexagon/MCTargetDesc/HexagonMCTargetDesc.h
new file mode 100644 (file)
index 0000000..364841f
--- /dev/null
@@ -0,0 +1,40 @@
+//===-- SPUMCTargetDesc.h - Hexagon Target Descriptions ---------*- C++ -*-===//
+//
+//                     The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file provides Hexagon specific target descriptions.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef SPUMCTARGETDESC_H
+#define SPUMCTARGETDESC_H
+
+namespace llvm {
+class MCSubtargetInfo;
+class Target;
+class StringRef;
+
+extern Target TheHexagonTarget;
+
+} // End llvm namespace
+
+// Define symbolic names for Hexagon registers.  This defines a mapping from
+// register name to register number.
+//
+#define GET_REGINFO_ENUM
+#include "HexagonGenRegisterInfo.inc"
+
+// Defines symbolic names for the Hexagon instructions.
+//
+#define GET_INSTRINFO_ENUM
+#include "HexagonGenInstrInfo.inc"
+
+#define GET_SUBTARGETINFO_ENUM
+#include "HexagonGenSubtargetInfo.inc"
+
+#endif
diff --git a/lib/Target/Hexagon/MCTargetDesc/LLVMBuild.txt b/lib/Target/Hexagon/MCTargetDesc/LLVMBuild.txt
new file mode 100644 (file)
index 0000000..1114d99
--- /dev/null
@@ -0,0 +1,23 @@
+;===- ./lib/Target/CellSPU/MCTargetDesc/LLVMBuild.txt ----------*- Conf -*--===;
+;
+;                     The LLVM Compiler Infrastructure
+;
+; This file is distributed under the University of Illinois Open Source
+; License. See LICENSE.TXT for details.
+;
+;===------------------------------------------------------------------------===;
+;
+; This is an LLVMBuild description file for the components in this subdirectory.
+;
+; For more information on the LLVMBuild system, please see:
+;
+;   http://llvm.org/docs/LLVMBuild.html
+;
+;===------------------------------------------------------------------------===;
+
+[component_0]
+type = Library
+name = HexagonDesc
+parent = Hexagon
+required_libraries = HexagonInfo MC
+add_to_library_groups = Hexagon
diff --git a/lib/Target/Hexagon/MCTargetDesc/Makefile b/lib/Target/Hexagon/MCTargetDesc/Makefile
new file mode 100644 (file)
index 0000000..67be2bc
--- /dev/null
@@ -0,0 +1,16 @@
+##===- lib/Target/CellSPU/TargetDesc/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 = LLVMHexagonDesc
+
+# Hack: we need to include 'main' target directory to grab private headers
+CPP.Flags += -I$(PROJ_OBJ_DIR)/.. -I$(PROJ_SRC_DIR)/..
+
+include $(LEVEL)/Makefile.common
index 836d303..c936e92 100644 (file)
@@ -18,6 +18,6 @@ BUILT_SOURCES = HexagonGenRegisterInfo.inc \
                 HexagonGenCallingConv.inc \
                 HexagonAsmPrinter.cpp
 
-DIRS = TargetInfo
+DIRS = TargetInfo MCTargetDesc
 
 include $(LEVEL)/Makefile.common