diff --git a/llvm/include/llvm/Target/Target.td b/llvm/include/llvm/Target/Target.td --- a/llvm/include/llvm/Target/Target.td +++ b/llvm/include/llvm/Target/Target.td @@ -1525,6 +1525,10 @@ // setting hasExtraDefRegAllocReq and hasExtraSrcRegAllocReq to 1 // for all opcodes if this flag is set to 0. int AllowRegisterRenaming = 0; + + // BitsPerByte - Specifies the size (in bits) of the smallest addressable + // unit in the target. Typically this is 8 bits, which is the default value. + int BitsPerByte = 8; } //===----------------------------------------------------------------------===// diff --git a/llvm/utils/TableGen/CodeGenTarget.h b/llvm/utils/TableGen/CodeGenTarget.h --- a/llvm/utils/TableGen/CodeGenTarget.h +++ b/llvm/utils/TableGen/CodeGenTarget.h @@ -86,6 +86,10 @@ /// bool getAllowRegisterRenaming() const; + /// getBitsPerByte - Return the BitsPerByte int value for this target. + /// + int getBitsPerByte() const; + /// getAsmParser - Return the AssemblyParser definition for this target. /// Record *getAsmParser() const; diff --git a/llvm/utils/TableGen/CodeGenTarget.cpp b/llvm/utils/TableGen/CodeGenTarget.cpp --- a/llvm/utils/TableGen/CodeGenTarget.cpp +++ b/llvm/utils/TableGen/CodeGenTarget.cpp @@ -293,6 +293,10 @@ return TargetRec->getValueAsInt("AllowRegisterRenaming"); } +int CodeGenTarget::getBitsPerByte() const { + return TargetRec->getValueAsInt("BitsPerByte"); +} + /// getAsmParser - Return the AssemblyParser definition for this target. /// Record *CodeGenTarget::getAsmParser() const { diff --git a/llvm/utils/TableGen/GlobalISelEmitter.cpp b/llvm/utils/TableGen/GlobalISelEmitter.cpp --- a/llvm/utils/TableGen/GlobalISelEmitter.cpp +++ b/llvm/utils/TableGen/GlobalISelEmitter.cpp @@ -3813,10 +3813,13 @@ // MMO's work in bytes so we must take care of unusual types like i1 // don't round down. unsigned MemSizeInBits = - llvm::alignTo(MemTyOrNone->get().getSizeInBits(), 8); + llvm::alignTo(MemTyOrNone->get().getSizeInBits(), + Target.getBitsPerByte()); - InsnMatcher.addPredicate(0, - MemSizeInBits / 8); + InsnMatcher + .addPredicate(0, + MemSizeInBits / + Target.getBitsPerByte()); return InsnMatcher; } } @@ -6168,3 +6171,4 @@ GlobalISelEmitter(RK).run(OS); } } // End llvm namespace +