[llvm-commits] [llvm] r151760 - in /llvm/trunk/utils/TableGen: AsmMatcherEmitter.cpp CodeGenTarget.cpp CodeGenTarget.h RegisterInfoEmitter.cpp

Benjamin Kramer benny.kra at googlemail.com
Wed Feb 29 17:13:02 PST 2012


On 01.03.2012, at 01:54, Jim Grosbach wrote:

> Hi Ben,
> 
> Unfortunately, this breaks what was my next step, which is to move getSubReg() into MCRegisterInfo and out of TargetRegisterInfo. For that to work, I need the table to always be of the same type so I can use a target-independent lookup function.

Feel free to revert if my stuff breaks your refactor.

- Ben

> 
> -Jim
> 
> 
> 
> On Feb 29, 2012, at 1:57 PM, Benjamin Kramer wrote:
> 
>> Author: d0k
>> Date: Wed Feb 29 15:57:08 2012
>> New Revision: 151760
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=151760&view=rev
>> Log:
>> Emit the SubRegTable with the smallest possible integer type.
>> 
>> Doesn't help ARM with its massive register set, but halves the size on x86 and all other targets.
>> 
>> Modified:
>>   llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp
>>   llvm/trunk/utils/TableGen/CodeGenTarget.cpp
>>   llvm/trunk/utils/TableGen/CodeGenTarget.h
>>   llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp
>> 
>> Modified: llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp?rev=151760&r1=151759&r2=151760&view=diff
>> ==============================================================================
>> --- llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp (original)
>> +++ llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Wed Feb 29 15:57:08 2012
>> @@ -2008,15 +2008,6 @@
>>  return true;
>> }
>> 
>> -static const char *getMinimalTypeForRange(uint64_t Range) {
>> -  assert(Range < 0xFFFFFFFFULL && "Enum too large");
>> -  if (Range > 0xFFFF)
>> -    return "uint32_t";
>> -  if (Range > 0xFF)
>> -    return "uint16_t";
>> -  return "uint8_t";
>> -}
>> -
>> static void EmitCustomOperandParsing(raw_ostream &OS, CodeGenTarget &Target,
>>                              const AsmMatcherInfo &Info, StringRef ClassName) {
>>  // Emit the static custom operand parsing table;
>> 
>> Modified: llvm/trunk/utils/TableGen/CodeGenTarget.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenTarget.cpp?rev=151760&r1=151759&r2=151760&view=diff
>> ==============================================================================
>> --- llvm/trunk/utils/TableGen/CodeGenTarget.cpp (original)
>> +++ llvm/trunk/utils/TableGen/CodeGenTarget.cpp Wed Feb 29 15:57:08 2012
>> @@ -108,6 +108,14 @@
>>  return Namespace + "::" + R->getName();
>> }
>> 
>> +const char *llvm::getMinimalTypeForRange(uint64_t Range) {
>> +  assert(Range < 0xFFFFFFFFULL && "Enum too large");
>> +  if (Range > 0xFFFF)
>> +    return "uint32_t";
>> +  if (Range > 0xFF)
>> +    return "uint16_t";
>> +  return "uint8_t";
>> +}
>> 
>> /// getTarget - Return the current instance of the Target class.
>> ///
>> 
>> Modified: llvm/trunk/utils/TableGen/CodeGenTarget.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenTarget.h?rev=151760&r1=151759&r2=151760&view=diff
>> ==============================================================================
>> --- llvm/trunk/utils/TableGen/CodeGenTarget.h (original)
>> +++ llvm/trunk/utils/TableGen/CodeGenTarget.h Wed Feb 29 15:57:08 2012
>> @@ -58,6 +58,10 @@
>> /// namespace qualifier if the record contains one.
>> std::string getQualifiedName(const Record *R);
>> 
>> +/// getMinimalTypeForRange - Helper method to get the minimum data type required
>> +/// to represent Range.
>> +const char *getMinimalTypeForRange(uint64_t Range);
>> +
>> /// CodeGenTarget - This class corresponds to the Target class in the .td files.
>> ///
>> class CodeGenTarget {
>> 
>> Modified: llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp?rev=151760&r1=151759&r2=151760&view=diff
>> ==============================================================================
>> --- llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp (original)
>> +++ llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp Wed Feb 29 15:57:08 2012
>> @@ -736,8 +736,8 @@
>> 
>>  // Emit the data table for getSubReg().
>>  if (SubRegIndices.size()) {
>> -    OS << "static const unsigned short " << TargetName << "SubRegTable[]["
>> -      << SubRegIndices.size() << "] = {\n";
>> +    OS << "static const " << getMinimalTypeForRange(Regs.size()) << ' '
>> +       << TargetName << "SubRegTable[][" << SubRegIndices.size() << "] = {\n";
>>    for (unsigned i = 0, e = Regs.size(); i != e; ++i) {
>>      const CodeGenRegister::SubRegMap &SRM = Regs[i]->getSubRegs();
>>      OS << "  /* " << Regs[i]->TheDef->getName() << " */\n";
>> 
>> 
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 





More information about the llvm-commits mailing list