Skip to content

Commit

Permalink
[DPWBS-1414] Add suppot for .word and .hword directives
Browse files Browse the repository at this point in the history
  • Loading branch information
Edgar Solymosi committed Mar 27, 2020
1 parent 9ae52d2 commit 63e2661
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 0 deletions.
5 changes: 5 additions & 0 deletions llvm/lib/Target/TriCore/AsmParser/TriCoreAsmParser.cpp
Expand Up @@ -98,6 +98,11 @@ class TriCoreAsmParser : public MCTargetAsmParser {
TriCoreAsmParser(const MCSubtargetInfo &STI, MCAsmParser &Parser,
const MCInstrInfo &MII, const MCTargetOptions &Options)
: MCTargetAsmParser(Options, STI, MII) {
// Alias .hword and .word to the target-independent .2byte and .4byte
// directives as they have the same form and semantics
Parser.addAliasForDirective(".hword", ".2byte");
Parser.addAliasForDirective(".word", ".4byte");

setAvailableFeatures(ComputeAvailableFeatures(STI.getFeatureBits()));
}
};
Expand Down
19 changes: 19 additions & 0 deletions llvm/test/MC/TriCore/data-directives-invalid.s
@@ -0,0 +1,19 @@
# RUN: not llvm-mc -arch=tricore -filetype=obj < %s -o /dev/null 2>&1 \
# RUN: | FileCheck -check-prefix=CHECK %s

# CHECK: [[@LINE+1]]:7: error: out of range literal value in '.byte' directive
.byte 0xffa
# 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 '.8byte' directive
.8byte 0xffffffffffffffffa
58 changes: 58 additions & 0 deletions llvm/test/MC/TriCore/data-directives-valid.s
@@ -0,0 +1,58 @@
# RUN: llvm-mc -filetype=obj -triple tricore < %s \
# RUN: | llvm-objdump -s - | FileCheck %s

# Test data directives with non-literal arguments

# CHECK: Contents of section .strtab:
# CHECK-NEXT: ..rela.text..str
# CHECK-NEXT: tab..symtab..dat
# CHECK-NEXT: a.L.BE.LA.
.word LA
.long BE
.4byte L

# Test data directives with literal arguments

.data
# CHECK: Contents of section .data:
# CHECK-NEXT: aabbbbcc ccccccbb bbcccccc ccbbbbaa
.byte 0xaa
.hword 0xbbbb
.word 0xcccccccc
.2byte 0xbbbb
.4byte 0xcccccccc
.short 0xbbbb
.byte 0xaa

# CHECK-NEXT: aacccccc ccdddddd dddddddd ddbbbbaa
.byte 0xaa
.long 0xcccccccc
.8byte 0xdddddddddddddddd
.short 0xbbbb
.byte 0xaa

# CHECK-NEXT: bs.h.2.w...l...4
.byte 'b'
.short 's'
.hword 'h'
.2byte '2'
.word 'w'
.long 'l'
.4byte '4'

# CHECK-NEXT: ...8.......
.8byte '8'

# Test data directives with no operands

# CHECK: Contents of section .symtab:
# CHECK-NEXT: 00000000 00000000 00000000 00000000
.byte
.short
.hword
.2byte
.word
.long
.4byte
.8byte

0 comments on commit 63e2661

Please sign in to comment.