Skip to content

Commit

Permalink
[AArch64] Don't store available subtarget features in AArch64SysReg::…
Browse files Browse the repository at this point in the history
…SysRegMapper

Subtarget features must not be a part of the target machine. So, they are now not being stored in SysRegMapper, but provided each time fromString()/toString() are called

Reviewers: jmolloy

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D8655


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@233386 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Vladimir Sukharev committed Mar 27, 2015
1 parent c18ea8d commit 0c27224
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
10 changes: 6 additions & 4 deletions lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2638,13 +2638,15 @@ AArch64AsmParser::tryParseSysReg(OperandVector &Operands) {
return MatchOperand_NoMatch;

bool IsKnown;
auto MRSMapper = AArch64SysReg::MRSMapper(STI.getFeatureBits());
uint32_t MRSReg = MRSMapper.fromString(Tok.getString(), IsKnown);
auto MRSMapper = AArch64SysReg::MRSMapper();
uint32_t MRSReg = MRSMapper.fromString(Tok.getString(), STI.getFeatureBits(),
IsKnown);
assert(IsKnown == (MRSReg != -1U) &&
"register should be -1 if and only if it's unknown");

auto MSRMapper = AArch64SysReg::MSRMapper(STI.getFeatureBits());
uint32_t MSRReg = MSRMapper.fromString(Tok.getString(), IsKnown);
auto MSRMapper = AArch64SysReg::MSRMapper();
uint32_t MSRReg = MSRMapper.fromString(Tok.getString(), STI.getFeatureBits(),
IsKnown);
assert(IsKnown == (MSRReg != -1U) &&
"register should be -1 if and only if it's unknown");

Expand Down
8 changes: 4 additions & 4 deletions lib/Target/AArch64/InstPrinter/AArch64InstPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1276,8 +1276,8 @@ void AArch64InstPrinter::printMRSSystemRegister(const MCInst *MI, unsigned OpNo,
raw_ostream &O) {
unsigned Val = MI->getOperand(OpNo).getImm();

auto Mapper = AArch64SysReg::MRSMapper(getAvailableFeatures());
std::string Name = Mapper.toString(Val);
auto Mapper = AArch64SysReg::MRSMapper();
std::string Name = Mapper.toString(Val, getAvailableFeatures());

O << StringRef(Name).upper();
}
Expand All @@ -1286,8 +1286,8 @@ void AArch64InstPrinter::printMSRSystemRegister(const MCInst *MI, unsigned OpNo,
raw_ostream &O) {
unsigned Val = MI->getOperand(OpNo).getImm();

auto Mapper = AArch64SysReg::MSRMapper(getAvailableFeatures());
std::string Name = Mapper.toString(Val);
auto Mapper = AArch64SysReg::MSRMapper();
std::string Name = Mapper.toString(Val, getAvailableFeatures());

O << StringRef(Name).upper();
}
Expand Down
11 changes: 5 additions & 6 deletions lib/Target/AArch64/Utils/AArch64BaseInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,7 @@ const AArch64NamedImmMapper::Mapping AArch64SysReg::MRSMapper::MRSMappings[] = {
{"ich_elsr_el2", ICH_ELSR_EL2}
};

AArch64SysReg::MRSMapper::MRSMapper(uint64_t FeatureBits)
: SysRegMapper(FeatureBits) {
AArch64SysReg::MRSMapper::MRSMapper() {
InstMappings = &MRSMappings[0];
NumInstMappings = llvm::array_lengthof(MRSMappings);
}
Expand All @@ -269,8 +268,7 @@ const AArch64NamedImmMapper::Mapping AArch64SysReg::MSRMapper::MSRMappings[] = {
{"icc_sgi0r_el1", ICC_SGI0R_EL1}
};

AArch64SysReg::MSRMapper::MSRMapper(uint64_t FeatureBits)
: SysRegMapper(FeatureBits) {
AArch64SysReg::MSRMapper::MSRMapper() {
InstMappings = &MSRMappings[0];
NumInstMappings = llvm::array_lengthof(MSRMappings);
}
Expand Down Expand Up @@ -761,7 +759,8 @@ AArch64SysReg::SysRegMapper::CycloneSysRegMappings[] = {
};

uint32_t
AArch64SysReg::SysRegMapper::fromString(StringRef Name, bool &Valid) const {
AArch64SysReg::SysRegMapper::fromString(StringRef Name, uint64_t FeatureBits,
bool &Valid) const {
std::string NameLower = Name.lower();

// First search the registers shared by all
Expand Down Expand Up @@ -814,7 +813,7 @@ AArch64SysReg::SysRegMapper::fromString(StringRef Name, bool &Valid) const {
}

std::string
AArch64SysReg::SysRegMapper::toString(uint32_t Bits) const {
AArch64SysReg::SysRegMapper::toString(uint32_t Bits, uint64_t FeatureBits) const {
// First search the registers shared by all
for (unsigned i = 0; i < array_lengthof(SysRegMappings); ++i) {
if (SysRegMappings[i].Value == Bits) {
Expand Down
11 changes: 5 additions & 6 deletions lib/Target/AArch64/Utils/AArch64BaseInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -1139,21 +1139,20 @@ namespace AArch64SysReg {

const AArch64NamedImmMapper::Mapping *InstMappings;
size_t NumInstMappings;
uint64_t FeatureBits;

SysRegMapper(uint64_t FeatureBits) : FeatureBits(FeatureBits) { }
uint32_t fromString(StringRef Name, bool &Valid) const;
std::string toString(uint32_t Bits) const;
SysRegMapper() { }
uint32_t fromString(StringRef Name, uint64_t FeatureBits, bool &Valid) const;
std::string toString(uint32_t Bits, uint64_t FeatureBits) const;
};

struct MSRMapper : SysRegMapper {
static const AArch64NamedImmMapper::Mapping MSRMappings[];
MSRMapper(uint64_t FeatureBits);
MSRMapper();
};

struct MRSMapper : SysRegMapper {
static const AArch64NamedImmMapper::Mapping MRSMappings[];
MRSMapper(uint64_t FeatureBits);
MRSMapper();
};

uint32_t ParseGenericRegister(StringRef Name, bool &Valid);
Expand Down

0 comments on commit 0c27224

Please sign in to comment.