Rizin
unix-like reverse engineering framework and cli tools
MCRegisterInfo.c File Reference
#include "MCRegisterInfo.h"

Go to the source code of this file.

Classes

struct  DiffListIterator
 

Typedefs

typedef struct DiffListIterator DiffListIterator
 

Functions

void MCRegisterInfo_InitMCRegisterInfo (MCRegisterInfo *RI, const MCRegisterDesc *D, unsigned NR, unsigned RA, unsigned PC, const MCRegisterClass *C, unsigned NC, uint16_t(*RURoots)[2], unsigned NRU, const MCPhysReg *DL, const char *Strings, const uint16_t *SubIndices, unsigned NumIndices, const uint16_t *RET)
 
static void DiffListIterator_init (DiffListIterator *d, MCPhysReg InitVal, const MCPhysReg *DiffList)
 
static uint16_t DiffListIterator_getVal (DiffListIterator *d)
 
static bool DiffListIterator_next (DiffListIterator *d)
 
static bool DiffListIterator_isValid (DiffListIterator *d)
 
unsigned MCRegisterInfo_getMatchingSuperReg (const MCRegisterInfo *RI, unsigned Reg, unsigned SubIdx, const MCRegisterClass *RC)
 
unsigned MCRegisterInfo_getSubReg (const MCRegisterInfo *RI, unsigned Reg, unsigned Idx)
 
const MCRegisterClassMCRegisterInfo_getRegClass (const MCRegisterInfo *RI, unsigned i)
 
bool MCRegisterClass_contains (const MCRegisterClass *c, unsigned Reg)
 

Typedef Documentation

◆ DiffListIterator

DiffListIterator - Base iterator class that can traverse the differentially encoded register and regunit lists in DiffLists. Don't use this class directly, use one of the specialized sub-classes defined below.

Function Documentation

◆ DiffListIterator_getVal()

static uint16_t DiffListIterator_getVal ( DiffListIterator d)
static

Definition at line 59 of file MCRegisterInfo.c.

60 {
61  return d->Val;
62 }
#define d(i)
Definition: sha256.c:44

References d.

Referenced by MCRegisterInfo_getMatchingSuperReg(), and MCRegisterInfo_getSubReg().

◆ DiffListIterator_init()

static void DiffListIterator_init ( DiffListIterator d,
MCPhysReg  InitVal,
const MCPhysReg DiffList 
)
static

Definition at line 53 of file MCRegisterInfo.c.

54 {
55  d->Val = InitVal;
56  d->List = DiffList;
57 }

References d.

Referenced by MCRegisterInfo_getMatchingSuperReg(), and MCRegisterInfo_getSubReg().

◆ DiffListIterator_isValid()

static bool DiffListIterator_isValid ( DiffListIterator d)
static

Definition at line 81 of file MCRegisterInfo.c.

82 {
83  return (d->List != 0);
84 }

References d.

Referenced by MCRegisterInfo_getMatchingSuperReg(), and MCRegisterInfo_getSubReg().

◆ DiffListIterator_next()

static bool DiffListIterator_next ( DiffListIterator d)
static

Definition at line 64 of file MCRegisterInfo.c.

65 {
66  MCPhysReg D;
67 
68  if (d->List == 0)
69  return false;
70 
71  D = *d->List;
72  d->List++;
73  d->Val += D;
74 
75  if (!D)
76  d->List = 0;
77 
78  return (D != 0);
79 }
uint16_t MCPhysReg
#define D
Definition: block.c:38

References D, and d.

Referenced by MCRegisterInfo_getMatchingSuperReg(), and MCRegisterInfo_getSubReg().

◆ MCRegisterClass_contains()

bool MCRegisterClass_contains ( const MCRegisterClass c,
unsigned  Reg 
)

Definition at line 134 of file MCRegisterInfo.c.

135 {
136  unsigned InByte = Reg % 8;
137  unsigned Byte = Reg / 8;
138 
139  if (Byte >= c->RegSetSize)
140  return false;
141 
142  return (c->RegSet[Byte] & (1 << InByte)) != 0;
143 }
#define c(i)
Definition: sha256.c:43
unsigned char Byte
Definition: zconf.h:391

References c.

Referenced by MCRegisterInfo_getMatchingSuperReg().

◆ MCRegisterInfo_getMatchingSuperReg()

unsigned MCRegisterInfo_getMatchingSuperReg ( const MCRegisterInfo RI,
unsigned  Reg,
unsigned  SubIdx,
const MCRegisterClass RC 
)

