OS << " = ";
Value->print(OS, &MAI);
OS << '\n';
+
+ // FIXME: Lift context changes into super class.
+ Symbol->setValue(Value);
}
-void MCAsmStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
+void MCAsmStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
SymbolAttr Attribute) {
switch (Attribute) {
case Global: OS << ".globl"; break;
.long 0
.text
-foo:
+foo:
// CHECK: addl $24, a$b(%eax)
- addl $24, "a$b"(%eax)
+ addl $24, "a$b"(%eax)
// CHECK: addl $24, a$b+10(%eax)
addl $24, ("a$b" + 10)(%eax)
-
+
// CHECK: b$c = 10
"b$c" = 10
-// CHECK: addl $b$c, %eax
+// CHECK: addl $10, %eax
addl "b$c", %eax
-
+
// CHECK: "a 0" = 11
.set "a 0", 11
-
-// CHECK: .long "a 0"
+
+// CHECK: .long 11
.long "a 0"
// XXCHCK: .section "a 1,a 2"
.lcomm "a 7", 1
// FIXME: We don't bother to support .lsym.
-
+
// CHECX: .lsym "a 8",1
// .lsym "a 8", 1
// CHECK: "a 9" = a-b
.set "a 9", a - b
-
+
// CHECK: .long "a 9"
.long "a 9"
#include "llvm/MC/MCSectionMachO.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSymbol.h"
+#include "llvm/MC/MCValue.h"
#include "llvm/Support/SourceMgr.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetAsmParser.h"
Res = MCUnaryExpr::CreateLNot(Res, getContext());
return false;
case AsmToken::String:
- case AsmToken::Identifier:
- // This is a label, this should be parsed as part of an expression, to
- // handle things like LFOO+4.
- Res = MCSymbolRefExpr::Create(Lexer.getTok().getIdentifier(), getContext());
+ case AsmToken::Identifier: {
+ // This is a symbol reference.
+ MCSymbol *Sym = CreateSymbol(Lexer.getTok().getIdentifier());
Lexer.Lex(); // Eat identifier.
+
+ // If this is an absolute variable reference, substitute it now to preserve
+ // semantics in the face of reassignment.
+ if (Sym->getValue() && isa<MCConstantExpr>(Sym->getValue())) {
+ Res = Sym->getValue();
+ return false;
+ }
+
+ // Otherwise create a symbol ref.
+ Res = MCSymbolRefExpr::Create(Sym, getContext());
return false;
+ }
case AsmToken::Integer:
Res = MCConstantExpr::Create(Lexer.getTok().getIntVal(), getContext());
Lexer.Lex(); // Eat token.