Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android riscv64 support #11

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions llvm/Android.bp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,14 @@ llvm_aarch64_static_libraries = [
"libLLVM15AArch64Disassembler",
]

llvm_riscv_static_libraries = [
"libLLVM15RISCVCodeGen",
"libLLVM15RISCVInfo",
"libLLVM15RISCVDesc",
"libLLVM15RISCVAsmParser",
"libLLVM15RISCVDisassembler",
]

llvm_amdgpu_static_libraries = [
"libLLVM15AMDGPUCodeGen",
"libLLVM15AMDGPUInfo",
Expand Down Expand Up @@ -394,6 +402,9 @@ cc_library_shared {
whole_static_libs: llvm_aarch64_static_libraries +
llvm_arm_static_libraries,
},
android_riscv64: {
whole_static_libs: llvm_riscv_static_libraries,
},
},
}

Expand Down
10 changes: 6 additions & 4 deletions llvm/device/include/llvm/Config/AsmParsers.def
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
#elif defined(__i386__) || defined(__x86_64__)
LLVM_ASM_PARSER(X86)

#if defined(FORCE_BUILD_AMDGPU)
LLVM_ASM_PARSER(AMDGPU)
#endif

#if defined(FORCE_BUILD_ARM)
LLVM_ASM_PARSER(ARM)
LLVM_ASM_PARSER(AArch64)
Expand All @@ -43,8 +39,14 @@
#elif defined(__aarch64__)
LLVM_ASM_PARSER(ARM)
LLVM_ASM_PARSER(AArch64)
#elif defined(__riscv)
LLVM_ASM_PARSER(RISCV)
#else
# error Unsupported TARGET_ARCH for LLVM_ASM_PARSER
#endif

#if defined(FORCE_BUILD_AMDGPU)
LLVM_ASM_PARSER(AMDGPU)
#endif

#undef LLVM_ASM_PARSER
10 changes: 6 additions & 4 deletions llvm/device/include/llvm/Config/AsmPrinters.def
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
#elif defined(__i386__) || defined(__x86_64__)
LLVM_ASM_PRINTER(X86)

#if defined(FORCE_BUILD_AMDGPU)
LLVM_ASM_PRINTER(AMDGPU)
#endif

#if defined(FORCE_BUILD_ARM)
LLVM_ASM_PRINTER(ARM)
LLVM_ASM_PRINTER(AArch64)
Expand All @@ -43,8 +39,14 @@
#elif defined(__aarch64__)
LLVM_ASM_PRINTER(ARM)
LLVM_ASM_PRINTER(AArch64)
#elif defined(__riscv)
LLVM_ASM_PRINTER(RISCV)
#else
# error Unsupported TARGET_ARCH for LLVM_ASM_PRINTER
#endif

#if defined(FORCE_BUILD_AMDGPU)
LLVM_ASM_PRINTER(AMDGPU)
#endif

#undef LLVM_ASM_PRINTER
10 changes: 6 additions & 4 deletions llvm/device/include/llvm/Config/Disassemblers.def
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
#elif defined(__i386__) || defined(__x86_64__)
LLVM_DISASSEMBLER(X86)

#if defined(FORCE_BUILD_AMDGPU)
LLVM_DISASSEMBLER(AMDGPU)
#endif

#if defined(FORCE_BUILD_ARM)
LLVM_DISASSEMBLER(ARM)
LLVM_DISASSEMBLER(AArch64)
Expand All @@ -43,8 +39,14 @@
#elif defined(__aarch64__)
LLVM_DISASSEMBLER(ARM)
LLVM_DISASSEMBLER(AArch64)
#elif defined(__riscv)
LLVM_DISASSEMBLER(RISCV)
#else
# error Unsupported TARGET_ARCH for LLVM_DISASSEMBLER
#endif

#if defined(FORCE_BUILD_AMDGPU)
LLVM_DISASSEMBLER(AMDGPU)
#endif

#undef LLVM_DISASSEMBLER
10 changes: 6 additions & 4 deletions llvm/device/include/llvm/Config/TargetMCAs.def
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@
#elif defined(__i386__) || defined(__x86_64__)
LLVM_TARGETMCA(X86)

#if defined(FORCE_BUILD_AMDGPU)
LLVM_TARGETMCA(AMDGPU)
#endif

#if defined(FORCE_BUILD_ARM)
LLVM_TARGETMCA(ARM)
LLVM_TARGETMCA(AArch64)
Expand All @@ -43,8 +39,14 @@
#elif defined(__aarch64__)
LLVM_TARGETMCA(ARM)
LLVM_TARGETMCA(AArch64)
#elif defined(__riscv)
LLVM_TARGETMCA(RISCV)
#else
# error Unsupported TARGET_ARCH for LLVM_TARGETMCA
#endif

#if defined(FORCE_BUILD_AMDGPU)
LLVM_TARGETMCA(AMDGPU)
#endif

#undef LLVM_TARGETMCA
10 changes: 6 additions & 4 deletions llvm/device/include/llvm/Config/Targets.def
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@
#elif defined(__i386__) || defined(__x86_64__)
LLVM_TARGET(X86)

#if defined(FORCE_BUILD_AMDGPU)
LLVM_TARGET(AMDGPU)
#endif

