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
Commits on Source (2)
......@@ -99,6 +99,14 @@ class STARS_IRDB_op_t : public STARS_op_t
switch(OpType)
{
case op_Reg:
case op_CrReg:
case op_DrReg:
case op_Eflags:
case op_MMXReg:
case op_XMMReg:
case op_YMMReg:
case op_FPReg:
case op_Mxcsr:
return operand.reg.RegNum;
case op_Mem:
return operand.mem.base;
......@@ -183,14 +191,10 @@ class STARS_IRDB_op_t : public STARS_op_t
virtual bool IsMemNoDisplacementOp(void) const { return OpType==op_Mem && operand.mem.disp==0; }
virtual bool IsMemOp(void) const { return OpType==op_Mem; }
virtual bool HasSIBByte(void) const { assert(OpType==op_Mem); return operand.mem.hasSIB; }
virtual bool IsFloatingPointRegOp(void) const
{ if(OpType!=op_Reg) return false; return STARS_x86_R_st0<= operand.reg.RegNum && operand.reg.RegNum<=STARS_x86_R_st7; }
virtual bool IsMMXRegOp(void) const
{ if(OpType!=op_Reg) return false; return STARS_x86_R_mm0<= operand.reg.RegNum && operand.reg.RegNum<=STARS_x86_R_mm7; }
virtual bool IsXMMRegOp(void) const
{ if(OpType!=op_Reg) return false; return STARS_x86_R_xmm0<= operand.reg.RegNum && operand.reg.RegNum<=STARS_x86_R_xmm15; }
virtual bool IsYMMRegOp(void) const
{ if(OpType!=op_Reg) return false; return STARS_x86_R_ymm0<= operand.reg.RegNum && operand.reg.RegNum<=STARS_x86_R_ymm15; }
virtual bool IsFloatingPointRegOp(void) const { return (OpType == op_FPReg); }
virtual bool IsMMXRegOp(void) const { return (OpType == op_MMXReg); }
virtual bool IsXMMRegOp(void) const { return (OpType == op_XMMReg); }
virtual bool IsYMMRegOp(void) const { return (OpType == op_YMMReg); }
virtual bool IsTestRegOp(void) const { return false; }
virtual bool IsDebugRegOp(void) const { return false; }
virtual bool IsControlRegOp(void) const { return false; }
......@@ -274,18 +278,7 @@ class STARS_IRDB_op_t : public STARS_op_t
uint32_t byteWidth:6;
bool visible:1;
void Init()
{
SegReg=STARS_x86_R_none;
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(&operand,0,sizeof(operand));
visible=0;
byteWidth=0;
}
void Init(void);
virtual void Dump();
......
......@@ -617,6 +617,7 @@ bool SMPFunction::ComputeInOutRegs(bool InheritPass, bool &WritesMem, bool &Call
STARSOpndTypePtr DefOp = DefIter->GetOp();
if (DefOp->IsRegOp() || DefOp->IsFloatingPointRegOp()) {
STARS_regnum_t RegNo = DefOp->GetReg();
assert(0 <= (int) RegNo);
this->OutputRegs.set((size_t) RegNo, true);
}
else if (DefOp->IsMemOp()) {
......
......@@ -225,7 +225,10 @@ void STARS_IDA_Program_t::InitStaticDataTable(SMPProgram *CurrProg) {
SMP_msg(" SegName: %s", SegName);
SMP_msg(" from %lx to %lx\n", (unsigned long)seg->get_startEA(), (unsigned long)seg->get_endEA());
#endif
if ((seg->IsDataSegment()) || (seg->IsBSSSegment()) || (seg->IsCommonSegment())) {
bool DataSegFlag = seg->IsDataSegment();
bool BSSSegFlag = seg->IsBSSSegment();
bool CommonSegFlag = seg->IsCommonSegment();
if (DataSegFlag || BSSSegFlag || CommonSegFlag) {
// Loop through each of the segments we are interested in,
// examining all data objects (effective addresses).
ReadOnlyFlag = ((seg->IsReadableSegment()) && (!(seg->IsWriteableSegment())));
......@@ -304,49 +307,51 @@ void STARS_IDA_Program_t::InitStaticDataTable(SMPProgram *CurrProg) {
pair<STARS_ea_t, struct GlobalVar> TempItem(ea, VarTemp);
CurrProg->InsertGlobalVarTableEntry(TempItem);
// Check for code xrefs from the data.
// Can have a table of pointers, so iterate through large data objects.
STARS_ea_t TempAddr = ea;
while ((NextEA - TempAddr) >= MD_DEFAULT_RETURN_ADDRESS_SIZE) {
SMP_xref_t xrefs;
for (bool ok = xrefs.SMP_first_from(TempAddr, XREF_DATA); ok; ok = xrefs.SMP_next_from()) {
STARS_ea_t TargetAddr = xrefs.GetTo();
if ((TargetAddr != 0) && (!xrefs.GetIscode())) {
// Found a target, with its address in xrefs.to
// Is the target code?
STARS_Segment_t *SegInfo = SMP_getseg(TargetAddr);
if ((NULL != SegInfo) && (SegInfo->IsCodeSegment())) {
if (!ReadOnlyFlag) {
SMP_msg("INFO: Code Xref from writeable data at %llx\n", (uint64_t) ea);
if (!BSSSegFlag) {
// Check for code xrefs from the data.
// Can have a table of pointers, so iterate through large data objects.
STARS_ea_t TempAddr = ea;
while ((NextEA - TempAddr) >= MD_DEFAULT_RETURN_ADDRESS_SIZE) {
SMP_xref_t xrefs;
for (bool ok = xrefs.SMP_first_from(TempAddr, XREF_DATA); ok; ok = xrefs.SMP_next_from()) {
STARS_ea_t TargetAddr = xrefs.GetTo();
if ((TargetAddr != 0) && (!xrefs.GetIscode())) {
// Found a target, with its address in xrefs.to
// Is the target code?
STARS_Segment_t *SegInfo = SMP_getseg(TargetAddr);
if ((NULL != SegInfo) && (SegInfo->IsCodeSegment())) {
if (!ReadOnlyFlag) {
SMP_msg("INFO: Code Xref from writeable data at %llx\n", (uint64_t)ea);
}
bool NewTarget = CurrProg->InsertDataToCodeXref(TargetAddr);
if (NewTarget)
global_STARS_program->PrintDataToCodeXref(TempAddr, TargetAddr, 0);
}
bool NewTarget = CurrProg->InsertDataToCodeXref(TargetAddr);
if (NewTarget)
global_STARS_program->PrintDataToCodeXref(TempAddr, TargetAddr, 0);
}
}
}
STARS_ea_t DataValue;
if (4 < global_STARS_program->GetSTARS_ISA_Bytewidth())
DataValue = (STARS_ea_t) ::get_qword(TempAddr);
else
STARS_ea_t DataValue;
if (4 < global_STARS_program->GetSTARS_ISA_Bytewidth())
DataValue = (STARS_ea_t) ::get_qword(TempAddr);
else
#if (IDA_SDK_VERSION < 700)
DataValue = (STARS_ea_t) ::get_long(TempAddr);
DataValue = (STARS_ea_t) ::get_long(TempAddr);
#else
DataValue = (STARS_ea_t) ::get_dword(TempAddr);
DataValue = (STARS_ea_t) ::get_dword(TempAddr);
#endif
if (DataValue != 0) {
// Is this a code address?
STARS_ea_t PossibleCodeAddr = (STARS_ea_t) DataValue;
STARS_Segment_t *SegInfo = SMP_getseg(PossibleCodeAddr);
if ((NULL != SegInfo) && (SegInfo->IsCodeSegment())) {
bool NewTarget = CurrProg->InsertDataToCodeXref(PossibleCodeAddr);
if (NewTarget)
global_STARS_program->PrintDataToCodeXref(TempAddr, PossibleCodeAddr, 0);
if (DataValue != 0) {
// Is this a code address?
STARS_ea_t PossibleCodeAddr = (STARS_ea_t)DataValue;
STARS_Segment_t *SegInfo = SMP_getseg(PossibleCodeAddr);
if ((NULL != SegInfo) && (SegInfo->IsCodeSegment())) {
bool NewTarget = CurrProg->InsertDataToCodeXref(PossibleCodeAddr);
if (NewTarget)
global_STARS_program->PrintDataToCodeXref(TempAddr, PossibleCodeAddr, 0);
}
}
}
TempAddr += MD_DEFAULT_RETURN_ADDRESS_SIZE;
}
TempAddr += MD_DEFAULT_RETURN_ADDRESS_SIZE;
} // end while ((NextEA - TempAddr) >= MD_DEFAULT_RETURN_ADDRESS_SIZE)
} // end if (!BSSSegFlag)
// Move on to next data object
ea = NextEA;
......@@ -359,7 +364,7 @@ void STARS_IDA_Program_t::InitStaticDataTable(SMPProgram *CurrProg) {
#endif
}
} // end while (ea < seg->endEA)
} // end if (seg->type == SEG_DATA ...)
} // end if (DataSegFlag || BSSSegFlag || CommonSegFlag)
else if (seg->IsCodeSegment()) {
if (seg->get_startEA() < TempLowestCodeAddress)
TempLowestCodeAddress = seg->get_startEA();
......@@ -544,7 +549,7 @@ void STARS_IDA_Program_t::FindCodeAddressesTaken(SMPProgram *CurrProg) {
STARS_ea_t ea = seg->get_startEA();
RecentAddr = ea;
bool ReadOnlyFlag = ((seg->IsReadableSegment()) && (!(seg->IsWriteableSegment())));
bool DataSegment = ((seg->IsDataSegment()) || (seg->IsBSSSegment()) || (seg->IsCommonSegment()));
bool DataSegment = ((seg->IsDataSegment()) || (seg->IsCommonSegment()));
#if 0
if (ReadOnlyFlag && DataSegment) {
#else
......
......@@ -1736,7 +1736,7 @@ bool STARS_IRDB_Instruction_t::STARS_GetCmd(void)
if(my_disasm.hasOperand(i))
Operands[i+1]=(std::make_shared<STARS_IRDB_op_t>(my_disasm,0,my_disasm.getOperand(i),length));
else
Operands[i+1]=(std::make_shared<STARS_IRDB_op_t>());
Operands[i+1] = this->MakeVoidOpnd();
}
features=GetInitialInstFeatures(true,my_disasm) | (STARS_CF_CHG1 | STARS_CF_USE1);
}
......@@ -1795,7 +1795,8 @@ bool STARS_IRDB_Instruction_t::STARS_GetCmd(void)
FPStore = true;
}
else
p->MakeRegOpnd(STARS_x86_R_st0);
p->MakeFloatingPointRegOpnd(STARS_x86_R_st0);
p->SetByteWidth(this->DetermineRegByteWidth(p->GetReg()));
Operands[0] = p;
do_default = false;
for (auto i = 0; i < 3; ++i)
......@@ -1803,7 +1804,7 @@ bool STARS_IRDB_Instruction_t::STARS_GetCmd(void)
if (my_disasm.hasOperand(i))
Operands[i + 1] = (std::make_shared<STARS_IRDB_op_t>(my_disasm, 0, my_disasm.getOperand(i),length));
else
Operands[i + 1] = (std::make_shared<STARS_IRDB_op_t>());
Operands[i + 1] = this->MakeVoidOpnd();
}
if (FloatingStackLoad)
features = GetInitialInstFeatures(true,my_disasm) | (STARS_CF_CHG1 | STARS_CF_USE2);
......@@ -1836,7 +1837,7 @@ bool STARS_IRDB_Instruction_t::STARS_GetCmd(void)
if(my_disasm.hasOperand(i))
Operands[i+1]=(std::make_shared<STARS_IRDB_op_t>(my_disasm,0,my_disasm.getOperand(i),length));
else
Operands[i+1]=(std::make_shared<STARS_IRDB_op_t>());
Operands[i+1] = this->MakeVoidOpnd();
}
features=GetInitialInstFeatures(true,my_disasm) | (STARS_CF_USE1);
......@@ -1853,7 +1854,7 @@ bool STARS_IRDB_Instruction_t::STARS_GetCmd(void)
Operands[1]=(std::make_shared<STARS_IRDB_op_t>(my_disasm,0,my_disasm.getOperand(0),length));
else
{
p->MakeRegOpnd(STARS_x86_R_st1);
p->MakeFloatingPointRegOpnd(STARS_x86_R_st1);
Operands[1]=p;
}
......@@ -1869,13 +1870,13 @@ bool STARS_IRDB_Instruction_t::STARS_GetCmd(void)
case STARS_NN_fucomp:
{
auto p = (std::make_shared<STARS_IRDB_op_t>());
p->MakeRegOpnd(STARS_x86_R_st0);
p->MakeFloatingPointRegOpnd(STARS_x86_R_st0);
Operands[0]=p;
if(my_disasm.hasOperand(0))
Operands[1]=(std::make_shared<STARS_IRDB_op_t>(my_disasm,0,my_disasm.getOperand(0),length));
else
{
p->MakeRegOpnd(STARS_x86_R_st1);
p->MakeFloatingPointRegOpnd(STARS_x86_R_st1);
Operands[1]=p;
}
features=GetInitialInstFeatures(true,my_disasm)
......@@ -1906,7 +1907,7 @@ bool STARS_IRDB_Instruction_t::STARS_GetCmd(void)
{
do_default=false;
shared_ptr<STARS_IRDB_op_t> p = (std::make_shared<STARS_IRDB_op_t>());
p->MakeRegOpnd(STARS_x86_R_st0);
p->MakeFloatingPointRegOpnd(STARS_x86_R_st0);
p->SetByteWidth(my_disasm.getOperand(0).getArgumentSizeInBytes());
Operands[0]=p;
for(auto i=0;i<3;i++)
......@@ -1914,7 +1915,7 @@ bool STARS_IRDB_Instruction_t::STARS_GetCmd(void)
if(my_disasm.hasOperand(i))
Operands[i+1]=(std::make_shared<STARS_IRDB_op_t>(my_disasm,0,my_disasm.getOperand(i),length));
else
Operands[i+1]=(std::make_shared<STARS_IRDB_op_t>());
Operands[i+1] = this->MakeVoidOpnd();
}
features=GetInitialInstFeatures(true,my_disasm) | (STARS_CF_CHG1 | STARS_CF_USE1);
}
......@@ -1924,11 +1925,11 @@ bool STARS_IRDB_Instruction_t::STARS_GetCmd(void)
shared_ptr<STARS_IRDB_op_t> p;
p = (std::make_shared<STARS_IRDB_op_t>());
p->MakeRegOpnd(STARS_x86_R_st0);
p->MakeFloatingPointRegOpnd(STARS_x86_R_st0);
Operands[0]=p;
p = (std::make_shared<STARS_IRDB_op_t>());
p->MakeRegOpnd(STARS_x86_R_st1);
p->MakeFloatingPointRegOpnd(STARS_x86_R_st1);
Operands[1]=p;
features=GetInitialInstFeatures(false,my_disasm) | (STARS_CF_CHG1 | STARS_CF_USE1 | STARS_CF_USE2);
......@@ -1946,11 +1947,11 @@ bool STARS_IRDB_Instruction_t::STARS_GetCmd(void)
shared_ptr<STARS_IRDB_op_t> p;
p = (std::make_shared<STARS_IRDB_op_t>());
p->MakeRegOpnd(STARS_x86_R_st0);
p->MakeFloatingPointRegOpnd(STARS_x86_R_st0);
Operands[0]=p;
p = (std::make_shared<STARS_IRDB_op_t>());
p->MakeRegOpnd(STARS_x86_R_st1);
p->MakeFloatingPointRegOpnd(STARS_x86_R_st1);
Operands[1]=p;
features=GetInitialInstFeatures(false,my_disasm) | (STARS_CF_CHG1 | STARS_CF_USE1 | STARS_CF_USE2);
......@@ -1994,11 +1995,11 @@ bool STARS_IRDB_Instruction_t::STARS_GetCmd(void)
shared_ptr<STARS_IRDB_op_t> p;
p = (std::make_shared<STARS_IRDB_op_t>());
p->MakeRegOpnd(STARS_x86_R_st0);
p->MakeFloatingPointRegOpnd(STARS_x86_R_st0);
Operands[0]=p;
p = (std::make_shared<STARS_IRDB_op_t>());
p->MakeRegOpnd(STARS_x86_R_st1);
p->MakeFloatingPointRegOpnd(STARS_x86_R_st1);
Operands[1]=p;
features=GetInitialInstFeatures(false,my_disasm) | (STARS_CF_USE1 | STARS_CF_USE2);
......@@ -2015,11 +2016,11 @@ bool STARS_IRDB_Instruction_t::STARS_GetCmd(void)
shared_ptr<STARS_IRDB_op_t> p;
p = (std::make_shared<STARS_IRDB_op_t>());
p->MakeRegOpnd(STARS_x86_R_st0);
p->MakeFloatingPointRegOpnd(STARS_x86_R_st0);
Operands[0]=p;
p = (std::make_shared<STARS_IRDB_op_t>());
p->MakeRegOpnd(STARS_x86_R_st1);
p->MakeFloatingPointRegOpnd(STARS_x86_R_st1);
Operands[1]=p;
features=GetInitialInstFeatures(false,my_disasm) | (STARS_CF_CHG2 | STARS_CF_USE1 | STARS_CF_USE2);
......@@ -2036,7 +2037,7 @@ bool STARS_IRDB_Instruction_t::STARS_GetCmd(void)
if(my_disasm.hasOperand(i))
Operands[i]=(std::make_shared<STARS_IRDB_op_t>(my_disasm,0,my_disasm.getOperand(i),length));
else
Operands[i]=(std::make_shared<STARS_IRDB_op_t>());
Operands[i] = this->MakeVoidOpnd();
}
features=GetInitialInstFeatures(false,my_disasm);
}
......@@ -2087,7 +2088,6 @@ STARSOpndTypePtr STARS_IRDB_Instruction_t::MakeImmediateOpnd(STARS_uval_t value)
// STARSIRDBOpndTypePtr p=std::dynamic_cast<STARSIRDBOpndTypePtr>(p);
// STARSIRDBOpndTypePtr p= std::dynamic_pointer_cast<STARS_IRDB_op_t>(MakeVoidOpnd());
STARSIRDBOpndTypePtr p=std::make_shared<STARS_IRDB_op_t>();
assert(p);
p->MakeImmediateOpnd(value);
......@@ -2096,7 +2096,6 @@ STARSOpndTypePtr STARS_IRDB_Instruction_t::MakeImmediateOpnd(STARS_uval_t value)
STARSOpndTypePtr STARS_IRDB_Instruction_t::MakeRegOpnd(STARS_regnum_t RegNum, bool DefaultToMachineWidth)
{
// STARSIRDBOpndTypePtr p=std::dynamic_pointer_cast<STARS_IRDB_op_t>(MakeVoidOpnd());
STARSIRDBOpndTypePtr p=std::make_shared<STARS_IRDB_op_t>();
assert(p);
uint16_t ByteWidth = this->DetermineRegByteWidth(RegNum);
......@@ -2108,7 +2107,6 @@ STARSOpndTypePtr STARS_IRDB_Instruction_t::MakeRegOpnd(STARS_regnum_t RegNum, bo
STARSOpndTypePtr STARS_IRDB_Instruction_t::MakeFloatingPointRegOpnd(STARS_regnum_t RegNum)
{
// STARSIRDBOpndTypePtr p=std::dynamic_pointer_cast<STARS_IRDB_op_t>(MakeVoidOpnd());
STARSIRDBOpndTypePtr p=std::make_shared<STARS_IRDB_op_t>();
assert(p);
p->MakeFloatingPointRegOpnd(RegNum);
......@@ -2118,7 +2116,6 @@ STARSOpndTypePtr STARS_IRDB_Instruction_t::MakeFloatingPointRegOpnd(STARS_regnum
STARSOpndTypePtr STARS_IRDB_Instruction_t::MakeMMXRegOpnd(STARS_regnum_t RegNum)
{
// STARSIRDBOpndTypePtr p=std::dynamic_pointer_cast<STARS_IRDB_op_t>(MakeVoidOpnd());
STARSIRDBOpndTypePtr p=std::make_shared<STARS_IRDB_op_t>();
assert(p);
p->MakeMMXRegOpnd(RegNum);
......@@ -2128,7 +2125,6 @@ STARSOpndTypePtr STARS_IRDB_Instruction_t::MakeMMXRegOpnd(STARS_regnum_t RegNum)
STARSOpndTypePtr STARS_IRDB_Instruction_t::MakeXMMRegOpnd(STARS_regnum_t RegNum)
{
// STARSIRDBOpndTypePtr p=std::dynamic_pointer_cast<STARS_IRDB_op_t>(MakeVoidOpnd());
STARSIRDBOpndTypePtr p=std::make_shared<STARS_IRDB_op_t>();
assert(p);
p->MakeXMMRegOpnd(RegNum);
......@@ -2138,7 +2134,6 @@ STARSOpndTypePtr STARS_IRDB_Instruction_t::MakeXMMRegOpnd(STARS_regnum_t RegNum)
STARSOpndTypePtr STARS_IRDB_Instruction_t::MakeYMMRegOpnd(STARS_regnum_t RegNum)
{
// STARSIRDBOpndTypePtr p=std::dynamic_pointer_cast<STARS_IRDB_op_t>(MakeVoidOpnd());
STARSIRDBOpndTypePtr p=std::make_shared<STARS_IRDB_op_t>();
assert(p);
p->MakeYMMRegOpnd(RegNum);
......@@ -2148,7 +2143,6 @@ STARSOpndTypePtr STARS_IRDB_Instruction_t::MakeYMMRegOpnd(STARS_regnum_t RegNum)
STARSOpndTypePtr STARS_IRDB_Instruction_t::MakeNearPointerOpnd(STARS_uval_t value) const
{
// STARSIRDBOpndTypePtr p=std::dynamic_pointer_cast<STARS_IRDB_op_t>(MakeVoidOpnd());
STARSIRDBOpndTypePtr p=std::make_shared<STARS_IRDB_op_t>();
assert(p);
p->MakeNearPointerOpnd(disasm.getAddress() /*Instruction.AddrValue*/);
......@@ -2159,7 +2153,6 @@ STARSOpndTypePtr STARS_IRDB_Instruction_t::MakeNearPointerOpnd(STARS_uval_t valu
STARSOpndTypePtr STARS_IRDB_Instruction_t::MakeMemDisplacementOpnd
(STARS_regnum_t BaseRegNum, STARS_regnum_t IndexRegNum, uint16_t ScaleFactor, STARS_ea_t offset)
{
// STARSIRDBOpndTypePtr p=std::dynamic_pointer_cast<STARS_IRDB_op_t>(MakeVoidOpnd());
STARSIRDBOpndTypePtr p=std::make_shared<STARS_IRDB_op_t>();
assert(p);
p->MakeMemDisplacementOpnd(BaseRegNum, IndexRegNum, ScaleFactor, offset);
......@@ -2168,7 +2161,6 @@ STARSOpndTypePtr STARS_IRDB_Instruction_t::MakeMemDisplacementOpnd
STARSOpndTypePtr STARS_IRDB_Instruction_t::MakeMemPhraseOpnd
(STARS_regnum_t BaseRegNum, STARS_regnum_t IndexRegNum, uint16_t ScaleFactor)
{
// STARSIRDBOpndTypePtr p=std::dynamic_pointer_cast<STARS_IRDB_op_t>(MakeVoidOpnd());
STARSIRDBOpndTypePtr p=std::make_shared<STARS_IRDB_op_t>();
assert(p);
p->MakeMemPhraseOpnd(BaseRegNum, IndexRegNum, ScaleFactor);
......
......@@ -4,6 +4,7 @@
#include "interfaces/SMPDBInterface.h"
#include "interfaces/irdb/STARSProgram.h"
#include "interfaces/irdb/STARSInstruction.h"
#include "interfaces/abstract/STARSInterface.h"
#include <libIRDB-core.hpp>
#include <iostream>
......@@ -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);
byteWidth=8;
OpType=op_MMXReg;
assert(bea_regno!=(decltype(bea_regno))-1);
#if 1 // Use specialized register types.
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);
}
// case REGISTER_TYPE + FPU_REG :
......@@ -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);
byteWidth=8;
OpType=op_MMXReg;
assert(bea_regno!=(decltype(bea_regno))-1);
#if 1 // Use specialized register types.
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);
}
// case REGISTER_TYPE + SSE_REG :
......@@ -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')
{
byteWidth=8;
#if 1 // Use specialized register types.
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);
if (16 > 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
else if(the_arg.getString()[0]=='y')
{
byteWidth=16;
OpType=op_YMMReg;
assert(bea_regno!=(decltype(bea_regno))-1);
#if 1 // Use specialized register types.
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)
operand.reg.RegNum = (STARS_RegNo)(STARS_x86_R_ymm0 + bea_regno);
else
......@@ -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
{
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()
uint16_t STARS_IRDB_op_t::GetByteWidth(void) const
{
if(OpType==op_Void)
return (uint16_t) global_STARS_program->GetSTARS_ISA_Bytewidth();
if (OpType == op_Void) {
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
return byteWidth;
}
......