diff options
| author | Alex Bradbury <asb@lowrisc.org> | 2017-08-08 14:32:35 +0000 |
|---|---|---|
| committer | Alex Bradbury <asb@lowrisc.org> | 2017-08-08 14:32:35 +0000 |
| commit | 1a4272914da23c2f39fcebcbe63998d1c0ff4330 (patch) | |
| tree | 23a72916bb3bf690de4c560b8a921dfcd6b6a2c1 /llvm/lib | |
| parent | 59b81e51d330420a73f93b46b264b8c7f07b178a (diff) | |
| download | bcm5719-llvm-1a4272914da23c2f39fcebcbe63998d1c0ff4330.tar.gz bcm5719-llvm-1a4272914da23c2f39fcebcbe63998d1c0ff4330.zip | |
[RISCV] Add basic RISCVAsmParser
This doesn't yet support parsing things like %pcrel_hi(foo), but will handle
basic instructions with register or immediate operands.
Differential Revision: https://reviews.llvm.org/D23563
llvm-svn: 310361
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Target/RISCV/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | llvm/lib/Target/RISCV/LLVMBuild.txt | 3 | ||||
| -rw-r--r-- | llvm/lib/Target/RISCV/RISCV.td | 5 | ||||
| -rw-r--r-- | llvm/lib/Target/RISCV/RISCVInstrInfo.td | 11 |
4 files changed, 19 insertions, 2 deletions
diff --git a/llvm/lib/Target/RISCV/CMakeLists.txt b/llvm/lib/Target/RISCV/CMakeLists.txt index c8887548b91..47e53a36722 100644 --- a/llvm/lib/Target/RISCV/CMakeLists.txt +++ b/llvm/lib/Target/RISCV/CMakeLists.txt @@ -3,6 +3,7 @@ set(LLVM_TARGET_DEFINITIONS RISCV.td) tablegen(LLVM RISCVGenRegisterInfo.inc -gen-register-info) tablegen(LLVM RISCVGenInstrInfo.inc -gen-instr-info) tablegen(LLVM RISCVGenMCCodeEmitter.inc -gen-emitter) +tablegen(LLVM RISCVGenAsmMatcher.inc -gen-asm-matcher) add_public_tablegen_target(RISCVCommonTableGen) @@ -10,5 +11,6 @@ add_llvm_target(RISCVCodeGen RISCVTargetMachine.cpp ) +add_subdirectory(AsmParser) add_subdirectory(TargetInfo) add_subdirectory(MCTargetDesc) diff --git a/llvm/lib/Target/RISCV/LLVMBuild.txt b/llvm/lib/Target/RISCV/LLVMBuild.txt index 9ba5fec928f..3e540048921 100644 --- a/llvm/lib/Target/RISCV/LLVMBuild.txt +++ b/llvm/lib/Target/RISCV/LLVMBuild.txt @@ -16,12 +16,13 @@ ;===------------------------------------------------------------------------===; [common] -subdirectories = TargetInfo MCTargetDesc +subdirectories = AsmParser TargetInfo MCTargetDesc [component_0] type = TargetGroup name = RISCV parent = Target +has_asmparser = 1 [component_1] type = Library diff --git a/llvm/lib/Target/RISCV/RISCV.td b/llvm/lib/Target/RISCV/RISCV.td index 14838309a1b..19e11839ac3 100644 --- a/llvm/lib/Target/RISCV/RISCV.td +++ b/llvm/lib/Target/RISCV/RISCV.td @@ -22,6 +22,11 @@ def : ProcessorModel<"generic-rv32", NoSchedModel, []>; def : ProcessorModel<"generic-rv64", NoSchedModel, [Feature64Bit]>; +def RISCVAsmParser : AsmParser { + let ShouldEmitMatchRegisterAltName = 1; +} + def RISCV : Target { let InstructionSet = RISCVInstrInfo; + let AssemblyParsers = [RISCVAsmParser]; } diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.td b/llvm/lib/Target/RISCV/RISCVInstrInfo.td index 52530c2f136..93d13f79390 100644 --- a/llvm/lib/Target/RISCV/RISCVInstrInfo.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.td @@ -13,7 +13,16 @@ include "RISCVInstrFormats.td" -def simm12 : Operand<i32>; +class SImmAsmOperand<int width> + : AsmOperandClass { + let Name = "SImm" # width; + let RenderMethod = "addImmOperands"; + let DiagnosticType = !strconcat("Invalid", Name); +} + +def simm12 : Operand<i32> { + let ParserMatchClass = SImmAsmOperand<12>; +} // As noted in RISCVRegisterInfo.td, the hope is that support for // variable-sized register classes will mean that instruction definitions do |

