Skip to content

Commit 484903e

Browse files
committed
MIR Parser: Allow the dollar characters in all of the identifier tokens.
This commit modifies the machine instruction lexer so that it now accepts the '$' characters in identifier tokens. This change makes the syntax for unquoted global value tokens consistent with the syntax for the global idenfitier tokens in the LLVM's assembly language. llvm-svn: 242584
1 parent 91443ed commit 484903e

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

llvm/lib/CodeGen/MIRParser/MILexer.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,11 @@ static Cursor skipWhitespace(Cursor C) {
6161
return C;
6262
}
6363

64+
/// Return true if the given character satisfies the following regular
65+
/// expression: [-a-zA-Z$._0-9]
6466
static bool isIdentifierChar(char C) {
65-
return isalpha(C) || isdigit(C) || C == '_' || C == '-' || C == '.';
67+
return isalpha(C) || isdigit(C) || C == '_' || C == '-' || C == '.' ||
68+
C == '$';
6669
}
6770

6871
static MIToken::TokenKind getIdentifierKind(StringRef Identifier) {

llvm/test/CodeGen/MIR/X86/global-value-operands.mir

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,20 @@
2020
ret i32 %b
2121
}
2222

23+
@.$0 = external global i32
24+
@-_- = external global i32
25+
@_-_a = external global i32
26+
@$.-B = external global i32
27+
28+
define i32 @test() {
29+
entry:
30+
%a = load i32, i32* @.$0
31+
store i32 %a, i32* @-_-
32+
%b = load i32, i32* @_-_a
33+
store i32 %b, i32* @$.-B
34+
ret i32 %b
35+
}
36+
2337
...
2438
---
2539
# CHECK: name: inc
@@ -47,3 +61,23 @@ body:
4761
- '%eax = INC32r %eax, implicit-def %eflags'
4862
- 'RETQ %eax'
4963
...
64+
---
65+
name: test
66+
body:
67+
- id: 0
68+
name: entry
69+
instructions:
70+
# CHECK: , @".$0",
71+
# CHECK: , @-_-,
72+
# CHECK: , @_-_a,
73+
# CHECK: , @"$.-B",
74+
- '%rax = MOV64rm %rip, 1, _, @.$0, _'
75+
- '%eax = MOV32rm killed %rax, 1, _, 0, _'
76+
- '%rcx = MOV64rm %rip, 1, _, @-_-, _'
77+
- 'MOV32mr killed %rcx, 1, _, 0, _, killed %eax'
78+
- '%rax = MOV64rm %rip, 1, _, @_-_a, _'
79+
- '%eax = MOV32rm killed %rax, 1, _, 0, _'
80+
- '%rcx = MOV64rm %rip, 1, _, @$.-B, _'
81+
- 'MOV32mr killed %rcx, 1, _, 0, _, %eax'
82+
- 'RETQ %eax'
83+
...

0 commit comments

Comments
 (0)