Add binops correctly
This commit is contained in:
parent
8d64416b5e
commit
2e08d373f5
@ -52,7 +52,9 @@ namespace types {
|
||||
}
|
||||
|
||||
// Signed comparisons
|
||||
for (auto& ty : { int_ty }) {
|
||||
for (auto& ty : {
|
||||
short_int_ty, int_ty, long_int_ty, long_long_int_ty, char_ty,
|
||||
}) {
|
||||
definitions.push_back(BinopDefinition{
|
||||
ty, types::BinOp::LessThan, ty,
|
||||
[](codegen::Builder& builder, llvm::Value* lhs, llvm::Value* rhs) {
|
||||
@ -77,11 +79,14 @@ namespace types {
|
||||
}
|
||||
|
||||
// Unsigned comparisons
|
||||
for (auto& ty : { bool_ty, char_ty }) {
|
||||
for (auto& ty : {
|
||||
ushort_int_ty, uint_ty, ulong_int_ty, ulong_long_int_ty, uchar_ty,
|
||||
bool_ty
|
||||
}) {
|
||||
definitions.push_back(BinopDefinition{
|
||||
ty, types::BinOp::LessThan, ty,
|
||||
[](codegen::Builder& builder, llvm::Value* lhs, llvm::Value* rhs) {
|
||||
return builder.builder->CreateICmpULT(lhs, rhs, "icmpslt");
|
||||
return builder.builder->CreateICmpULT(lhs, rhs, "icmpult");
|
||||
},
|
||||
[](BinopDefinition&, std::shared_ptr<types::Type>, std::shared_ptr<types::Type>) {
|
||||
return std::shared_ptr<types::Type>{
|
||||
@ -92,7 +97,7 @@ namespace types {
|
||||
definitions.push_back(BinopDefinition{
|
||||
ty, types::BinOp::GreaterThan, ty,
|
||||
[](codegen::Builder& builder, llvm::Value* lhs, llvm::Value* rhs) {
|
||||
return builder.builder->CreateICmpUGT(lhs, rhs, "icmpsgt");
|
||||
return builder.builder->CreateICmpUGT(lhs, rhs, "icmpugt");
|
||||
},
|
||||
[](BinopDefinition&, std::shared_ptr<types::Type>, std::shared_ptr<types::Type>) {
|
||||
return std::shared_ptr<types::Type>{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user