forked from OSchip/llvm-project
Add conversion of StandardOps and, or and xor to LLVM dialect.
-- PiperOrigin-RevId: 242831203
This commit is contained in:
parent
44f6dffbf8
commit
d6037276af
|
@ -148,6 +148,9 @@ def LLVM_UDivOp : LLVM_ArithmeticOp<"udiv", "CreateUDiv">;
|
|||
def LLVM_SDivOp : LLVM_ArithmeticOp<"sdiv", "CreateSDiv">;
|
||||
def LLVM_URemOp : LLVM_ArithmeticOp<"urem", "CreateURem">;
|
||||
def LLVM_SRemOp : LLVM_ArithmeticOp<"srem", "CreateSRem">;
|
||||
def LLVM_AndOp : LLVM_ArithmeticOp<"and", "CreateAnd">;
|
||||
def LLVM_OrOp : LLVM_ArithmeticOp<"or", "CreateOr">;
|
||||
def LLVM_XOrOp : LLVM_ArithmeticOp<"xor", "CreateXor">;
|
||||
|
||||
// Other integer operations.
|
||||
def LLVM_ICmpOp : LLVM_OneResultOp<"icmp", [NoSideEffect]>,
|
||||
|
|
|
@ -489,6 +489,15 @@ struct RemISOpLowering : public OneToOneLLVMOpLowering<RemISOp, LLVM::SRemOp> {
|
|||
struct RemIUOpLowering : public OneToOneLLVMOpLowering<RemIUOp, LLVM::URemOp> {
|
||||
using Super::Super;
|
||||
};
|
||||
struct AndOpLowering : public OneToOneLLVMOpLowering<AndOp, LLVM::AndOp> {
|
||||
using Super::Super;
|
||||
};
|
||||
struct OrOpLowering : public OneToOneLLVMOpLowering<OrOp, LLVM::OrOp> {
|
||||
using Super::Super;
|
||||
};
|
||||
struct XOrOpLowering : public OneToOneLLVMOpLowering<XOrOp, LLVM::XOrOp> {
|
||||
using Super::Super;
|
||||
};
|
||||
struct AddFOpLowering : public OneToOneLLVMOpLowering<AddFOp, LLVM::FAddOp> {
|
||||
using Super::Super;
|
||||
};
|
||||
|
@ -1101,14 +1110,15 @@ protected:
|
|||
|
||||
// FIXME: this should be tablegen'ed
|
||||
return ConversionListBuilder<
|
||||
AddFOpLowering, AddIOpLowering, AllocOpLowering, BranchOpLowering,
|
||||
CallIndirectOpLowering, CallOpLowering, CmpIOpLowering,
|
||||
CondBranchOpLowering, ConstLLVMOpLowering, DeallocOpLowering,
|
||||
DimOpLowering, DivISOpLowering, DivIUOpLowering, DivFOpLowering,
|
||||
LoadOpLowering, MemRefCastOpLowering, MulFOpLowering, MulIOpLowering,
|
||||
RemISOpLowering, RemIUOpLowering, RemFOpLowering, ReturnOpLowering,
|
||||
SelectOpLowering, StoreOpLowering, SubFOpLowering,
|
||||
SubIOpLowering>::build(&converterStorage, *llvmDialect);
|
||||
AddFOpLowering, AddIOpLowering, AndOpLowering, AllocOpLowering,
|
||||
BranchOpLowering, CallIndirectOpLowering, CallOpLowering,
|
||||
CmpIOpLowering, CondBranchOpLowering, ConstLLVMOpLowering,
|
||||
DeallocOpLowering, DimOpLowering, DivISOpLowering, DivIUOpLowering,
|
||||
DivFOpLowering, LoadOpLowering, MemRefCastOpLowering, MulFOpLowering,
|
||||
MulIOpLowering, OrOpLowering, RemISOpLowering, RemIUOpLowering,
|
||||
RemFOpLowering, ReturnOpLowering, SelectOpLowering, StoreOpLowering,
|
||||
SubFOpLowering, SubIOpLowering, XOrOpLowering>::build(&converterStorage,
|
||||
*llvmDialect);
|
||||
}
|
||||
|
||||
// Convert types using the stored LLVM IR module.
|
||||
|
|
|
@ -375,6 +375,12 @@ func @vector_ops(vector<4xf32>, vector<4xi1>, vector<4xi64>) -> vector<4xf32> {
|
|||
%7 = divf %arg0, %0 : vector<4xf32>
|
||||
// CHECK-NEXT: %7 = llvm.frem %arg0, %0 : !llvm<"<4 x float>">
|
||||
%8 = remf %arg0, %0 : vector<4xf32>
|
||||
// CHECK-NEXT: %8 = llvm.and %arg2, %arg2 : !llvm<"<4 x i64>">
|
||||
%9 = and %arg2, %arg2 : vector<4xi64>
|
||||
// CHECK-NEXT: %9 = llvm.or %arg2, %arg2 : !llvm<"<4 x i64>">
|
||||
%10 = or %arg2, %arg2 : vector<4xi64>
|
||||
// CHECK-NEXT: %10 = llvm.xor %arg2, %arg2 : !llvm<"<4 x i64>">
|
||||
%11 = xor %arg2, %arg2 : vector<4xi64>
|
||||
return %1 : vector<4xf32>
|
||||
}
|
||||
|
||||
|
@ -401,6 +407,12 @@ func @ops(f32, f32, i32, i32) -> (f32, i32) {
|
|||
%9 = divf %arg0, %arg1 : f32
|
||||
// CHECK-NEXT: %9 = llvm.frem %arg0, %arg1 : !llvm.float
|
||||
%10 = remf %arg0, %arg1 : f32
|
||||
// CHECK-NEXT: %10 = llvm.and %arg2, %arg3 : !llvm.i32
|
||||
%11 = and %arg2, %arg3 : i32
|
||||
// CHECK-NEXT: %11 = llvm.or %arg2, %arg3 : !llvm.i32
|
||||
%12 = or %arg2, %arg3 : i32
|
||||
// CHECK-NEXT: %12 = llvm.xor %arg2, %arg3 : !llvm.i32
|
||||
%13 = xor %arg2, %arg3 : i32
|
||||
|
||||
return %0, %4 : f32, i32
|
||||
}
|
||||
|
|
|
@ -711,6 +711,12 @@ func @vector_ops(%arg0: !llvm<"<4 x float>">, %arg1: !llvm<"<4 x i1>">, %arg2: !
|
|||
%7 = llvm.fdiv %arg0, %0 : !llvm<"<4 x float>">
|
||||
// CHECK-NEXT: %11 = frem <4 x float> %0, <float 4.200000e+01, float 4.200000e+01, float 4.200000e+01, float 4.200000e+01>
|
||||
%8 = llvm.frem %arg0, %0 : !llvm<"<4 x float>">
|
||||
// CHECK-NEXT: %12 = and <4 x i64> %2, %2
|
||||
%9 = llvm.and %arg2, %arg2 : !llvm<"<4 x i64>">
|
||||
// CHECK-NEXT: %13 = or <4 x i64> %2, %2
|
||||
%10 = llvm.or %arg2, %arg2 : !llvm<"<4 x i64>">
|
||||
// CHECK-NEXT: %14 = xor <4 x i64> %2, %2
|
||||
%11 = llvm.xor %arg2, %arg2 : !llvm<"<4 x i64>">
|
||||
// CHECK-NEXT: ret <4 x float> %4
|
||||
llvm.return %1 : !llvm<"<4 x float>">
|
||||
}
|
||||
|
@ -743,6 +749,13 @@ func @ops(%arg0: !llvm.float, %arg1: !llvm.float, %arg2: !llvm.i32, %arg3: !llvm
|
|||
// CHECK-NEXT: %16 = frem float %0, %1
|
||||
%12 = llvm.frem %arg0, %arg1 : !llvm.float
|
||||
|
||||
// CHECK-NEXT: %17 = and i32 %2, %3
|
||||
%13 = llvm.and %arg2, %arg3 : !llvm.i32
|
||||
// CHECK-NEXT: %18 = or i32 %2, %3
|
||||
%14 = llvm.or %arg2, %arg3 : !llvm.i32
|
||||
// CHECK-NEXT: %19 = xor i32 %2, %3
|
||||
%15 = llvm.xor %arg2, %arg3 : !llvm.i32
|
||||
|
||||
llvm.return %10 : !llvm<"{ float, i32 }">
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue