mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-29 22:50:47 +00:00
Move various generated tables into read-only memory, fixing up const correctness along the way.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142726 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
5b2bba6122
commit
1a2f9886a2
@ -1886,9 +1886,10 @@ void ARMOperand::print(raw_ostream &OS) const {
|
||||
OS << "<ccout " << getReg() << ">";
|
||||
break;
|
||||
case k_ITCondMask: {
|
||||
static char MaskStr[][6] = { "()", "(t)", "(e)", "(tt)", "(et)", "(te)",
|
||||
"(ee)", "(ttt)", "(ett)", "(tet)", "(eet)", "(tte)", "(ete)",
|
||||
"(tee)", "(eee)" };
|
||||
static const char *MaskStr[] = {
|
||||
"()", "(t)", "(e)", "(tt)", "(et)", "(te)", "(ee)", "(ttt)", "(ett)",
|
||||
"(tet)", "(eet)", "(tte)", "(ete)", "(tee)", "(eee)"
|
||||
};
|
||||
assert((ITMask.Mask & 0xf) == ITMask.Mask);
|
||||
OS << "<it-mask " << MaskStr[ITMask.Mask] << ">";
|
||||
break;
|
||||
@ -2366,7 +2367,7 @@ parseRegisterList(SmallVectorImpl<MCParsedAsmOperand*> &Operands) {
|
||||
if (Reg == -1)
|
||||
return Error(RegLoc, "register expected");
|
||||
|
||||
MCRegisterClass *RC;
|
||||
const MCRegisterClass *RC;
|
||||
if (ARMMCRegisterClasses[ARM::GPRRegClassID].contains(Reg))
|
||||
RC = &ARMMCRegisterClasses[ARM::GPRRegClassID];
|
||||
else if (ARMMCRegisterClasses[ARM::DPRRegClassID].contains(Reg))
|
||||
@ -4237,9 +4238,9 @@ static bool listContainsReg(MCInst &Inst, unsigned OpNo, unsigned Reg) {
|
||||
// the ARMInsts array) instead. Getting that here requires awkward
|
||||
// API changes, though. Better way?
|
||||
namespace llvm {
|
||||
extern MCInstrDesc ARMInsts[];
|
||||
extern const MCInstrDesc ARMInsts[];
|
||||
}
|
||||
static MCInstrDesc &getInstDesc(unsigned Opcode) {
|
||||
static const MCInstrDesc &getInstDesc(unsigned Opcode) {
|
||||
return ARMInsts[Opcode];
|
||||
}
|
||||
|
||||
@ -4247,7 +4248,7 @@ static MCInstrDesc &getInstDesc(unsigned Opcode) {
|
||||
bool ARMAsmParser::
|
||||
validateInstruction(MCInst &Inst,
|
||||
const SmallVectorImpl<MCParsedAsmOperand*> &Operands) {
|
||||
MCInstrDesc &MCID = getInstDesc(Inst.getOpcode());
|
||||
const MCInstrDesc &MCID = getInstDesc(Inst.getOpcode());
|
||||
SMLoc Loc = Operands[0]->getStartLoc();
|
||||
// Check the IT block state first.
|
||||
// NOTE: In Thumb mode, the BKPT instruction has the interesting property of
|
||||
@ -4605,7 +4606,7 @@ unsigned ARMAsmParser::checkTargetMatchPredicate(MCInst &Inst) {
|
||||
// 16-bit thumb arithmetic instructions either require or preclude the 'S'
|
||||
// suffix depending on whether they're in an IT block or not.
|
||||
unsigned Opc = Inst.getOpcode();
|
||||
MCInstrDesc &MCID = getInstDesc(Opc);
|
||||
const MCInstrDesc &MCID = getInstDesc(Opc);
|
||||
if (MCID.TSFlags & ARMII::ThumbArithFlagSetting) {
|
||||
assert(MCID.hasOptionalDef() &&
|
||||
"optionally flag setting instruction missing optional def operand");
|
||||
|
@ -415,7 +415,7 @@ DecodeStatus ARMDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
|
||||
}
|
||||
|
||||
namespace llvm {
|
||||
extern MCInstrDesc ARMInsts[];
|
||||
extern const MCInstrDesc ARMInsts[];
|
||||
}
|
||||
|
||||
/// tryAddingSymbolicOperand - trys to add a symbolic operand in place of the
|
||||
|
@ -30,14 +30,14 @@
|
||||
#include "MBlazeGenEDInfo.inc"
|
||||
|
||||
namespace llvm {
|
||||
extern MCInstrDesc MBlazeInsts[];
|
||||
extern const MCInstrDesc MBlazeInsts[];
|
||||
}
|
||||
|
||||
using namespace llvm;
|
||||
|
||||
const unsigned UNSUPPORTED = -1;
|
||||
|
||||
static unsigned mblazeBinary2Opcode[] = {
|
||||
static const unsigned mblazeBinary2Opcode[] = {
|
||||
MBlaze::ADD, MBlaze::RSUB, MBlaze::ADDC, MBlaze::RSUBC, //00,01,02,03
|
||||
MBlaze::ADDK, MBlaze::RSUBK, MBlaze::ADDKC, MBlaze::RSUBKC, //04,05,06,07
|
||||
MBlaze::ADDI, MBlaze::RSUBI, MBlaze::ADDIC, MBlaze::RSUBIC, //08,09,0A,0B
|
||||
|
@ -203,7 +203,7 @@ void InstrInfoEmitter::run(raw_ostream &OS) {
|
||||
|
||||
// Emit all of the MCInstrDesc records in their ENUM ordering.
|
||||
//
|
||||
OS << "\nMCInstrDesc " << TargetName << "Insts[] = {\n";
|
||||
OS << "\nextern const MCInstrDesc " << TargetName << "Insts[] = {\n";
|
||||
const std::vector<const CodeGenInstruction*> &NumberedInstructions =
|
||||
Target.getInstructionsByEnumValue();
|
||||
|
||||
@ -239,7 +239,7 @@ void InstrInfoEmitter::run(raw_ostream &OS) {
|
||||
OS << "#undef GET_INSTRINFO_CTOR\n";
|
||||
|
||||
OS << "namespace llvm {\n";
|
||||
OS << "extern MCInstrDesc " << TargetName << "Insts[];\n";
|
||||
OS << "extern const MCInstrDesc " << TargetName << "Insts[];\n";
|
||||
OS << ClassName << "::" << ClassName << "(int SO, int DO)\n"
|
||||
<< " : TargetInstrInfoImpl(SO, DO) {\n"
|
||||
<< " InitMCInstrInfo(" << TargetName << "Insts, "
|
||||
|
@ -41,7 +41,8 @@ RegisterInfoEmitter::runEnums(raw_ostream &OS,
|
||||
OS << "namespace llvm {\n\n";
|
||||
|
||||
OS << "class MCRegisterClass;\n"
|
||||
<< "extern MCRegisterClass " << Namespace << "MCRegisterClasses[];\n\n";
|
||||
<< "extern const MCRegisterClass " << Namespace
|
||||
<< "MCRegisterClasses[];\n\n";
|
||||
|
||||
if (!Namespace.empty())
|
||||
OS << "namespace " << Namespace << " {\n";
|
||||
@ -308,7 +309,7 @@ RegisterInfoEmitter::runMCDesc(raw_ostream &OS, CodeGenTarget &Target,
|
||||
}
|
||||
OS << "}\n"; // End of anonymous namespace...
|
||||
|
||||
OS << "\nMCRegisterDesc " << TargetName
|
||||
OS << "\nextern const MCRegisterDesc " << TargetName
|
||||
<< "RegDesc[] = { // Descriptors\n";
|
||||
OS << " { \"NOREG\",\t0,\t0,\t0 },\n";
|
||||
|
||||
@ -367,7 +368,8 @@ RegisterInfoEmitter::runMCDesc(raw_ostream &OS, CodeGenTarget &Target,
|
||||
}
|
||||
OS << "}\n\n";
|
||||
|
||||
OS << "MCRegisterClass " << TargetName << "MCRegisterClasses[] = {\n";
|
||||
OS << "extern const MCRegisterClass " << TargetName
|
||||
<< "MCRegisterClasses[] = {\n";
|
||||
|
||||
for (unsigned rc = 0, e = RegisterClasses.size(); rc != e; ++rc) {
|
||||
const CodeGenRegisterClass &RC = *RegisterClasses[rc];
|
||||
@ -489,8 +491,8 @@ RegisterInfoEmitter::runTargetDesc(raw_ostream &OS, CodeGenTarget &Target,
|
||||
OS << "namespace llvm {\n\n";
|
||||
|
||||
// Get access to MCRegisterClass data.
|
||||
OS << "extern MCRegisterClass " << Target.getName()
|
||||
<< "MCRegisterClasses[];\n";
|
||||
OS << "extern const MCRegisterClass " << Target.getName()
|
||||
<< "MCRegisterClasses[];\n";
|
||||
|
||||
// Start out by emitting each of the register classes.
|
||||
ArrayRef<CodeGenRegisterClass*> RegisterClasses = RegBank.getRegClasses();
|
||||
@ -818,7 +820,7 @@ RegisterInfoEmitter::runTargetDesc(raw_ostream &OS, CodeGenTarget &Target,
|
||||
OS << "}\n\n";
|
||||
|
||||
// Emit the constructor of the class...
|
||||
OS << "extern MCRegisterDesc " << TargetName << "RegDesc[];\n";
|
||||
OS << "extern const MCRegisterDesc " << TargetName << "RegDesc[];\n";
|
||||
|
||||
OS << ClassName << "::" << ClassName
|
||||
<< "(unsigned RA, unsigned DwarfFlavour, unsigned EHFlavour)\n"
|
||||
|
@ -81,7 +81,8 @@ unsigned SubtargetEmitter::FeatureKeyValues(raw_ostream &OS) {
|
||||
|
||||
// Begin feature table
|
||||
OS << "// Sorted (by key) array of values for CPU features.\n"
|
||||
<< "llvm::SubtargetFeatureKV " << Target << "FeatureKV[] = {\n";
|
||||
<< "extern const llvm::SubtargetFeatureKV " << Target
|
||||
<< "FeatureKV[] = {\n";
|
||||
|
||||
// For each feature
|
||||
unsigned NumFeatures = 0;
|
||||
@ -140,7 +141,8 @@ unsigned SubtargetEmitter::CPUKeyValues(raw_ostream &OS) {
|
||||
|
||||
// Begin processor table
|
||||
OS << "// Sorted (by key) array of values for CPU subtype.\n"
|
||||
<< "llvm::SubtargetFeatureKV " << Target << "SubTypeKV[] = {\n";
|
||||
<< "extern const llvm::SubtargetFeatureKV " << Target
|
||||
<< "SubTypeKV[] = {\n";
|
||||
|
||||
// For each processor
|
||||
for (unsigned i = 0, N = ProcessorList.size(); i < N;) {
|
||||
@ -327,9 +329,9 @@ void SubtargetEmitter::EmitStageAndOperandCycleData(raw_ostream &OS,
|
||||
OS << "\n// Pipeline forwarding pathes for itineraries \"" << Name
|
||||
<< "\"\n" << "namespace " << Name << "Bypass {\n";
|
||||
|
||||
OS << " unsigned NoBypass = 0;\n";
|
||||
OS << " const unsigned NoBypass = 0;\n";
|
||||
for (unsigned j = 0, BPN = BPs.size(); j < BPN; ++j)
|
||||
OS << " unsigned " << BPs[j]->getName()
|
||||
OS << " const unsigned " << BPs[j]->getName()
|
||||
<< " = 1 << " << j << ";\n";
|
||||
|
||||
OS << "}\n";
|
||||
@ -337,16 +339,17 @@ void SubtargetEmitter::EmitStageAndOperandCycleData(raw_ostream &OS,
|
||||
}
|
||||
|
||||
// Begin stages table
|
||||
std::string StageTable = "\nllvm::InstrStage " + Target + "Stages[] = {\n";
|
||||
std::string StageTable = "\nextern const llvm::InstrStage " + Target +
|
||||
"Stages[] = {\n";
|
||||
StageTable += " { 0, 0, 0, llvm::InstrStage::Required }, // No itinerary\n";
|
||||
|
||||
// Begin operand cycle table
|
||||
std::string OperandCycleTable = "unsigned " + Target +
|
||||
std::string OperandCycleTable = "extern const unsigned " + Target +
|
||||
"OperandCycles[] = {\n";
|
||||
OperandCycleTable += " 0, // No itinerary\n";
|
||||
|
||||
// Begin pipeline bypass table
|
||||
std::string BypassTable = "unsigned " + Target +
|
||||
std::string BypassTable = "extern const unsigned " + Target +
|
||||
"ForwardingPathes[] = {\n";
|
||||
BypassTable += " 0, // No itinerary\n";
|
||||
|
||||
@ -488,7 +491,7 @@ EmitProcessorData(raw_ostream &OS,
|
||||
|
||||
// Begin processor itinerary table
|
||||
OS << "\n";
|
||||
OS << "llvm::InstrItinerary " << Name << "[] = {\n";
|
||||
OS << "static const llvm::InstrItinerary " << Name << "[] = {\n";
|
||||
|
||||
// For each itinerary class
|
||||
std::vector<InstrItinerary> &ItinList = *ProcListIter++;
|
||||
@ -530,7 +533,7 @@ void SubtargetEmitter::EmitProcessorLookup(raw_ostream &OS) {
|
||||
// Begin processor table
|
||||
OS << "\n";
|
||||
OS << "// Sorted (by key) array of itineraries for CPU subtype.\n"
|
||||
<< "llvm::SubtargetInfoKV "
|
||||
<< "extern const llvm::SubtargetInfoKV "
|
||||
<< Target << "ProcItinKV[] = {\n";
|
||||
|
||||
// For each processor
|
||||
@ -720,13 +723,13 @@ void SubtargetEmitter::run(raw_ostream &OS) {
|
||||
OS << "#undef GET_SUBTARGETINFO_CTOR\n";
|
||||
|
||||
OS << "namespace llvm {\n";
|
||||
OS << "extern llvm::SubtargetFeatureKV " << Target << "FeatureKV[];\n";
|
||||
OS << "extern llvm::SubtargetFeatureKV " << Target << "SubTypeKV[];\n";
|
||||
OS << "extern const llvm::SubtargetFeatureKV " << Target << "FeatureKV[];\n";
|
||||
OS << "extern const llvm::SubtargetFeatureKV " << Target << "SubTypeKV[];\n";
|
||||
if (HasItineraries) {
|
||||
OS << "extern llvm::SubtargetInfoKV " << Target << "ProcItinKV[];\n";
|
||||
OS << "extern llvm::InstrStage " << Target << "Stages[];\n";
|
||||
OS << "extern unsigned " << Target << "OperandCycles[];\n";
|
||||
OS << "extern unsigned " << Target << "ForwardingPathes[];\n";
|
||||
OS << "extern const llvm::SubtargetInfoKV " << Target << "ProcItinKV[];\n";
|
||||
OS << "extern const llvm::InstrStage " << Target << "Stages[];\n";
|
||||
OS << "extern const unsigned " << Target << "OperandCycles[];\n";
|
||||
OS << "extern const unsigned " << Target << "ForwardingPathes[];\n";
|
||||
}
|
||||
|
||||
OS << ClassName << "::" << ClassName << "(StringRef TT, StringRef CPU, "
|
||||
|
Loading…
Reference in New Issue
Block a user