Fix for Test error with latest XED

This commit is contained in:
wizardengineer
2025-11-24 00:45:50 -05:00
committed by Kyle Elliott
parent 380578b2ab
commit 0aa74ba2b1
2 changed files with 39 additions and 3 deletions
+5 -3
View File
@@ -835,7 +835,8 @@ static bool IsAVX512(xed_isa_set_enum_t isa_set, xed_category_enum_t category) {
case XED_ISA_SET_AVX512BW_128N:
case XED_ISA_SET_AVX512BW_256:
case XED_ISA_SET_AVX512BW_512:
case XED_ISA_SET_AVX512BW_KOP:
case XED_ISA_SET_AVX512BW_KOPD:
case XED_ISA_SET_AVX512BW_KOPQ:
case XED_ISA_SET_AVX512CD_128:
case XED_ISA_SET_AVX512CD_256:
case XED_ISA_SET_AVX512CD_512:
@@ -843,7 +844,8 @@ static bool IsAVX512(xed_isa_set_enum_t isa_set, xed_category_enum_t category) {
case XED_ISA_SET_AVX512DQ_128N:
case XED_ISA_SET_AVX512DQ_256:
case XED_ISA_SET_AVX512DQ_512:
case XED_ISA_SET_AVX512DQ_KOP:
case XED_ISA_SET_AVX512DQ_KOPB:
case XED_ISA_SET_AVX512DQ_KOPW:
case XED_ISA_SET_AVX512DQ_SCALAR:
case XED_ISA_SET_AVX512ER_512:
case XED_ISA_SET_AVX512ER_SCALAR:
@@ -851,7 +853,7 @@ static bool IsAVX512(xed_isa_set_enum_t isa_set, xed_category_enum_t category) {
case XED_ISA_SET_AVX512F_128N:
case XED_ISA_SET_AVX512F_256:
case XED_ISA_SET_AVX512F_512:
case XED_ISA_SET_AVX512F_KOP:
case XED_ISA_SET_AVX512F_KOPW:
case XED_ISA_SET_AVX512F_SCALAR:
case XED_ISA_SET_AVX512PF_512:
case XED_ISA_SET_AVX512_4FMAPS_512:
+34
View File
@@ -593,7 +593,25 @@ llvm::Value *InstructionLifter::LiftRegisterOperand(Instruction &inst,
auto arg_size = data_layout.getTypeAllocSizeInBits(arg_type);
if (val_size < arg_size) {
// Because of using the latest version of Intex XED we support (which is currently v2025.06.08),
// it reports XMM/YMM registers as vectors instead of integers. When remills tries to extend/truncate
// these values we'll bitcast those vectors into integers
if (arg_type->isIntegerTy()) {
if (val_type->isVectorTy()) {
auto int_type = llvm::Type::getIntNTy(module->getContext(), val_size);
val = new llvm::BitCastInst(val, int_type, llvm::Twine::createNull(), block);
val_type = int_type;
} else if (val_type->isArrayTy()) {
// Arrays cannot be bitcast directly. Store to memory, bitcast pointer, then load.
auto int_type = llvm::Type::getIntNTy(module->getContext(), val_size);
auto temp_alloca = new llvm::AllocaInst(val_type, 0, llvm::Twine::createNull(), block);
new llvm::StoreInst(val, temp_alloca, block);
auto int_ptr = new llvm::BitCastInst(temp_alloca, llvm::PointerType::get(int_type, 0),
llvm::Twine::createNull(), block);
val = new llvm::LoadInst(int_type, int_ptr, llvm::Twine::createNull(), block);
val_type = int_type;
}
CHECK(val_type->isIntegerTy())
<< "Expected " << arch_reg.name << " to be an integral type ("
<< "val_type: " << LLVMThingToString(val_type) << ", "
@@ -616,6 +634,22 @@ llvm::Value *InstructionLifter::LiftRegisterOperand(Instruction &inst,
} else if (val_size > arg_size) {
if (arg_type->isIntegerTy()) {
if (val_type->isVectorTy()) {
auto int_type = llvm::Type::getIntNTy(module->getContext(), val_size);
val = new llvm::BitCastInst(val, int_type, llvm::Twine::createNull(), block);
val_type = int_type;
} else if (val_type->isArrayTy()) {
// Arrays cannot be bitcast directly. Store to memory, bitcast pointer, then load.
auto int_type = llvm::Type::getIntNTy(module->getContext(), val_size);
auto temp_alloca = new llvm::AllocaInst(val_type, 0, llvm::Twine::createNull(), block);
new llvm::StoreInst(val, temp_alloca, block);
auto int_ptr = new llvm::BitCastInst(temp_alloca, llvm::PointerType::get(int_type, 0),
llvm::Twine::createNull(), block);
val = new llvm::LoadInst(int_type, int_ptr, llvm::Twine::createNull(), block);
val_type = int_type;
}
CHECK(val_type->isIntegerTy())
<< "Expected " << arch_reg.name << " to be an integral type ("
<< "val_type: " << LLVMThingToString(val_type) << ", "