2018-05-24 23:37:18 +00:00
|
|
|
|
// Copyright 2018 yuzu Emulator Project
|
2018-04-05 01:43:40 +00:00
|
|
|
|
// Licensed under GPLv2 or any later version
|
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2018-04-21 00:49:05 +00:00
|
|
|
|
#include <bitset>
|
2018-04-16 00:45:56 +00:00
|
|
|
|
#include <cstring>
|
2018-04-05 01:43:40 +00:00
|
|
|
|
#include <map>
|
|
|
|
|
#include <string>
|
2018-04-21 00:49:05 +00:00
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
#include <boost/optional.hpp>
|
|
|
|
|
|
2018-08-19 19:00:12 +00:00
|
|
|
|
#include "common/assert.h"
|
2018-04-05 01:43:40 +00:00
|
|
|
|
#include "common/bit_field.h"
|
2018-04-21 00:49:05 +00:00
|
|
|
|
#include "common/common_types.h"
|
2018-04-05 01:43:40 +00:00
|
|
|
|
|
2018-07-20 22:14:17 +00:00
|
|
|
|
namespace Tegra::Shader {
|
2018-04-05 01:43:40 +00:00
|
|
|
|
|
|
|
|
|
struct Register {
|
2018-04-26 03:55:21 +00:00
|
|
|
|
/// Number of registers
|
2018-09-15 13:21:06 +00:00
|
|
|
|
static constexpr std::size_t NumRegisters = 256;
|
2018-04-26 03:55:21 +00:00
|
|
|
|
|
|
|
|
|
/// Register 255 is special cased to always be 0
|
2018-09-15 13:21:06 +00:00
|
|
|
|
static constexpr std::size_t ZeroIndex = 255;
|
2018-04-20 14:04:54 +00:00
|
|
|
|
|
2018-04-28 02:19:14 +00:00
|
|
|
|
enum class Size : u64 {
|
|
|
|
|
Byte = 0,
|
|
|
|
|
Short = 1,
|
|
|
|
|
Word = 2,
|
|
|
|
|
Long = 3,
|
|
|
|
|
};
|
|
|
|
|
|
2018-04-17 22:06:10 +00:00
|
|
|
|
constexpr Register() = default;
|
2018-04-05 01:43:40 +00:00
|
|
|
|
|
|
|
|
|
constexpr Register(u64 value) : value(value) {}
|
|
|
|
|
|
|
|
|
|
constexpr operator u64() const {
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
|
constexpr u64 operator-(const T& oth) const {
|
|
|
|
|
return value - oth;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
|
|
|
|
constexpr u64 operator&(const T& oth) const {
|
|
|
|
|
return value & oth;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
constexpr u64 operator&(const Register& oth) const {
|
|
|
|
|
return value & oth.value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
constexpr u64 operator~() const {
|
|
|
|
|
return ~value;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-26 03:55:21 +00:00
|
|
|
|
u64 GetSwizzledIndex(u64 elem) const {
|
|
|
|
|
elem = (value + elem) & 3;
|
|
|
|
|
return (value & ~3) + elem;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-05 01:43:40 +00:00
|
|
|
|
private:
|
2018-04-17 22:06:10 +00:00
|
|
|
|
u64 value{};
|
2018-04-05 01:43:40 +00:00
|
|
|
|
};
|
|
|
|
|
|
2018-09-08 21:13:02 +00:00
|
|
|
|
enum class AttributeSize : u64 {
|
|
|
|
|
Word = 0,
|
|
|
|
|
DoubleWord = 1,
|
|
|
|
|
TripleWord = 2,
|
|
|
|
|
QuadWord = 3,
|
|
|
|
|
};
|
|
|
|
|
|
2018-04-05 01:43:40 +00:00
|
|
|
|
union Attribute {
|
2018-04-14 18:09:32 +00:00
|
|
|
|
Attribute() = default;
|
2018-04-05 01:43:40 +00:00
|
|
|
|
|
2018-04-17 22:06:10 +00:00
|
|
|
|
constexpr explicit Attribute(u64 value) : value(value) {}
|
2018-04-05 01:43:40 +00:00
|
|
|
|
|
|
|
|
|
enum class Index : u64 {
|
|
|
|
|
Position = 7,
|
|
|
|
|
Attribute_0 = 8,
|
2018-08-10 16:34:51 +00:00
|
|
|
|
Attribute_31 = 39,
|
2018-09-05 03:09:24 +00:00
|
|
|
|
PointCoord = 46,
|
2018-05-30 15:58:03 +00:00
|
|
|
|
// This attribute contains a tuple of (~, ~, InstanceId, VertexId) when inside a vertex
|
|
|
|
|
// shader, and a tuple of (TessCoord.x, TessCoord.y, TessCoord.z, ~) when inside a Tess Eval
|
|
|
|
|
// shader.
|
|
|
|
|
TessCoordInstanceIDVertexID = 47,
|
2018-08-19 05:14:34 +00:00
|
|
|
|
// This attribute contains a tuple of (Unk, Unk, Unk, gl_FrontFacing) when inside a fragment
|
|
|
|
|
// shader. It is unknown what the other values contain.
|
|
|
|
|
FrontFacing = 63,
|
2018-04-05 01:43:40 +00:00
|
|
|
|
};
|
|
|
|
|
|
2018-04-10 03:39:44 +00:00
|
|
|
|
union {
|
2018-09-08 21:13:02 +00:00
|
|
|
|
BitField<20, 10, u64> immediate;
|
2018-04-10 03:39:44 +00:00
|
|
|
|
BitField<22, 2, u64> element;
|
|
|
|
|
BitField<24, 6, Index> index;
|
2018-09-08 21:13:02 +00:00
|
|
|
|
BitField<47, 3, AttributeSize> size;
|
2018-04-10 03:39:44 +00:00
|
|
|
|
} fmt20;
|
|
|
|
|
|
|
|
|
|
union {
|
|
|
|
|
BitField<30, 2, u64> element;
|
|
|
|
|
BitField<32, 6, Index> index;
|
|
|
|
|
} fmt28;
|
2018-04-05 01:43:40 +00:00
|
|
|
|
|
|
|
|
|
BitField<39, 8, u64> reg;
|
2018-04-17 22:06:10 +00:00
|
|
|
|
u64 value{};
|
2018-04-05 01:43:40 +00:00
|
|
|
|
};
|
|
|
|
|
|
2018-04-10 05:26:15 +00:00
|
|
|
|
union Sampler {
|
|
|
|
|
Sampler() = default;
|
|
|
|
|
|
2018-04-17 22:06:10 +00:00
|
|
|
|
constexpr explicit Sampler(u64 value) : value(value) {}
|
2018-04-10 05:26:15 +00:00
|
|
|
|
|
|
|
|
|
enum class Index : u64 {
|
|
|
|
|
Sampler_0 = 8,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
BitField<36, 13, Index> index;
|
2018-04-17 22:06:10 +00:00
|
|
|
|
u64 value{};
|
2018-04-10 05:26:15 +00:00
|
|
|
|
};
|
|
|
|
|
|
2018-07-20 22:14:17 +00:00
|
|
|
|
} // namespace Tegra::Shader
|
2018-04-05 01:43:40 +00:00
|
|
|
|
|
|
|
|
|
namespace std {
|
|
|
|
|
|
2018-04-21 00:49:05 +00:00
|
|
|
|
// TODO(bunnei): The below is forbidden by the C++ standard, but works fine. See #330.
|
2018-04-05 01:43:40 +00:00
|
|
|
|
template <>
|
|
|
|
|
struct make_unsigned<Tegra::Shader::Attribute> {
|
|
|
|
|
using type = Tegra::Shader::Attribute;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
template <>
|
|
|
|
|
struct make_unsigned<Tegra::Shader::Register> {
|
|
|
|
|
using type = Tegra::Shader::Register;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace std
|
|
|
|
|
|
2018-07-20 22:14:17 +00:00
|
|
|
|
namespace Tegra::Shader {
|
2018-04-05 01:43:40 +00:00
|
|
|
|
|
|
|
|
|
enum class Pred : u64 {
|
|
|
|
|
UnusedIndex = 0x7,
|
2018-04-20 14:09:50 +00:00
|
|
|
|
NeverExecute = 0xF,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum class PredCondition : u64 {
|
|
|
|
|
LessThan = 1,
|
|
|
|
|
Equal = 2,
|
|
|
|
|
LessEqual = 3,
|
|
|
|
|
GreaterThan = 4,
|
|
|
|
|
NotEqual = 5,
|
|
|
|
|
GreaterEqual = 6,
|
2018-07-13 00:03:45 +00:00
|
|
|
|
LessThanWithNan = 9,
|
2018-08-18 07:49:59 +00:00
|
|
|
|
GreaterThanWithNan = 12,
|
2018-06-30 07:00:39 +00:00
|
|
|
|
NotEqualWithNan = 13,
|
2018-08-31 07:40:18 +00:00
|
|
|
|
GreaterEqualWithNan = 14,
|
2018-04-20 14:09:50 +00:00
|
|
|
|
// TODO(Subv): Other condition types
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum class PredOperation : u64 {
|
|
|
|
|
And = 0,
|
|
|
|
|
Or = 1,
|
|
|
|
|
Xor = 2,
|
2018-04-05 01:43:40 +00:00
|
|
|
|
};
|
|
|
|
|
|
2018-06-04 18:24:31 +00:00
|
|
|
|
enum class LogicOperation : u64 {
|
|
|
|
|
And = 0,
|
|
|
|
|
Or = 1,
|
|
|
|
|
Xor = 2,
|
|
|
|
|
PassB = 3,
|
|
|
|
|
};
|
|
|
|
|
|
2018-04-10 02:09:23 +00:00
|
|
|
|
enum class SubOp : u64 {
|
|
|
|
|
Cos = 0x0,
|
|
|
|
|
Sin = 0x1,
|
|
|
|
|
Ex2 = 0x2,
|
|
|
|
|
Lg2 = 0x3,
|
|
|
|
|
Rcp = 0x4,
|
|
|
|
|
Rsq = 0x5,
|
2018-07-03 00:48:15 +00:00
|
|
|
|
Sqrt = 0x8,
|
2018-04-10 02:09:23 +00:00
|
|
|
|
};
|
|
|
|
|
|
2018-06-07 02:21:29 +00:00
|
|
|
|
enum class F2iRoundingOp : u64 {
|
2018-06-04 23:05:12 +00:00
|
|
|
|
None = 0,
|
|
|
|
|
Floor = 1,
|
|
|
|
|
Ceil = 2,
|
|
|
|
|
Trunc = 3,
|
|
|
|
|
};
|
|
|
|
|
|
2018-06-07 02:21:29 +00:00
|
|
|
|
enum class F2fRoundingOp : u64 {
|
|
|
|
|
None = 0,
|
|
|
|
|
Pass = 3,
|
|
|
|
|
Round = 8,
|
|
|
|
|
Floor = 9,
|
|
|
|
|
Ceil = 10,
|
|
|
|
|
Trunc = 11,
|
|
|
|
|
};
|
|
|
|
|
|
2018-06-06 03:46:23 +00:00
|
|
|
|
enum class UniformType : u64 {
|
|
|
|
|
UnsignedByte = 0,
|
|
|
|
|
SignedByte = 1,
|
|
|
|
|
UnsignedShort = 2,
|
|
|
|
|
SignedShort = 3,
|
|
|
|
|
Single = 4,
|
|
|
|
|
Double = 5,
|
|
|
|
|
};
|
|
|
|
|
|
2018-07-04 20:25:48 +00:00
|
|
|
|
enum class IMinMaxExchange : u64 {
|
|
|
|
|
None = 0,
|
|
|
|
|
XLo = 1,
|
|
|
|
|
XMed = 2,
|
|
|
|
|
XHi = 3,
|
|
|
|
|
};
|
|
|
|
|
|
2018-08-12 20:51:32 +00:00
|
|
|
|
enum class XmadMode : u64 {
|
|
|
|
|
None = 0,
|
|
|
|
|
CLo = 1,
|
|
|
|
|
CHi = 2,
|
|
|
|
|
CSfu = 3,
|
|
|
|
|
CBcc = 4,
|
|
|
|
|
};
|
|
|
|
|
|
2018-08-24 16:15:43 +00:00
|
|
|
|
enum class IAdd3Mode : u64 {
|
|
|
|
|
None = 0,
|
|
|
|
|
RightShift = 1,
|
|
|
|
|
LeftShift = 2,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum class IAdd3Height : u64 {
|
|
|
|
|
None = 0,
|
|
|
|
|
LowerHalfWord = 1,
|
|
|
|
|
UpperHalfWord = 2,
|
|
|
|
|
};
|
|
|
|
|
|
2018-07-13 00:00:37 +00:00
|
|
|
|
enum class FlowCondition : u64 {
|
|
|
|
|
Always = 0xF,
|
|
|
|
|
Fcsm_Tr = 0x1C, // TODO(bunnei): What is this used for?
|
|
|
|
|
};
|
|
|
|
|
|
2018-09-09 01:54:11 +00:00
|
|
|
|
enum class ControlCode : u64 {
|
|
|
|
|
F = 0,
|
|
|
|
|
LT = 1,
|
|
|
|
|
EQ = 2,
|
|
|
|
|
LE = 3,
|
|
|
|
|
GT = 4,
|
|
|
|
|
NE = 5,
|
|
|
|
|
GE = 6,
|
|
|
|
|
Num = 7,
|
|
|
|
|
Nan = 8,
|
|
|
|
|
LTU = 9,
|
|
|
|
|
EQU = 10,
|
|
|
|
|
LEU = 11,
|
|
|
|
|
GTU = 12,
|
|
|
|
|
NEU = 13,
|
|
|
|
|
GEU = 14,
|
|
|
|
|
//
|
|
|
|
|
OFF = 16,
|
|
|
|
|
LO = 17,
|
|
|
|
|
SFF = 18,
|
|
|
|
|
LS = 19,
|
|
|
|
|
HI = 20,
|
|
|
|
|
SFT = 21,
|
|
|
|
|
HS = 22,
|
|
|
|
|
OFT = 23,
|
|
|
|
|
CSM_TA = 24,
|
|
|
|
|
CSM_TR = 25,
|
|
|
|
|
CSM_MX = 26,
|
|
|
|
|
FCSM_TA = 27,
|
|
|
|
|
FCSM_TR = 28,
|
|
|
|
|
FCSM_MX = 29,
|
|
|
|
|
RLE = 30,
|
|
|
|
|
RGT = 31,
|
|
|
|
|
};
|
|
|
|
|
|
2018-08-18 19:36:37 +00:00
|
|
|
|
enum class PredicateResultMode : u64 {
|
|
|
|
|
None = 0x0,
|
|
|
|
|
NotZero = 0x3,
|
|
|
|
|
};
|
|
|
|
|
|
2018-08-19 17:46:35 +00:00
|
|
|
|
enum class TextureType : u64 {
|
|
|
|
|
Texture1D = 0,
|
|
|
|
|
Texture2D = 1,
|
|
|
|
|
Texture3D = 2,
|
|
|
|
|
TextureCube = 3,
|
|
|
|
|
};
|
|
|
|
|
|
2018-09-07 23:53:06 +00:00
|
|
|
|
enum class TextureQueryType : u64 {
|
|
|
|
|
Dimension = 1,
|
|
|
|
|
TextureType = 2,
|
|
|
|
|
SamplePosition = 5,
|
|
|
|
|
Filter = 16,
|
|
|
|
|
LevelOfDetail = 18,
|
|
|
|
|
Wrap = 20,
|
|
|
|
|
BorderColor = 22,
|
|
|
|
|
};
|
|
|
|
|
|
2018-09-08 01:09:39 +00:00
|
|
|
|
enum class TextureProcessMode : u64 {
|
|
|
|
|
None = 0,
|
|
|
|
|
LZ = 1, // Unknown, appears to be the same as none.
|
|
|
|
|
LB = 2, // Load Bias.
|
|
|
|
|
LL = 3, // Load LOD (LevelOfDetail)
|
|
|
|
|
LBA = 6, // Load Bias. The A is unknown, does not appear to differ with LB
|
|
|
|
|
LLA = 7 // Load LOD. The A is unknown, does not appear to differ with LL
|
|
|
|
|
};
|
|
|
|
|
|
2018-09-01 06:34:27 +00:00
|
|
|
|
enum class IpaInterpMode : u64 { Linear = 0, Perspective = 1, Flat = 2, Sc = 3 };
|
|
|
|
|
enum class IpaSampleMode : u64 { Default = 0, Centroid = 1, Offset = 2 };
|
2018-08-29 04:37:29 +00:00
|
|
|
|
|
2018-09-05 03:09:24 +00:00
|
|
|
|
struct IpaMode {
|
|
|
|
|
IpaInterpMode interpolation_mode;
|
|
|
|
|
IpaSampleMode sampling_mode;
|
|
|
|
|
inline bool operator==(const IpaMode& a) {
|
|
|
|
|
return (a.interpolation_mode == interpolation_mode) && (a.sampling_mode == sampling_mode);
|
|
|
|
|
}
|
|
|
|
|
inline bool operator!=(const IpaMode& a) {
|
|
|
|
|
return !((*this) == a);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2018-04-05 01:43:40 +00:00
|
|
|
|
union Instruction {
|
|
|
|
|
Instruction& operator=(const Instruction& instr) {
|
2018-04-21 00:49:05 +00:00
|
|
|
|
value = instr.value;
|
2018-04-05 01:43:40 +00:00
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-21 00:49:05 +00:00
|
|
|
|
constexpr Instruction(u64 value) : value{value} {}
|
|
|
|
|
|
2018-04-10 03:39:44 +00:00
|
|
|
|
BitField<0, 8, Register> gpr0;
|
|
|
|
|
BitField<8, 8, Register> gpr8;
|
2018-04-20 14:16:55 +00:00
|
|
|
|
union {
|
|
|
|
|
BitField<16, 4, Pred> full_pred;
|
|
|
|
|
BitField<16, 3, u64> pred_index;
|
|
|
|
|
} pred;
|
|
|
|
|
BitField<19, 1, u64> negate_pred;
|
2018-04-10 03:39:44 +00:00
|
|
|
|
BitField<20, 8, Register> gpr20;
|
2018-06-30 19:48:25 +00:00
|
|
|
|
BitField<20, 4, SubOp> sub_op;
|
2018-04-10 03:39:44 +00:00
|
|
|
|
BitField<28, 8, Register> gpr28;
|
|
|
|
|
BitField<39, 8, Register> gpr39;
|
2018-04-21 00:49:05 +00:00
|
|
|
|
BitField<48, 16, u64> opcode;
|
2018-04-10 03:39:44 +00:00
|
|
|
|
|
|
|
|
|
union {
|
2018-04-19 18:34:50 +00:00
|
|
|
|
BitField<20, 19, u64> imm20_19;
|
2018-06-12 16:24:10 +00:00
|
|
|
|
BitField<20, 32, s64> imm20_32;
|
2018-04-10 03:39:44 +00:00
|
|
|
|
BitField<45, 1, u64> negate_b;
|
|
|
|
|
BitField<46, 1, u64> abs_a;
|
|
|
|
|
BitField<48, 1, u64> negate_a;
|
|
|
|
|
BitField<49, 1, u64> abs_b;
|
2018-06-09 06:36:33 +00:00
|
|
|
|
BitField<50, 1, u64> saturate_d;
|
2018-04-16 00:45:56 +00:00
|
|
|
|
BitField<56, 1, u64> negate_imm;
|
|
|
|
|
|
2018-05-20 22:53:06 +00:00
|
|
|
|
union {
|
|
|
|
|
BitField<39, 3, u64> pred;
|
|
|
|
|
BitField<42, 1, u64> negate_pred;
|
|
|
|
|
} fmnmx;
|
|
|
|
|
|
2018-06-17 17:26:11 +00:00
|
|
|
|
union {
|
|
|
|
|
BitField<39, 1, u64> invert_a;
|
|
|
|
|
BitField<40, 1, u64> invert_b;
|
|
|
|
|
BitField<41, 2, LogicOperation> operation;
|
2018-08-18 19:36:37 +00:00
|
|
|
|
BitField<44, 2, PredicateResultMode> pred_result_mode;
|
2018-06-17 17:26:11 +00:00
|
|
|
|
BitField<48, 3, Pred> pred48;
|
|
|
|
|
} lop;
|
|
|
|
|
|
2018-06-04 18:24:31 +00:00
|
|
|
|
union {
|
|
|
|
|
BitField<53, 2, LogicOperation> operation;
|
|
|
|
|
BitField<55, 1, u64> invert_a;
|
|
|
|
|
BitField<56, 1, u64> invert_b;
|
2018-06-17 16:49:34 +00:00
|
|
|
|
} lop32i;
|
2018-06-04 18:24:31 +00:00
|
|
|
|
|
2018-08-22 07:02:18 +00:00
|
|
|
|
union {
|
|
|
|
|
BitField<28, 8, u64> imm_lut28;
|
|
|
|
|
BitField<48, 8, u64> imm_lut48;
|
|
|
|
|
|
|
|
|
|
u32 GetImmLut28() const {
|
|
|
|
|
return static_cast<u32>(imm_lut28);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
u32 GetImmLut48() const {
|
|
|
|
|
return static_cast<u32>(imm_lut48);
|
|
|
|
|
}
|
|
|
|
|
} lop3;
|
|
|
|
|
|
2018-08-08 05:27:12 +00:00
|
|
|
|
u32 GetImm20_19() const {
|
2018-04-19 18:34:50 +00:00
|
|
|
|
u32 imm{static_cast<u32>(imm20_19)};
|
2018-04-16 00:45:56 +00:00
|
|
|
|
imm <<= 12;
|
|
|
|
|
imm |= negate_imm ? 0x80000000 : 0;
|
2018-08-08 05:27:12 +00:00
|
|
|
|
return imm;
|
2018-04-16 00:45:56 +00:00
|
|
|
|
}
|
2018-04-19 18:34:50 +00:00
|
|
|
|
|
2018-08-08 05:27:12 +00:00
|
|
|
|
u32 GetImm20_32() const {
|
|
|
|
|
return static_cast<u32>(imm20_32);
|
2018-04-19 18:34:50 +00:00
|
|
|
|
}
|
2018-06-05 00:03:47 +00:00
|
|
|
|
|
2018-06-05 02:15:19 +00:00
|
|
|
|
s32 GetSignedImm20_20() const {
|
|
|
|
|
u32 immediate = static_cast<u32>(imm20_19 | (negate_imm << 19));
|
2018-06-05 00:03:47 +00:00
|
|
|
|
// Sign extend the 20-bit value.
|
|
|
|
|
u32 mask = 1U << (20 - 1);
|
|
|
|
|
return static_cast<s32>((immediate ^ mask) - mask);
|
|
|
|
|
}
|
2018-06-05 02:15:19 +00:00
|
|
|
|
} alu;
|
2018-06-05 00:03:47 +00:00
|
|
|
|
|
2018-08-29 04:37:29 +00:00
|
|
|
|
union {
|
2018-09-01 06:34:27 +00:00
|
|
|
|
BitField<51, 1, u64> saturate;
|
|
|
|
|
BitField<52, 2, IpaSampleMode> sample_mode;
|
|
|
|
|
BitField<54, 2, IpaInterpMode> interp_mode;
|
2018-08-29 04:37:29 +00:00
|
|
|
|
} ipa;
|
|
|
|
|
|
2018-06-09 04:01:17 +00:00
|
|
|
|
union {
|
2018-09-01 09:05:10 +00:00
|
|
|
|
BitField<39, 2, u64> tab5cb8_2;
|
|
|
|
|
BitField<41, 3, u64> tab5c68_1;
|
|
|
|
|
BitField<44, 2, u64> tab5c68_0;
|
|
|
|
|
BitField<47, 1, u64> cc;
|
2018-08-16 14:05:16 +00:00
|
|
|
|
BitField<48, 1, u64> negate_b;
|
|
|
|
|
} fmul;
|
|
|
|
|
|
2018-06-09 04:01:17 +00:00
|
|
|
|
union {
|
|
|
|
|
BitField<48, 1, u64> is_signed;
|
|
|
|
|
} shift;
|
|
|
|
|
|
2018-06-05 02:15:19 +00:00
|
|
|
|
union {
|
|
|
|
|
BitField<39, 5, u64> shift_amount;
|
|
|
|
|
BitField<48, 1, u64> negate_b;
|
|
|
|
|
BitField<49, 1, u64> negate_a;
|
2018-06-09 03:25:22 +00:00
|
|
|
|
} alu_integer;
|
2018-06-05 00:03:47 +00:00
|
|
|
|
|
2018-08-31 01:32:58 +00:00
|
|
|
|
union {
|
|
|
|
|
BitField<40, 1, u64> invert;
|
|
|
|
|
} popc;
|
|
|
|
|
|
2018-07-22 04:37:12 +00:00
|
|
|
|
union {
|
|
|
|
|
BitField<39, 3, u64> pred;
|
|
|
|
|
BitField<42, 1, u64> neg_pred;
|
|
|
|
|
} sel;
|
|
|
|
|
|
2018-07-04 20:25:48 +00:00
|
|
|
|
union {
|
|
|
|
|
BitField<39, 3, u64> pred;
|
|
|
|
|
BitField<42, 1, u64> negate_pred;
|
|
|
|
|
BitField<43, 2, IMinMaxExchange> exchange;
|
|
|
|
|
BitField<48, 1, u64> is_signed;
|
|
|
|
|
} imnmx;
|
|
|
|
|
|
2018-08-24 16:15:43 +00:00
|
|
|
|
union {
|
|
|
|
|
BitField<31, 2, IAdd3Height> height_c;
|
|
|
|
|
BitField<33, 2, IAdd3Height> height_b;
|
|
|
|
|
BitField<35, 2, IAdd3Height> height_a;
|
|
|
|
|
BitField<37, 2, IAdd3Mode> mode;
|
|
|
|
|
BitField<49, 1, u64> neg_c;
|
|
|
|
|
BitField<50, 1, u64> neg_b;
|
|
|
|
|
BitField<51, 1, u64> neg_a;
|
|
|
|
|
} iadd3;
|
|
|
|
|
|
2018-06-12 16:24:10 +00:00
|
|
|
|
union {
|
|
|
|
|
BitField<54, 1, u64> saturate;
|
|
|
|
|
BitField<56, 1, u64> negate_a;
|
|
|
|
|
} iadd32i;
|
|
|
|
|
|
2018-07-12 17:00:31 +00:00
|
|
|
|
union {
|
|
|
|
|
BitField<53, 1, u64> negate_b;
|
|
|
|
|
BitField<54, 1, u64> abs_a;
|
|
|
|
|
BitField<56, 1, u64> negate_a;
|
|
|
|
|
BitField<57, 1, u64> abs_b;
|
|
|
|
|
} fadd32i;
|
|
|
|
|
|
2018-06-07 04:58:12 +00:00
|
|
|
|
union {
|
|
|
|
|
BitField<20, 8, u64> shift_position;
|
|
|
|
|
BitField<28, 8, u64> shift_length;
|
|
|
|
|
BitField<48, 1, u64> negate_b;
|
|
|
|
|
BitField<49, 1, u64> negate_a;
|
|
|
|
|
|
|
|
|
|
u64 GetLeftShiftValue() const {
|
|
|
|
|
return 32 - (shift_position + shift_length);
|
|
|
|
|
}
|
|
|
|
|
} bfe;
|
|
|
|
|
|
2018-09-11 16:26:42 +00:00
|
|
|
|
union {
|
|
|
|
|
BitField<48, 3, u64> pred48;
|
|
|
|
|
|
|
|
|
|
union {
|
|
|
|
|
BitField<20, 20, u64> entry_a;
|
|
|
|
|
BitField<39, 5, u64> entry_b;
|
|
|
|
|
BitField<45, 1, u64> neg;
|
|
|
|
|
BitField<46, 1, u64> uses_cc;
|
|
|
|
|
} imm;
|
|
|
|
|
|
|
|
|
|
union {
|
|
|
|
|
BitField<20, 14, u64> cb_index;
|
|
|
|
|
BitField<34, 5, u64> cb_offset;
|
|
|
|
|
BitField<56, 1, u64> neg;
|
|
|
|
|
BitField<57, 1, u64> uses_cc;
|
|
|
|
|
} hi;
|
|
|
|
|
|
|
|
|
|
union {
|
|
|
|
|
BitField<20, 14, u64> cb_index;
|
|
|
|
|
BitField<34, 5, u64> cb_offset;
|
|
|
|
|
BitField<39, 5, u64> entry_a;
|
|
|
|
|
BitField<45, 1, u64> neg;
|
|
|
|
|
BitField<46, 1, u64> uses_cc;
|
|
|
|
|
} rz;
|
|
|
|
|
|
|
|
|
|
union {
|
|
|
|
|
BitField<39, 5, u64> entry_a;
|
|
|
|
|
BitField<45, 1, u64> neg;
|
|
|
|
|
BitField<46, 1, u64> uses_cc;
|
|
|
|
|
} r1;
|
|
|
|
|
|
|
|
|
|
union {
|
|
|
|
|
BitField<28, 8, u64> entry_a;
|
|
|
|
|
BitField<37, 1, u64> neg;
|
|
|
|
|
BitField<38, 1, u64> uses_cc;
|
|
|
|
|
} r2;
|
|
|
|
|
|
|
|
|
|
} lea;
|
|
|
|
|
|
2018-07-13 00:00:37 +00:00
|
|
|
|
union {
|
|
|
|
|
BitField<0, 5, FlowCondition> cond;
|
|
|
|
|
} flow;
|
|
|
|
|
|
2018-04-10 03:39:44 +00:00
|
|
|
|
union {
|
2018-09-01 08:45:14 +00:00
|
|
|
|
BitField<47, 1, u64> cc;
|
2018-04-10 03:39:44 +00:00
|
|
|
|
BitField<48, 1, u64> negate_b;
|
|
|
|
|
BitField<49, 1, u64> negate_c;
|
2018-09-01 08:45:14 +00:00
|
|
|
|
BitField<51, 2, u64> tab5980_1;
|
|
|
|
|
BitField<53, 2, u64> tab5980_0;
|
2018-04-10 03:39:44 +00:00
|
|
|
|
} ffma;
|
|
|
|
|
|
2018-06-06 03:46:23 +00:00
|
|
|
|
union {
|
|
|
|
|
BitField<48, 3, UniformType> type;
|
|
|
|
|
BitField<44, 2, u64> unknown;
|
|
|
|
|
} ld_c;
|
|
|
|
|
|
2018-04-20 14:09:50 +00:00
|
|
|
|
union {
|
|
|
|
|
BitField<0, 3, u64> pred0;
|
|
|
|
|
BitField<3, 3, u64> pred3;
|
|
|
|
|
BitField<7, 1, u64> abs_a;
|
|
|
|
|
BitField<39, 3, u64> pred39;
|
|
|
|
|
BitField<42, 1, u64> neg_pred;
|
|
|
|
|
BitField<43, 1, u64> neg_a;
|
|
|
|
|
BitField<44, 1, u64> abs_b;
|
|
|
|
|
BitField<45, 2, PredOperation> op;
|
|
|
|
|
BitField<47, 1, u64> ftz;
|
|
|
|
|
BitField<48, 4, PredCondition> cond;
|
|
|
|
|
BitField<56, 1, u64> neg_b;
|
|
|
|
|
} fsetp;
|
|
|
|
|
|
2018-06-04 16:12:03 +00:00
|
|
|
|
union {
|
|
|
|
|
BitField<0, 3, u64> pred0;
|
|
|
|
|
BitField<3, 3, u64> pred3;
|
|
|
|
|
BitField<39, 3, u64> pred39;
|
|
|
|
|
BitField<42, 1, u64> neg_pred;
|
|
|
|
|
BitField<45, 2, PredOperation> op;
|
|
|
|
|
BitField<48, 1, u64> is_signed;
|
|
|
|
|
BitField<49, 3, PredCondition> cond;
|
|
|
|
|
} isetp;
|
|
|
|
|
|
2018-07-04 20:15:03 +00:00
|
|
|
|
union {
|
|
|
|
|
BitField<0, 3, u64> pred0;
|
|
|
|
|
BitField<3, 3, u64> pred3;
|
|
|
|
|
BitField<12, 3, u64> pred12;
|
|
|
|
|
BitField<15, 1, u64> neg_pred12;
|
|
|
|
|
BitField<24, 2, PredOperation> cond;
|
|
|
|
|
BitField<29, 3, u64> pred29;
|
|
|
|
|
BitField<32, 1, u64> neg_pred29;
|
|
|
|
|
BitField<39, 3, u64> pred39;
|
|
|
|
|
BitField<42, 1, u64> neg_pred39;
|
|
|
|
|
BitField<45, 2, PredOperation> op;
|
|
|
|
|
} psetp;
|
|
|
|
|
|
2018-09-11 16:26:42 +00:00
|
|
|
|
union {
|
|
|
|
|
BitField<12, 3, u64> pred12;
|
|
|
|
|
BitField<15, 1, u64> neg_pred12;
|
|
|
|
|
BitField<24, 2, PredOperation> cond;
|
|
|
|
|
BitField<29, 3, u64> pred29;
|
|
|
|
|
BitField<32, 1, u64> neg_pred29;
|
|
|
|
|
BitField<39, 3, u64> pred39;
|
|
|
|
|
BitField<42, 1, u64> neg_pred39;
|
|
|
|
|
BitField<44, 1, u64> bf;
|
|
|
|
|
BitField<45, 2, PredOperation> op;
|
|
|
|
|
} pset;
|
|
|
|
|
|
2018-09-09 02:44:20 +00:00
|
|
|
|
union {
|
|
|
|
|
BitField<0, 3, u64> pred0;
|
|
|
|
|
BitField<3, 3, u64> pred3;
|
|
|
|
|
BitField<8, 5, ControlCode> cc; // flag in cc
|
|
|
|
|
BitField<39, 3, u64> pred39;
|
|
|
|
|
BitField<42, 1, u64> neg_pred39;
|
|
|
|
|
BitField<45, 4, PredOperation> op; // op with pred39
|
|
|
|
|
} csetp;
|
|
|
|
|
|
2018-04-25 03:42:54 +00:00
|
|
|
|
union {
|
|
|
|
|
BitField<39, 3, u64> pred39;
|
|
|
|
|
BitField<42, 1, u64> neg_pred;
|
|
|
|
|
BitField<43, 1, u64> neg_a;
|
|
|
|
|
BitField<44, 1, u64> abs_b;
|
|
|
|
|
BitField<45, 2, PredOperation> op;
|
|
|
|
|
BitField<48, 4, PredCondition> cond;
|
2018-06-04 16:58:29 +00:00
|
|
|
|
BitField<52, 1, u64> bf;
|
2018-04-25 03:42:54 +00:00
|
|
|
|
BitField<53, 1, u64> neg_b;
|
|
|
|
|
BitField<54, 1, u64> abs_a;
|
|
|
|
|
BitField<55, 1, u64> ftz;
|
|
|
|
|
BitField<56, 1, u64> neg_imm;
|
|
|
|
|
} fset;
|
2018-06-09 21:19:13 +00:00
|
|
|
|
|
|
|
|
|
union {
|
|
|
|
|
BitField<39, 3, u64> pred39;
|
|
|
|
|
BitField<42, 1, u64> neg_pred;
|
|
|
|
|
BitField<44, 1, u64> bf;
|
|
|
|
|
BitField<45, 2, PredOperation> op;
|
|
|
|
|
BitField<48, 1, u64> is_signed;
|
|
|
|
|
BitField<49, 3, PredCondition> cond;
|
|
|
|
|
} iset;
|
2018-04-25 03:42:54 +00:00
|
|
|
|
|
2018-04-28 02:19:14 +00:00
|
|
|
|
union {
|
2018-06-15 23:40:34 +00:00
|
|
|
|
BitField<8, 2, Register::Size> dest_size;
|
|
|
|
|
BitField<10, 2, Register::Size> src_size;
|
2018-06-04 23:05:12 +00:00
|
|
|
|
BitField<12, 1, u64> is_output_signed;
|
|
|
|
|
BitField<13, 1, u64> is_input_signed;
|
2018-04-28 02:19:14 +00:00
|
|
|
|
BitField<41, 2, u64> selector;
|
|
|
|
|
BitField<45, 1, u64> negate_a;
|
|
|
|
|
BitField<49, 1, u64> abs_a;
|
2018-06-04 23:05:12 +00:00
|
|
|
|
|
|
|
|
|
union {
|
2018-06-07 02:21:29 +00:00
|
|
|
|
BitField<39, 2, F2iRoundingOp> rounding;
|
2018-06-04 23:05:12 +00:00
|
|
|
|
} f2i;
|
|
|
|
|
|
|
|
|
|
union {
|
2018-06-07 02:21:29 +00:00
|
|
|
|
BitField<39, 4, F2fRoundingOp> rounding;
|
2018-06-04 23:05:12 +00:00
|
|
|
|
} f2f;
|
2018-04-29 00:01:36 +00:00
|
|
|
|
} conversion;
|
2018-04-28 02:19:14 +00:00
|
|
|
|
|
2018-06-01 03:22:21 +00:00
|
|
|
|
union {
|
2018-08-19 17:46:35 +00:00
|
|
|
|
BitField<28, 1, u64> array;
|
|
|
|
|
BitField<29, 2, TextureType> texture_type;
|
2018-06-01 03:22:21 +00:00
|
|
|
|
BitField<31, 4, u64> component_mask;
|
2018-09-08 01:09:39 +00:00
|
|
|
|
BitField<55, 3, TextureProcessMode> process_mode;
|
2018-06-01 03:22:21 +00:00
|
|
|
|
|
2018-09-15 13:21:06 +00:00
|
|
|
|
bool IsComponentEnabled(std::size_t component) const {
|
2018-06-20 16:39:10 +00:00
|
|
|
|
return ((1ull << component) & component_mask) != 0;
|
2018-06-01 03:22:21 +00:00
|
|
|
|
}
|
|
|
|
|
} tex;
|
|
|
|
|
|
2018-09-07 23:53:06 +00:00
|
|
|
|
union {
|
|
|
|
|
BitField<22, 6, TextureQueryType> query_type;
|
|
|
|
|
BitField<31, 4, u64> component_mask;
|
|
|
|
|
} txq;
|
|
|
|
|
|
2018-09-08 16:40:18 +00:00
|
|
|
|
union {
|
|
|
|
|
BitField<28, 1, u64> array;
|
|
|
|
|
BitField<29, 2, TextureType> texture_type;
|
|
|
|
|
BitField<31, 4, u64> component_mask;
|
|
|
|
|
|
2018-09-15 13:21:06 +00:00
|
|
|
|
bool IsComponentEnabled(std::size_t component) const {
|
2018-09-08 16:40:18 +00:00
|
|
|
|
return ((1ull << component) & component_mask) != 0;
|
|
|
|
|
}
|
|
|
|
|
} tmml;
|
|
|
|
|
|
2018-06-01 02:57:32 +00:00
|
|
|
|
union {
|
2018-08-19 17:46:35 +00:00
|
|
|
|
BitField<28, 1, u64> array;
|
|
|
|
|
BitField<29, 2, TextureType> texture_type;
|
|
|
|
|
BitField<56, 2, u64> component;
|
|
|
|
|
} tld4;
|
|
|
|
|
|
|
|
|
|
union {
|
|
|
|
|
BitField<52, 2, u64> component;
|
|
|
|
|
} tld4s;
|
|
|
|
|
|
|
|
|
|
union {
|
2018-07-22 07:23:15 +00:00
|
|
|
|
BitField<0, 8, Register> gpr0;
|
2018-06-03 16:08:17 +00:00
|
|
|
|
BitField<28, 8, Register> gpr28;
|
2018-09-01 07:00:01 +00:00
|
|
|
|
BitField<49, 1, u64> nodep;
|
2018-08-19 17:46:35 +00:00
|
|
|
|
BitField<50, 3, u64> component_mask_selector;
|
|
|
|
|
BitField<53, 4, u64> texture_info;
|
|
|
|
|
|
|
|
|
|
TextureType GetTextureType() const {
|
|
|
|
|
// The TEXS instruction has a weird encoding for the texture type.
|
|
|
|
|
if (texture_info == 0)
|
|
|
|
|
return TextureType::Texture1D;
|
|
|
|
|
if (texture_info >= 1 && texture_info <= 9)
|
|
|
|
|
return TextureType::Texture2D;
|
|
|
|
|
if (texture_info >= 10 && texture_info <= 11)
|
|
|
|
|
return TextureType::Texture3D;
|
|
|
|
|
if (texture_info >= 12 && texture_info <= 13)
|
|
|
|
|
return TextureType::TextureCube;
|
|
|
|
|
|
2018-08-21 01:53:49 +00:00
|
|
|
|
LOG_CRITICAL(HW_GPU, "Unhandled texture_info: {}",
|
|
|
|
|
static_cast<u32>(texture_info.Value()));
|
|
|
|
|
UNREACHABLE();
|
2018-08-19 17:46:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool IsArrayTexture() const {
|
|
|
|
|
// TEXS only supports Texture2D arrays.
|
|
|
|
|
return texture_info >= 7 && texture_info <= 9;
|
|
|
|
|
}
|
2018-06-03 16:08:17 +00:00
|
|
|
|
|
|
|
|
|
bool HasTwoDestinations() const {
|
|
|
|
|
return gpr28.Value() != Register::ZeroIndex;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-15 13:21:06 +00:00
|
|
|
|
bool IsComponentEnabled(std::size_t component) const {
|
2018-08-19 19:00:12 +00:00
|
|
|
|
static constexpr std::array<std::array<u32, 8>, 4> mask_lut{{
|
|
|
|
|
{},
|
|
|
|
|
{0x1, 0x2, 0x4, 0x8, 0x3, 0x9, 0xa, 0xc},
|
|
|
|
|
{0x1, 0x2, 0x4, 0x8, 0x3, 0x9, 0xa, 0xc},
|
|
|
|
|
{0x7, 0xb, 0xd, 0xe, 0xf},
|
|
|
|
|
}};
|
2018-06-03 16:08:17 +00:00
|
|
|
|
|
2018-09-15 13:21:06 +00:00
|
|
|
|
std::size_t index{gpr0.Value() != Register::ZeroIndex ? 1U : 0U};
|
2018-07-22 07:23:15 +00:00
|
|
|
|
index |= gpr28.Value() != Register::ZeroIndex ? 2 : 0;
|
2018-06-03 16:08:17 +00:00
|
|
|
|
|
2018-08-19 19:00:12 +00:00
|
|
|
|
u32 mask = mask_lut[index][component_mask_selector];
|
|
|
|
|
// A mask of 0 means this instruction uses an unimplemented mask.
|
|
|
|
|
ASSERT(mask != 0);
|
|
|
|
|
return ((1ull << component) & mask) != 0;
|
2018-06-03 16:08:17 +00:00
|
|
|
|
}
|
2018-06-01 02:57:32 +00:00
|
|
|
|
} texs;
|
|
|
|
|
|
2018-08-19 17:46:35 +00:00
|
|
|
|
union {
|
|
|
|
|
BitField<53, 4, u64> texture_info;
|
|
|
|
|
|
|
|
|
|
TextureType GetTextureType() const {
|
|
|
|
|
// The TLDS instruction has a weird encoding for the texture type.
|
|
|
|
|
if (texture_info >= 0 && texture_info <= 1) {
|
|
|
|
|
return TextureType::Texture1D;
|
|
|
|
|
}
|
|
|
|
|
if (texture_info == 2 || texture_info == 8 || texture_info == 12 ||
|
2018-08-21 19:08:33 +00:00
|
|
|
|
(texture_info >= 4 && texture_info <= 6)) {
|
2018-08-19 17:46:35 +00:00
|
|
|
|
return TextureType::Texture2D;
|
|
|
|
|
}
|
|
|
|
|
if (texture_info == 7) {
|
|
|
|
|
return TextureType::Texture3D;
|
|
|
|
|
}
|
|
|
|
|
|
2018-08-21 01:53:49 +00:00
|
|
|
|
LOG_CRITICAL(HW_GPU, "Unhandled texture_info: {}",
|
|
|
|
|
static_cast<u32>(texture_info.Value()));
|
|
|
|
|
UNREACHABLE();
|
2018-08-19 17:46:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool IsArrayTexture() const {
|
|
|
|
|
// TEXS only supports Texture2D arrays.
|
|
|
|
|
return texture_info == 8;
|
|
|
|
|
}
|
|
|
|
|
} tlds;
|
|
|
|
|
|
2018-06-02 19:45:50 +00:00
|
|
|
|
union {
|
2018-06-05 03:56:28 +00:00
|
|
|
|
BitField<20, 24, u64> target;
|
2018-06-02 19:45:50 +00:00
|
|
|
|
BitField<5, 1, u64> constant_buffer;
|
|
|
|
|
|
|
|
|
|
s32 GetBranchTarget() const {
|
|
|
|
|
// Sign extend the branch target offset
|
2018-06-05 03:56:28 +00:00
|
|
|
|
u32 mask = 1U << (24 - 1);
|
2018-06-02 19:45:50 +00:00
|
|
|
|
u32 value = static_cast<u32>(target);
|
2018-06-05 03:56:28 +00:00
|
|
|
|
// The branch offset is relative to the next instruction and is stored in bytes, so
|
|
|
|
|
// divide it by the size of an instruction and add 1 to it.
|
|
|
|
|
return static_cast<s32>((value ^ mask) - mask) / sizeof(Instruction) + 1;
|
2018-06-02 19:45:50 +00:00
|
|
|
|
}
|
|
|
|
|
} bra;
|
|
|
|
|
|
2018-08-12 20:51:32 +00:00
|
|
|
|
union {
|
|
|
|
|
BitField<20, 16, u64> imm20_16;
|
|
|
|
|
BitField<36, 1, u64> product_shift_left;
|
|
|
|
|
BitField<37, 1, u64> merge_37;
|
|
|
|
|
BitField<48, 1, u64> sign_a;
|
|
|
|
|
BitField<49, 1, u64> sign_b;
|
|
|
|
|
BitField<50, 3, XmadMode> mode;
|
|
|
|
|
BitField<52, 1, u64> high_b;
|
|
|
|
|
BitField<53, 1, u64> high_a;
|
|
|
|
|
BitField<56, 1, u64> merge_56;
|
|
|
|
|
} xmad;
|
|
|
|
|
|
2018-06-06 02:45:22 +00:00
|
|
|
|
union {
|
|
|
|
|
BitField<20, 14, u64> offset;
|
|
|
|
|
BitField<34, 5, u64> index;
|
|
|
|
|
} cbuf34;
|
|
|
|
|
|
|
|
|
|
union {
|
|
|
|
|
BitField<20, 16, s64> offset;
|
|
|
|
|
BitField<36, 5, u64> index;
|
|
|
|
|
} cbuf36;
|
|
|
|
|
|
2018-09-09 01:54:11 +00:00
|
|
|
|
BitField<47, 1, u64> generates_cc;
|
2018-04-16 00:45:56 +00:00
|
|
|
|
BitField<61, 1, u64> is_b_imm;
|
2018-04-10 03:39:44 +00:00
|
|
|
|
BitField<60, 1, u64> is_b_gpr;
|
|
|
|
|
BitField<59, 1, u64> is_c_gpr;
|
|
|
|
|
|
2018-04-05 01:43:40 +00:00
|
|
|
|
Attribute attribute;
|
2018-04-10 05:26:15 +00:00
|
|
|
|
Sampler sampler;
|
2018-04-05 01:43:40 +00:00
|
|
|
|
|
2018-04-21 00:49:05 +00:00
|
|
|
|
u64 value;
|
2018-04-05 01:43:40 +00:00
|
|
|
|
};
|
|
|
|
|
static_assert(sizeof(Instruction) == 0x8, "Incorrect structure size");
|
2018-08-10 00:39:30 +00:00
|
|
|
|
static_assert(std::is_standard_layout_v<Instruction>, "Instruction is not standard layout");
|
2018-04-05 01:43:40 +00:00
|
|
|
|
|
2018-04-21 00:49:05 +00:00
|
|
|
|
class OpCode {
|
|
|
|
|
public:
|
|
|
|
|
enum class Id {
|
|
|
|
|
KIL,
|
2018-06-09 03:46:10 +00:00
|
|
|
|
SSY,
|
2018-07-04 20:29:51 +00:00
|
|
|
|
SYNC,
|
|
|
|
|
DEPBAR,
|
2018-06-06 03:48:38 +00:00
|
|
|
|
BFE_C,
|
|
|
|
|
BFE_R,
|
|
|
|
|
BFE_IMM,
|
2018-06-02 19:22:55 +00:00
|
|
|
|
BRA,
|
2018-04-21 00:49:05 +00:00
|
|
|
|
LD_A,
|
2018-06-06 03:46:23 +00:00
|
|
|
|
LD_C,
|
2018-04-21 00:49:05 +00:00
|
|
|
|
ST_A,
|
2018-08-19 05:46:34 +00:00
|
|
|
|
LDG, // Load from global memory
|
|
|
|
|
STG, // Store in global memory
|
2018-06-01 03:22:21 +00:00
|
|
|
|
TEX,
|
2018-09-08 16:40:18 +00:00
|
|
|
|
TXQ, // Texture Query
|
|
|
|
|
TEXS, // Texture Fetch with scalar/non-vec4 source/destinations
|
|
|
|
|
TLDS, // Texture Load with scalar/non-vec4 source/destinations
|
|
|
|
|
TLD4, // Texture Load 4
|
|
|
|
|
TLD4S, // Texture Load 4 with scalar / non - vec4 source / destinations
|
|
|
|
|
TMML_B, // Texture Mip Map Level
|
|
|
|
|
TMML, // Texture Mip Map Level
|
2018-04-21 00:49:05 +00:00
|
|
|
|
EXIT,
|
|
|
|
|
IPA,
|
2018-04-21 02:23:52 +00:00
|
|
|
|
FFMA_IMM, // Fused Multiply and Add
|
2018-04-21 00:49:05 +00:00
|
|
|
|
FFMA_CR,
|
|
|
|
|
FFMA_RC,
|
|
|
|
|
FFMA_RR,
|
|
|
|
|
FADD_C,
|
|
|
|
|
FADD_R,
|
|
|
|
|
FADD_IMM,
|
2018-07-12 17:00:31 +00:00
|
|
|
|
FADD32I,
|
2018-04-21 00:49:05 +00:00
|
|
|
|
FMUL_C,
|
|
|
|
|
FMUL_R,
|
|
|
|
|
FMUL_IMM,
|
|
|
|
|
FMUL32_IMM,
|
2018-06-09 03:25:22 +00:00
|
|
|
|
IADD_C,
|
|
|
|
|
IADD_R,
|
|
|
|
|
IADD_IMM,
|
2018-08-24 16:15:43 +00:00
|
|
|
|
IADD3_C, // Add 3 Integers
|
2018-08-23 19:46:59 +00:00
|
|
|
|
IADD3_R,
|
|
|
|
|
IADD3_IMM,
|
2018-06-12 16:24:10 +00:00
|
|
|
|
IADD32I,
|
2018-06-04 23:29:51 +00:00
|
|
|
|
ISCADD_C, // Scale and Add
|
|
|
|
|
ISCADD_R,
|
|
|
|
|
ISCADD_IMM,
|
2018-09-11 16:26:42 +00:00
|
|
|
|
LEA_R1,
|
|
|
|
|
LEA_R2,
|
|
|
|
|
LEA_RZ,
|
|
|
|
|
LEA_IMM,
|
|
|
|
|
LEA_HI,
|
2018-08-31 01:32:58 +00:00
|
|
|
|
POPC_C,
|
|
|
|
|
POPC_R,
|
|
|
|
|
POPC_IMM,
|
2018-07-22 04:37:12 +00:00
|
|
|
|
SEL_C,
|
|
|
|
|
SEL_R,
|
|
|
|
|
SEL_IMM,
|
2018-06-01 04:03:23 +00:00
|
|
|
|
MUFU, // Multi-Function Operator
|
|
|
|
|
RRO_C, // Range Reduction Operator
|
|
|
|
|
RRO_R,
|
|
|
|
|
RRO_IMM,
|
2018-04-21 02:23:52 +00:00
|
|
|
|
F2F_C,
|
|
|
|
|
F2F_R,
|
|
|
|
|
F2F_IMM,
|
|
|
|
|
F2I_C,
|
|
|
|
|
F2I_R,
|
|
|
|
|
F2I_IMM,
|
|
|
|
|
I2F_C,
|
|
|
|
|
I2F_R,
|
|
|
|
|
I2F_IMM,
|
2018-04-25 17:52:55 +00:00
|
|
|
|
I2I_C,
|
|
|
|
|
I2I_R,
|
|
|
|
|
I2I_IMM,
|
2018-06-17 17:26:11 +00:00
|
|
|
|
LOP_C,
|
|
|
|
|
LOP_R,
|
|
|
|
|
LOP_IMM,
|
2018-04-21 02:23:52 +00:00
|
|
|
|
LOP32I,
|
2018-08-22 07:02:18 +00:00
|
|
|
|
LOP3_C,
|
|
|
|
|
LOP3_R,
|
|
|
|
|
LOP3_IMM,
|
2018-04-21 02:23:52 +00:00
|
|
|
|
MOV_C,
|
|
|
|
|
MOV_R,
|
|
|
|
|
MOV_IMM,
|
2018-04-27 03:21:17 +00:00
|
|
|
|
MOV32_IMM,
|
2018-06-05 02:15:19 +00:00
|
|
|
|
SHL_C,
|
|
|
|
|
SHL_R,
|
|
|
|
|
SHL_IMM,
|
2018-04-21 02:23:52 +00:00
|
|
|
|
SHR_C,
|
|
|
|
|
SHR_R,
|
|
|
|
|
SHR_IMM,
|
2018-05-24 23:37:18 +00:00
|
|
|
|
FMNMX_C,
|
|
|
|
|
FMNMX_R,
|
|
|
|
|
FMNMX_IMM,
|
2018-06-06 03:48:38 +00:00
|
|
|
|
IMNMX_C,
|
|
|
|
|
IMNMX_R,
|
|
|
|
|
IMNMX_IMM,
|
2018-04-21 02:23:52 +00:00
|
|
|
|
FSETP_C, // Set Predicate
|
2018-04-21 00:49:05 +00:00
|
|
|
|
FSETP_R,
|
|
|
|
|
FSETP_IMM,
|
2018-04-25 03:42:54 +00:00
|
|
|
|
FSET_C,
|
|
|
|
|
FSET_R,
|
|
|
|
|
FSET_IMM,
|
2018-04-21 02:23:52 +00:00
|
|
|
|
ISETP_C,
|
|
|
|
|
ISETP_IMM,
|
|
|
|
|
ISETP_R,
|
2018-06-09 20:56:50 +00:00
|
|
|
|
ISET_R,
|
|
|
|
|
ISET_C,
|
|
|
|
|
ISET_IMM,
|
2018-05-19 16:41:14 +00:00
|
|
|
|
PSETP,
|
2018-09-11 16:26:42 +00:00
|
|
|
|
PSET,
|
2018-09-09 02:44:20 +00:00
|
|
|
|
CSETP,
|
2018-06-06 03:48:38 +00:00
|
|
|
|
XMAD_IMM,
|
|
|
|
|
XMAD_CR,
|
|
|
|
|
XMAD_RC,
|
|
|
|
|
XMAD_RR,
|
2018-04-21 00:49:05 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum class Type {
|
|
|
|
|
Trivial,
|
|
|
|
|
Arithmetic,
|
2018-06-19 00:50:35 +00:00
|
|
|
|
ArithmeticImmediate,
|
2018-06-09 03:25:22 +00:00
|
|
|
|
ArithmeticInteger,
|
2018-06-12 16:24:10 +00:00
|
|
|
|
ArithmeticIntegerImmediate,
|
2018-06-07 04:58:12 +00:00
|
|
|
|
Bfe,
|
2018-06-05 02:15:19 +00:00
|
|
|
|
Shift,
|
2018-04-21 00:49:05 +00:00
|
|
|
|
Ffma,
|
|
|
|
|
Flow,
|
2018-07-04 20:29:51 +00:00
|
|
|
|
Synch,
|
2018-04-21 00:49:05 +00:00
|
|
|
|
Memory,
|
2018-04-25 03:42:54 +00:00
|
|
|
|
FloatSet,
|
|
|
|
|
FloatSetPredicate,
|
2018-06-09 20:56:50 +00:00
|
|
|
|
IntegerSet,
|
2018-04-25 03:42:54 +00:00
|
|
|
|
IntegerSetPredicate,
|
2018-05-19 16:41:14 +00:00
|
|
|
|
PredicateSetPredicate,
|
2018-09-11 16:26:42 +00:00
|
|
|
|
PredicateSetRegister,
|
2018-04-29 00:01:36 +00:00
|
|
|
|
Conversion,
|
2018-08-12 20:51:32 +00:00
|
|
|
|
Xmad,
|
2018-04-21 00:49:05 +00:00
|
|
|
|
Unknown,
|
|
|
|
|
};
|
|
|
|
|
|
2018-08-11 21:00:14 +00:00
|
|
|
|
/// Returns whether an opcode has an execution predicate field or not (ie, whether it can be
|
|
|
|
|
/// conditionally executed).
|
|
|
|
|
static bool IsPredicatedInstruction(Id opcode) {
|
|
|
|
|
// TODO(Subv): Add the rest of unpredicated instructions.
|
|
|
|
|
return opcode != Id::SSY;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-21 00:49:05 +00:00
|
|
|
|
class Matcher {
|
|
|
|
|
public:
|
|
|
|
|
Matcher(const char* const name, u16 mask, u16 expected, OpCode::Id id, OpCode::Type type)
|
|
|
|
|
: name{name}, mask{mask}, expected{expected}, id{id}, type{type} {}
|
|
|
|
|
|
|
|
|
|
const char* GetName() const {
|
|
|
|
|
return name;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
u16 GetMask() const {
|
|
|
|
|
return mask;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Id GetId() const {
|
|
|
|
|
return id;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Type GetType() const {
|
|
|
|
|
return type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Tests to see if the given instruction is the instruction this matcher represents.
|
|
|
|
|
* @param instruction The instruction to test
|
|
|
|
|
* @returns true if the given instruction matches.
|
|
|
|
|
*/
|
|
|
|
|
bool Matches(u16 instruction) const {
|
|
|
|
|
return (instruction & mask) == expected;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
const char* name;
|
|
|
|
|
u16 mask;
|
|
|
|
|
u16 expected;
|
|
|
|
|
Id id;
|
|
|
|
|
Type type;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static boost::optional<const Matcher&> Decode(Instruction instr) {
|
|
|
|
|
static const auto table{GetDecodeTable()};
|
|
|
|
|
|
|
|
|
|
const auto matches_instruction = [instr](const auto& matcher) {
|
|
|
|
|
return matcher.Matches(static_cast<u16>(instr.opcode));
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
auto iter = std::find_if(table.begin(), table.end(), matches_instruction);
|
|
|
|
|
return iter != table.end() ? boost::optional<const Matcher&>(*iter) : boost::none;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
struct Detail {
|
|
|
|
|
private:
|
2018-09-15 13:21:06 +00:00
|
|
|
|
static constexpr std::size_t opcode_bitsize = 16;
|
2018-04-21 00:49:05 +00:00
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Generates the mask and the expected value after masking from a given bitstring.
|
|
|
|
|
* A '0' in a bitstring indicates that a zero must be present at that bit position.
|
|
|
|
|
* A '1' in a bitstring indicates that a one must be present at that bit position.
|
|
|
|
|
*/
|
|
|
|
|
static auto GetMaskAndExpect(const char* const bitstring) {
|
|
|
|
|
u16 mask = 0, expect = 0;
|
2018-09-15 13:21:06 +00:00
|
|
|
|
for (std::size_t i = 0; i < opcode_bitsize; i++) {
|
|
|
|
|
const std::size_t bit_position = opcode_bitsize - i - 1;
|
2018-04-21 00:49:05 +00:00
|
|
|
|
switch (bitstring[i]) {
|
|
|
|
|
case '0':
|
|
|
|
|
mask |= 1 << bit_position;
|
|
|
|
|
break;
|
|
|
|
|
case '1':
|
|
|
|
|
expect |= 1 << bit_position;
|
|
|
|
|
mask |= 1 << bit_position;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
// Ignore
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return std::make_tuple(mask, expect);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
/// Creates a matcher that can match and parse instructions based on bitstring.
|
|
|
|
|
static auto GetMatcher(const char* const bitstring, OpCode::Id op, OpCode::Type type,
|
|
|
|
|
const char* const name) {
|
|
|
|
|
const auto mask_expect = GetMaskAndExpect(bitstring);
|
|
|
|
|
return Matcher(name, std::get<0>(mask_expect), std::get<1>(mask_expect), op, type);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
static std::vector<Matcher> GetDecodeTable() {
|
|
|
|
|
std::vector<Matcher> table = {
|
|
|
|
|
#define INST(bitstring, op, type, name) Detail::GetMatcher(bitstring, op, type, name)
|
|
|
|
|
INST("111000110011----", Id::KIL, Type::Flow, "KIL"),
|
2018-06-09 03:46:10 +00:00
|
|
|
|
INST("111000101001----", Id::SSY, Type::Flow, "SSY"),
|
2018-06-02 19:22:55 +00:00
|
|
|
|
INST("111000100100----", Id::BRA, Type::Flow, "BRA"),
|
2018-07-04 20:29:51 +00:00
|
|
|
|
INST("1111000011110---", Id::DEPBAR, Type::Synch, "DEPBAR"),
|
|
|
|
|
INST("1111000011111---", Id::SYNC, Type::Synch, "SYNC"),
|
2018-04-21 00:49:05 +00:00
|
|
|
|
INST("1110111111011---", Id::LD_A, Type::Memory, "LD_A"),
|
2018-06-06 03:46:23 +00:00
|
|
|
|
INST("1110111110010---", Id::LD_C, Type::Memory, "LD_C"),
|
2018-04-21 00:49:05 +00:00
|
|
|
|
INST("1110111111110---", Id::ST_A, Type::Memory, "ST_A"),
|
2018-08-19 05:46:34 +00:00
|
|
|
|
INST("1110111011010---", Id::LDG, Type::Memory, "LDG"),
|
|
|
|
|
INST("1110111011011---", Id::STG, Type::Memory, "STG"),
|
2018-07-04 20:19:20 +00:00
|
|
|
|
INST("110000----111---", Id::TEX, Type::Memory, "TEX"),
|
2018-09-07 23:02:33 +00:00
|
|
|
|
INST("1101111101001---", Id::TXQ, Type::Memory, "TXQ"),
|
2018-04-21 00:49:05 +00:00
|
|
|
|
INST("1101100---------", Id::TEXS, Type::Memory, "TEXS"),
|
2018-04-21 02:23:52 +00:00
|
|
|
|
INST("1101101---------", Id::TLDS, Type::Memory, "TLDS"),
|
2018-08-19 17:45:01 +00:00
|
|
|
|
INST("110010----111---", Id::TLD4, Type::Memory, "TLD4"),
|
|
|
|
|
INST("1101111100------", Id::TLD4S, Type::Memory, "TLD4S"),
|
2018-09-08 16:40:18 +00:00
|
|
|
|
INST("110111110110----", Id::TMML_B, Type::Memory, "TMML_B"),
|
|
|
|
|
INST("1101111101011---", Id::TMML, Type::Memory, "TMML"),
|
2018-04-21 00:49:05 +00:00
|
|
|
|
INST("111000110000----", Id::EXIT, Type::Trivial, "EXIT"),
|
|
|
|
|
INST("11100000--------", Id::IPA, Type::Trivial, "IPA"),
|
2018-07-12 15:15:48 +00:00
|
|
|
|
INST("0011001-1-------", Id::FFMA_IMM, Type::Ffma, "FFMA_IMM"),
|
2018-04-21 00:49:05 +00:00
|
|
|
|
INST("010010011-------", Id::FFMA_CR, Type::Ffma, "FFMA_CR"),
|
|
|
|
|
INST("010100011-------", Id::FFMA_RC, Type::Ffma, "FFMA_RC"),
|
|
|
|
|
INST("010110011-------", Id::FFMA_RR, Type::Ffma, "FFMA_RR"),
|
|
|
|
|
INST("0100110001011---", Id::FADD_C, Type::Arithmetic, "FADD_C"),
|
|
|
|
|
INST("0101110001011---", Id::FADD_R, Type::Arithmetic, "FADD_R"),
|
|
|
|
|
INST("0011100-01011---", Id::FADD_IMM, Type::Arithmetic, "FADD_IMM"),
|
2018-07-12 17:00:31 +00:00
|
|
|
|
INST("000010----------", Id::FADD32I, Type::ArithmeticImmediate, "FADD32I"),
|
2018-04-21 00:49:05 +00:00
|
|
|
|
INST("0100110001101---", Id::FMUL_C, Type::Arithmetic, "FMUL_C"),
|
|
|
|
|
INST("0101110001101---", Id::FMUL_R, Type::Arithmetic, "FMUL_R"),
|
|
|
|
|
INST("0011100-01101---", Id::FMUL_IMM, Type::Arithmetic, "FMUL_IMM"),
|
2018-06-19 00:50:35 +00:00
|
|
|
|
INST("00011110--------", Id::FMUL32_IMM, Type::ArithmeticImmediate, "FMUL32_IMM"),
|
2018-06-09 03:25:22 +00:00
|
|
|
|
INST("0100110000010---", Id::IADD_C, Type::ArithmeticInteger, "IADD_C"),
|
|
|
|
|
INST("0101110000010---", Id::IADD_R, Type::ArithmeticInteger, "IADD_R"),
|
|
|
|
|
INST("0011100-00010---", Id::IADD_IMM, Type::ArithmeticInteger, "IADD_IMM"),
|
2018-08-23 19:46:59 +00:00
|
|
|
|
INST("010011001100----", Id::IADD3_C, Type::ArithmeticInteger, "IADD3_C"),
|
|
|
|
|
INST("010111001100----", Id::IADD3_R, Type::ArithmeticInteger, "IADD3_R"),
|
|
|
|
|
INST("0011100-1100----", Id::IADD3_IMM, Type::ArithmeticInteger, "IADD3_IMM"),
|
2018-06-12 16:24:10 +00:00
|
|
|
|
INST("0001110---------", Id::IADD32I, Type::ArithmeticIntegerImmediate, "IADD32I"),
|
2018-06-09 03:25:22 +00:00
|
|
|
|
INST("0100110000011---", Id::ISCADD_C, Type::ArithmeticInteger, "ISCADD_C"),
|
|
|
|
|
INST("0101110000011---", Id::ISCADD_R, Type::ArithmeticInteger, "ISCADD_R"),
|
|
|
|
|
INST("0011100-00011---", Id::ISCADD_IMM, Type::ArithmeticInteger, "ISCADD_IMM"),
|
2018-08-31 01:32:58 +00:00
|
|
|
|
INST("0100110000001---", Id::POPC_C, Type::ArithmeticInteger, "POPC_C"),
|
|
|
|
|
INST("0101110000001---", Id::POPC_R, Type::ArithmeticInteger, "POPC_R"),
|
|
|
|
|
INST("0011100-00001---", Id::POPC_IMM, Type::ArithmeticInteger, "POPC_IMM"),
|
2018-07-22 04:37:12 +00:00
|
|
|
|
INST("0100110010100---", Id::SEL_C, Type::ArithmeticInteger, "SEL_C"),
|
|
|
|
|
INST("0101110010100---", Id::SEL_R, Type::ArithmeticInteger, "SEL_R"),
|
2018-08-24 04:18:12 +00:00
|
|
|
|
INST("0011100-10100---", Id::SEL_IMM, Type::ArithmeticInteger, "SEL_IMM"),
|
2018-09-11 16:26:42 +00:00
|
|
|
|
INST("0101101111011---", Id::LEA_R2, Type::ArithmeticInteger, "LEA_R2"),
|
|
|
|
|
INST("0101101111010---", Id::LEA_R1, Type::ArithmeticInteger, "LEA_R1"),
|
|
|
|
|
INST("001101101101----", Id::LEA_IMM, Type::ArithmeticInteger, "LEA_IMM"),
|
|
|
|
|
INST("010010111101----", Id::LEA_RZ, Type::ArithmeticInteger, "LEA_RZ"),
|
|
|
|
|
INST("00011000--------", Id::LEA_HI, Type::ArithmeticInteger, "LEA_HI"),
|
2018-04-21 00:49:05 +00:00
|
|
|
|
INST("0101000010000---", Id::MUFU, Type::Arithmetic, "MUFU"),
|
2018-06-01 04:03:23 +00:00
|
|
|
|
INST("0100110010010---", Id::RRO_C, Type::Arithmetic, "RRO_C"),
|
|
|
|
|
INST("0101110010010---", Id::RRO_R, Type::Arithmetic, "RRO_R"),
|
|
|
|
|
INST("0011100-10010---", Id::RRO_IMM, Type::Arithmetic, "RRO_IMM"),
|
2018-05-30 03:10:44 +00:00
|
|
|
|
INST("0100110010101---", Id::F2F_C, Type::Conversion, "F2F_C"),
|
|
|
|
|
INST("0101110010101---", Id::F2F_R, Type::Conversion, "F2F_R"),
|
|
|
|
|
INST("0011100-10101---", Id::F2F_IMM, Type::Conversion, "F2F_IMM"),
|
2018-06-04 23:05:12 +00:00
|
|
|
|
INST("0100110010110---", Id::F2I_C, Type::Conversion, "F2I_C"),
|
|
|
|
|
INST("0101110010110---", Id::F2I_R, Type::Conversion, "F2I_R"),
|
|
|
|
|
INST("0011100-10110---", Id::F2I_IMM, Type::Conversion, "F2I_IMM"),
|
2018-04-21 02:23:52 +00:00
|
|
|
|
INST("0100110010011---", Id::MOV_C, Type::Arithmetic, "MOV_C"),
|
|
|
|
|
INST("0101110010011---", Id::MOV_R, Type::Arithmetic, "MOV_R"),
|
|
|
|
|
INST("0011100-10011---", Id::MOV_IMM, Type::Arithmetic, "MOV_IMM"),
|
2018-06-19 00:50:35 +00:00
|
|
|
|
INST("000000010000----", Id::MOV32_IMM, Type::ArithmeticImmediate, "MOV32_IMM"),
|
2018-05-24 23:37:18 +00:00
|
|
|
|
INST("0100110001100---", Id::FMNMX_C, Type::Arithmetic, "FMNMX_C"),
|
|
|
|
|
INST("0101110001100---", Id::FMNMX_R, Type::Arithmetic, "FMNMX_R"),
|
|
|
|
|
INST("0011100-01100---", Id::FMNMX_IMM, Type::Arithmetic, "FMNMX_IMM"),
|
2018-07-04 20:25:48 +00:00
|
|
|
|
INST("0100110000100---", Id::IMNMX_C, Type::ArithmeticInteger, "IMNMX_C"),
|
|
|
|
|
INST("0101110000100---", Id::IMNMX_R, Type::ArithmeticInteger, "IMNMX_R"),
|
|
|
|
|
INST("0011100-00100---", Id::IMNMX_IMM, Type::ArithmeticInteger, "IMNMX_IMM"),
|
2018-06-07 04:58:12 +00:00
|
|
|
|
INST("0100110000000---", Id::BFE_C, Type::Bfe, "BFE_C"),
|
|
|
|
|
INST("0101110000000---", Id::BFE_R, Type::Bfe, "BFE_R"),
|
|
|
|
|
INST("0011100-00000---", Id::BFE_IMM, Type::Bfe, "BFE_IMM"),
|
2018-06-17 17:26:11 +00:00
|
|
|
|
INST("0100110001000---", Id::LOP_C, Type::ArithmeticInteger, "LOP_C"),
|
|
|
|
|
INST("0101110001000---", Id::LOP_R, Type::ArithmeticInteger, "LOP_R"),
|
|
|
|
|
INST("0011100001000---", Id::LOP_IMM, Type::ArithmeticInteger, "LOP_IMM"),
|
2018-06-17 16:49:34 +00:00
|
|
|
|
INST("000001----------", Id::LOP32I, Type::ArithmeticIntegerImmediate, "LOP32I"),
|
2018-08-22 07:02:18 +00:00
|
|
|
|
INST("0000001---------", Id::LOP3_C, Type::ArithmeticInteger, "LOP3_C"),
|
|
|
|
|
INST("0101101111100---", Id::LOP3_R, Type::ArithmeticInteger, "LOP3_R"),
|
|
|
|
|
INST("0011110---------", Id::LOP3_IMM, Type::ArithmeticInteger, "LOP3_IMM"),
|
2018-06-05 02:15:19 +00:00
|
|
|
|
INST("0100110001001---", Id::SHL_C, Type::Shift, "SHL_C"),
|
|
|
|
|
INST("0101110001001---", Id::SHL_R, Type::Shift, "SHL_R"),
|
|
|
|
|
INST("0011100-01001---", Id::SHL_IMM, Type::Shift, "SHL_IMM"),
|
|
|
|
|
INST("0100110000101---", Id::SHR_C, Type::Shift, "SHR_C"),
|
|
|
|
|
INST("0101110000101---", Id::SHR_R, Type::Shift, "SHR_R"),
|
|
|
|
|
INST("0011100-00101---", Id::SHR_IMM, Type::Shift, "SHR_IMM"),
|
2018-04-29 00:01:36 +00:00
|
|
|
|
INST("0100110011100---", Id::I2I_C, Type::Conversion, "I2I_C"),
|
|
|
|
|
INST("0101110011100---", Id::I2I_R, Type::Conversion, "I2I_R"),
|
|
|
|
|
INST("01110001-1000---", Id::I2I_IMM, Type::Conversion, "I2I_IMM"),
|
|
|
|
|
INST("0100110010111---", Id::I2F_C, Type::Conversion, "I2F_C"),
|
|
|
|
|
INST("0101110010111---", Id::I2F_R, Type::Conversion, "I2F_R"),
|
|
|
|
|
INST("0011100-10111---", Id::I2F_IMM, Type::Conversion, "I2F_IMM"),
|
2018-04-25 03:42:54 +00:00
|
|
|
|
INST("01011000--------", Id::FSET_R, Type::FloatSet, "FSET_R"),
|
|
|
|
|
INST("0100100---------", Id::FSET_C, Type::FloatSet, "FSET_C"),
|
|
|
|
|
INST("0011000---------", Id::FSET_IMM, Type::FloatSet, "FSET_IMM"),
|
|
|
|
|
INST("010010111011----", Id::FSETP_C, Type::FloatSetPredicate, "FSETP_C"),
|
|
|
|
|
INST("010110111011----", Id::FSETP_R, Type::FloatSetPredicate, "FSETP_R"),
|
|
|
|
|
INST("0011011-1011----", Id::FSETP_IMM, Type::FloatSetPredicate, "FSETP_IMM"),
|
|
|
|
|
INST("010010110110----", Id::ISETP_C, Type::IntegerSetPredicate, "ISETP_C"),
|
|
|
|
|
INST("010110110110----", Id::ISETP_R, Type::IntegerSetPredicate, "ISETP_R"),
|
|
|
|
|
INST("0011011-0110----", Id::ISETP_IMM, Type::IntegerSetPredicate, "ISETP_IMM"),
|
2018-06-09 20:56:50 +00:00
|
|
|
|
INST("010110110101----", Id::ISET_R, Type::IntegerSet, "ISET_R"),
|
|
|
|
|
INST("010010110101----", Id::ISET_C, Type::IntegerSet, "ISET_C"),
|
|
|
|
|
INST("0011011-0101----", Id::ISET_IMM, Type::IntegerSet, "ISET_IMM"),
|
2018-09-11 16:26:42 +00:00
|
|
|
|
INST("0101000010001---", Id::PSET, Type::PredicateSetRegister, "PSET"),
|
2018-05-19 16:41:14 +00:00
|
|
|
|
INST("0101000010010---", Id::PSETP, Type::PredicateSetPredicate, "PSETP"),
|
2018-09-09 02:44:20 +00:00
|
|
|
|
INST("010100001010----", Id::PSETP, Type::PredicateSetPredicate, "CSETP"),
|
2018-08-12 20:51:32 +00:00
|
|
|
|
INST("0011011-00------", Id::XMAD_IMM, Type::Xmad, "XMAD_IMM"),
|
|
|
|
|
INST("0100111---------", Id::XMAD_CR, Type::Xmad, "XMAD_CR"),
|
|
|
|
|
INST("010100010-------", Id::XMAD_RC, Type::Xmad, "XMAD_RC"),
|
|
|
|
|
INST("0101101100------", Id::XMAD_RR, Type::Xmad, "XMAD_RR"),
|
2018-04-21 00:49:05 +00:00
|
|
|
|
};
|
|
|
|
|
#undef INST
|
|
|
|
|
std::stable_sort(table.begin(), table.end(), [](const auto& a, const auto& b) {
|
|
|
|
|
// If a matcher has more bits in its mask it is more specific, so it
|
|
|
|
|
// should come first.
|
|
|
|
|
return std::bitset<16>(a.GetMask()).count() > std::bitset<16>(b.GetMask()).count();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return table;
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2018-07-20 22:14:17 +00:00
|
|
|
|
} // namespace Tegra::Shader
|