mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-26 21:32:10 +00:00
Add support for assigning to . in AsmParser.
This is implemented by handling assignments to the '.' pseudo symbol as ".org" directives. Differential Revision: http://llvm-reviews.chandlerc.com/D2625 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201530 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3457506fb9
commit
1410f7ffc6
@ -2119,12 +2119,6 @@ bool AsmParser::parseAssignment(StringRef Name, bool allow_redef,
|
|||||||
if (Lexer.isNot(AsmToken::EndOfStatement))
|
if (Lexer.isNot(AsmToken::EndOfStatement))
|
||||||
return TokError("unexpected token in assignment");
|
return TokError("unexpected token in assignment");
|
||||||
|
|
||||||
// Error on assignment to '.'.
|
|
||||||
if (Name == ".") {
|
|
||||||
return Error(EqualLoc, ("assignment to pseudo-symbol '.' is unsupported "
|
|
||||||
"(use '.space' or '.org').)"));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Eat the end of statement marker.
|
// Eat the end of statement marker.
|
||||||
Lex();
|
Lex();
|
||||||
|
|
||||||
@ -2152,11 +2146,15 @@ bool AsmParser::parseAssignment(StringRef Name, bool allow_redef,
|
|||||||
|
|
||||||
// Don't count these checks as uses.
|
// Don't count these checks as uses.
|
||||||
Sym->setUsed(false);
|
Sym->setUsed(false);
|
||||||
|
} else if (Name == ".") {
|
||||||
|
if (Out.EmitValueToOffset(Value, 0)) {
|
||||||
|
Error(EqualLoc, "expected absolute expression");
|
||||||
|
eatToEndOfStatement();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
} else
|
} else
|
||||||
Sym = getContext().GetOrCreateSymbol(Name);
|
Sym = getContext().GetOrCreateSymbol(Name);
|
||||||
|
|
||||||
// FIXME: Handle '.'.
|
|
||||||
|
|
||||||
// Do the assignment.
|
// Do the assignment.
|
||||||
Out.EmitAssignment(Sym, Value);
|
Out.EmitAssignment(Sym, Value);
|
||||||
if (NoDeadStrip)
|
if (NoDeadStrip)
|
||||||
|
12
test/MC/AsmParser/dot-symbol-assignment-backwards.s
Normal file
12
test/MC/AsmParser/dot-symbol-assignment-backwards.s
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# RUN: not llvm-mc -filetype=obj -triple i386-unknown-unknown %s 2> %t
|
||||||
|
# RUN: FileCheck -input-file %t %s
|
||||||
|
|
||||||
|
. = 0x10
|
||||||
|
.byte 1
|
||||||
|
|
||||||
|
. = . + 10
|
||||||
|
.byte 2
|
||||||
|
|
||||||
|
# CHECK: LLVM ERROR: invalid .org offset '24' (at offset '28')
|
||||||
|
. = 0x18
|
||||||
|
.byte 3
|
31
test/MC/AsmParser/dot-symbol-assignment.s
Normal file
31
test/MC/AsmParser/dot-symbol-assignment.s
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
# RUN: llvm-mc -triple i386-unknown-unknown %s | FileCheck %s
|
||||||
|
|
||||||
|
.extern start
|
||||||
|
|
||||||
|
# CHECK: .org 1024, 0
|
||||||
|
. = 0x400
|
||||||
|
lgdt 0x400 + 0x100
|
||||||
|
|
||||||
|
ljmpl $0x08, $(0x400 + 0x150)
|
||||||
|
|
||||||
|
|
||||||
|
# CHECK: .org 1280, 0
|
||||||
|
. = 0x400 + 0x100
|
||||||
|
.word (3*8)-1
|
||||||
|
.quad (0x400 + 0x110)
|
||||||
|
|
||||||
|
# CHECK: .org 1296, 0
|
||||||
|
. = 0x400 + 0x110
|
||||||
|
.quad 0x0
|
||||||
|
.quad 0x0020980000000000
|
||||||
|
.quad 0x0000900000000000
|
||||||
|
|
||||||
|
.code64
|
||||||
|
|
||||||
|
# CHECK: .org 1360, 0
|
||||||
|
. = 0x400 + 0x150
|
||||||
|
movabsq $start, %rcx
|
||||||
|
jmp *%rcx
|
||||||
|
|
||||||
|
|
||||||
|
. = 0x300
|
9
test/MC/AsmParser/dot-symbol-non-absolute.s
Normal file
9
test/MC/AsmParser/dot-symbol-non-absolute.s
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# RUN: not llvm-mc -filetype=obj -triple i386-unknown-unknown %s 2> %t
|
||||||
|
# RUN: FileCheck -input-file %t %s
|
||||||
|
|
||||||
|
|
||||||
|
.extern foo
|
||||||
|
|
||||||
|
# CHECK: error: expected absolute expression
|
||||||
|
. = foo + 10
|
||||||
|
.byte 1
|
@ -1,12 +1,9 @@
|
|||||||
# Historically 'as' treats '.' as a reference to the current location in
|
# Historically 'as' treats '.' as a reference to the current location in
|
||||||
# arbitrary contects. We don't support this in general.
|
# arbitrary contexts. We don't support this in general.
|
||||||
|
|
||||||
# RUN: not llvm-mc -triple i386-unknown-unknown %s 2> %t
|
# RUN: not llvm-mc -triple i386-unknown-unknown %s 2> %t
|
||||||
# RUN: FileCheck -input-file %t %s
|
# RUN: FileCheck -input-file %t %s
|
||||||
|
|
||||||
# CHECK: assignment to pseudo-symbol '.' is unsupported (use '.space' or '.org').
|
|
||||||
. = . + 8
|
|
||||||
|
|
||||||
# CHECK: invalid use of pseudo-symbol '.' as a label
|
# CHECK: invalid use of pseudo-symbol '.' as a label
|
||||||
.:
|
.:
|
||||||
.long 0
|
.long 0
|
||||||
|
22
test/MC/ELF/dot-symbol-assignment.s
Normal file
22
test/MC/ELF/dot-symbol-assignment.s
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o - | llvm-readobj -sections -section-data | FileCheck %s
|
||||||
|
|
||||||
|
one:
|
||||||
|
.quad 0xffffffffffffffff
|
||||||
|
|
||||||
|
. = . + 16
|
||||||
|
two:
|
||||||
|
.quad 0xeeeeeeeeeeeeeeee
|
||||||
|
|
||||||
|
. = 0x20
|
||||||
|
three:
|
||||||
|
.quad 0xdddddddddddddddd
|
||||||
|
|
||||||
|
// CHECK: Section {
|
||||||
|
// CHECK: Name: .text
|
||||||
|
// CHECK-NEXT: Type:
|
||||||
|
// CHECK-NEXT: Flags [
|
||||||
|
// CHECK: SectionData (
|
||||||
|
// CHECK-NEXT: 0000: FFFFFFFF FFFFFFFF 00000000 00000000
|
||||||
|
// CHECK-NEXT: 0010: 00000000 00000000 EEEEEEEE EEEEEEEE
|
||||||
|
// CHECK-NEXT: 0020: DDDDDDDD DDDDDDDD
|
||||||
|
// CHECK-NEXT: )
|
Loading…
Reference in New Issue
Block a user