forked from xcore/tool_axe
-
Notifications
You must be signed in to change notification settings - Fork 1
/
JITOptimize.h
53 lines (47 loc) · 1.49 KB
/
JITOptimize.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
// Copyright (c) 2012, Richard Osborne, All rights reserved
// This software is freely distributable under a derivative of the
// University of Illinois/NCSA Open Source License posted in
// LICENSE.txt and at <http://github.xcore.com/>
#ifndef _JITOptimize_h_
#define _JITOptimize_h_
#include <vector>
#include <queue>
#include <utility>
#include "Instruction.h"
#include "Register.h"
// Let x = baseReg + scale + offsetReg + offsetImm
class MemoryCheck {
public:
enum Type {
CheckAlignment = 1 << 0,
CheckAddress = 1 << 1,
CheckInvalidation = 1 << 2,
};
private:
unsigned size;
Register::Reg baseReg;
unsigned scale;
Register::Reg offsetReg;
uint32_t offsetImm;
/// Bitwise OR of MemoryCheck::Type.
unsigned flags;
public:
MemoryCheck(unsigned Size, Register::Reg base, unsigned s,
Register::Reg offset, uint32_t offsetI, unsigned f) :
size(Size),
baseReg(base),
scale(s),
offsetReg(offset),
offsetImm(offsetI),
flags(f) {}
unsigned getSize() const { return size; }
Register::Reg getBaseReg() const { return baseReg; }
unsigned getScale() const { return scale; }
Register::Reg getOffsetReg() const { return offsetReg; }
uint32_t getOffsetImm() const { return offsetImm; }
unsigned getFlags() const { return flags; }
};
void placeMemoryChecks(std::vector<InstructionOpcode> &opcode,
std::vector<Operands> &operands,
std::queue<std::pair<uint32_t,MemoryCheck*> > &checks);
#endif // _JITOptimize_h_