Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • opensrc/SMPStaticAnalyzer
1 result
Show changes
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "interfaces/SMPDBInterface.h" #include "interfaces/SMPDBInterface.h"
#include "interfaces/irdb/STARSProgram.h" #include "interfaces/irdb/STARSProgram.h"
#include "interfaces/irdb/STARSInstruction.h" #include "interfaces/irdb/STARSInstruction.h"
#include "interfaces/abstract/STARSInterface.h"
#include <libIRDB-core.hpp> #include <libIRDB-core.hpp>
#include <iostream> #include <iostream>
...@@ -99,8 +100,12 @@ STARS_IRDB_op_t::STARS_IRDB_op_t(const DecodedInstruction_t &d, int indx, const ...@@ -99,8 +100,12 @@ STARS_IRDB_op_t::STARS_IRDB_op_t(const DecodedInstruction_t &d, int indx, const
{ {
const auto bea_regno=the_arg.getRegNumber(); // log2int_or_err(the_arg.ArgType&0xFFFF); const auto bea_regno=the_arg.getRegNumber(); // log2int_or_err(the_arg.ArgType&0xFFFF);
byteWidth=8; byteWidth=8;
OpType=op_MMXReg; #if 1 // Use specialized register types.
assert(bea_regno!=(decltype(bea_regno))-1); OpType = op_MMXReg;
#else // Using op_Reg for all regs, distinguishing them by the regno only.
OpType = op_Reg;
#endif
assert(bea_regno != (decltype(bea_regno))-1);
operand.reg.RegNum=(STARS_RegNo)(STARS_x86_R_mm0+bea_regno); operand.reg.RegNum=(STARS_RegNo)(STARS_x86_R_mm0+bea_regno);
} }
// case REGISTER_TYPE + FPU_REG : // case REGISTER_TYPE + FPU_REG :
...@@ -108,8 +113,12 @@ STARS_IRDB_op_t::STARS_IRDB_op_t(const DecodedInstruction_t &d, int indx, const ...@@ -108,8 +113,12 @@ STARS_IRDB_op_t::STARS_IRDB_op_t(const DecodedInstruction_t &d, int indx, const
{ {
const auto bea_regno=the_arg.getRegNumber(); // log2int_or_err(the_arg.ArgType&0xFFFF); const auto bea_regno=the_arg.getRegNumber(); // log2int_or_err(the_arg.ArgType&0xFFFF);
byteWidth=8; byteWidth=8;
OpType=op_MMXReg; #if 1 // Use specialized register types.
assert(bea_regno!=(decltype(bea_regno))-1); OpType = op_FPReg;
#else // Using op_Reg for all regs, distinguishing them by the regno only.
OpType = op_Reg;
#endif
assert(bea_regno != (decltype(bea_regno))-1);
operand.reg.RegNum=(STARS_RegNo)(STARS_x86_R_st0+bea_regno); operand.reg.RegNum=(STARS_RegNo)(STARS_x86_R_st0+bea_regno);
} }
// case REGISTER_TYPE + SSE_REG : // case REGISTER_TYPE + SSE_REG :
...@@ -121,7 +130,11 @@ STARS_IRDB_op_t::STARS_IRDB_op_t(const DecodedInstruction_t &d, int indx, const ...@@ -121,7 +130,11 @@ STARS_IRDB_op_t::STARS_IRDB_op_t(const DecodedInstruction_t &d, int indx, const
if (the_arg.getString()[0] == 'x') if (the_arg.getString()[0] == 'x')
{ {
byteWidth=8; byteWidth=8;
#if 1 // Use specialized register types.
OpType=op_XMMReg; OpType=op_XMMReg;
#else // Using op_Reg for all regs, distinguishing them by the regno only.
OpType = op_Reg;
#endif
assert(bea_regno!=(decltype(bea_regno))-1); assert(bea_regno!=(decltype(bea_regno))-1);
if (16 > bea_regno) if (16 > bea_regno)
operand.reg.RegNum=(STARS_RegNo)(STARS_x86_R_xmm0 + bea_regno); operand.reg.RegNum=(STARS_RegNo)(STARS_x86_R_xmm0 + bea_regno);
...@@ -131,8 +144,12 @@ STARS_IRDB_op_t::STARS_IRDB_op_t(const DecodedInstruction_t &d, int indx, const ...@@ -131,8 +144,12 @@ STARS_IRDB_op_t::STARS_IRDB_op_t(const DecodedInstruction_t &d, int indx, const
else if(the_arg.getString()[0]=='y') else if(the_arg.getString()[0]=='y')
{ {
byteWidth=16; byteWidth=16;
OpType=op_YMMReg; #if 1 // Use specialized register types.
assert(bea_regno!=(decltype(bea_regno))-1); OpType = op_YMMReg;
#else // Using op_Reg for all regs, distinguishing them by the regno only.
OpType = op_Reg;
#endif
assert(bea_regno != (decltype(bea_regno))-1);
if (16 > bea_regno) if (16 > bea_regno)
operand.reg.RegNum = (STARS_RegNo)(STARS_x86_R_ymm0 + bea_regno); operand.reg.RegNum = (STARS_RegNo)(STARS_x86_R_ymm0 + bea_regno);
else else
...@@ -275,6 +292,22 @@ no operands for eflags or mxcsr? ...@@ -275,6 +292,22 @@ no operands for eflags or mxcsr?
} }
void STARS_IRDB_op_t::Init(void)
{
this->SegReg = STARS_x86_R_none;
this->OpType = op_Void;
// init the operand to 0, because the it should have no semantically valid meaning in any sense anyhow if OpType==Void.
memset(&this->operand, 0, sizeof(this->operand));
this->visible = 0;
if (nullptr != global_STARS_program) // global_STARS_program not available for early static initialization
this->byteWidth = global_STARS_program->GetSTARS_ISA_Bytewidth();
else
this->byteWidth = 8;
}
bool STARS_IRDB_op_t::operator<(const STARS_op_t &rOp_param) const bool STARS_IRDB_op_t::operator<(const STARS_op_t &rOp_param) const
{ {
const STARS_IRDB_op_t* p=dynamic_cast<const STARS_IRDB_op_t*>(&rOp_param); const STARS_IRDB_op_t* p=dynamic_cast<const STARS_IRDB_op_t*>(&rOp_param);
...@@ -420,8 +453,12 @@ void STARS_IRDB_op_t::Dump() ...@@ -420,8 +453,12 @@ void STARS_IRDB_op_t::Dump()
uint16_t STARS_IRDB_op_t::GetByteWidth(void) const uint16_t STARS_IRDB_op_t::GetByteWidth(void) const
{ {
if(OpType==op_Void) if (OpType == op_Void) {
return (uint16_t) global_STARS_program->GetSTARS_ISA_Bytewidth(); if (nullptr != global_STARS_program) // global_STARS_program not available for early static initialization
return global_STARS_program->GetSTARS_ISA_Bytewidth();
else
return 8;
}
else else
return byteWidth; return byteWidth;
} }
......