~cypheon/rapid

4f877c9f39334c2d6019fde361d079cf7d083c2f — Johann Rudloff 18 days ago a36fa72
Add some more generic casts from Char -> several int types
1 files changed, 5 insertions(+), 12 deletions(-)

M src/Compiler/GenLLVMIR.idr
M src/Compiler/GenLLVMIR.idr => src/Compiler/GenLLVMIR.idr +5 -12
@@ 2045,18 2045,6 @@ getInstIR i (OP r (Cast StringType DoubleType) [r1]) = do
  newDouble <- cgMkDouble parsedVal
  store newDouble (reg2val r)

getInstIR i (OP r (Cast CharType IntegerType) [r1]) = do
  charHdr <- getObjectHeader !(load (reg2val r1))
  charVal <- mkAnd charHdr (ConstI64 0x1fffff)
  newInt <- cgMkIntegerSigned charVal
  store newInt (reg2val r)

getInstIR i (OP r (Cast CharType IntType) [r1]) = do
  charHdr <- getObjectHeader !(load (reg2val r1))
  charVal <- mkAnd charHdr (ConstI64 0x1fffff)
  newInt <- cgMkInt charVal
  store newInt (reg2val r)

getInstIR i (OP r (Cast Bits8Type IntegerType) [r1]) = do
  ival <- unboxInt (reg2val r1)
  newInt <- cgMkIntegerSigned ival


@@ 2111,6 2099,11 @@ getInstIR i (OP r (Cast CharType StringType) [r1]) = do
  putObjectHeader newStr !(mkHeader OBJECT_TYPE_ID_STR charLength)
  store newStr (reg2val r)

getInstIR i (OP r (Cast CharType toType) [r1]) = do
  charVal <- unboxChar' !(load (reg2val r1))
  newInt <- genericIntBox toType !(mkZext charVal)
  store newInt (reg2val r)

getInstIR i (OP r (Cast IntType IntegerType) [r1]) = do
  ival <- unboxInt (reg2val r1)
  integerObj <- cgMkIntegerSigned ival