mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1041673 - IonMonkey: Implement opcode testing and casts with member function templates. r=nbp
This commit is contained in:
parent
ef3acdccf9
commit
d0f7653db0
@ -686,12 +686,27 @@ class MDefinition : public MNode
|
||||
|
||||
public:
|
||||
// Opcode testing and casts.
|
||||
template<typename MIRType> bool is() const {
|
||||
return op() == MIRType::classOpcode;
|
||||
}
|
||||
template<typename MIRType> MIRType *to() {
|
||||
JS_ASSERT(is<MIRType>());
|
||||
return static_cast<MIRType *>(this);
|
||||
}
|
||||
template<typename MIRType> const MIRType *to() const {
|
||||
JS_ASSERT(is<MIRType>());
|
||||
return static_cast<const MIRType *>(this);
|
||||
}
|
||||
# define OPCODE_CASTS(opcode) \
|
||||
bool is##opcode() const { \
|
||||
return op() == Op_##opcode; \
|
||||
return is<M##opcode>(); \
|
||||
} \
|
||||
inline M##opcode *to##opcode(); \
|
||||
inline const M##opcode *to##opcode() const;
|
||||
M##opcode *to##opcode() { \
|
||||
return to<M##opcode>(); \
|
||||
} \
|
||||
const M##opcode *to##opcode() const { \
|
||||
return to<M##opcode>(); \
|
||||
}
|
||||
MIR_OPCODE_LIST(OPCODE_CASTS)
|
||||
# undef OPCODE_CASTS
|
||||
|
||||
@ -832,8 +847,9 @@ class MInstruction
|
||||
};
|
||||
|
||||
#define INSTRUCTION_HEADER(opcode) \
|
||||
static const Opcode classOpcode = MDefinition::Op_##opcode; \
|
||||
Opcode op() const { \
|
||||
return MDefinition::Op_##opcode; \
|
||||
return classOpcode; \
|
||||
} \
|
||||
const char *opName() const { \
|
||||
return #opcode; \
|
||||
@ -11252,6 +11268,8 @@ class MAsmJSCall MOZ_FINAL : public MVariadicInstruction
|
||||
}
|
||||
};
|
||||
|
||||
#undef INSTRUCTION_HEADER
|
||||
|
||||
void MUse::init(MDefinition *producer, MNode *consumer)
|
||||
{
|
||||
MOZ_ASSERT(!consumer_, "Initializing MUse that already has a consumer");
|
||||
@ -11289,22 +11307,7 @@ void MUse::discardProducer()
|
||||
producer_ = nullptr;
|
||||
}
|
||||
|
||||
#undef INSTRUCTION_HEADER
|
||||
|
||||
// Implement opcode casts now that the compiler can see the inheritance.
|
||||
#define OPCODE_CASTS(opcode) \
|
||||
M##opcode *MDefinition::to##opcode() \
|
||||
{ \
|
||||
JS_ASSERT(is##opcode()); \
|
||||
return static_cast<M##opcode *>(this); \
|
||||
} \
|
||||
const M##opcode *MDefinition::to##opcode() const \
|
||||
{ \
|
||||
JS_ASSERT(is##opcode()); \
|
||||
return static_cast<const M##opcode *>(this); \
|
||||
}
|
||||
MIR_OPCODE_LIST(OPCODE_CASTS)
|
||||
#undef OPCODE_CASTS
|
||||
// Implement cast functions now that the compiler can see the inheritance.
|
||||
|
||||
MDefinition *MNode::toDefinition()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user