mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-04-02 15:51:54 +00:00
[RISCV] Add support for .half, .hword, .word, .dword directives
These directives are recognised by gas. Support is added through the use of addAliasForDirective. Also match RISC-V gcc in preferring .half and .word for 16-bit and 32-bit data directives. llvm-svn: 332574
This commit is contained in:
parent
0f5432fae7
commit
b8b1f76ba4
@ -105,6 +105,10 @@ public:
|
||||
RISCVAsmParser(const MCSubtargetInfo &STI, MCAsmParser &Parser,
|
||||
const MCInstrInfo &MII, const MCTargetOptions &Options)
|
||||
: MCTargetAsmParser(Options, STI, MII) {
|
||||
Parser.addAliasForDirective(".half", ".2byte");
|
||||
Parser.addAliasForDirective(".hword", ".2byte");
|
||||
Parser.addAliasForDirective(".word", ".4byte");
|
||||
Parser.addAliasForDirective(".dword", ".8byte");
|
||||
setAvailableFeatures(ComputeAvailableFeatures(STI.getFeatureBits()));
|
||||
}
|
||||
};
|
||||
|
@ -22,4 +22,6 @@ RISCVMCAsmInfo::RISCVMCAsmInfo(const Triple &TT) {
|
||||
CommentString = "#";
|
||||
AlignmentIsInBytes = false;
|
||||
SupportsDebugInformation = true;
|
||||
Data16bitsDirective = "\t.half\t";
|
||||
Data32bitsDirective = "\t.word\t";
|
||||
}
|
||||
|
23
test/MC/RISCV/data-directives-invalid.s
Normal file
23
test/MC/RISCV/data-directives-invalid.s
Normal file
@ -0,0 +1,23 @@
|
||||
# RUN: not llvm-mc -triple riscv32 < %s 2>&1 | FileCheck %s
|
||||
# RUN: not llvm-mc -triple riscv64 < %s 2>&1 | FileCheck %s
|
||||
|
||||
# CHECK: [[@LINE+1]]:7: error: out of range literal value in '.byte' directive
|
||||
.byte 0xffa
|
||||
# CHECK: [[@LINE+1]]:7: error: out of range literal value in '.half' directive
|
||||
.half 0xffffa
|
||||
# CHECK: [[@LINE+1]]:8: error: out of range literal value in '.short' directive
|
||||
.short 0xffffa
|
||||
# CHECK: [[@LINE+1]]:8: error: out of range literal value in '.hword' directive
|
||||
.hword 0xffffa
|
||||
# CHECK: [[@LINE+1]]:8: error: out of range literal value in '.2byte' directive
|
||||
.2byte 0xffffa
|
||||
# CHECK: [[@LINE+1]]:7: error: out of range literal value in '.word' directive
|
||||
.word 0xffffffffa
|
||||
# CHECK: [[@LINE+1]]:7: error: out of range literal value in '.long' directive
|
||||
.long 0xffffffffa
|
||||
# CHECK: [[@LINE+1]]:8: error: out of range literal value in '.4byte' directive
|
||||
.4byte 0xffffffffa
|
||||
# CHECK: [[@LINE+1]]:8: error: literal value out of range for directive in '.dword' directive
|
||||
.dword 0xffffffffffffffffa
|
||||
# CHECK: [[@LINE+1]]:8: error: literal value out of range for directive in '.8byte' directive
|
||||
.8byte 0xffffffffffffffffa
|
32
test/MC/RISCV/data-directives-valid.s
Normal file
32
test/MC/RISCV/data-directives-valid.s
Normal file
@ -0,0 +1,32 @@
|
||||
# RUN: llvm-mc -filetype=obj -triple riscv32 < %s \
|
||||
# RUN: | llvm-objdump -s - | FileCheck %s
|
||||
# RUN: llvm-mc -filetype=obj -triple riscv64 < %s \
|
||||
# RUN: | llvm-objdump -s - | FileCheck %s
|
||||
|
||||
# Check that data directives supported by gas are also supported by LLVM MC.
|
||||
# As there was some confusion about whether .half/.word/.dword imply
|
||||
# alignment (see <https://github.com/riscv/riscv-asm-manual/issues/12>), we
|
||||
# are sure to check this.
|
||||
|
||||
.data
|
||||
|
||||
# CHECK: Contents of section .data:
|
||||
# CHECK-NEXT: 0000 deadbeef badcaf11 22334455 66778800
|
||||
.byte 0xde
|
||||
.half 0xbead
|
||||
.word 0xafdcbaef
|
||||
.dword 0x8877665544332211
|
||||
.byte 0
|
||||
|
||||
# CHECK-NEXT: 0010 deadbeef badcaf11 22334455 66778800
|
||||
.byte 0xde
|
||||
.2byte 0xbead
|
||||
.4byte 0xafdcbaef
|
||||
.8byte 0x8877665544332211
|
||||
.byte 0
|
||||
|
||||
# CHECK-NEXT: 0020 deadbeef badcaf11 22
|
||||
.byte 0xde
|
||||
.short 0xbead
|
||||
.long 0xafdcbaef
|
||||
.hword 0x2211
|
Loading…
x
Reference in New Issue
Block a user