#if defined(FORCE_BUILD_ARM)
LLVM_TARGET(ARM)
LLVM_TARGET(AArch64)
Expand All @@ -42,8 +38,14 @@
#elif defined(__aarch64__)
LLVM_TARGET(ARM)
LLVM_TARGET(AArch64)
#elif defined(__riscv)
LLVM_TARGET(RISCV)
#else
# error Unsupported TARGET_ARCH for LLVM_TARGET
#endif

#if defined(FORCE_BUILD_AMDGPU)
LLVM_TARGET(AMDGPU)
#endif

#undef LLVM_TARGET
26 changes: 26 additions & 0 deletions llvm/include/llvm/Config/llvm-platform-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,32 @@
/* LLVM name for the native target MC init function, if available */
#define LLVM_NATIVE_TARGETMC LLVMInitializeAArch64TargetMC

#elif defined(__riscv)

/* LLVM architecture name for the native architecture, if available */
#define LLVM_NATIVE_ARCH RISCV

/* Host triple LLVM will be executed on */
#define LLVM_HOST_TRIPLE "riscv64-none-linux-gnu"

/* LLVM name for the native AsmParser init function, if available */
#define LLVM_NATIVE_ASMPARSER LLVMInitializeRISCVAsmParser

/* LLVM name for the native AsmPrinter init function, if available */
#define LLVM_NATIVE_ASMPRINTER LLVMInitializeRISCVAsmPrinter

/* LLVM name for the native Disassembler init function, if available */
#define LLVM_NATIVE_DISASSEMBLER LLVMInitializeRISCVDisassembler

/* LLVM name for the native Target init function, if available */
#define LLVM_NATIVE_TARGET LLVMInitializeRISCVTarget

/* LLVM name for the native TargetInfo init function, if available */
#define LLVM_NATIVE_TARGETINFO LLVMInitializeRISCVTargetInfo

/* LLVM name for the native target MC init function, if available */
#define LLVM_NATIVE_TARGETMC LLVMInitializeRISCVTargetMC

#else

#error "Unknown native architecture"
Expand Down
48 changes: 48 additions & 0 deletions llvm/lib/Target/RISCV/Android.bp
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
cc_library_static {
name: "libLLVM15RISCVCodeGen",
defaults: [
"llvm15-lib-defaults",
"llvm15-riscv-defaults",
],
srcs: ["*.cpp"],
}

cc_defaults {
name: "llvm15-riscv-defaults",
generated_headers: ["llvm15-gen-riscv"],
static_libs: ["llvm15-riscv-headers"],
}

cc_library_static {
name: "llvm15-riscv-headers",
vendor_available: true,
host_supported: true,
target: {
windows: {
enabled: true,
},
},
export_include_dirs: ["."],
}

llvm15_tblgen {
name: "llvm15-gen-riscv",
in: "RISCV.td",
outs: [
"RISCVGenAsmMatcher.inc",
"RISCVGenAsmWriter.inc",
"RISCVGenCompressInstEmitter.inc",
"RISCVGenDAGISel.inc",
"RISCVGenDisassemblerTables.inc",
"RISCVGenGlobalISel.inc",
"RISCVGenInstrInfo.inc",
"RISCVGenMCCodeEmitter.inc",
"RISCVGenMCPseudoLowering.inc",
"RISCVGenRegisterBank.inc",
"RISCVGenRegisterInfo.inc",
"RISCVGenSearchableTables.inc",
"RISCVGenSubtargetInfo.inc",
],
}

subdirs = ["*"]
8 changes: 8 additions & 0 deletions llvm/lib/Target/RISCV/AsmParser/Android.bp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cc_library_static {
name: "libLLVM15RISCVAsmParser",
defaults: [
"llvm15-lib-defaults",
"llvm15-riscv-defaults",
],
srcs: ["*.cpp"],
}
8 changes: 8 additions & 0 deletions llvm/lib/Target/RISCV/Disassembler/Android.bp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cc_library_static {
name: "libLLVM15RISCVDisassembler",
defaults: [
"llvm15-lib-defaults",
"llvm15-riscv-defaults",
],
srcs: ["*.cpp"],
}
8 changes: 8 additions & 0 deletions llvm/lib/Target/RISCV/MCTargetDesc/Android.bp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cc_library_static {
name: "libLLVM15RISCVDesc",
defaults: [
"llvm15-lib-defaults",
"llvm15-riscv-defaults",
],
srcs: ["*.cpp"],
}
8 changes: 8 additions & 0 deletions llvm/lib/Target/RISCV/TargetInfo/Android.bp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cc_library_static {
name: "libLLVM15RISCVInfo",
defaults: [
"llvm15-lib-defaults",
"llvm15-riscv-defaults",
],
srcs: ["*.cpp"],
}
2 changes: 2 additions & 0 deletions llvm/soong/tblgen.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,8 @@ func outToGenerator(ctx android.ModuleContext, out string) string {
return "-gen-x86-EVEX2VEX-tables"
case strings.HasSuffix(out, "X86GenMnemonicTables.inc"):
return "-gen-x86-mnemonic-tables -asmwriternum=1"
case strings.HasSuffix(out, "CompressInstEmitter.inc"):
return "-gen-compress-inst-emitter"
case out == "Attributes.inc", out == "AttributesCompatFunc.inc":
return "-gen-attrs"
case out == "IntrinsicEnums.inc":
Expand Down