translator: add division to types

This commit is contained in:
Alexey Stepanov
2016-08-24 09:59:59 +03:00
parent 9af356503d
commit 7067288cf4
7 changed files with 19 additions and 0 deletions
@@ -18,6 +18,9 @@ class LLVMBooleanType() : LLVMType() {
override fun operatorPlus(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMBooleanType(), "add nsw i1 $firstOp, $secondOp")
override fun operatorDiv(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMBooleanType(), "sdiv i1 $firstOp, $secondOp")
override fun operatorLt(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMBooleanType(), "icmp slt i1 $firstOp, $secondOp")
@@ -21,6 +21,9 @@ class LLVMDoubleType() : LLVMType() {
override fun operatorInc(firstOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMDoubleType(), "fadd double $firstOp, 1.0")
override fun operatorDiv(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMDoubleType(), "fdiv double $firstOp, 1.0")
override fun operatorDec(firstOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMDoubleType(), "fsub double $firstOp, 1.0")
@@ -18,6 +18,9 @@ class LLVMFloatType() : LLVMType() {
override fun operatorPlus(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMFloatType(), "fadd float $firstOp, $secondOp")
override fun operatorDiv(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMFloatType(), "fdiv float $firstOp, 1.0")
override fun operatorInc(firstOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMDoubleType(), "fadd float $firstOp, 1.0")
@@ -37,6 +37,9 @@ class LLVMIntType() : LLVMType() {
override fun operatorPlus(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMIntType(), "add nsw i32 $firstOp, $secondOp")
override fun operatorDiv(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMIntType(), "sdiv i32 $firstOp, $secondOp")
override fun operatorInc(firstOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMIntType(), "add nsw i32 $firstOp, 1")
@@ -37,6 +37,9 @@ class LLVMLongType() : LLVMType() {
override fun operatorPlus(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMLongType(), "add nsw i64 $firstOp, $secondOp")
override fun operatorDiv(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMLongType(), "sdiv i64 $firstOp, $secondOp")
override fun operatorLt(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMBooleanType(), "icmp slt i64 $firstOp, $secondOp")
@@ -25,6 +25,9 @@ class LLVMShortType() : LLVMType() {
override fun operatorMod(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMShortType(), "srem i16 $firstOp, $secondOp")
override fun operatorDiv(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression =
LLVMExpression(LLVMShortType(), "sdiv i16 $firstOp, $secondOp")
override fun equals(other: Any?): Boolean {
return other is LLVMShortType
}
@@ -9,6 +9,7 @@ abstract class LLVMType() : Cloneable {
open fun operatorPlus(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression = throw UnimplementedException()
open fun operatorTimes(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression = throw UnimplementedException()
open fun operatorMinus(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression = throw UnimplementedException()
open fun operatorDiv(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression = throw UnimplementedException()
open fun operatorLt(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression = throw UnimplementedException()
open fun operatorGt(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression = throw UnimplementedException()
open fun operatorLeq(firstOp: LLVMSingleValue, secondOp: LLVMSingleValue): LLVMExpression = throw UnimplementedException()