mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-04-06 09:44:39 +00:00
Formatting changes. No functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122789 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
6f96b275b6
commit
2c502f915f
@ -10,11 +10,6 @@
|
||||
#include "ARM.h"
|
||||
#include "ARMTargetMachine.h"
|
||||
|
||||
#include "llvm/ADT/OwningPtr.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
#include "llvm/ADT/StringSwitch.h"
|
||||
|
||||
#include "llvm/MC/MCAsmInfo.h"
|
||||
#include "llvm/MC/MCParser/MCAsmLexer.h"
|
||||
#include "llvm/MC/MCParser/MCParsedAsmOperand.h"
|
||||
@ -23,6 +18,11 @@
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Target/TargetRegistry.h"
|
||||
|
||||
#include "llvm/ADT/OwningPtr.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
#include "llvm/ADT/StringSwitch.h"
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
@ -30,93 +30,92 @@ using namespace llvm;
|
||||
|
||||
namespace {
|
||||
|
||||
class ARMBaseAsmLexer : public TargetAsmLexer {
|
||||
const MCAsmInfo &AsmInfo;
|
||||
class ARMBaseAsmLexer : public TargetAsmLexer {
|
||||
const MCAsmInfo &AsmInfo;
|
||||
|
||||
const AsmToken &lexDefinite() {
|
||||
return getLexer()->Lex();
|
||||
const AsmToken &lexDefinite() {
|
||||
return getLexer()->Lex();
|
||||
}
|
||||
|
||||
AsmToken LexTokenUAL();
|
||||
protected:
|
||||
typedef std::map <std::string, unsigned> rmap_ty;
|
||||
|
||||
rmap_ty RegisterMap;
|
||||
|
||||
void InitRegisterMap(const TargetRegisterInfo *info) {
|
||||
unsigned numRegs = info->getNumRegs();
|
||||
|
||||
for (unsigned i = 0; i < numRegs; ++i) {
|
||||
const char *regName = info->getName(i);
|
||||
if (regName)
|
||||
RegisterMap[regName] = i;
|
||||
}
|
||||
}
|
||||
|
||||
unsigned MatchRegisterName(StringRef Name) {
|
||||
rmap_ty::iterator iter = RegisterMap.find(Name.str());
|
||||
if (iter != RegisterMap.end())
|
||||
return iter->second;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
AsmToken LexToken() {
|
||||
if (!Lexer) {
|
||||
SetError(SMLoc(), "No MCAsmLexer installed");
|
||||
return AsmToken(AsmToken::Error, "", 0);
|
||||
}
|
||||
|
||||
AsmToken LexTokenUAL();
|
||||
protected:
|
||||
typedef std::map <std::string, unsigned> rmap_ty;
|
||||
|
||||
rmap_ty RegisterMap;
|
||||
|
||||
void InitRegisterMap(const TargetRegisterInfo *info) {
|
||||
unsigned numRegs = info->getNumRegs();
|
||||
|
||||
for (unsigned i = 0; i < numRegs; ++i) {
|
||||
const char *regName = info->getName(i);
|
||||
if (regName)
|
||||
RegisterMap[regName] = i;
|
||||
}
|
||||
switch (AsmInfo.getAssemblerDialect()) {
|
||||
default:
|
||||
SetError(SMLoc(), "Unhandled dialect");
|
||||
return AsmToken(AsmToken::Error, "", 0);
|
||||
case 0:
|
||||
return LexTokenUAL();
|
||||
}
|
||||
}
|
||||
public:
|
||||
ARMBaseAsmLexer(const Target &T, const MCAsmInfo &MAI)
|
||||
: TargetAsmLexer(T), AsmInfo(MAI) {
|
||||
}
|
||||
};
|
||||
|
||||
unsigned MatchRegisterName(StringRef Name) {
|
||||
rmap_ty::iterator iter = RegisterMap.find(Name.str());
|
||||
if (iter != RegisterMap.end())
|
||||
return iter->second;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
class ARMAsmLexer : public ARMBaseAsmLexer {
|
||||
public:
|
||||
ARMAsmLexer(const Target &T, const MCAsmInfo &MAI)
|
||||
: ARMBaseAsmLexer(T, MAI) {
|
||||
std::string tripleString("arm-unknown-unknown");
|
||||
std::string featureString;
|
||||
OwningPtr<const TargetMachine>
|
||||
targetMachine(T.createTargetMachine(tripleString, featureString));
|
||||
InitRegisterMap(targetMachine->getRegisterInfo());
|
||||
}
|
||||
};
|
||||
|
||||
AsmToken LexToken() {
|
||||
if (!Lexer) {
|
||||
SetError(SMLoc(), "No MCAsmLexer installed");
|
||||
return AsmToken(AsmToken::Error, "", 0);
|
||||
}
|
||||
class ThumbAsmLexer : public ARMBaseAsmLexer {
|
||||
public:
|
||||
ThumbAsmLexer(const Target &T, const MCAsmInfo &MAI)
|
||||
: ARMBaseAsmLexer(T, MAI) {
|
||||
std::string tripleString("thumb-unknown-unknown");
|
||||
std::string featureString;
|
||||
OwningPtr<const TargetMachine>
|
||||
targetMachine(T.createTargetMachine(tripleString, featureString));
|
||||
InitRegisterMap(targetMachine->getRegisterInfo());
|
||||
}
|
||||
};
|
||||
|
||||
switch (AsmInfo.getAssemblerDialect()) {
|
||||
default:
|
||||
SetError(SMLoc(), "Unhandled dialect");
|
||||
return AsmToken(AsmToken::Error, "", 0);
|
||||
case 0:
|
||||
return LexTokenUAL();
|
||||
}
|
||||
}
|
||||
public:
|
||||
ARMBaseAsmLexer(const Target &T, const MCAsmInfo &MAI)
|
||||
: TargetAsmLexer(T), AsmInfo(MAI) {
|
||||
}
|
||||
};
|
||||
|
||||
class ARMAsmLexer : public ARMBaseAsmLexer {
|
||||
public:
|
||||
ARMAsmLexer(const Target &T, const MCAsmInfo &MAI)
|
||||
: ARMBaseAsmLexer(T, MAI) {
|
||||
std::string tripleString("arm-unknown-unknown");
|
||||
std::string featureString;
|
||||
OwningPtr<const TargetMachine>
|
||||
targetMachine(T.createTargetMachine(tripleString, featureString));
|
||||
InitRegisterMap(targetMachine->getRegisterInfo());
|
||||
}
|
||||
};
|
||||
|
||||
class ThumbAsmLexer : public ARMBaseAsmLexer {
|
||||
public:
|
||||
ThumbAsmLexer(const Target &T, const MCAsmInfo &MAI)
|
||||
: ARMBaseAsmLexer(T, MAI) {
|
||||
std::string tripleString("thumb-unknown-unknown");
|
||||
std::string featureString;
|
||||
OwningPtr<const TargetMachine>
|
||||
targetMachine(T.createTargetMachine(tripleString, featureString));
|
||||
InitRegisterMap(targetMachine->getRegisterInfo());
|
||||
}
|
||||
};
|
||||
}
|
||||
} // end anonymous namespace
|
||||
|
||||
AsmToken ARMBaseAsmLexer::LexTokenUAL() {
|
||||
const AsmToken &lexedToken = lexDefinite();
|
||||
|
||||
switch (lexedToken.getKind()) {
|
||||
default:
|
||||
return AsmToken(lexedToken);
|
||||
default: break;
|
||||
case AsmToken::Error:
|
||||
SetError(Lexer->getErrLoc(), Lexer->getErr());
|
||||
return AsmToken(lexedToken);
|
||||
case AsmToken::Identifier:
|
||||
{
|
||||
break;
|
||||
case AsmToken::Identifier: {
|
||||
std::string upperCase = lexedToken.getString().str();
|
||||
std::string lowerCase = LowercaseString(upperCase);
|
||||
StringRef lowerRef(lowerCase);
|
||||
@ -137,19 +136,17 @@ AsmToken ARMBaseAsmLexer::LexTokenUAL() {
|
||||
.Default(0);
|
||||
}
|
||||
|
||||
if (regID) {
|
||||
if (regID)
|
||||
return AsmToken(AsmToken::Register,
|
||||
lexedToken.getString(),
|
||||
static_cast<int64_t>(regID));
|
||||
} else {
|
||||
return AsmToken(lexedToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return AsmToken(lexedToken);
|
||||
}
|
||||
|
||||
extern "C" void LLVMInitializeARMAsmLexer() {
|
||||
RegisterAsmLexer<ARMAsmLexer> X(TheARMTarget);
|
||||
RegisterAsmLexer<ThumbAsmLexer> Y(TheThumbTarget);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user