Index: llvm/trunk/utils/gn/secondary/BUILD.gn =================================================================== --- llvm/trunk/utils/gn/secondary/BUILD.gn +++ llvm/trunk/utils/gn/secondary/BUILD.gn @@ -1,9 +1,7 @@ group("default") { deps = [ - "//llvm/lib/CodeGen", - "//llvm/lib/Object", + "//llvm/tools/llc", "//llvm/tools/llvm-undname", - "//llvm/utils/TableGen:llvm-tblgen", ] } Index: llvm/trunk/utils/gn/secondary/llvm/lib/Target/BUILD.gn =================================================================== --- llvm/trunk/utils/gn/secondary/llvm/lib/Target/BUILD.gn +++ llvm/trunk/utils/gn/secondary/llvm/lib/Target/BUILD.gn @@ -1,5 +1,23 @@ import("//llvm/lib/Target/targets.gni") +# This build file has two parts: +# 1. The actual //llvm/lib/Target build target, which is just a static +# library containing the cpp files in this directory. It contains general +# shared target code. +# 2. Forwarding targets that forward to the concrete targets (X86, ARM, ...). +# These are defined in subdirectories, and the forwarding names match +# the names of the forwarding targets in CMake. They all (indirectly, +# through CodeGen) depend on the //llvm/lib/Target build target. +# (See also `gn help labels`). +# The dependency chain is: +# //llvm/lib/Target:TargetsToBuild (a target in this file) -> +# /llvm/lib/Target/(X86|ARM|...) (in the subdirectories) -> +# //llvm/lib/CodeGen -> +# //llvm/lib/Target (a target in this file again) +# Note that while this file appears twice in that stack, it's with different +# targets in this file, so there's no cyclic dependency. + +# 1. Actual build target. static_library("Target") { output_name = "LLVMTarget" deps = [ @@ -24,3 +42,49 @@ "TargetMachineC.cpp", ] } + +# 2. Forwarding targets. +group("NativeTarget") { + deps = [ + "$native_target", + ] +} + +group("TargetsToBuild") { + deps = llvm_targets_to_build +} + +group("AllTargetsAsmParsers") { + deps = [] + foreach(target, llvm_targets_to_build) { + deps += [ "$target/AsmParser" ] + } +} + +group("AllTargetsAsmPrinters") { + deps = [] + foreach(target, llvm_targets_to_build) { + deps += [ "$target/InstPrinter" ] + } +} + +group("AllTargetsDescs") { + deps = [] + foreach(target, llvm_targets_to_build) { + deps += [ "$target/MCTargetDesc" ] + } +} + +group("AllTargetsDisassemblers") { + deps = [] + foreach(target, llvm_targets_to_build) { + deps += [ "$target/Disassembler" ] + } +} + +group("AllTargetsInfos") { + deps = [] + foreach(target, llvm_targets_to_build) { + deps += [ "$target/TargetInfo" ] + } +} Index: llvm/trunk/utils/gn/secondary/llvm/lib/Target/X86/AsmParser/BUILD.gn =================================================================== --- llvm/trunk/utils/gn/secondary/llvm/lib/Target/X86/AsmParser/BUILD.gn +++ llvm/trunk/utils/gn/secondary/llvm/lib/Target/X86/AsmParser/BUILD.gn @@ -0,0 +1,25 @@ +import("//llvm/utils/TableGen/tablegen.gni") + +tablegen("X86GenAsmMatcher") { + visibility = [ ":AsmParser" ] + args = [ "-gen-asm-matcher" ] + td_file = "../X86.td" +} + +static_library("AsmParser") { + output_name = "LLVMX86AsmParser" + deps = [ + ":X86GenAsmMatcher", + "//llvm/lib/MC", + "//llvm/lib/MC/MCParser", + "//llvm/lib/Support", + "//llvm/lib/Target/X86/InstPrinter", + "//llvm/lib/Target/X86/MCTargetDesc", + "//llvm/lib/Target/X86/TargetInfo", + ] + include_dirs = [ ".." ] + sources = [ + "X86AsmInstrumentation.cpp", + "X86AsmParser.cpp", + ] +} Index: llvm/trunk/utils/gn/secondary/llvm/lib/Target/X86/BUILD.gn =================================================================== --- llvm/trunk/utils/gn/secondary/llvm/lib/Target/X86/BUILD.gn +++ llvm/trunk/utils/gn/secondary/llvm/lib/Target/X86/BUILD.gn @@ -0,0 +1,145 @@ +import("//llvm/utils/TableGen/tablegen.gni") + +declare_args() { + # Buggy, only use if you know what you're doing. + x86_gen_fold_tables = false +} + +tablegen("X86GenCallingConv") { + visibility = [ ":LLVMX86CodeGen" ] + args = [ "-gen-callingconv" ] + td_file = "X86.td" +} + +tablegen("X86GenDAGISel") { + visibility = [ ":LLVMX86CodeGen" ] + args = [ "-gen-dag-isel" ] + td_file = "X86.td" +} + +tablegen("X86GenEVEX2VEXTables") { + visibility = [ ":LLVMX86CodeGen" ] + args = [ "-gen-x86-EVEX2VEX-tables" ] + td_file = "X86.td" +} + +tablegen("X86GenFastISel") { + visibility = [ ":LLVMX86CodeGen" ] + args = [ "-gen-fast-isel" ] + td_file = "X86.td" +} + +tablegen("X86GenGlobalISel") { + visibility = [ ":LLVMX86CodeGen" ] + args = [ "-gen-global-isel" ] + td_file = "X86.td" +} + +tablegen("X86GenRegisterBank") { + visibility = [ ":LLVMX86CodeGen" ] + args = [ "-gen-register-bank" ] + td_file = "X86.td" +} + +if (x86_gen_fold_tables) { + tablegen("X86GenFoldTables") { + visibility = [ ":LLVMX86CodeGen" ] + args = [ "-gen-x86-fold-tables" ] + td_file = "X86.td" + } +} + +static_library("LLVMX86CodeGen") { + deps = [ + ":X86GenCallingConv", + ":X86GenDAGISel", + ":X86GenEVEX2VEXTables", + ":X86GenFastISel", + ":X86GenGlobalISel", + ":X86GenRegisterBank", + "InstPrinter", + "MCTargetDesc", + "TargetInfo", + "Utils", + "//llvm/include/llvm/Config:llvm-config", + "//llvm/lib/Analysis", + "//llvm/lib/CodeGen", + "//llvm/lib/CodeGen/AsmPrinter", + "//llvm/lib/CodeGen/GlobalISel", + "//llvm/lib/CodeGen/SelectionDAG", + "//llvm/lib/IR", + "//llvm/lib/MC", + "//llvm/lib/Support", + "//llvm/lib/Target", + ] + if (x86_gen_fold_tables) { + deps += [ ":X86GenFoldTables" ] + } + sources = [ + "ShadowCallStack.cpp", + "X86AsmPrinter.cpp", + "X86AvoidStoreForwardingBlocks.cpp", + "X86CallFrameOptimization.cpp", + "X86CallLowering.cpp", + "X86CallingConv.cpp", + "X86CmovConversion.cpp", + "X86CondBrFolding.cpp", + "X86DiscriminateMemOps.cpp", + "X86DomainReassignment.cpp", + "X86EvexToVex.cpp", + "X86ExpandPseudo.cpp", + "X86FastISel.cpp", + "X86FixupBWInsts.cpp", + "X86FixupLEAs.cpp", + "X86FixupSetCC.cpp", + "X86FlagsCopyLowering.cpp", + "X86FloatingPoint.cpp", + "X86FrameLowering.cpp", + "X86ISelDAGToDAG.cpp", + "X86ISelLowering.cpp", + "X86IndirectBranchTracking.cpp", + "X86InsertPrefetch.cpp", + "X86InstrFMA3Info.cpp", + "X86InstrFoldTables.cpp", + "X86InstrInfo.cpp", + "X86InstructionSelector.cpp", + "X86InterleavedAccess.cpp", + "X86LegalizerInfo.cpp", + "X86MCInstLower.cpp", + "X86MachineFunctionInfo.cpp", + "X86MacroFusion.cpp", + "X86OptimizeLEAs.cpp", + "X86PadShortFunction.cpp", + "X86RegisterBankInfo.cpp", + "X86RegisterInfo.cpp", + "X86RetpolineThunks.cpp", + "X86SelectionDAGInfo.cpp", + "X86ShuffleDecodeConstantPool.cpp", + "X86SpeculativeLoadHardening.cpp", + "X86Subtarget.cpp", + "X86TargetMachine.cpp", + "X86TargetObjectFile.cpp", + "X86TargetTransformInfo.cpp", + "X86VZeroUpper.cpp", + "X86WinAllocaExpander.cpp", + "X86WinEHState.cpp", + ] +} + +# This is a bit different from most build files: Due to this group +# having the directory's name, "//llvm/lib/Target/X86" 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("X86") { + deps = [ + ":LLVMX86CodeGen", + "AsmParser", + "Disassembler", + "InstPrinter", + "MCTargetDesc", + "TargetInfo", + "Utils", + ] +} Index: llvm/trunk/utils/gn/secondary/llvm/lib/Target/X86/Disassembler/BUILD.gn =================================================================== --- llvm/trunk/utils/gn/secondary/llvm/lib/Target/X86/Disassembler/BUILD.gn +++ llvm/trunk/utils/gn/secondary/llvm/lib/Target/X86/Disassembler/BUILD.gn @@ -0,0 +1,23 @@ +import("//llvm/utils/TableGen/tablegen.gni") + +tablegen("X86GenDisassemblerTables") { + visibility = [ ":Disassembler" ] + args = [ "-gen-disassembler" ] + td_file = "../X86.td" +} + +static_library("Disassembler") { + output_name = "LLVMX86Disassembler" + deps = [ + ":X86GenDisassemblerTables", + "//llvm/lib/MC/MCDisassembler", + "//llvm/lib/Support", + "//llvm/lib/Target/X86/MCTargetDesc", + "//llvm/lib/Target/X86/TargetInfo", + ] + include_dirs = [ ".." ] + sources = [ + "X86Disassembler.cpp", + "X86DisassemblerDecoder.cpp", + ] +} Index: llvm/trunk/utils/gn/secondary/llvm/lib/Target/X86/InstPrinter/BUILD.gn =================================================================== --- llvm/trunk/utils/gn/secondary/llvm/lib/Target/X86/InstPrinter/BUILD.gn +++ llvm/trunk/utils/gn/secondary/llvm/lib/Target/X86/InstPrinter/BUILD.gn @@ -0,0 +1,38 @@ +import("//llvm/utils/TableGen/tablegen.gni") + +tablegen("X86GenAsmWriter") { + visibility = [ ":InstPrinter" ] + args = [ "-gen-asm-writer" ] + td_file = "../X86.td" +} + +tablegen("X86GenAsmWriter1") { + visibility = [ ":InstPrinter" ] + args = [ + "-gen-asm-writer", + "-asmwriternum=1", + ] + td_file = "../X86.td" +} + +static_library("InstPrinter") { + output_name = "LLVMX86AsmPrinter" + deps = [ + ":X86GenAsmWriter", + ":X86GenAsmWriter1", + "//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/X86/MCTargetDesc:tablegen", + "//llvm/lib/Target/X86/Utils", + ] + include_dirs = [ ".." ] + sources = [ + "X86ATTInstPrinter.cpp", + "X86InstComments.cpp", + "X86InstPrinterCommon.cpp", + "X86IntelInstPrinter.cpp", + ] +} Index: llvm/trunk/utils/gn/secondary/llvm/lib/Target/X86/MCTargetDesc/BUILD.gn =================================================================== --- llvm/trunk/utils/gn/secondary/llvm/lib/Target/X86/MCTargetDesc/BUILD.gn +++ llvm/trunk/utils/gn/secondary/llvm/lib/Target/X86/MCTargetDesc/BUILD.gn @@ -0,0 +1,59 @@ +import("//llvm/utils/TableGen/tablegen.gni") + +tablegen("X86GenInstrInfo") { + visibility = [ ":tablegen" ] + args = [ "-gen-instr-info" ] + td_file = "../X86.td" +} + +tablegen("X86GenRegisterInfo") { + visibility = [ ":tablegen" ] + args = [ "-gen-register-info" ] + td_file = "../X86.td" +} + +tablegen("X86GenSubtargetInfo") { + visibility = [ ":tablegen" ] + args = [ "-gen-subtarget" ] + td_file = "../X86.td" +} + +group("tablegen") { + visibility = [ + ":MCTargetDesc", + "../InstPrinter", + "../TargetInfo", + ] + public_deps = [ + ":X86GenInstrInfo", + ":X86GenRegisterInfo", + ":X86GenSubtargetInfo", + ] +} + +static_library("MCTargetDesc") { + output_name = "LLVMX86Desc" + public_deps = [ + ":tablegen", + ] + deps = [ + "//llvm/lib/MC", + "//llvm/lib/MC/MCDisassembler", + "//llvm/lib/Object", + "//llvm/lib/Support", + "//llvm/lib/Target/X86/InstPrinter", + "//llvm/lib/Target/X86/TargetInfo", + ] + include_dirs = [ ".." ] + sources = [ + "X86AsmBackend.cpp", + "X86ELFObjectWriter.cpp", + "X86MCAsmInfo.cpp", + "X86MCCodeEmitter.cpp", + "X86MCTargetDesc.cpp", + "X86MachObjectWriter.cpp", + "X86WinCOFFObjectWriter.cpp", + "X86WinCOFFStreamer.cpp", + "X86WinCOFFTargetStreamer.cpp", + ] +} Index: llvm/trunk/utils/gn/secondary/llvm/lib/Target/X86/TargetInfo/BUILD.gn =================================================================== --- llvm/trunk/utils/gn/secondary/llvm/lib/Target/X86/TargetInfo/BUILD.gn +++ llvm/trunk/utils/gn/secondary/llvm/lib/Target/X86/TargetInfo/BUILD.gn @@ -0,0 +1,14 @@ +static_library("TargetInfo") { + output_name = "LLVMX86Info" + 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/X86/MCTargetDesc:tablegen", + ] + include_dirs = [ ".." ] + sources = [ + "X86TargetInfo.cpp", + ] +} Index: llvm/trunk/utils/gn/secondary/llvm/lib/Target/X86/Utils/BUILD.gn =================================================================== --- llvm/trunk/utils/gn/secondary/llvm/lib/Target/X86/Utils/BUILD.gn +++ llvm/trunk/utils/gn/secondary/llvm/lib/Target/X86/Utils/BUILD.gn @@ -0,0 +1,9 @@ +static_library("Utils") { + output_name = "LLVMX86Utils" + deps = [ + "//llvm/lib/Support", + ] + sources = [ + "X86ShuffleDecode.cpp", + ] +} Index: llvm/trunk/utils/gn/secondary/llvm/lib/Target/targets.gni =================================================================== --- llvm/trunk/utils/gn/secondary/llvm/lib/Target/targets.gni +++ llvm/trunk/utils/gn/secondary/llvm/lib/Target/targets.gni @@ -8,33 +8,21 @@ if (llvm_targets_to_build == "host") { if (host_cpu == "x86" || host_cpu == "x64") { llvm_targets_to_build = [ "X86" ] - } else if (host_cpu == "arm") { - llvm_targets_to_build = [ "ARM" ] - } else if (host_cpu == "arm64") { - llvm_targets_to_build = [ "AArch64" ] } else { assert(false, "add your host_cpu above") } } else if (llvm_targets_to_build == "all") { # FIXME: Port the remaining targets. llvm_targets_to_build = [ - "AArch64", - "ARM", "X86", ] } # Validate that llvm_targets_to_build is set to a list of valid targets, # and remember which targets are built. -llvm_build_AArch64 = false -llvm_build_ARM = false llvm_build_X86 = false foreach(target, llvm_targets_to_build) { - if (target == "AArch64") { - llvm_build_AArch64 = true - } else if (target == "ARM") { - llvm_build_ARM = true - } else if (target == "X86") { + if (target == "X86") { llvm_build_X86 = true } else { #FIXME : Port the remaining targets. @@ -45,10 +33,6 @@ # FIXME: This should be based off target_cpu once cross compiles work. if (host_cpu == "x86" || host_cpu == "x64") { native_target = "X86" -} else if (host_cpu == "arm") { - native_target = "ARM" -} else if (host_cpu == "arm64") { - native_target = "AArch64" } else { assert(false, "Unsuppored host_cpu '$host_cpu'.") } Index: llvm/trunk/utils/gn/secondary/llvm/tools/llc/BUILD.gn =================================================================== --- llvm/trunk/utils/gn/secondary/llvm/tools/llc/BUILD.gn +++ llvm/trunk/utils/gn/secondary/llvm/tools/llc/BUILD.gn @@ -0,0 +1,28 @@ +executable("llc") { + deps = [ + "//llvm/lib/Analysis", + "//llvm/lib/CodeGen", + "//llvm/lib/CodeGen/AsmPrinter", + "//llvm/lib/CodeGen/MIRParser", + "//llvm/lib/CodeGen/SelectionDAG", + "//llvm/lib/IR", + "//llvm/lib/IRReader", + "//llvm/lib/MC", + "//llvm/lib/Support", + "//llvm/lib/Target", + "//llvm/lib/Target:TargetsToBuild", + "//llvm/lib/Transforms/Scalar", + "//llvm/lib/Transforms/Utils", + "//llvm/lib/Transforms/Vectorize", + ] + sources = [ + "llc.cpp", + ] + + # Support plugins. + # FIXME: Disable dead stripping once other binaries are dead-stripped + if (host_os == "linux") { + # Corresponds to export_executable_symbols() in cmake. + ldflags = [ "-rdynamic" ] + } +}