Introduce instruction alignment information

This commit is contained in:
Alessandro Di Federico
2016-04-13 09:00:29 +02:00
parent bbab7763ce
commit 3eb8caed40
2 changed files with 26 additions and 3 deletions
+17 -1
View File
@@ -89,7 +89,23 @@ CodeGenerator::CodeGenerator(std::string Input,
// We only support ELF for now
auto *TheBinary = cast<object::ObjectFile>(BinaryHandle.getBinary());
SourceArchitecture = Architecture(1,
unsigned InstructionAlignment = 0;
switch (TheBinary->getArch()) {
case Triple::x86_64:
InstructionAlignment = 1;
break;
case Triple::arm:
InstructionAlignment = 4;
break;
case Triple::mips:
InstructionAlignment = 4;
break;
default:
assert(false);
}
SourceArchitecture = Architecture(InstructionAlignment,
1,
TheBinary->isLittleEndian(),
TheBinary->getBytesInAddress() * 8);