llvm/llvm/utils/gn/secondary/llvm/lib/Target/RISCV/BUILD.gn

import("//llvm/utils/TableGen/tablegen.gni")

# RISCV is the only target that has a "compress instr emitter", and it's
# a bit strange in that it defines static functions depending on which
# defines are set. Instead of housing these functions in one library,
# various libraries include the generated .inc file with different defines set.
tablegen("RISCVGenCompressInstEmitter") {
  visibility = [
    ":LLVMRISCVCodeGen",
    "AsmParser",
    "MCTargetDesc",
  ]
  args = [ "-gen-compress-inst-emitter" ]
  td_file = "RISCV.td"
}

tablegen("RISCVGenMacroFusion") {
  visibility = [
    ":LLVMRISCVCodeGen",
    "//llvm/unittests/Target/RISCV:RISCVTests",
  ]
  args = [ "-gen-macro-fusion-pred" ]
  td_file = "RISCV.td"
}

tablegen("RISCVGenDAGISel") {
  visibility = [ ":LLVMRISCVCodeGen" ]
  args = [ "-gen-dag-isel" ]
  td_file = "RISCV.td"
}

tablegen("RISCVGenGlobalISel") {
  visibility = [ ":LLVMRISCVCodeGen" ]
  args = [ "-gen-global-isel" ]
  td_file = "RISCVGISel.td"
}

tablegen("RISCVGenO0PreLegalizeGICombiner") {
  visibility = [ ":LLVMRISCVCodeGen" ]
  args = [
    "-gen-global-isel-combiner",
    "-combiners=RISCVO0PreLegalizerCombiner",
  ]
  td_file = "RISCVGISel.td"
}

tablegen("RISCVGenMCPseudoLowering") {
  visibility = [ ":LLVMRISCVCodeGen" ]
  args = [ "-gen-pseudo-lowering" ]
  td_file = "RISCV.td"
}

tablegen("RISCVGenPreLegalizeGICombiner") {
  visibility = [ ":LLVMRISCVCodeGen" ]
  args = [
    "-gen-global-isel-combiner",
    "-combiners=RISCVPreLegalizerCombiner",
  ]
  td_file = "RISCVGISel.td"
}

tablegen("RISCVGenPostLegalizeGICombiner") {
  visibility = [ ":LLVMRISCVCodeGen" ]
  args = [
    "-gen-global-isel-combiner",
    "-combiners=RISCVPostLegalizerCombiner",
  ]
  td_file = "RISCVGISel.td"
}

tablegen("RISCVGenRegisterBank") {
  visibility = [ ":LLVMRISCVCodeGen" ]
  args = [ "-gen-register-bank" ]
  td_file = "RISCV.td"
}

static_library("LLVMRISCVCodeGen") {
  deps = [
    ":RISCVGenCompressInstEmitter",
    ":RISCVGenDAGISel",
    ":RISCVGenGlobalISel",
    ":RISCVGenMCPseudoLowering",
    ":RISCVGenMacroFusion",
    ":RISCVGenO0PreLegalizeGICombiner",
    ":RISCVGenPostLegalizeGICombiner",
    ":RISCVGenPreLegalizeGICombiner",
    ":RISCVGenRegisterBank",

    # See https://reviews.llvm.org/D69130
    "AsmParser:RISCVGenAsmMatcher",
    "MCTargetDesc",
    "TargetInfo",
    "//llvm/include/llvm/Config:llvm-config",
    "//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",
    "//llvm/lib/TargetParser",
    "//llvm/lib/Transforms/IPO",
  ]
  include_dirs = [ "." ]
  sources = [
    "GISel/RISCVCallLowering.cpp",
    "GISel/RISCVInstructionSelector.cpp",
    "GISel/RISCVLegalizerInfo.cpp",
    "GISel/RISCVO0PreLegalizerCombiner.cpp",
    "GISel/RISCVPostLegalizerCombiner.cpp",
    "GISel/RISCVPreLegalizerCombiner.cpp",
    "GISel/RISCVRegisterBankInfo.cpp",
    "RISCVAsmPrinter.cpp",
    "RISCVCallingConv.cpp",
    "RISCVCodeGenPrepare.cpp",
    "RISCVConstantPoolValue.cpp",
    "RISCVDeadRegisterDefinitions.cpp",
    "RISCVExpandAtomicPseudoInsts.cpp",
    "RISCVExpandPseudoInsts.cpp",
    "RISCVFrameLowering.cpp",
    "RISCVGatherScatterLowering.cpp",
    "RISCVISelDAGToDAG.cpp",
    "RISCVISelLowering.cpp",
    "RISCVIndirectBranchTracking.cpp",
    "RISCVInsertReadWriteCSR.cpp",
    "RISCVInsertVSETVLI.cpp",
    "RISCVInsertWriteVXRM.cpp",
    "RISCVInstrInfo.cpp",
    "RISCVLandingPadSetup.cpp",
    "RISCVMachineFunctionInfo.cpp",
    "RISCVMakeCompressible.cpp",
    "RISCVMergeBaseOffset.cpp",
    "RISCVMoveMerger.cpp",
    "RISCVOptWInstrs.cpp",
    "RISCVPostRAExpandPseudoInsts.cpp",
    "RISCVPushPopOptimizer.cpp",
    "RISCVRedundantCopyElimination.cpp",
    "RISCVRegisterInfo.cpp",
    "RISCVSubtarget.cpp",
    "RISCVTargetMachine.cpp",
    "RISCVTargetObjectFile.cpp",
    "RISCVTargetTransformInfo.cpp",
    "RISCVVectorPeephole.cpp",
    "RISCVZacasABIFix.cpp",
  ]
}

# This is a bit different from most build files: Due to this group
# having the directory's name, "//llvm/lib/Target/RISCV" 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("RISCV") {
  deps = [
    ":LLVMRISCVCodeGen",
    "AsmParser",
    "Disassembler",
    "MCA",
    "MCTargetDesc",
    "TargetInfo",
  ]
}