#ifndef BRW_INST_H
#define BRW_INST_H
+#include <assert.h>
#include <stdint.h>
-#include "brw_context.h"
+#include "brw_eu_defines.h"
+#include "common/gen_device_info.h"
#ifdef __cplusplus
extern "C" {
#define FC(name, high, low, assertions) \
static inline void \
-brw_inst_set_##name(const struct brw_device_info *devinfo, \
+brw_inst_set_##name(const struct gen_device_info *devinfo, \
brw_inst *inst, uint64_t v) \
{ \
assert(assertions); \
brw_inst_set_bits(inst, high, low, v); \
} \
static inline uint64_t \
-brw_inst_##name(const struct brw_device_info *devinfo, \
+brw_inst_##name(const struct gen_device_info *devinfo, \
const brw_inst *inst) \
{ \
assert(assertions); \
*/
#define FF(name, hi4, lo4, hi45, lo45, hi5, lo5, hi6, lo6, hi7, lo7, hi8, lo8)\
static inline void \
-brw_inst_set_##name(const struct brw_device_info *devinfo, \
+brw_inst_set_##name(const struct gen_device_info *devinfo, \
brw_inst *inst, uint64_t value) \
{ \
BOUNDS(hi4, lo4, hi45, lo45, hi5, lo5, hi6, lo6, hi7, lo7, hi8, lo8) \
brw_inst_set_bits(inst, high, low, value); \
} \
static inline uint64_t \
-brw_inst_##name(const struct brw_device_info *devinfo, const brw_inst *inst) \
+brw_inst_##name(const struct gen_device_info *devinfo, const brw_inst *inst) \
{ \
BOUNDS(hi4, lo4, hi45, lo45, hi5, lo5, hi6, lo6, hi7, lo7, hi8, lo8) \
return brw_inst_bits(inst, high, low); \
* @{
*/
static inline void
-brw_inst_set_uip(const struct brw_device_info *devinfo,
+brw_inst_set_uip(const struct gen_device_info *devinfo,
brw_inst *inst, int32_t value)
{
assert(devinfo->gen >= 6);
}
static inline int32_t
-brw_inst_uip(const struct brw_device_info *devinfo, const brw_inst *inst)
+brw_inst_uip(const struct gen_device_info *devinfo, const brw_inst *inst)
{
assert(devinfo->gen >= 6);
}
static inline void
-brw_inst_set_jip(const struct brw_device_info *devinfo,
+brw_inst_set_jip(const struct gen_device_info *devinfo,
brw_inst *inst, int32_t value)
{
assert(devinfo->gen >= 6);
if (devinfo->gen >= 8) {
brw_inst_set_bits(inst, 127, 96, (uint32_t)value);
} else {
- assert(value <= (1 << 16) - 1);
- assert(value > -(1 << 16));
+ assert(value <= (1 << 15) - 1);
+ assert(value >= -(1 << 15));
brw_inst_set_bits(inst, 111, 96, (uint16_t)value);
}
}
static inline int32_t
-brw_inst_jip(const struct brw_device_info *devinfo, const brw_inst *inst)
+brw_inst_jip(const struct gen_device_info *devinfo, const brw_inst *inst)
{
assert(devinfo->gen >= 6);
/** Like FC, but using int16_t to handle negative jump targets. */
#define FJ(name, high, low, assertions) \
static inline void \
-brw_inst_set_##name(const struct brw_device_info *devinfo, brw_inst *inst, int16_t v) \
+brw_inst_set_##name(const struct gen_device_info *devinfo, brw_inst *inst, int16_t v) \
{ \
assert(assertions); \
(void) devinfo; \
brw_inst_set_bits(inst, high, low, (uint16_t) v); \
} \
static inline int16_t \
-brw_inst_##name(const struct brw_device_info *devinfo, const brw_inst *inst) \
+brw_inst_##name(const struct gen_device_info *devinfo, const brw_inst *inst) \
{ \
assert(assertions); \
(void) devinfo; \
* @{
*/
static inline int
-brw_inst_imm_d(const struct brw_device_info *devinfo, const brw_inst *insn)
+brw_inst_imm_d(const struct gen_device_info *devinfo, const brw_inst *insn)
{
(void) devinfo;
return brw_inst_bits(insn, 127, 96);
}
static inline unsigned
-brw_inst_imm_ud(const struct brw_device_info *devinfo, const brw_inst *insn)
+brw_inst_imm_ud(const struct gen_device_info *devinfo, const brw_inst *insn)
{
(void) devinfo;
return brw_inst_bits(insn, 127, 96);
}
static inline float
-brw_inst_imm_f(const struct brw_device_info *devinfo, const brw_inst *insn)
+brw_inst_imm_f(const struct gen_device_info *devinfo, const brw_inst *insn)
{
- fi_type ft;
+ union {
+ float f;
+ uint32_t u;
+ } ft;
(void) devinfo;
ft.u = brw_inst_bits(insn, 127, 96);
return ft.f;
}
+static inline double
+brw_inst_imm_df(const struct gen_device_info *devinfo, const brw_inst *insn)
+{
+ union {
+ double d;
+ uint64_t u;
+ } dt;
+ (void) devinfo;
+ dt.u = brw_inst_bits(insn, 127, 64);
+ return dt.d;
+}
+
static inline void
-brw_inst_set_imm_d(const struct brw_device_info *devinfo,
+brw_inst_set_imm_d(const struct gen_device_info *devinfo,
brw_inst *insn, int value)
{
(void) devinfo;
}
static inline void
-brw_inst_set_imm_ud(const struct brw_device_info *devinfo,
+brw_inst_set_imm_ud(const struct gen_device_info *devinfo,
brw_inst *insn, unsigned value)
{
(void) devinfo;
}
static inline void
-brw_inst_set_imm_f(const struct brw_device_info *devinfo,
+brw_inst_set_imm_f(const struct gen_device_info *devinfo,
brw_inst *insn, float value)
{
- fi_type ft;
+ union {
+ float f;
+ uint32_t u;
+ } ft;
(void) devinfo;
ft.f = value;
brw_inst_set_bits(insn, 127, 96, ft.u);
}
+static inline void
+brw_inst_set_imm_df(const struct gen_device_info *devinfo,
+ brw_inst *insn, double value)
+{
+ union {
+ double d;
+ uint64_t u;
+ } dt;
+ (void) devinfo;
+ dt.d = value;
+ brw_inst_set_bits(insn, 127, 64, dt.u);
+}
+
+static inline void
+brw_inst_set_imm_uq(const struct gen_device_info *devinfo,
+ brw_inst *insn, uint64_t value)
+{
+ (void) devinfo;
+ brw_inst_set_bits(insn, 127, 64, value);
+}
+
/** @} */
/* The AddrImm fields are split into two discontiguous sections on Gen8+ */
#define BRW_IA1_ADDR_IMM(reg, g4_high, g4_low, g8_nine, g8_high, g8_low) \
static inline void \
-brw_inst_set_##reg##_ia1_addr_imm(const struct brw_device_info *devinfo, \
+brw_inst_set_##reg##_ia1_addr_imm(const struct gen_device_info *devinfo, \
brw_inst *inst, \
unsigned value) \
{ \
} \
} \
static inline unsigned \
-brw_inst_##reg##_ia1_addr_imm(const struct brw_device_info *devinfo, \
+brw_inst_##reg##_ia1_addr_imm(const struct gen_device_info *devinfo, \
const brw_inst *inst) \
{ \
if (devinfo->gen >= 8) { \
#define BRW_IA16_ADDR_IMM(reg, g4_high, g4_low, g8_nine, g8_high, g8_low) \
static inline void \
-brw_inst_set_##reg##_ia16_addr_imm(const struct brw_device_info *devinfo, \
+brw_inst_set_##reg##_ia16_addr_imm(const struct gen_device_info *devinfo, \
brw_inst *inst, unsigned value) \
{ \
assert((value & ~0x3ff) == 0); \
} \
} \
static inline unsigned \
-brw_inst_##reg##_ia16_addr_imm(const struct brw_device_info *devinfo, \
+brw_inst_##reg##_ia16_addr_imm(const struct gen_device_info *devinfo, \
const brw_inst *inst) \
{ \
if (devinfo->gen >= 8) { \
#define FC(name, high, low, assertions) \
static inline void \
-brw_compact_inst_set_##name(const struct brw_device_info *devinfo, \
+brw_compact_inst_set_##name(const struct gen_device_info *devinfo, \
brw_compact_inst *inst, unsigned v) \
{ \
assert(assertions); \
brw_compact_inst_set_bits(inst, high, low, v); \
} \
static inline unsigned \
-brw_compact_inst_##name(const struct brw_device_info *devinfo, \
+brw_compact_inst_##name(const struct gen_device_info *devinfo, \
const brw_compact_inst *inst) \
{ \
assert(assertions); \