Definition at line 86 of file MCRegisterInfo.c.

87 {
89 
90  if (Reg >= RI->NumRegs) {
91  return 0;
92  }
93 
96 
99  if (MCRegisterClass_contains(RC, val) && Reg == MCRegisterInfo_getSubReg(RI, val, SubIdx))
100  return val;
101 
103  }
104 
105  return 0;
106 }
static uint16_t DiffListIterator_getVal(DiffListIterator *d)
static bool DiffListIterator_isValid(DiffListIterator *d)
static void DiffListIterator_init(DiffListIterator *d, MCPhysReg InitVal, const MCPhysReg *DiffList)
bool MCRegisterClass_contains(const MCRegisterClass *c, unsigned Reg)
static bool DiffListIterator_next(DiffListIterator *d)
unsigned MCRegisterInfo_getSubReg(const MCRegisterInfo *RI, unsigned Reg, unsigned Idx)
ut16 val
Definition: armass64_const.h:6
unsigned short uint16_t
Definition: sftypes.h:30
uint32_t SuperRegs
const MCRegisterDesc * Desc
const MCPhysReg * DiffLists
unsigned NumRegs

References MCRegisterInfo::Desc, DiffListIterator_getVal(), DiffListIterator_init(), DiffListIterator_isValid(), DiffListIterator_next(), MCRegisterInfo::DiffLists, MCRegisterClass_contains(), MCRegisterInfo_getSubReg(), MCRegisterInfo::NumRegs, MCRegisterDesc::SuperRegs, and val.

◆ MCRegisterInfo_getRegClass()

const MCRegisterClass* MCRegisterInfo_getRegClass ( const MCRegisterInfo RI,
unsigned  i 
)

Definition at line 126 of file MCRegisterInfo.c.

127 {
128  //assert(i < getNumRegClasses() && "Register Class ID out of range");
129  if (i >= RI->NumClasses)
130  return 0;
131  return &(RI->Classes[i]);
132 }
lzma_index ** i
Definition: index.h:629
unsigned NumClasses
const MCRegisterClass * Classes

References MCRegisterInfo::Classes, i, and MCRegisterInfo::NumClasses.

◆ MCRegisterInfo_getSubReg()

unsigned MCRegisterInfo_getSubReg ( const MCRegisterInfo RI,
unsigned  Reg,
unsigned  Idx 
)

◆ MCRegisterInfo_InitMCRegisterInfo()

void MCRegisterInfo_InitMCRegisterInfo ( MCRegisterInfo RI,
const MCRegisterDesc D,
unsigned  NR,
unsigned  RA,
unsigned  PC,
const MCRegisterClass C,
unsigned  NC,
uint16_t(*)  RURoots[2],
unsigned  NRU,
const MCPhysReg DL,
const char *  Strings,
const uint16_t SubIndices,
unsigned  NumIndices,
const uint16_t RET 
)

Definition at line 28 of file MCRegisterInfo.c.

37 {
38  RI->Desc = D;
39  RI->NumRegs = NR;
40  RI->RAReg = RA;
41  RI->PCReg = PC;
42  RI->Classes = C;
43  RI->DiffLists = DL;
44  RI->RegStrings = Strings;
45  RI->NumClasses = NC;
46  RI->RegUnitRoots = RURoots;
47  RI->NumRegUnits = NRU;
48  RI->SubRegIndices = SubIndices;
49  RI->NumSubRegIndices = NumIndices;
50  RI->RegEncodingTable = RET;
51 }
#define RET
#define C(x)
Definition: arc.h:167
#define PC(addr, is_thumb)
Definition: arm_il32.c:108
#define NC
Definition: utils.h:42
const char * RegStrings
unsigned NumRegUnits
uint16_t(* RegUnitRoots)[2]
unsigned NumSubRegIndices
const uint16_t * RegEncodingTable

References C, MCRegisterInfo::Classes, D, MCRegisterInfo::Desc, MCRegisterInfo::DiffLists, NC, MCRegisterInfo::NumClasses, MCRegisterInfo::NumRegs, MCRegisterInfo::NumRegUnits, MCRegisterInfo::NumSubRegIndices, PC, MCRegisterInfo::PCReg, MCRegisterInfo::RAReg, MCRegisterInfo::RegEncodingTable, MCRegisterInfo::RegStrings, MCRegisterInfo::RegUnitRoots, RET, and MCRegisterInfo::SubRegIndices.