AsmParser.cpp (204961) | AsmParser.cpp (205218) |
---|---|
1//===- AsmParser.cpp - Parser for Assembly Files --------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 6 unchanged lines hidden (view full) --- 15#include "llvm/ADT/SmallString.h" 16#include "llvm/ADT/Twine.h" 17#include "llvm/MC/MCContext.h" 18#include "llvm/MC/MCExpr.h" 19#include "llvm/MC/MCInst.h" 20#include "llvm/MC/MCSectionMachO.h" 21#include "llvm/MC/MCStreamer.h" 22#include "llvm/MC/MCSymbol.h" | 1//===- AsmParser.cpp - Parser for Assembly Files --------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// --- 6 unchanged lines hidden (view full) --- 15#include "llvm/ADT/SmallString.h" 16#include "llvm/ADT/Twine.h" 17#include "llvm/MC/MCContext.h" 18#include "llvm/MC/MCExpr.h" 19#include "llvm/MC/MCInst.h" 20#include "llvm/MC/MCSectionMachO.h" 21#include "llvm/MC/MCStreamer.h" 22#include "llvm/MC/MCSymbol.h" |
23#include "llvm/MC/MCValue.h" | |
24#include "llvm/MC/MCParser/MCParsedAsmOperand.h" 25#include "llvm/Support/Compiler.h" 26#include "llvm/Support/SourceMgr.h" 27#include "llvm/Support/raw_ostream.h" 28#include "llvm/Target/TargetAsmParser.h" 29using namespace llvm; 30 31 --- 102 unchanged lines hidden (view full) --- 134 } 135 136 if (tok->is(AsmToken::Error)) 137 PrintMessage(Lexer.getErrLoc(), Lexer.getErr(), "error"); 138 139 return *tok; 140} 141 | 23#include "llvm/MC/MCParser/MCParsedAsmOperand.h" 24#include "llvm/Support/Compiler.h" 25#include "llvm/Support/SourceMgr.h" 26#include "llvm/Support/raw_ostream.h" 27#include "llvm/Target/TargetAsmParser.h" 28using namespace llvm; 29 30 --- 102 unchanged lines hidden (view full) --- 133 } 134 135 if (tok->is(AsmToken::Error)) 136 PrintMessage(Lexer.getErrLoc(), Lexer.getErr(), "error"); 137 138 return *tok; 139} 140 |
142bool AsmParser::Run() { 143 // Create the initial section. | 141bool AsmParser::Run(bool NoInitialTextSection) { 142 // Create the initial section, if requested. |
144 // | 143 // |
145 // FIXME: Support -n. | |
146 // FIXME: Target hook & command line option for initial section. | 144 // FIXME: Target hook & command line option for initial section. |
147 Out.SwitchSection(getMachOSection("__TEXT", "__text", 148 MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS, 149 0, SectionKind::getText())); | 145 if (!NoInitialTextSection) 146 Out.SwitchSection(getMachOSection("__TEXT", "__text", 147 MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS, 148 0, SectionKind::getText())); |
150 | 149 |
151 | |
152 // Prime the lexer. 153 Lex(); 154 155 bool HadError = false; 156 157 AsmCond StartingCondState = TheCondState; 158 159 // While we have input, parse each statement. --- 99 unchanged lines hidden (view full) --- 259 Lex(); // Eat the operator. 260 if (ParsePrimaryExpr(Res, EndLoc)) 261 return true; 262 Res = MCUnaryExpr::CreateLNot(Res, getContext()); 263 return false; 264 case AsmToken::String: 265 case AsmToken::Identifier: { 266 // This is a symbol reference. | 150 // Prime the lexer. 151 Lex(); 152 153 bool HadError = false; 154 155 AsmCond StartingCondState = TheCondState; 156 157 // While we have input, parse each statement. --- 99 unchanged lines hidden (view full) --- 257 Lex(); // Eat the operator. 258 if (ParsePrimaryExpr(Res, EndLoc)) 259 return true; 260 Res = MCUnaryExpr::CreateLNot(Res, getContext()); 261 return false; 262 case AsmToken::String: 263 case AsmToken::Identifier: { 264 // This is a symbol reference. |
267 MCSymbol *Sym = CreateSymbol(getTok().getIdentifier()); | 265 std::pair<StringRef, StringRef> Split = getTok().getIdentifier().split('@'); 266 MCSymbol *Sym = CreateSymbol(Split.first); 267 268 // Lookup the symbol variant if used. 269 MCSymbolRefExpr::VariantKind Variant = MCSymbolRefExpr::VK_None; 270 if (Split.first.size() != getTok().getIdentifier().size()) 271 Variant = MCSymbolRefExpr::getVariantKindForName(Split.second); 272 |
268 EndLoc = Lexer.getLoc(); 269 Lex(); // Eat identifier. 270 271 // If this is an absolute variable reference, substitute it now to preserve 272 // semantics in the face of reassignment. 273 if (Sym->getValue() && isa<MCConstantExpr>(Sym->getValue())) { | 273 EndLoc = Lexer.getLoc(); 274 Lex(); // Eat identifier. 275 276 // If this is an absolute variable reference, substitute it now to preserve 277 // semantics in the face of reassignment. 278 if (Sym->getValue() && isa<MCConstantExpr>(Sym->getValue())) { |
279 if (Variant) 280 return Error(EndLoc, "unexpected modified on variable reference"); 281 |
|
274 Res = Sym->getValue(); 275 return false; 276 } 277 278 // Otherwise create a symbol ref. | 282 Res = Sym->getValue(); 283 return false; 284 } 285 286 // Otherwise create a symbol ref. |
279 Res = MCSymbolRefExpr::Create(Sym, getContext()); | 287 Res = MCSymbolRefExpr::Create(Sym, Variant, getContext()); |
280 return false; 281 } 282 case AsmToken::Integer: 283 Res = MCConstantExpr::Create(getTok().getIntVal(), getContext()); 284 EndLoc = Lexer.getLoc(); 285 Lex(); // Eat token. 286 return false; 287 case AsmToken::LParen: --- 1511 unchanged lines hidden --- | 288 return false; 289 } 290 case AsmToken::Integer: 291 Res = MCConstantExpr::Create(getTok().getIntVal(), getContext()); 292 EndLoc = Lexer.getLoc(); 293 Lex(); // Eat token. 294 return false; 295 case AsmToken::LParen: --- 1511 unchanged lines hidden --- |