1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00

GlobalISel: also add G_TRUNC to IRTranslator.

llvm-svn: 277749
This commit is contained in:
Tim Northover 2016-08-04 18:35:17 +00:00
parent da14a9a2d2
commit 7bdc05cfaa
2 changed files with 16 additions and 1 deletions

View File

@ -252,13 +252,15 @@ bool IRTranslator::translate(const Instruction &Inst) {
case Instruction::Call:
return translateCall(cast<CallInst>(Inst));
// Casts
// Casts and allied operations
case Instruction::BitCast:
return translateBitCast(cast<CastInst>(Inst));
case Instruction::IntToPtr:
return translateCast(TargetOpcode::G_INTTOPTR, cast<CastInst>(Inst));
case Instruction::PtrToInt:
return translateCast(TargetOpcode::G_PTRTOINT, cast<CastInst>(Inst));
case Instruction::Trunc:
return translateCast(TargetOpcode::G_TRUNC, cast<CastInst>(Inst));
// Memory ops.
case Instruction::Load:

View File

@ -223,6 +223,19 @@ define i64 @bitcast(i64 %a) {
ret i64 %res2
}
; CHECK-LABEL: name: trunc
; CHECK: [[ARG1:%[0-9]+]](64) = COPY %x0
; CHECK: [[VEC:%[0-9]+]](128) = G_LOAD { <4 x s32>, p0 }
; CHECK: [[RES1:%[0-9]+]](8) = G_TRUNC { s8, s64 } [[ARG1]]
; CHECK: [[RES2:%[0-9]+]](64) = G_TRUNC { <4 x s16>, <4 x s32> } [[VEC]]
define void @trunc(i64 %a) {
%vecptr = alloca <4 x i32>
%vec = load <4 x i32>, <4 x i32>* %vecptr
%res1 = trunc i64 %a to i8
%res2 = trunc <4 x i32> %vec to <4 x i16>
ret void
}
; CHECK-LABEL: name: load
; CHECK: [[ADDR:%[0-9]+]](64) = COPY %x0
; CHECK: [[ADDR42:%[0-9]+]](64) = COPY %x1