templates = regTemplates
# Get everything ready for the substitution
- iop = InstObjParams(name, Name + suffix, base, {"code" : code})
+ opt_args = []
+ if self.op_class:
+ opt_args.append(self.op_class)
+ iop = InstObjParams(name, Name + suffix, base, {"code" : code},
+ opt_args)
# Generate the actual code (finally!)
header_output += templates[0].subst(iop)
if "abstract" in dict:
abstract = dict['abstract']
del dict['abstract']
+ if not "op_class" in dict:
+ dict["op_class"] = None
cls = super(MediaOpMeta, mcls).__new__(mcls, Name, bases, dict)
if not abstract:
size = None, destSize = None, srcSize = None, ext = None):
super(Mov2int, self).__init__(dest, src1,\
src2, size, destSize, srcSize, ext)
+ op_class = 'SimdMiscOp'
code = '''
int items = sizeof(FloatRegBits) / srcSize;
int offset = imm8;
size = None, destSize = None, srcSize = None, ext = None):
super(Mov2fp, self).__init__(dest, src1,\
src2, size, destSize, srcSize, ext)
+ op_class = 'SimdMiscOp'
code = '''
int items = sizeof(FloatRegBits) / destSize;
int offset = imm8;
size = None, destSize = None, srcSize = None, ext = None):
super(Movsign, self).__init__(dest, src,\
"InstRegIndex(0)", size, destSize, srcSize, ext)
+ op_class = 'SimdMiscOp'
code = '''
int items = sizeof(FloatRegBits) / srcSize;
uint64_t result = 0;
'''
class Maskmov(MediaOp):
+ op_class = 'SimdMiscOp'
code = '''
assert(srcSize == destSize);
int size = srcSize;
'''
class shuffle(MediaOp):
+ op_class = 'SimdMiscOp'
code = '''
assert(srcSize == destSize);
int size = srcSize;
'''
class Unpack(MediaOp):
+ op_class = 'SimdMiscOp'
code = '''
assert(srcSize == destSize);
int size = destSize;
'''
class Pack(MediaOp):
+ op_class = 'SimdMiscOp'
code = '''
assert(srcSize == destSize * 2);
int items = (sizeof(FloatRegBits) / destSize);
class Mxor(MediaOp):
def __init__(self, dest, src1, src2):
super(Mxor, self).__init__(dest, src1, src2, 1)
+ op_class = 'SimdAluOp'
code = '''
FpDestReg_uqw = FpSrcReg1_uqw ^ FpSrcReg2_uqw;
'''
class Mor(MediaOp):
def __init__(self, dest, src1, src2):
super(Mor, self).__init__(dest, src1, src2, 1)
+ op_class = 'SimdAluOp'
code = '''
FpDestReg_uqw = FpSrcReg1_uqw | FpSrcReg2_uqw;
'''
class Mand(MediaOp):
def __init__(self, dest, src1, src2):
super(Mand, self).__init__(dest, src1, src2, 1)
+ op_class = 'SimdAluOp'
code = '''
FpDestReg_uqw = FpSrcReg1_uqw & FpSrcReg2_uqw;
'''
class Mandn(MediaOp):
def __init__(self, dest, src1, src2):
super(Mandn, self).__init__(dest, src1, src2, 1)
+ op_class = 'SimdAluOp'
code = '''
FpDestReg_uqw = ~FpSrcReg1_uqw & FpSrcReg2_uqw;
'''
class Mminf(MediaOp):
+ op_class = 'SimdFloatCmpOp'
code = '''
union floatInt
{
'''
class Mmaxf(MediaOp):
+ op_class = 'SimdFloatCmpOp'
code = '''
union floatInt
{
'''
class Mmini(MediaOp):
+ op_class = 'SimdCmpOp'
code = '''
assert(srcSize == destSize);
'''
class Mmaxi(MediaOp):
+ op_class = 'SimdCmpOp'
code = '''
assert(srcSize == destSize);
'''
class Msqrt(MediaOp):
+ op_class = 'SimdFloatSqrtOp'
def __init__(self, dest, src, \
size = None, destSize = None, srcSize = None, ext = None):
super(Msqrt, self).__init__(dest, src,\
size = None, destSize = None, srcSize = None, ext = None):
super(Mrcp, self).__init__(dest, src,\
"InstRegIndex(0)", size, destSize, srcSize, ext)
+ op_class = 'SimdFloatAluOp'
code = '''
union floatInt
{
'''
class Maddf(MediaOp):
+ op_class = 'SimdFloatAddOp'
code = '''
union floatInt
{
'''
class Msubf(MediaOp):
+ op_class = 'SimdFloatAddOp'
code = '''
union floatInt
{
'''
class Mmulf(MediaOp):
+ op_class = 'SimdFloatMultOp'
code = '''
union floatInt
{
'''
class Mdivf(MediaOp):
+ op_class = 'SimdFloatDivOp'
code = '''
union floatInt
{
'''
class Maddi(MediaOp):
+ op_class = 'SimdAddOp'
code = '''
assert(srcSize == destSize);
int size = srcSize;
'''
class Msubi(MediaOp):
+ op_class = 'SimdAddOp'
code = '''
assert(srcSize == destSize);
int size = srcSize;
'''
class Mmuli(MediaOp):
+ op_class = 'SimdMultOp'
code = '''
int srcBits = srcSize * 8;
int destBits = destSize * 8;
'''
class Mavg(MediaOp):
+ op_class = 'SimdAddOp'
code = '''
assert(srcSize == destSize);
int size = srcSize;
'''
class Msad(MediaOp):
+ op_class = 'SimdAddOp'
code = '''
int srcBits = srcSize * 8;
int items = sizeof(FloatRegBits) / srcSize;
'''
class Msrl(MediaOp):
+ op_class = 'SimdShiftOp'
code = '''
assert(srcSize == destSize);
'''
class Msra(MediaOp):
+ op_class = 'SimdShiftOp'
code = '''
assert(srcSize == destSize);
'''
class Msll(MediaOp):
+ op_class = 'SimdShiftOp'
code = '''
assert(srcSize == destSize);
size = None, destSize = None, srcSize = None, ext = None):
super(Cvtf2i, self).__init__(dest, src,\
"InstRegIndex(0)", size, destSize, srcSize, ext)
+ op_class = 'SimdFloatCvtOp'
code = '''
union floatInt
{
size = None, destSize = None, srcSize = None, ext = None):
super(Cvti2f, self).__init__(dest, src,\
"InstRegIndex(0)", size, destSize, srcSize, ext)
+ op_class = 'SimdFloatCvtOp'
code = '''
union floatInt
{
size = None, destSize = None, srcSize = None, ext = None):
super(Cvtf2f, self).__init__(dest, src,\
"InstRegIndex(0)", size, destSize, srcSize, ext)
+ op_class = 'SimdFloatCvtOp'
code = '''
union floatInt
{
'''
class Mcmpi2r(MediaOp):
+ op_class = 'SimdCvtOp'
code = '''
union floatInt
{
'''
class Mcmpf2r(MediaOp):
+ op_class = 'SimdFloatCvtOp'
code = '''
union floatInt
{
size = None, destSize = None, srcSize = None, ext = None):
super(Mcmpf2rf, self).__init__("InstRegIndex(0)", src1,\
src2, size, destSize, srcSize, ext)
+ op_class = 'SimdFloatCvtOp'
code = '''
union floatInt
{
'''
class Emms(MediaOp):
+ op_class = 'FloatMiscOp'
def __init__(self):
super(Emms, self).__init__('InstRegIndex(MISCREG_FTW)',
'InstRegIndex(0)', 'InstRegIndex(0)', 2)