Optimization: Implement Return Stack Buffer

This commit is contained in:
MerryMage
2016-08-13 00:10:23 +01:00
parent 8e68e6fdd9
commit 960d14d18e
18 changed files with 167 additions and 31 deletions

View File

@@ -41,6 +41,10 @@ Value::Value(u32 value) : type(Type::U32) {
inner.imm_u32 = value;
}
Value::Value(u64 value) : type(Type::U64) {
inner.imm_u64 = value;
}
bool Value::IsImmediate() const {
if (type == Type::Opaque)
return inner.inst->GetOpcode() == Opcode::Identity ? inner.inst->GetArg(0).IsImmediate() : false;
@@ -98,6 +102,13 @@ u32 Value::GetU32() const {
return inner.imm_u32;
}
u64 Value::GetU64() const {
if (type == Type::Opaque && inner.inst->GetOpcode() == Opcode::Identity)
return inner.inst->GetArg(0).GetU64();
DEBUG_ASSERT(type == Type::U64);
return inner.imm_u64;
}
// Inst class member definitions
Value Inst::GetArg(size_t index) const {

View File

@@ -50,6 +50,7 @@ public:
explicit Value(bool value);
explicit Value(u8 value);
explicit Value(u32 value);
explicit Value(u64 value);
bool IsEmpty() const;
bool IsImmediate() const;
@@ -61,6 +62,7 @@ public:
bool GetU1() const;
u8 GetU8() const;
u32 GetU32() const;
u64 GetU64() const;
private:
Type type;
@@ -72,6 +74,7 @@ private:
bool imm_u1;
u8 imm_u8;
u32 imm_u32;
u64 imm_u64;
} inner;
};

View File

@@ -98,6 +98,10 @@ void IREmitter::CallSupervisor(const IR::Value& value) {
Inst(IR::Opcode::CallSupervisor, {value});
}
void IREmitter::PushRSB(const LocationDescriptor& return_location) {
Inst(IR::Opcode::PushRSB, {IR::Value(return_location.UniqueHash())});
}
IR::Value IREmitter::GetCFlag() {
return Inst(IR::Opcode::GetCFlag, {});
}

View File

@@ -54,6 +54,7 @@ public:
void BXWritePC(const IR::Value& value);
void LoadWritePC(const IR::Value& value);
void CallSupervisor(const IR::Value& value);
void PushRSB(const LocationDescriptor& return_location);
IR::Value GetCFlag();
void SetNFlag(const IR::Value& value);

View File

@@ -22,6 +22,9 @@ OPCODE(OrQFlag, T::Void, T::U1
OPCODE(BXWritePC, T::Void, T::U32 )
OPCODE(CallSupervisor, T::Void, T::U32 )
// Hints
OPCODE(PushRSB, T::Void, T::U64 )
// Pseudo-operation, handled specially at final emit
OPCODE(GetCarryFromOp, T::U1, T::U32 )
OPCODE(GetOverflowFromOp, T::U1, T::U32 )