[gn build] Add build files for llvm/lib/Target/PowerPC + tests
authorNico Weber <nicolasweber@gmx.de>
Tue, 8 Jan 2019 15:16:14 +0000 (15:16 +0000)
committerNico Weber <nicolasweber@gmx.de>
Tue, 8 Jan 2019 15:16:14 +0000 (15:16 +0000)
The PowerPC target itself is similar to the X86 target in https://reviews.llvm.org/rL348903
The llvm-exegesis unittests bits are similar to the corresponding AArch64 in https://reviews.llvm.org/rL350499
The whole patch is very similar to the WebAssembly target being added in https://reviews.llvm.org/rL350628

Also add a dep from tools/llvm-exegesis/lib to the AArch64 subdir, which I
failed to do in r350499.

The motivation for this target is solely that it has a unit test and I want to
enable the GN<->CMake unittest syncing check for llvm.

Differential Revision: https://reviews.llvm.org/D56416

llvm-svn: 350629

12 files changed:
llvm/utils/gn/secondary/llvm/lib/Target/ARM/BUILD.gn
llvm/utils/gn/secondary/llvm/lib/Target/PowerPC/AsmParser/BUILD.gn [new file with mode: 0644]
llvm/utils/gn/secondary/llvm/lib/Target/PowerPC/BUILD.gn [new file with mode: 0644]
llvm/utils/gn/secondary/llvm/lib/Target/PowerPC/Disassembler/BUILD.gn [new file with mode: 0644]
llvm/utils/gn/secondary/llvm/lib/Target/PowerPC/InstPrinter/BUILD.gn [new file with mode: 0644]
llvm/utils/gn/secondary/llvm/lib/Target/PowerPC/MCTargetDesc/BUILD.gn [new file with mode: 0644]
llvm/utils/gn/secondary/llvm/lib/Target/PowerPC/TargetInfo/BUILD.gn [new file with mode: 0644]
llvm/utils/gn/secondary/llvm/lib/Target/targets.gni
llvm/utils/gn/secondary/llvm/tools/llvm-exegesis/lib/BUILD.gn
llvm/utils/gn/secondary/llvm/tools/llvm-exegesis/lib/PowerPC/BUILD.gn [new file with mode: 0644]
llvm/utils/gn/secondary/llvm/unittests/BUILD.gn
llvm/utils/gn/secondary/llvm/unittests/tools/llvm-exegesis/PowerPC/BUILD.gn [new file with mode: 0644]

index 416d4da..b299be5 100644 (file)
@@ -103,7 +103,7 @@ static_library("LLVMARMCodeGen") {
 }
 
 # This is a bit different from most build files: Due to this group
-# having the directory's name, "//llvm/lib/Target/AArch64" will refer to this
+# having the directory's name, "//llvm/lib/Target/ARM" will refer to this
 # target, which pulls in the code in this directory *and all subdirectories*.
 # For most other directories, "//llvm/lib/Foo" only pulls in the code directly
 # in "llvm/lib/Foo". The forwarding targets in //llvm/lib/Target expect this
