Skip to content

Commit

Permalink
gn build: add RISCV target
Browse files Browse the repository at this point in the history
Patch from David L. Jones <dlj@google.com>, with minor tweaks by me.

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

llvm-svn: 363154
  • Loading branch information
nico committed Jun 12, 2019
1 parent a4db4bb commit 2aa3f3d
Show file tree
Hide file tree
Showing 7 changed files with 234 additions and 0 deletions.
24 changes: 24 additions & 0 deletions llvm/utils/gn/secondary/llvm/lib/Target/RISCV/AsmParser/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import("//llvm/utils/TableGen/tablegen.gni")

tablegen("RISCVGenAsmMatcher") {
visibility = [ ":AsmParser" ]
args = [ "-gen-asm-matcher" ]
td_file = "../RISCV.td"
}

static_library("AsmParser") {
output_name = "LLVMRISCVAsmParser"
deps = [
":RISCVGenAsmMatcher",
"//llvm/lib/MC",
"//llvm/lib/MC/MCParser",
"//llvm/lib/Support",
"//llvm/lib/Target/RISCV:RISCVGenCompressInstEmitter",
"//llvm/lib/Target/RISCV/MCTargetDesc",
"//llvm/lib/Target/RISCV/Utils",
]
include_dirs = [ ".." ]
sources = [
"RISCVAsmParser.cpp",
]
}
78 changes: 78 additions & 0 deletions llvm/utils/gn/secondary/llvm/lib/Target/RISCV/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
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("RISCVGenDAGISel") {
visibility = [ ":LLVMRISCVCodeGen" ]
args = [ "-gen-dag-isel" ]
td_file = "RISCV.td"
}

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

static_library("LLVMRISCVCodeGen") {
deps = [
":RISCVGenCompressInstEmitter",
":RISCVGenDAGISel",
":RISCVGenMCPseudoLowering",
"MCTargetDesc",
"TargetInfo",
"Utils",
"//llvm/include/llvm/Config:llvm-config",
"//llvm/lib/CodeGen",
"//llvm/lib/CodeGen/AsmPrinter",
"//llvm/lib/CodeGen/SelectionDAG",
"//llvm/lib/IR",
"//llvm/lib/MC",
"//llvm/lib/Support",
"//llvm/lib/Target",
]
include_dirs = [ "." ]
sources = [
"RISCVAsmPrinter.cpp",
"RISCVExpandPseudoInsts.cpp",
"RISCVFrameLowering.cpp",
"RISCVISelDAGToDAG.cpp",
"RISCVISelLowering.cpp",
"RISCVInstrInfo.cpp",
"RISCVMCInstLower.cpp",
"RISCVMergeBaseOffset.cpp",
"RISCVRegisterInfo.cpp",
"RISCVSubtarget.cpp",
"RISCVTargetMachine.cpp",
"RISCVTargetObjectFile.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",
"MCTargetDesc",
"TargetInfo",
"Utils",
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import("//llvm/utils/TableGen/tablegen.gni")

tablegen("RISCVGenDisassemblerTables") {
visibility = [ ":Disassembler" ]
args = [ "-gen-disassembler" ]
td_file = "../RISCV.td"
}

static_library("Disassembler") {
output_name = "LLVMRISCVDisassembler"
deps = [
":RISCVGenDisassemblerTables",
"//llvm/lib/MC/MCDisassembler",
"//llvm/lib/Support",
"//llvm/lib/Target/RISCV/MCTargetDesc",
"//llvm/lib/Target/RISCV/Utils",
]
include_dirs = [ ".." ]
sources = [
"RISCVDisassembler.cpp",
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
import("//llvm/utils/TableGen/tablegen.gni")

tablegen("RISCVGenAsmWriter") {
visibility = [ ":MCTargetDesc" ]
args = [ "-gen-asm-writer" ]
td_file = "../RISCV.td"
}

tablegen("RISCVGenInstrInfo") {
visibility = [ ":tablegen" ]
args = [ "-gen-instr-info" ]
td_file = "../RISCV.td"
}

tablegen("RISCVGenMCCodeEmitter") {
visibility = [ ":MCTargetDesc" ]
args = [ "-gen-emitter" ]
td_file = "../RISCV.td"
}

tablegen("RISCVGenRegisterInfo") {
visibility = [ ":tablegen" ]
args = [ "-gen-register-info" ]
td_file = "../RISCV.td"
}

tablegen("RISCVGenSubtargetInfo") {
visibility = [ ":tablegen" ]
args = [ "-gen-subtarget" ]
td_file = "../RISCV.td"
}

# This should contain tablegen targets generating .inc files included
# by other targets. .inc files only used by .cpp files in this directory
# should be in deps on the static_library instead.
group("tablegen") {
visibility = [
":MCTargetDesc",
"../Utils",
]
public_deps = [
":RISCVGenInstrInfo",
":RISCVGenRegisterInfo",
":RISCVGenSubtargetInfo",
]
}

static_library("MCTargetDesc") {
output_name = "LLVMRISCVDesc"
public_deps = [
":tablegen",
]
deps = [
":RISCVGenAsmWriter",
":RISCVGenMCCodeEmitter",
"//llvm/lib/MC",
"//llvm/lib/Support",
"//llvm/lib/Target/RISCV:RISCVGenCompressInstEmitter",
"//llvm/lib/Target/RISCV/Utils",
]
include_dirs = [ ".." ]
sources = [
"RISCVAsmBackend.cpp",
"RISCVELFObjectWriter.cpp",
"RISCVELFStreamer.cpp",
"RISCVInstPrinter.cpp",
"RISCVMCAsmInfo.cpp",
"RISCVMCCodeEmitter.cpp",
"RISCVMCExpr.cpp",
"RISCVMCTargetDesc.cpp",
"RISCVTargetStreamer.cpp",
]
}
10 changes: 10 additions & 0 deletions llvm/utils/gn/secondary/llvm/lib/Target/RISCV/TargetInfo/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
static_library("TargetInfo") {
output_name = "LLVMRISCVInfo"
deps = [
"//llvm/lib/Support",
]
include_dirs = [ ".." ]
sources = [
"RISCVTargetInfo.cpp",
]
}
25 changes: 25 additions & 0 deletions llvm/utils/gn/secondary/llvm/lib/Target/RISCV/Utils/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import("//llvm/utils/TableGen/tablegen.gni")

tablegen("RISCVGenSystemOperands") {
visibility = [ ":Utils" ]
args = [ "-gen-searchable-tables" ]
td_file = "../RISCV.td"
}

static_library("Utils") {
output_name = "LLVMRISCVUtils"
public_deps = [
":RISCVGenSystemOperands",
]
deps = [
"//llvm/lib/MC",
"//llvm/lib/Support",
"//llvm/lib/Target/RISCV/MCTargetDesc:tablegen",
]

include_dirs = [ ".." ]
sources = [
"RISCVBaseInfo.cpp",
"RISCVMatInt.cpp",
]
}
2 changes: 2 additions & 0 deletions llvm/utils/gn/secondary/llvm/lib/Target/targets.gni
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ foreach(target, llvm_targets_to_build) {
# Nothing to do.
} else if (target == "PowerPC") {
llvm_build_PowerPC = true
} else if (target == "RISCV") {
# Nothing to do.
} else if (target == "Sparc") {
# Nothing to do.
} else if (target == "WebAssembly") {
Expand Down

0 comments on commit 2aa3f3d

Please sign in to comment.