[llvm] r310361 - [RISCV] Add basic RISCVAsmParser
Alex Bradbury via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 8 07:32:35 PDT 2017
Author: asb
Date: Tue Aug 8 07:32:35 2017
New Revision: 310361
URL: http://llvm.org/viewvc/llvm-project?rev=310361&view=rev
Log:
[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
Modified:
llvm/trunk/lib/Target/RISCV/CMakeLists.txt
llvm/trunk/lib/Target/RISCV/LLVMBuild.txt
llvm/trunk/lib/Target/RISCV/RISCV.td
llvm/trunk/lib/Target/RISCV/RISCVInstrInfo.td
Modified: llvm/trunk/lib/Target/RISCV/CMakeLists.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/RISCV/CMakeLists.txt?rev=310361&r1=310360&r2=310361&view=diff
==============================================================================
--- llvm/trunk/lib/Target/RISCV/CMakeLists.txt (original)
+++ llvm/trunk/lib/Target/RISCV/CMakeLists.txt Tue Aug 8 07:32:35 2017
@@ -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)
Modified: llvm/trunk/lib/Target/RISCV/LLVMBuild.txt
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/RISCV/LLVMBuild.txt?rev=310361&r1=310360&r2=310361&view=diff
==============================================================================
--- llvm/trunk/lib/Target/RISCV/LLVMBuild.txt (original)
+++ llvm/trunk/lib/Target/RISCV/LLVMBuild.txt Tue Aug 8 07:32:35 2017
@@ -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
Modified: llvm/trunk/lib/Target/RISCV/RISCV.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/RISCV/RISCV.td?rev=310361&r1=310360&r2=310361&view=diff
==============================================================================
--- llvm/trunk/lib/Target/RISCV/RISCV.td (original)
+++ llvm/trunk/lib/Target/RISCV/RISCV.td Tue Aug 8 07:32:35 2017
@@ -22,6 +22,11 @@ def : ProcessorModel<"generic-rv32", NoS
def : ProcessorModel<"generic-rv64", NoSchedModel, [Feature64Bit]>;
+def RISCVAsmParser : AsmParser {
+ let ShouldEmitMatchRegisterAltName = 1;
+}
+
def RISCV : Target {
let InstructionSet = RISCVInstrInfo;
+ let AssemblyParsers = [RISCVAsmParser];
}
Modified: llvm/trunk/lib/Target/RISCV/RISCVInstrInfo.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/RISCV/RISCVInstrInfo.td?rev=310361&r1=310360&r2=310361&view=diff
==============================================================================
--- llvm/trunk/lib/Target/RISCV/RISCVInstrInfo.td (original)
+++ llvm/trunk/lib/Target/RISCV/RISCVInstrInfo.td Tue Aug 8 07:32:35 2017
@@ -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
More information about the llvm-commits
mailing list