165557Sjasone(* 265557Sjasone Signature for built-in functions 365557Sjasone 465557Sjasone Copyright David C. J. Matthews 2016, 2018-20 565557Sjasone 665557Sjasone This library is free software; you can redistribute it and/or 765557Sjasone modify it under the terms of the GNU Lesser General Public 865557Sjasone License version 2.1 as published by the Free Software Foundation. 965557Sjasone 1065557Sjasone This library is distributed in the hope that it will be useful, 1165557Sjasone but WITHOUT ANY WARRANTY; without even the implied warranty of 1265557Sjasone MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 1365557Sjasone Lesser General Public License for more details. 1465557Sjasone 1565557Sjasone You should have received a copy of the GNU Lesser General Public 1665557Sjasone License along with this library; if not, write to the Free Software 1765557Sjasone Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 1865557Sjasone*) 1965557Sjasone 2065557Sjasonesignature BUILTINS = 2165557Sjasonesig 2265557Sjasone datatype testConditions = 2365557Sjasone TestEqual (* No TestNotEqual because that is always generated with "not" *) 2465557Sjasone | TestLess 2565557Sjasone | TestLessEqual 2665557Sjasone | TestGreater 2765557Sjasone | TestGreaterEqual 2865557Sjasone | TestUnordered (* Reals only. *) 2967352Sjhb 3065557Sjasone datatype arithmeticOperations = 3165557Sjasone ArithAdd 3265557Sjasone | ArithSub 3365557Sjasone | ArithMult 3474912Sjhb | ArithQuot 3574912Sjhb | ArithRem 3674912Sjhb | ArithDiv 3772200Sbmilekic | ArithMod 3872200Sbmilekic 3972200Sbmilekic datatype logicalOperations = 4065557Sjasone LogicalAnd 4165557Sjasone | LogicalOr 4265557Sjasone | LogicalXor 4365557Sjasone 4465557Sjasone datatype shiftOperations = 4565557Sjasone ShiftLeft 4665557Sjasone | ShiftRightLogical (* Logical shift - zero added bits. *) 4765557Sjasone | ShiftRightArithmetic (* Arithmetic shift - add the sign bit. *) 4865557Sjasone 4965557Sjasone datatype unaryOps = 5065557Sjasone NotBoolean (* true => false; false => true - XOR *) 5165557Sjasone | IsTaggedValue (* Test the tag bit. *) 5265557Sjasone | MemoryCellLength (* Return the length of a memory cell (heap object) *) 5365557Sjasone | MemoryCellFlags (* Return the flags byte of a memory cell (heap object) *) 5465557Sjasone | ClearMutableFlag (* Remove the mutable flag from the flags byte *) 5565557Sjasone | AtomicIncrement 5665557Sjasone | AtomicDecrement 5765557Sjasone | AtomicReset (* Set a value to (tagged) zero atomically. *) 5865557Sjasone | LongWordToTagged (* Convert a LargeWord.word to a Word.word or FixedInt.int. *) 5968790Sjhb | SignedToLongWord (* Convert a tagged value to a LargeWord with sign extension. *) 6067676Sjhb | UnsignedToLongWord (* Convert a tagged value to a LargeWord without sign extension. *) 6167676Sjhb | RealAbs of precision (* Set the sign bit of a real to positive. *) 6265557Sjasone | RealNeg of precision (* Invert the sign bit of a real. *) 6367352Sjhb | RealFixedInt of precision (* Convert an integer value into a real value. *) 6467352Sjhb | FloatToDouble (* Convert a single precision floating point value to double precision. *) 6574912Sjhb | DoubleToFloat of IEEEReal.rounding_mode option (* Convert a double precision floating point value to single precision. *) 6674912Sjhb | RealToInt of precision * IEEEReal.rounding_mode (* Convert a double or float to a fixed precision int. *) 6767352Sjhb | TouchAddress (* Ensures that the cell is reachable. *) 6874912Sjhb | AllocCStack (* Allocate space on the C stack. *) 6965557Sjasone 7067676Sjhb and precision = PrecSingle | PrecDouble (* Single or double precision floating pt. *) 7165557Sjasone 7265557Sjasone and binaryOps = 7368790Sjhb (* Compare two words and return the result. This is used for both 7468790Sjhb word values (isSigned=false) and fixed precision integer (isSigned=true). 7574912Sjhb Values must be tagged and not pointers. *) 7674912Sjhb WordComparison of { test: testConditions, isSigned: bool } 7765557Sjasone (* Fixed precision int operations. These may raise Overflow. *) 7883798Sjhb | FixedPrecisionArith of arithmeticOperations 7974912Sjhb (* Arithmetic operations on word values. These do not raise Overflow. *) 8074912Sjhb | WordArith of arithmeticOperations 8167352Sjhb (* Load a word at a specific offset in a heap object. If this is immutable and the 8274912Sjhb arguments are constants it can be folded at compile time since the result will 8371352Sjasone never change. *) 8474912Sjhb | WordLogical of logicalOperations (* Logical operations on words. *) 8571352Sjasone | WordShift of shiftOperations (* Shift operations on words. *) 8674912Sjhb (* Allocate a heap cell for byte data. The first argument is the number of words (not bytes) 8771352Sjasone needed. The second argument is the "flags" byte which must include F_bytes and F_mutable. 8874912Sjhb The new cell is not initialised. *) 8974912Sjhb | AllocateByteMemory 9074912Sjhb (* Operations on LargeWords. These are 32/64 bit values that are "boxed". *) 9174912Sjhb | LargeWordComparison of testConditions 9274912Sjhb | LargeWordArith of arithmeticOperations 9374912Sjhb | LargeWordLogical of logicalOperations 9474912Sjhb | LargeWordShift of shiftOperations 9574912Sjhb | RealComparison of testConditions * precision 9674912Sjhb | RealArith of arithmeticOperations * precision 9774912Sjhb (* Equality of values which could be pointers or tagged values. 9874912Sjhb At the lowest level this is the same as WordComparison but 9974912Sjhb if we try to use an indexed case there must be a check that the 10074912Sjhb values are tagged. *) 10174912Sjhb | PointerEq 10271352Sjasone | FreeCStack (* Free space on the C stack. *) 10374912Sjhb 10474912Sjhb and nullaryOps = 10574912Sjhb (* Get the current thread id *) 10674912Sjhb GetCurrentThreadId 10774912Sjhb (* Check whether the last RTS call set the exception status and raise it if it had. *) 10871352Sjasone | CheckRTSException 10974912Sjhb 11071352Sjasone val unaryRepr: unaryOps -> string 11174912Sjhb and binaryRepr: binaryOps -> string 11274912Sjhb and testRepr: testConditions -> string 11374912Sjhb and arithRepr: arithmeticOperations -> string 11474912Sjhb and nullaryRepr: nullaryOps -> string 11571352Sjasoneend; 11674912Sjhb