-
Notifications
You must be signed in to change notification settings - Fork 1
/
line.h
76 lines (67 loc) · 1.99 KB
/
line.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#ifndef LINE_H
#define LINE_H
#include <asmjit/asmjit.h>
#include <vector>
#include <stdlib.h>
#include <sstream>
#ifndef MAX_OPS
#define MAX_OPS 3
#endif
class Line
{
private:
uint32_t instruction;
asmjit::Operand ops[MAX_OPS];
uint32_t label;
uint32_t align;
uint8_t byte;
char orig_line[128];
uint32_t options;
std::vector<int> dependencies;
std::vector<asmjit::X86Reg> regsIn;
std::vector<asmjit::X86Reg> regsOut;
public:
enum InstOptions {
OptNotShortForm,
OptNrOptions
};
Line(uint32_t inst = asmjit::kInstIdNone):
instruction(inst),
ops({asmjit::noOperand, asmjit::noOperand, asmjit::noOperand}),
label(-1),
align(0),
byte(-1),
options(0),
dependencies(std::vector<int>()),
regsIn(std::vector<asmjit::X86Reg>()),
regsOut(std::vector<asmjit::X86Reg>()) {
memset(orig_line, 0, sizeof(orig_line));
};
uint32_t getInstruction() const;
const char *getOrigLine() const;
bool hasOption(uint32_t option) const;
uint32_t getLabel() const;
uint32_t getByte() const;
uint32_t getAlign() const;
asmjit::Operand getOp(int i) const;
asmjit::Operand* getOpPtr(int i);
std::vector<int>& getDependencies();
std::vector<asmjit::X86Reg> getRegsIn() const;
std::vector<asmjit::X86Reg> getRegsOut() const;
int isInstruction() const;
int isLabel() const;
int isAlign() const;
int isByte() const;
bool isValid() const; // one of isInstruction, isLabel, isAlign, or isByte must be true
void setInstruction(uint32_t inst, const char *_orig_line);
void addOption(uint32_t option);
void setLabel(uint32_t lab);
void setAlign(uint8_t ali);
void setByte(uint8_t byt);
void setOp(int i, asmjit::Operand op);
void addRegIn(asmjit::X86Reg reg);
void addRegOut(asmjit::X86Reg reg);
void addDependency(int dep);
friend std::ostream& operator << (std::ostream& outs, const Line& l);
};
#endif