mediaop.isa (10196:be0e1724eb39) mediaop.isa (11160:10f28b61fcb1)
1/// Copyright (c) 2009 The Regents of The University of Michigan
1// Copyright (c) 2009 The Regents of The University of Michigan
2// Copyright (c) 2015 Advanced Micro Devices, Inc.
3//
2// All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without
5// modification, are permitted provided that the following conditions are
6// met: redistributions of source code must retain the above copyright
7// notice, this list of conditions and the following disclaimer;
8// redistributions in binary form must reproduce the above copyright
9// notice, this list of conditions and the following disclaimer in the

--- 676 unchanged lines hidden (view full) ---

686 di.d = sqrt(di.d);
687 argBits = di.i;
688 }
689 result = insertBits(result, hiIndex, loIndex, argBits);
690 }
691 FpDestReg_uqw = result;
692 '''
693
4// All rights reserved.
5//
6// Redistribution and use in source and binary forms, with or without
7// modification, are permitted provided that the following conditions are
8// met: redistributions of source code must retain the above copyright
9// notice, this list of conditions and the following disclaimer;
10// redistributions in binary form must reproduce the above copyright
11// notice, this list of conditions and the following disclaimer in the

--- 676 unchanged lines hidden (view full) ---

688 di.d = sqrt(di.d);
689 argBits = di.i;
690 }
691 result = insertBits(result, hiIndex, loIndex, argBits);
692 }
693 FpDestReg_uqw = result;
694 '''
695
696 # compute approximate reciprocal --- single-precision only
697 class Mrcp(MediaOp):
698 def __init__(self, dest, src, \
699 size = None, destSize = None, srcSize = None, ext = None):
700 super(Mrcp, self).__init__(dest, src,\
701 "InstRegIndex(0)", size, destSize, srcSize, ext)
702 code = '''
703 union floatInt
704 {
705 float f;
706 uint32_t i;
707 };
708
709 assert(srcSize == 4); // ISA defines single-precision only
710 assert(srcSize == destSize);
711 const int size = 4;
712 const int sizeBits = size * 8;
713 int items = numItems(size);
714 uint64_t result = FpDestReg_uqw;
715
716 for (int i = 0; i < items; i++) {
717 int hiIndex = (i + 1) * sizeBits - 1;
718 int loIndex = (i + 0) * sizeBits;
719 uint64_t argBits = bits(FpSrcReg1_uqw, hiIndex, loIndex);
720
721 floatInt fi;
722 fi.i = argBits;
723 // This is more accuracy than HW provides, but oh well
724 fi.f = 1.0 / fi.f;
725 argBits = fi.i;
726 result = insertBits(result, hiIndex, loIndex, argBits);
727 }
728 FpDestReg_uqw = result;
729 '''
730
694 class Maddf(MediaOp):
695 code = '''
696 union floatInt
697 {
698 float f;
699 uint32_t i;
700 };
701 union doubleInt

--- 810 unchanged lines hidden ---
731 class Maddf(MediaOp):
732 code = '''
733 union floatInt
734 {
735 float f;
736 uint32_t i;
737 };
738 union doubleInt

--- 810 unchanged lines hidden ---