-
Notifications
You must be signed in to change notification settings - Fork 392
/
FPCompareAnalyser.hpp
142 lines (120 loc) · 5.33 KB
/
FPCompareAnalyser.hpp
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*******************************************************************************
* Copyright (c) 2000, 2019 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
* distribution and is available at http://eclipse.org/legal/epl-2.0
* or the Apache License, Version 2.0 which accompanies this distribution
* and is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License, v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception [1] and GNU General Public
* License, version 2 with the OpenJDK Assembly Exception [2].
*
* [1] https://www.gnu.org/software/classpath/license.html
* [2] http://openjdk.java.net/legal/assembly-exception.html
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/
#ifndef IA32FPCOMPAREANALYSER_INCL
#define IA32FPCOMPAREANALYSER_INCL
#include <stddef.h>
#include <stdint.h>
#include "codegen/CodeGenerator.hpp"
#include "infra/Assert.hpp"
#include "codegen/InstOpCode.hpp"
namespace TR { class Machine; }
namespace TR { class Node; }
namespace TR { class Register; }
#define NUM_FPCOMPARE_ACTION_SETS 128
#define fpEvalChild1 0x01
#define fpEvalChild2 0x02
#define fpCmpReg1Reg2 0x04
#define fpCmpReg2Reg1 0x08
#define fpCmpReg1Mem2 0x10
#define fpCmpReg2Mem1 0x20
#define fpNoOperandSwapping 0x40
class TR_X86FPCompareAnalyser
{
public:
TR_X86FPCompareAnalyser(TR::CodeGenerator *cg)
: _cg(cg), _machine(cg->machine()),
_reversedOperands(false),
_inputs(0) {}
virtual TR::Register *fpCompareAnalyser(TR::Node *root,
TR_X86OpCodes cmpRegRegOpCode,
TR_X86OpCodes cmpRegMemOpCode,
TR_X86OpCodes cmpiRegRegOpCode,
bool useFCOMIInstructions);
// Possible actions based on the characteristics of the operands.
//
enum EFPActions
{
kEvalChild1 = 0x01,
kEvalChild2 = 0x02,
kCmpReg1Reg2 = 0x04,
kCmpReg2Reg1 = 0x08,
kCmpReg1Mem2 = 0x10,
kCmpReg2Mem1 = 0x20
};
// Operand characteristics
//
enum Einputs
{
kClob2 = 0x01,
kMem2 = 0x02,
kReg2 = 0x04,
kClob1 = 0x08,
kMem1 = 0x10,
kReg1 = 0x20,
kNoOpSwap = 0x40
};
void setReg1() {_inputs |= kReg1;}
void setReg2() {_inputs |= kReg2;}
void setMem1() {_inputs |= kMem1;}
void setMem2() {_inputs |= kMem2;}
void setClob1() {_inputs |= kClob1;}
void setClob2() {_inputs |= kClob2;}
void setNoOperandSwapping() {_inputs |= kNoOpSwap;}
bool getEvalChild1() {return (_actionMap[_inputs] & kEvalChild1) ? true : false;}
bool getEvalChild2() {return (_actionMap[_inputs] & kEvalChild2) ? true : false;}
bool getCmpReg1Reg2() {return (_actionMap[_inputs] & kCmpReg1Reg2) ? true : false;}
bool getCmpReg2Reg1() {return (_actionMap[_inputs] & kCmpReg2Reg1) ? true : false;}
bool getCmpReg1Mem2() {return (_actionMap[_inputs] & kCmpReg1Mem2) ? true : false;}
bool getCmpReg2Mem1() {return (_actionMap[_inputs] & kCmpReg2Mem1) ? true : false;}
bool getReversedOperands() {return _reversedOperands;}
bool setReversedOperands(bool b) {return (_reversedOperands = b);}
bool notReversedOperands() {return (_reversedOperands = ((_reversedOperands == false) ? true : false));}
void setInputs(TR::Node *firstChild,
TR::Register *firstRegister,
TR::Node *secondChild,
TR::Register *secondRegister,
bool disallowMemoryFormInstructions,
bool disallowOperandSwapping);
protected:
TR::CodeGenerator * _cg;
bool _reversedOperands;
uint8_t _inputs;
TR::Machine *_machine;
static const uint8_t _actionMap[NUM_FPCOMPARE_ACTION_SETS];
};
class TR_IA32XMMCompareAnalyser : public TR_X86FPCompareAnalyser
{
public:
TR_IA32XMMCompareAnalyser(TR::CodeGenerator *cg) : TR_X86FPCompareAnalyser(cg) {}
virtual TR::Register *fpCompareAnalyser(TR::Node *root,
TR_X86OpCodes cmpRegRegOpCode,
TR_X86OpCodes cmpRegMemOpCode,
TR_X86OpCodes cmpiRegRegOpCode,
bool useFCOMIInstructions)
{
TR_ASSERT(0, "TR_IA32XMMCompareAnalyser::fpCompareAnalyser() should not be called\n");
return NULL;
}
TR::Register *xmmCompareAnalyser(TR::Node *root,
TR_X86OpCodes cmpRegRegOpCode,
TR_X86OpCodes cmpRegMemOpCode);
};
#endif