diff --git a/llvm/utils/gn/secondary/llvm/lib/Target/PowerPC/AsmParser/BUILD.gn b/llvm/utils/gn/secondary/llvm/lib/Target/PowerPC/AsmParser/BUILD.gn
new file mode 100644 (file)
index 0000000..28c8945
--- /dev/null
@@ -0,0 +1,23 @@
+import("//llvm/utils/TableGen/tablegen.gni")
+
+tablegen("PPCGenAsmMatcher") {
+  visibility = [ ":AsmParser" ]
+  args = [ "-gen-asm-matcher" ]
+  td_file = "../PPC.td"
+}
+
+static_library("AsmParser") {
+  output_name = "LLVMPowerPCAsmParser"
+  deps = [
+    ":PPCGenAsmMatcher",
+    "//llvm/lib/MC",
+    "//llvm/lib/MC/MCParser",
+    "//llvm/lib/Support",
+    "//llvm/lib/Target/PowerPC/MCTargetDesc",
+    "//llvm/lib/Target/PowerPC/TargetInfo",
+  ]
+  include_dirs = [ ".." ]
+  sources = [
+    "PPCAsmParser.cpp",
+  ]
+}
diff --git a/llvm/utils/gn/secondary/llvm/lib/Target/PowerPC/BUILD.gn b/llvm/utils/gn/secondary/llvm/lib/Target/PowerPC/BUILD.gn
new file mode 100644 (file)
index 0000000..84dac6c
--- /dev/null
@@ -0,0 +1,91 @@
+import("//llvm/utils/TableGen/tablegen.gni")
+
+tablegen("PPCGenCallingConv") {
+  visibility = [ ":LLVMPowerPCCodeGen" ]
+  args = [ "-gen-callingconv" ]
+  td_file = "PPC.td"
+}
+
+tablegen("PPCGenDAGISel") {
+  visibility = [ ":LLVMPowerPCCodeGen" ]
+  args = [ "-gen-dag-isel" ]
+  td_file = "PPC.td"
+}
+
+tablegen("PPCGenFastISel") {
+  visibility = [ ":LLVMPowerPCCodeGen" ]
+  args = [ "-gen-fast-isel" ]
+  td_file = "PPC.td"
+}
+
+static_library("LLVMPowerPCCodeGen") {
+  deps = [
+    ":PPCGenCallingConv",
+    ":PPCGenDAGISel",
+    ":PPCGenFastISel",
+    "InstPrinter",
+    "MCTargetDesc",
+    "TargetInfo",
+    "//llvm/include/llvm/Config:llvm-config",
+    "//llvm/lib/Analysis",
+    "//llvm/lib/CodeGen",
+    "//llvm/lib/CodeGen/AsmPrinter",
+    "//llvm/lib/CodeGen/SelectionDAG",
+    "//llvm/lib/IR",
+    "//llvm/lib/MC",
+    "//llvm/lib/Support",
+    "//llvm/lib/Target",
+    "//llvm/lib/Transforms/Utils",
+  ]
+  include_dirs = [ "." ]
+  sources = [
+    "PPCBoolRetToInt.cpp",
+    "PPCAsmPrinter.cpp",
+    "PPCBranchSelector.cpp",
+    "PPCBranchCoalescing.cpp",
+    "PPCCCState.cpp",
+    "PPCCTRLoops.cpp",
+    "PPCHazardRecognizers.cpp",
+    "PPCInstrInfo.cpp",
+    "PPCISelDAGToDAG.cpp",
+    "PPCISelLowering.cpp",
+    "PPCEarlyReturn.cpp",
+    "PPCFastISel.cpp",
+    "PPCFrameLowering.cpp",
+    "PPCLoopPreIncPrep.cpp",
+    "PPCMCInstLower.cpp",
+    "PPCMachineFunctionInfo.cpp",
+    "PPCMIPeephole.cpp",
+    "PPCRegisterInfo.cpp",
+    "PPCQPXLoadSplat.cpp",
+    "PPCSubtarget.cpp",
+    "PPCTargetMachine.cpp",
+    "PPCTargetObjectFile.cpp",
+    "PPCTargetTransformInfo.cpp",
+    "PPCTOCRegDeps.cpp",
+    "PPCTLSDynamicCall.cpp",
+    "PPCVSXCopy.cpp",
+    "PPCReduceCRLogicals.cpp",
+    "PPCVSXFMAMutate.cpp",
+    "PPCVSXSwapRemoval.cpp",
+    "PPCExpandISEL.cpp",
+    "PPCPreEmitPeephole.cpp",
+  ]
+}
+
+# This is a bit different from most build files: Due to this group
+# having the directory's name, "//llvm/lib/Target/PowerPC" will refer to this
+# target, which pulls in the code in this directory *and all subdirectories*.
+# For most other directories, "//llvm/lib/Foo" only pulls in the code directly
+# in "llvm/lib/Foo". The forwarding targets in //llvm/lib/Target expect this
+# different behavior.
+group("PowerPC") {
+  deps = [
+    ":LLVMPowerPCCodeGen",
+    "AsmParser",
+    "Disassembler",
+    "InstPrinter",
+    "MCTargetDesc",
+    "TargetInfo",
+  ]
+}
diff --git a/llvm/utils/gn/secondary/llvm/lib/Target/PowerPC/Disassembler/BUILD.gn b/llvm/utils/gn/secondary/llvm/lib/Target/PowerPC/Disassembler/BUILD.gn
new file mode 100644 (file)
index 0000000..cdbd47a
--- /dev/null
@@ -0,0 +1,23 @@
+import("//llvm/utils/TableGen/tablegen.gni")
+
+tablegen("PPCGenDisassemblerTables") {
+  visibility = [ ":Disassembler" ]
+  args = [ "-gen-disassembler" ]
+  td_file = "../PPC.td"
+}
+
+static_library("Disassembler") {
+  output_name = "LLVMPowerPCDisassembler"
+  deps = [
+    ":PPCGenDisassemblerTables",
+    "//llvm/lib/MC/MCDisassembler",
+    "//llvm/lib/Support",
+    "//llvm/lib/Target/PowerPC/MCTargetDesc",
+    "//llvm/lib/Target/PowerPC/TargetInfo",
+  ]
+  include_dirs = [ ".." ]
+  sources = [
+    "PPCDisassembler.cpp",
+  ]
+}
+
diff --git a/llvm/utils/gn/secondary/llvm/lib/Target/PowerPC/InstPrinter/BUILD.gn b/llvm/utils/gn/secondary/llvm/lib/Target/PowerPC/InstPrinter/BUILD.gn
new file mode 100644 (file)
index 0000000..fcc9633
--- /dev/null
@@ -0,0 +1,25 @@
+import("//llvm/utils/TableGen/tablegen.gni")
+
+tablegen("PPCGenAsmWriter") {
+  visibility = [ ":InstPrinter" ]
+  args = [ "-gen-asm-writer" ]
+  td_file = "../PPC.td"
+}
+
+static_library("InstPrinter") {
+  output_name = "LLVMPowerPCAsmPrinter"
+  deps = [
+    ":PPCGenAsmWriter",
+    "//llvm/lib/MC",
+    "//llvm/lib/Support",
+
+    # MCTargetDesc depends on InstPrinter, so we can't depend on the full
+    # MCTargetDesc target here: it would form a cycle.
+    "//llvm/lib/Target/PowerPC/MCTargetDesc:tablegen",
+  ]
+  include_dirs = [ ".." ]
+  sources = [
+    "PPCInstPrinter.cpp",
+  ]
+}
+
diff --git a/llvm/utils/gn/secondary/llvm/lib/Target/PowerPC/MCTargetDesc/BUILD.gn b/llvm/utils/gn/secondary/llvm/lib/Target/PowerPC/MCTargetDesc/BUILD.gn
new file mode 100644 (file)
index 0000000..e5e01d2
--- /dev/null
@@ -0,0 +1,64 @@
+import("//llvm/utils/TableGen/tablegen.gni")
+
+tablegen("PPCGenInstrInfo") {
+  visibility = [ ":tablegen" ]
+  args = [ "-gen-instr-info" ]
+  td_file = "../PPC.td"
+}
+
+tablegen("PPCGenMCCodeEmitter") {
+  visibility = [ ":tablegen" ]
+  args = [ "-gen-emitter" ]
+  td_file = "../PPC.td"
+}
+
+tablegen("PPCGenRegisterInfo") {
+  visibility = [ ":tablegen" ]
+  args = [ "-gen-register-info" ]
+  td_file = "../PPC.td"
+}
+
+tablegen("PPCGenSubtargetInfo") {
+  visibility = [ ":tablegen" ]
+  args = [ "-gen-subtarget" ]
+  td_file = "../PPC.td"
+}
+
+group("tablegen") {
+  visibility = [
+    ":MCTargetDesc",
+    "../InstPrinter",
+    "../TargetInfo",
+  ]
+  public_deps = [
+    ":PPCGenInstrInfo",
+    ":PPCGenMCCodeEmitter",
+    ":PPCGenRegisterInfo",
+    ":PPCGenSubtargetInfo",
+  ]
+}
+
+static_library("MCTargetDesc") {
+  output_name = "LLVMPowerPCDesc"
+  public_deps = [
+    ":tablegen",
+  ]
+  deps = [
+    "//llvm/lib/MC",
+    "//llvm/lib/Support",
+    "//llvm/lib/Target/PowerPC/InstPrinter",
+    "//llvm/lib/Target/PowerPC/TargetInfo",
+  ]
+  include_dirs = [ ".." ]
+  sources = [
+    "PPCAsmBackend.cpp",
+    "PPCMCTargetDesc.cpp",
+    "PPCMCAsmInfo.cpp",
+    "PPCMCCodeEmitter.cpp",
+    "PPCMCExpr.cpp",
+    "PPCPredicates.cpp",
+    "PPCMachObjectWriter.cpp",
+    "PPCELFObjectWriter.cpp",
+  ]
+}
+
diff --git a/llvm/utils/gn/secondary/llvm/lib/Target/PowerPC/TargetInfo/BUILD.gn b/llvm/utils/gn/secondary/llvm/lib/Target/PowerPC/TargetInfo/BUILD.gn
new file mode 100644 (file)
index 0000000..fe9a5ef
--- /dev/null
@@ -0,0 +1,15 @@
+static_library("TargetInfo") {
+  output_name = "LLVMPowerPCInfo"
+  deps = [
+    "//llvm/lib/Support",
+
+    # MCTargetDesc depends on TargetInfo, so we can't depend on the full
+    # MCTargetDesc target here: it would form a cycle.
+    "//llvm/lib/Target/PowerPC/MCTargetDesc:tablegen",
+  ]
+  include_dirs = [ ".." ]
+  sources = [
+    "PowerPCTargetInfo.cpp",
+  ]
+}
+
index 5a01d7f..85055cf 100644 (file)
@@ -10,6 +10,8 @@ if (llvm_targets_to_build == "host") {
     llvm_targets_to_build = [ "AArch64" ]
   } else if (host_cpu == "arm") {
     llvm_targets_to_build = [ "ARM" ]
+  } else if (host_cpu == "pcc" || host_cpu == "pcc64") {
+    llvm_targets_to_build = [ "PowerPC" ]
   } else if (host_cpu == "x86" || host_cpu == "x64") {
     llvm_targets_to_build = [ "X86" ]
   } else {
@@ -20,6 +22,7 @@ if (llvm_targets_to_build == "host") {
   llvm_targets_to_build = [
     "AArch64",
     "ARM",
+    "PowerPC",
     "WebAssembly",
     "X86",
   ]
@@ -29,6 +32,7 @@ if (llvm_targets_to_build == "host") {
 # and remember which targets are built.
 llvm_build_AArch64 = false
 llvm_build_ARM = false
+llvm_build_PowerPC = false
 llvm_build_WebAssembly = false
 llvm_build_X86 = false
 foreach(target, llvm_targets_to_build) {
@@ -36,6 +40,8 @@ foreach(target, llvm_targets_to_build) {
     llvm_build_AArch64 = true
   } else if (target == "ARM") {
     llvm_build_ARM = true
+  } else if (target == "PowerPC") {
+    llvm_build_PowerPC = true
   } else if (target == "WebAssembly") {
     llvm_build_WebAssembly = true
   } else if (target == "X86") {
@@ -51,6 +57,8 @@ if (host_cpu == "arm64") {
   native_target = "AArch64"
 } else if (host_cpu == "arm") {
   native_target = "ARM"
+} else if (host_cpu == "pcc" || host_cpu == "pcc64") {
+  native_target = [ "PowerPC" ]
 } else if (host_cpu == "x86" || host_cpu == "x64") {
   native_target = "X86"
 } else {
index 418e8bc..ef4eea6 100644 (file)
@@ -5,6 +5,7 @@ static_library("lib") {
   deps = [
     "//llvm/lib/Analysis",
     "//llvm/lib/CodeGen",
+    "//llvm/lib/CodeGen/GlobalISel",
     "//llvm/lib/ExecutionEngine",
     "//llvm/lib/ExecutionEngine/MCJIT",
     "//llvm/lib/IR",
@@ -31,10 +32,12 @@ static_library("lib") {
     "Uops.cpp",
   ]
 
-  # FIXME: Add this once llvm/lib/Target/AArch64 exists.
-  #if (llvm_build_AArch64) {
-  #  deps += [ "AArch64" ]
-  #}
+  if (llvm_build_AArch64) {
+    deps += [ "AArch64" ]
+  }
+  if (llvm_build_PowerPC) {
+    deps += [ "PowerPC" ]
+  }
   if (llvm_build_X86) {
     deps += [ "X86" ]
   }
diff --git a/llvm/utils/gn/secondary/llvm/tools/llvm-exegesis/lib/PowerPC/BUILD.gn b/llvm/utils/gn/secondary/llvm/tools/llvm-exegesis/lib/PowerPC/BUILD.gn
new file mode 100644 (file)
index 0000000..4c4af42
--- /dev/null
@@ -0,0 +1,21 @@
+import("//llvm/utils/TableGen/tablegen.gni")
+
+tablegen("PPCGenExegesis") {
+  args = [ "-gen-exegesis" ]
+  td_file = "//llvm/lib/Target/PowerPC/PPC.td"
+}
+
+static_library("PowerPC") {
+  output_name = "LLVMExegesisPowerPC"
+  deps = [
+    ":PPCGenExegesis",
+
+    # Exegesis reaches inside the Target/PowerPC tablegen internals and must
+    # depend on these Target/PowerPC-internal build targets.
+    "//llvm/lib/Target/PowerPC/MCTargetDesc",
+  ]
+  sources = [
+    "Target.cpp",
+  ]
+  include_dirs = [ "//llvm/lib/Target/PowerPC" ]
+}
index de8e89f..b46d402 100644 (file)
@@ -57,6 +57,9 @@ group("unittests") {
   if (llvm_build_WebAssembly) {
     deps += [ "Target/WebAssembly:WebAssemblyTests" ]
   }
+  if (llvm_build_PowerPC) {
+    deps += [ "tools/llvm-exegesis/PowerPC:LLVMExegesisPowerPCTests" ]
+  }
   if (llvm_build_X86) {
     deps += [ "tools/llvm-exegesis/X86:LLVMExegesisX86Tests" ]
   }
diff --git a/llvm/utils/gn/secondary/llvm/unittests/tools/llvm-exegesis/PowerPC/BUILD.gn b/llvm/utils/gn/secondary/llvm/unittests/tools/llvm-exegesis/PowerPC/BUILD.gn
new file mode 100644 (file)
index 0000000..bbb37bd
--- /dev/null
@@ -0,0 +1,26 @@
+import("//llvm/utils/unittest/unittest.gni")
+
+unittest("LLVMExegesisPowerPCTests") {
+  deps = [
+    "//llvm/lib/DebugInfo/Symbolize",
+    "//llvm/lib/MC",
+    "//llvm/lib/MC/MCParser",
+    "//llvm/lib/Object",
+    "//llvm/lib/Support",
+    "//llvm/lib/Target/PowerPC",
+
+    # Exegesis reaches inside the Target/PowerPC tablegen internals and must
+    # depend on these Target/PowerPC-internal build targets.
+    "//llvm/lib/Target/PowerPC/MCTargetDesc",
+    "//llvm/tools/llvm-exegesis/lib",
+    "//llvm/tools/llvm-exegesis/lib/PowerPC",
+  ]
+  include_dirs = [
+    "//llvm/lib/Target/PowerPC",
+    "//llvm/tools/llvm-exegesis/lib",
+  ]
+  sources = [
+    "AnalysisTest.cpp",
+    "TargetTest.cpp",
+  ]
+}