2016-08-17 15:53:36 +01:00
|
|
|
/* This file is part of the dynarmic project.
|
|
|
|
* Copyright (c) 2016 MerryMage
|
|
|
|
* This software may be used and distributed according to the terms of the GNU
|
|
|
|
* General Public License version 2 or any later version.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "common/common_types.h"
|
2016-09-06 00:52:33 +01:00
|
|
|
#include "frontend/arm/types.h"
|
2016-08-17 15:53:36 +01:00
|
|
|
|
|
|
|
namespace Dynarmic {
|
|
|
|
namespace IR {
|
|
|
|
|
|
|
|
class Inst;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A representation of a value in the IR.
|
|
|
|
* A value may either be an immediate or the result of a microinstruction.
|
|
|
|
*/
|
2016-09-05 11:53:56 +01:00
|
|
|
class Value final {
|
2016-08-17 15:53:36 +01:00
|
|
|
public:
|
|
|
|
Value() : type(Type::Void) {}
|
|
|
|
explicit Value(Inst* value);
|
|
|
|
explicit Value(Arm::Reg value);
|
|
|
|
explicit Value(Arm::ExtReg value);
|
|
|
|
explicit Value(bool value);
|
|
|
|
explicit Value(u8 value);
|
|
|
|
explicit Value(u32 value);
|
|
|
|
explicit Value(u64 value);
|
2016-12-31 10:46:13 +00:00
|
|
|
explicit Value(std::array<u8, 8> value);
|
2016-08-17 15:53:36 +01:00
|
|
|
|
|
|
|
bool IsEmpty() const;
|
|
|
|
bool IsImmediate() const;
|
|
|
|
Type GetType() const;
|
|
|
|
|
|
|
|
Inst* GetInst() const;
|
|
|
|
Arm::Reg GetRegRef() const;
|
|
|
|
Arm::ExtReg GetExtRegRef() const;
|
|
|
|
bool GetU1() const;
|
|
|
|
u8 GetU8() const;
|
|
|
|
u32 GetU32() const;
|
|
|
|
u64 GetU64() const;
|
2016-12-31 10:46:13 +00:00
|
|
|
std::array<u8, 8> GetCoprocInfo() const;
|
2016-08-17 15:53:36 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
Type type;
|
|
|
|
|
|
|
|
union {
|
|
|
|
Inst* inst; // type == Type::Opaque
|
|
|
|
Arm::Reg imm_regref;
|
|
|
|
Arm::ExtReg imm_extregref;
|
|
|
|
bool imm_u1;
|
|
|
|
u8 imm_u8;
|
|
|
|
u32 imm_u32;
|
|
|
|
u64 imm_u64;
|
2016-12-31 10:46:13 +00:00
|
|
|
std::array<u8, 8> imm_coproc;
|
2016-08-17 15:53:36 +01:00
|
|
|
} inner;
|
|
|
|
};
|
2016-12-31 10:46:13 +00:00
|
|
|
static_assert(sizeof(Value) <= 2 * sizeof(u64), "IR::Value should be kept small in size");
|
2016-08-17 15:53:36 +01:00
|
|
|
|
|
|
|
} // namespace IR
|
|
|
|
} // namespace Dynarmic
|