Index: test/CodeGen/NDS32/Insn.ll =================================================================== --- /dev/null +++ test/CodeGen/NDS32/Insn.ll @@ -0,0 +1,300 @@ +; RUN: llc < %s | FileCheck %s +target datalayout = "e-m:e-p:32:32-i64:64-a:0:32-n32-S64" +target triple = "nds32le---elf" + +@global_a = common global i32 0, align 4 + +; Function Attrs: nounwind +define i32 @and() #0 { +entry: + %a = alloca i32, align 4 + %b = alloca i32, align 4 + store i32 7, i32* %a, align 4 + store i32 8, i32* %b, align 4 + %0 = load i32, i32* %a, align 4 + %1 = load i32, i32* %b, align 4 + %and = and i32 %0, %1 +; CHECK: andi $r0, $r0, 8 + ret i32 %and +} + +; Function Attrs: nounwind +define i32 @mul() #0 { +entry: + %a = alloca i32, align 4 + %b = alloca i32, align 4 + store i32 7, i32* %a, align 4 + store i32 7, i32* %b, align 4 + %0 = load i32, i32* %a, align 4 + %1 = load i32, i32* %b, align 4 + %mul = mul nsw i32 %0, %1 +; CHECK: mul33 $r0, $r1 + ret i32 %mul +} + +; Function Attrs: nounwind +define i32 @or() #0 { +entry: + %a = alloca i32, align 4 + %b = alloca i32, align 4 + store i32 7, i32* %a, align 4 + store i32 17, i32* %b, align 4 + %0 = load i32, i32* %a, align 4 + %1 = load i32, i32* %b, align 4 + %or = or i32 %0, %1 +; CHECK: ori $r0, $r0, 17 + ret i32 %or +} + +; Function Attrs: nounwind +define i32 @xor() #0 { +entry: + %a = alloca i32, align 4 + %b = alloca i32, align 4 + store i32 7, i32* %a, align 4 + store i32 17, i32* %b, align 4 + %0 = load i32, i32* %a, align 4 + %1 = load i32, i32* %b, align 4 + %xor = xor i32 %0, %1 +; CHECK: xori $r0, $r0, 17 + ret i32 %xor +} + +; Function Attrs: nounwind +define i32 @jal() #0 { +entry: + %call = call i32 @jal() +; CHECK: jal jal + ret i32 %call +} + +; Function Attrs: nounwind +define i32 @beq(i32 %a, i32 %b) #0 { +entry: + %retval = alloca i32, align 4 + %a.addr = alloca i32, align 4 + %b.addr = alloca i32, align 4 + store i32 %a, i32* %a.addr, align 4 + store i32 %b, i32* %b.addr, align 4 + %0 = load i32, i32* %a.addr, align 4 + %1 = load i32, i32* %b.addr, align 4 + %cmp = icmp ne i32 %0, %1 + br i1 %cmp, label %if.then, label %if.else +; CHECK: beq $r0, $r1, .LBB5_2 + +if.then: ; preds = %entry + store i32 0, i32* %retval, align 4 + br label %return + +if.else: ; preds = %entry + store i32 1, i32* %retval, align 4 + br label %return + +return: ; preds = %if.else, %if.then + %2 = load i32, i32* %retval, align 4 + ret i32 %2 +} + +; Function Attrs: nounwind +define i32 @bne(i32 %a, i32 %b) #0 { +entry: + %retval = alloca i32, align 4 + %a.addr = alloca i32, align 4 + %b.addr = alloca i32, align 4 + store i32 %a, i32* %a.addr, align 4 + store i32 %b, i32* %b.addr, align 4 + %0 = load i32, i32* %a.addr, align 4 + %1 = load i32, i32* %b.addr, align 4 + %cmp = icmp eq i32 %0, %1 + br i1 %cmp, label %if.then, label %if.else +; CHECK: bne $r0, $r1, .LBB6_2 + +if.then: ; preds = %entry + store i32 0, i32* %retval, align 4 + br label %return + +if.else: ; preds = %entry + store i32 1, i32* %retval, align 4 + br label %return + +return: ; preds = %if.else, %if.then + %2 = load i32, i32* %retval, align 4 + ret i32 %2 +} + +; Function Attrs: nounwind +define i32 @beqz(i32 %a, i32 %b) #0 { +entry: + %retval = alloca i32, align 4 + %a.addr = alloca i32, align 4 + %b.addr = alloca i32, align 4 + store i32 %a, i32* %a.addr, align 4 + store i32 %b, i32* %b.addr, align 4 + %0 = load i32, i32* %a.addr, align 4 + %cmp = icmp ne i32 %0, 0 + br i1 %cmp, label %if.then, label %if.else +; CHECK: beqz38 $r0, .LBB7_2 + +if.then: ; preds = %entry + store i32 0, i32* %retval, align 4 + br label %return + +if.else: ; preds = %entry + store i32 1, i32* %retval, align 4 + br label %return + +return: ; preds = %if.else, %if.then + %1 = load i32, i32* %retval, align 4 + ret i32 %1 +} + +; Function Attrs: nounwind +define i32 @bnez(i32 %a, i32 %b) #0 { +entry: + %retval = alloca i32, align 4 + %a.addr = alloca i32, align 4 + %b.addr = alloca i32, align 4 + store i32 %a, i32* %a.addr, align 4 + store i32 %b, i32* %b.addr, align 4 + %0 = load i32, i32* %a.addr, align 4 + %cmp = icmp eq i32 %0, 0 + br i1 %cmp, label %if.then, label %if.else +; CHECK: bnez38 $r0, .LBB8_2 + +if.then: ; preds = %entry + store i32 0, i32* %retval, align 4 + br label %return + +if.else: ; preds = %entry + store i32 1, i32* %retval, align 4 + br label %return + +return: ; preds = %if.else, %if.then + %1 = load i32, i32* %retval, align 4 + ret i32 %1 +} + +; Function Attrs: nounwind +define i32 @blez(i32 %a, i32 %b) #0 { +entry: + %retval = alloca i32, align 4 + %a.addr = alloca i32, align 4 + %b.addr = alloca i32, align 4 + store i32 %a, i32* %a.addr, align 4 + store i32 %b, i32* %b.addr, align 4 + %0 = load i32, i32* %a.addr, align 4 + %cmp = icmp sgt i32 %0, 0 + br i1 %cmp, label %if.then, label %if.else +; CHECK: blez $r0, .LBB9_2 + +if.then: ; preds = %entry + store i32 0, i32* %retval, align 4 + br label %return + +if.else: ; preds = %entry + store i32 1, i32* %retval, align 4 + br label %return + +return: ; preds = %if.else, %if.then + %1 = load i32, i32* %retval, align 4 + ret i32 %1 +} + +; Function Attrs: nounwind +define i32 @bltz(i32 %a, i32 %b) #0 { +entry: + %retval = alloca i32, align 4 + %a.addr = alloca i32, align 4 + %b.addr = alloca i32, align 4 + store i32 %a, i32* %a.addr, align 4 + store i32 %b, i32* %b.addr, align 4 + %0 = load i32, i32* %a.addr, align 4 + %cmp = icmp sge i32 %0, 0 + br i1 %cmp, label %if.then, label %if.else +; CHECK: bltz $r0, .LBB10_2 + +if.then: ; preds = %entry + store i32 0, i32* %retval, align 4 + br label %return + +if.else: ; preds = %entry + store i32 1, i32* %retval, align 4 + br label %return + +return: ; preds = %if.else, %if.then + %1 = load i32, i32* %retval, align 4 + ret i32 %1 +} + +; Function Attrs: nounwind +define i32 @bgez(i32 %a, i32 %b) #0 { +entry: + %retval = alloca i32, align 4 + %a.addr = alloca i32, align 4 + %b.addr = alloca i32, align 4 + store i32 %a, i32* %a.addr, align 4 + store i32 %b, i32* %b.addr, align 4 + %0 = load i32, i32* %a.addr, align 4 + %cmp = icmp slt i32 %0, 0 + br i1 %cmp, label %if.then, label %if.else +; CHECK: bgez $r0, .LBB11_2 + +if.then: ; preds = %entry + store i32 0, i32* %retval, align 4 + br label %return + +if.else: ; preds = %entry + store i32 1, i32* %retval, align 4 + br label %return + +return: ; preds = %if.else, %if.then + %1 = load i32, i32* %retval, align 4 + ret i32 %1 +} + +; Function Attrs: nounwind +define i32 @bgtz(i32 %a, i32 %b) #0 { +entry: + %retval = alloca i32, align 4 + %a.addr = alloca i32, align 4 + %b.addr = alloca i32, align 4 + store i32 %a, i32* %a.addr, align 4 + store i32 %b, i32* %b.addr, align 4 + %0 = load i32, i32* %a.addr, align 4 + %cmp = icmp sle i32 %0, 0 + br i1 %cmp, label %if.then, label %if.else +; CHECK: bgtz $r0, .LBB12_2 + +if.then: ; preds = %entry + store i32 0, i32* %retval, align 4 + br label %return + +if.else: ; preds = %entry + store i32 1, i32* %retval, align 4 + br label %return + +return: ; preds = %if.else, %if.then + %1 = load i32, i32* %retval, align 4 + ret i32 %1 +} + +; Function Attrs: nounwind +define i32 @big_const() #0 { +entry: +; CHECK: sethi $r0, 65535 +; CHECK: ori $r0, $r0, 4095 + ret i32 268435455 +} + +; Function Attrs: nounwind +define i32 @global() #0 { +entry: + %b = alloca i32, align 4 + store i32 8, i32* %b, align 4 + %0 = load i32, i32* @global_a, align 4 +; CHECK: sethi $r0, hi20(global_a) +; CHECK: ori $r0, $r0, lo12(global_a) + %1 = load i32, i32* %b, align 4 + %and = and i32 %0, %1 + ret i32 %and +} Index: test/CodeGen/NDS32/add_shift.ll =================================================================== --- /dev/null +++ test/CodeGen/NDS32/add_shift.ll @@ -0,0 +1,48 @@ +; RUN: llc < %s | FileCheck %s +target datalayout = "e-m:e-p:32:32-i64:64-a:0:32-n32-S64" +target triple = "nds32le---elf" + +; Function Attrs: norecurse nounwind readnone +define i32 @add_shift(i32 %a, i32 %b) local_unnamed_addr #0 { +entry: + %shl = shl i32 %b, 2 + %add = add nsw i32 %shl, %a +; CHECK: add_slli $r0, $r0, $r1, 2 + ret i32 %add +} + +; Function Attrs: norecurse nounwind readnone +define i32 @sub_shift(i32 %a, i32 %b) local_unnamed_addr #0 { +entry: + %shl = shl i32 %b, 2 + %sub = sub nsw i32 %a, %shl +; CHECK: sub_slli $r0, $r0, $r1, 2 + ret i32 %sub +} + +; Function Attrs: norecurse nounwind readnone +define i32 @and_shift(i32 %a, i32 %b) local_unnamed_addr #0 { +entry: + %shl = shl i32 %b, 5 + %and = and i32 %shl, %a +; CHECK: and_slli $r0, $r0, $r1, 5 + ret i32 %and +} + +; Function Attrs: norecurse nounwind readnone +define i32 @or_shift(i32 %a, i32 %b) local_unnamed_addr #0 { +entry: + %shl = shl i32 %b, 6 + %or = or i32 %shl, %a +; CHECK: or_slli $r0, $r0, $r1, 6 + ret i32 %or +} + +; Function Attrs: norecurse nounwind readnone +define i32 @xor_shift(i32 %a, i32 %b) local_unnamed_addr #0 { +entry: + %shl = shl i32 %b, 7 + %xor = xor i32 %shl, %a +; CHECK: xor_slli $r0, $r0, $r1, 7 + ret i32 %xor +} Index: test/CodeGen/NDS32/cmov.ll =================================================================== --- /dev/null +++ test/CodeGen/NDS32/cmov.ll @@ -0,0 +1,23 @@ +; RUN: llc < %s | FileCheck %s +target datalayout = "e-m:e-p:32:32-i64:64-a:0:32-n32-S64" +target triple = "nds32le---elf" + +; Function Attrs: norecurse nounwind readnone +define i32 @cmovn(i32 %a) local_unnamed_addr #0 { +entry: + %cmp = icmp slt i32 %a, 1 + %mul = select i1 %cmp, i32 1, i32 %a +; CHECK: cmovn $r1, $r3, $r2 + %retval.0 = mul nsw i32 %mul, %a + ret i32 %retval.0 +} + +; Function Attrs: norecurse nounwind readnone +define i32 @cmovz(i32 %a) local_unnamed_addr #0 { +entry: + %cmp = icmp eq i32 %a, 2 + %a. = select i1 %cmp, i32 2, i32 3 +; CHECK: cmovz $r1, $r3, $r2 + %retval.0 = mul nsw i32 %a., %a + ret i32 %retval.0 +} Index: test/CodeGen/NDS32/div.ll =================================================================== --- /dev/null +++ test/CodeGen/NDS32/div.ll @@ -0,0 +1,18 @@ +; RUN: llc < %s | FileCheck %s +target datalayout = "e-m:e-p:32:32-i64:64-a:0:32-n32-S64" +target triple = "nds32le---elf" + +@.str = private unnamed_addr constant [8 x i8] c"%d, %d\0A\00", align 1 + +; Function Attrs: nounwind +define i32 @div(i32 %a, i32 %b) local_unnamed_addr #0 { +entry: + %div = sdiv i32 %a, %b + %rem = srem i32 %a, %b +; CHECK: divsr $r1, $r2, $r0, $r1 + %call = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i32 %div, i32 %rem) + ret i32 undef +} + +; Function Attrs: nounwind +declare i32 @printf(i8* nocapture readonly, ...) local_unnamed_addr #1 Index: test/CodeGen/NDS32/jumptable.ll =================================================================== --- /dev/null +++ test/CodeGen/NDS32/jumptable.ll @@ -0,0 +1,44 @@ +; RUN: llc < %s | FileCheck %s +target datalayout = "e-m:e-p:32:32-i64:64-a:0:32-n32-S64" +target triple = "nds32le---elf" + +; Function Attrs: norecurse nounwind readnone +define i32 @jumptable(i32 %a, i32 %b) local_unnamed_addr #0 { +entry: +; CHECK-LABEL: jumptable: +; CHECK: add_slli $r0, $r2, $r0, 2 +; CHECK: lwi $r0, [$r0 + (0)] +; CHECK: jr5 $r0 + switch i32 %a, label %sw.epilog [ + i32 1, label %sw.bb + i32 2, label %return + i32 3, label %sw.bb2 + i32 4, label %sw.bb4 + ] + +sw.bb: ; preds = %entry + %mul = mul nsw i32 %b, %b + br label %return + +sw.bb2: ; preds = %entry + %mul3 = mul nsw i32 %b, 3 + br label %return + +sw.bb4: ; preds = %entry + %mul5 = mul nsw i32 %b, %b + %mul6 = mul nsw i32 %mul5, %b + br label %return + +sw.epilog: ; preds = %entry + br label %return + +return: ; preds = %entry, %sw.epilog, %sw.bb4, %sw.bb2, %sw.bb + %retval.0 = phi i32 [ 0, %sw.epilog ], [ %mul6, %sw.bb4 ], [ %mul3, %sw.bb2 ], [ %mul, %sw.bb ], [ %b, %entry ] + ret i32 %retval.0 +} + +; CHECK: .LJTI0_0: +; CHECK-NEXT: .long .LBB0_2 +; CHECK-NEXT: .long .LBB0_6 +; CHECK-NEXT: .long .LBB0_3 +; CHECK-NEXT: .long .LBB0_4 Index: test/CodeGen/NDS32/lit.local.cfg =================================================================== --- /dev/null +++ test/CodeGen/NDS32/lit.local.cfg @@ -0,0 +1,2 @@ +if not 'NDS32' in config.root.targets: + config.unsupported = True Index: test/CodeGen/NDS32/maddr32.ll =================================================================== --- /dev/null +++ test/CodeGen/NDS32/maddr32.ll @@ -0,0 +1,21 @@ +; RUN: llc < %s | FileCheck %s +target datalayout = "e-m:e-p:32:32-i64:64-a:0:32-n32-S64" +target triple = "nds32le---elf" + +; Function Attrs: norecurse nounwind readnone +define i32 @maddr32(i32 %a, i32 %b, i32 %c) local_unnamed_addr #0 { +entry: + %mul = mul nsw i32 %c, %b + %add = add nsw i32 %mul, %a +; CHECK: maddr32 $r0, $r2, $r1 + ret i32 %add +} + +; Function Attrs: norecurse nounwind readnone +define i32 @msubr32(i32 %a, i32 %b, i32 %c) local_unnamed_addr #0 { +entry: + %mul = mul nsw i32 %c, %b + %sub = sub nsw i32 %a, %mul +; CHECK: msubr32 $r0, $r2, $r1 + ret i32 %sub +} Index: test/CodeGen/NDS32/post_inc.ll =================================================================== --- /dev/null +++ test/CodeGen/NDS32/post_inc.ll @@ -0,0 +1,53 @@ +; RUN: llc < %s | FileCheck %s +target datalayout = "e-m:e-p:32:32-i64:64-a:0:32-n32-S64" +target triple = "nds32le---elf" + +@a = common local_unnamed_addr global [100 x i32] zeroinitializer, align 4 + +; Function Attrs: norecurse nounwind readonly +define i32 @array_sum() local_unnamed_addr #0 { +entry: + br label %for.body + +for.body: ; preds = %entry, %for.body + %sum.07 = phi i32 [ 0, %entry ], [ %add, %for.body ] + %i.06 = phi i32 [ 99, %entry ], [ %sub, %for.body ] + %arrayidx = getelementptr inbounds [100 x i32], [100 x i32]* @a, i32 0, i32 %i.06 + %0 = load i32, i32* %arrayidx, align 4, !tbaa !1 +; CHECK: lwi.bi $r4, [$r2], -4 + %add = add i32 %0, %sum.07 +; CHECK: add333 $r0, $r4, $r0 + %sub = add nsw i32 %i.06, -1 +; CHECK: addi $r1, $r1, -1 + %cmp = icmp sgt i32 %i.06, 1 +; CHECK: slts $r4, $r3, $r1 + br i1 %cmp, label %for.body, label %for.end +; CHECK: bnez38 $r4, .LBB0_1 + +for.end: ; preds = %for.body + ret i32 %add +} + +; Function Attrs: norecurse nounwind readonly +define i32 @main() local_unnamed_addr #0 { +entry: + br label %for.body.i + +for.body.i: ; preds = %for.body.i, %entry + %sum.07.i = phi i32 [ 0, %entry ], [ %add.i, %for.body.i ] + %i.06.i = phi i32 [ 99, %entry ], [ %sub.i, %for.body.i ] + %arrayidx.i = getelementptr inbounds [100 x i32], [100 x i32]* @a, i32 0, i32 %i.06.i + %0 = load i32, i32* %arrayidx.i, align 4, !tbaa !1 + %add.i = add i32 %0, %sum.07.i + %sub.i = add nsw i32 %i.06.i, -1 + %cmp.i = icmp sgt i32 %i.06.i, 1 + br i1 %cmp.i, label %for.body.i, label %array_sum.exit + +array_sum.exit: ; preds = %for.body.i + ret i32 %add.i +} + +!1 = !{!2, !2, i64 0} +!2 = !{!"int", !3, i64 0} +!3 = !{!"omnipotent char", !4, i64 0} +!4 = !{!"Simple C/C++ TBAA"} Index: test/CodeGen/NDS32/post_reg.ll =================================================================== --- /dev/null +++ test/CodeGen/NDS32/post_reg.ll @@ -0,0 +1,34 @@ +; RUN: llc < %s | FileCheck %s +target datalayout = "e-m:e-p:32:32-i64:64-a:0:32-n32-S64" +target triple = "nds32le---elf" + +@a = common local_unnamed_addr global [100000000 x i32] zeroinitializer, align 4 + +; Function Attrs: norecurse nounwind readonly +define i32 @main() local_unnamed_addr #0 { +entry: + br label %for.body + +for.body: ; preds = %entry, %for.body + %sum.08 = phi i32 [ 0, %entry ], [ %add, %for.body ] + %i.07 = phi i32 [ 0, %entry ], [ %add1, %for.body ] + %arrayidx = getelementptr inbounds [100000000 x i32], [100000000 x i32]* @a, i32 0, i32 %i.07 + %0 = load i32, i32* %arrayidx, align 4, !tbaa !1 +; CHECK: lw.bi $r6, [$r1], $r2 + %add = add nsw i32 %0, %sum.08 +; CHECK: add333 $r0, $r6, $r0 + %add1 = add nuw nsw i32 %i.07, 10000000 +; CHECK: add333 $r5, $r5, $r3 + %cmp = icmp slt i32 %add1, 1000000000 +; CHECK: slts $r6, $r5, $r4 + br i1 %cmp, label %for.body, label %for.end +; CHECK: bnez38 $r6, .LBB0_1 + +for.end: ; preds = %for.body + ret i32 %add +} + +!1 = !{!2, !2, i64 0} +!2 = !{!"int", !3, i64 0} +!3 = !{!"omnipotent char", !4, i64 0} +!4 = !{!"Simple C/C++ TBAA"} Index: test/CodeGen/NDS32/va-arg.ll =================================================================== --- /dev/null +++ test/CodeGen/NDS32/va-arg.ll @@ -0,0 +1,63 @@ +; RUN: llc < %s | FileCheck %s +target datalayout = "e-m:e-p:32:32-i64:64-a:0:32-n32-S64" +target triple = "nds32le---elf" + +; Function Attrs: nounwind +define i32 @f(i32 %p0, i32 %p1, i32 %p2, ...) local_unnamed_addr #0 { +entry: +; CHECK-LABEL: f: + %select = alloca i8*, align 4 + %0 = bitcast i8** %select to i8* + call void @llvm.lifetime.start(i64 4, i8* %0) #2 + call void @llvm.va_start(i8* %0) +; CHECK: swi37.sp $r5, [+ (20)] +; CHECK: swi37.sp $r4, [+ (16)] +; CHECK: swi37.sp $r3, [+ (12)] +; CHECK: addi $r0, $sp, 12 +; CHECK: swi37.sp $r0, [+ (4)] +; CHECK: addi333 $r0, $r0, 4 +; CHECK: swi37.sp $r0, [+ (4)] +; CHECK: lwi37.sp $r0, [+ (12)] + %argp.cur = load i8*, i8** %select, align 4 + %argp.next = getelementptr inbounds i8, i8* %argp.cur, i32 4 + store i8* %argp.next, i8** %select, align 4 + %1 = bitcast i8* %argp.cur to i32* + %2 = load i32, i32* %1, align 4 + %cmp = icmp eq i32 %2, 4 + br i1 %cmp, label %if.end, label %if.then + +if.then: ; preds = %entry + call void @abort() #5 + unreachable + +if.end: ; preds = %entry + call void @llvm.va_end(i8* %0) + call void @llvm.lifetime.end(i64 4, i8* %0) #2 + ret i32 undef +} + +; Function Attrs: argmemonly nounwind +declare void @llvm.lifetime.start(i64, i8* nocapture) #1 + +; Function Attrs: nounwind +declare void @llvm.va_start(i8*) #2 + +; Function Attrs: noreturn +declare void @abort() local_unnamed_addr #3 + +; Function Attrs: nounwind +declare void @llvm.va_end(i8*) #2 + +; Function Attrs: argmemonly nounwind +declare void @llvm.lifetime.end(i64, i8* nocapture) #1 + +; Function Attrs: noreturn nounwind +define i32 @main() local_unnamed_addr #4 { +entry: + %call = tail call i32 (i32, i32, i32, ...) @f(i32 undef, i32 undef, i32 undef, i32 4, i32 5) + tail call void @exit(i32 0) #5 + unreachable +} + +; Function Attrs: noreturn +declare void @exit(i32) local_unnamed_addr #3 Index: test/MC/NDS32/elf-reloc.s =================================================================== --- /dev/null +++ test/MC/NDS32/elf-reloc.s @@ -0,0 +1,16 @@ +! RUN: llvm-mc -triple=nds32 -filetype=obj %s -o - | \ +! RUN: llvm-readobj -r | FileCheck -check-prefix=OBJ %s + + sethi $r1, hi20(.L.str) + ori $r1, $r1, lo12(.L.str) + + .section .rodata,"a",%progbits +.L.str: + .asciz "@null\n" + +! OBJ: Relocations [ +! OBJ: Section {{.*}} .rela.text { +! OBJ-NEXT: 0x{{[0-9,A-F]+}} R_NDS32_HI20_RELA .rodata 0x0 +! OBJ-NEXT: 0x{{[0-9,A-F]+}} R_NDS32_LO12S0_RELA .rodata 0x0 +! OBJ: } +! OBJ: ] Index: test/MC/NDS32/lit.local.cfg =================================================================== --- /dev/null +++ test/MC/NDS32/lit.local.cfg @@ -0,0 +1,2 @@ +if not 'NDS32' in config.root.targets: + config.unsupported = True Index: test/MC/NDS32/lmw-smw.s =================================================================== --- /dev/null +++ test/MC/NDS32/lmw-smw.s @@ -0,0 +1,19 @@ +! RUN: llvm-mc -triple nds32 -show-encoding < %s | FileCheck %s +foo: + smw.adm $sp, [$sp], $sp, 2 + smw.adm $r6, [$sp], $r8, 2 + smw.ai $r6, [$sp], $r6, 2 + smw.bi $r7, [$sp], $r9, 10 + lmw.bim $r6, [$sp], $r8, 2 + lmw.bim $sp, [$sp], $sp, 2 + lmw.ai $r6, [$sp], $r6, 2 + lmw.bi $r7, [$sp], $r9, 10 + +! CHECK: smw.adm $sp, [$sp], $sp, 2 ! encoding: [0x3b,0xff,0xfc,0xbc] +! CHECK: smw.adm $r6, [$sp], $r8, 2 ! encoding: [0x3a,0x6f,0xa0,0xbc] +! CHECK: smw.ai $r6, [$sp], $r6, 2 ! encoding: [0x3a,0x6f,0x98,0xb0] +! CHECK: smw.bi $r7, [$sp], $r9, 10 ! encoding: [0x3a,0x7f,0xa6,0xa0] +! CHECK: lmw.bim $r6, [$sp], $r8, 2 ! encoding: [0x3a,0x6f,0xa0,0x84] +! CHECK: lmw.bim $sp, [$sp], $sp, 2 ! encoding: [0x3b,0xff,0xfc,0x84] +! CHECK: lmw.ai $r6, [$sp], $r6, 2 ! encoding: [0x3a,0x6f,0x98,0x90] +! CHECK: lmw.bi $r7, [$sp], $r9, 10 ! encoding: [0x3a,0x7f,0xa6,0x80] Index: test/MC/NDS32/nds32-branches.s =================================================================== --- /dev/null +++ test/MC/NDS32/nds32-branches.s @@ -0,0 +1,33 @@ +! RUN: llvm-mc -triple nds32 -filetype=obj -o %t %s +! RUN: llvm-objdump -d -r -triple nds32 %t | FileCheck %s +foo: + j .LBB0_1 + jal .LBB0_1 + beq $r1, $r0, .LBB0_1 + bne $r1, $r0, .LBB0_1 + bnez $r2, .LBB0_1 + beqz $r2, .LBB0_1 + bgtz $r2, .LBB0_1 + bgez $r2, .LBB0_1 + bltz $r2, .LBB0_1 + blez $r2, .LBB0_1 + beqc $r1, 2, .LBB0_1 + bnec $r1, 2, .LBB0_1 + beqz38 $r2, .LBB0_1 + bnez38 $r2, .LBB0_1 +.LBB0_1: + +! CHECK: 48 00 00 1a j 52 +! CHECK: 49 00 00 18 jal 48 +! CHECK: 4c 10 00 16 beq $r1, $r0, 44 +! CHECK: 4c 10 40 14 bne $r1, $r0, 40 +! CHECK: 4e 23 00 12 bnez $r2, 36 +! CHECK: 4e 22 00 10 beqz $r2, 32 +! CHECK: 4e 26 00 0e bgtz $r2, 28 +! CHECK: 4e 24 00 0c bgez $r2, 24 +! CHECK: 4e 25 00 0a bltz $r2, 20 +! CHECK: 4e 27 00 08 blez $r2, 16 +! CHECK: 5a 10 02 06 beqc $r1, 2, 12 +! CHECK: 5a 18 02 04 bnec $r1, 2, 8 +! CHECK: c2 02 beqz38 $r2, 4 +! CHECK: ca 01 bnez38 $r2, 2 Index: test/MC/NDS32/nds32-memory-instructions.s =================================================================== --- /dev/null +++ test/MC/NDS32/nds32-memory-instructions.s @@ -0,0 +1,70 @@ +! RUN: llvm-mc -triple nds32 -show-encoding < %s | FileCheck %s +foo: + +!------------------------------------------------------------------------------ +! Load instructions +!------------------------------------------------------------------------------ + lwi $r0, [$r1 + 4] + lw $r0, [$r1 + $r2] + lhi $r0, [$r1 + 4] + lh $r0, [$r1 + $r2] + lbi $r0, [$r1 + 4] + lb $r0, [$r1 + $r2] + +! CHECK: lwi $r0, [$r1 + (4)] ! encoding: [0x04,0x00,0x80,0x01] +! CHECK: lw $r0, [$r1 + $r2] ! encoding: [0x38,0x00,0x88,0x02] +! CHECK: lhi $r0, [$r1 + (4)] ! encoding: [0x02,0x00,0x80,0x02] +! CHECK: lh $r0, [$r1 + $r2] ! encoding: [0x38,0x00,0x88,0x01] +! CHECK: lbi $r0, [$r1 + (4)] ! encoding: [0x00,0x00,0x80,0x04] +! CHECK: lb $r0, [$r1 + $r2] ! encoding: [0x38,0x00,0x88,0x00] + +!------------------------------------------------------------------------------ +! Post-indexed Load instructions +!------------------------------------------------------------------------------ + lwi.bi $r0, [$r1], 4 + lw.bi $r0, [$r1], $r2 + lhi.bi $r0, [$r1], 4 + lh.bi $r0, [$r1], $r2 + lbi.bi $r0, [$r1], 4 + lb.bi $r0, [$r1], $r2 + +! CHECK: lwi.bi $r0, [$r1], 4 ! encoding: [0x0c,0x00,0x80,0x01] +! CHECK: lw.bi $r0, [$r1], $r2 ! encoding: [0x38,0x00,0x88,0x06] +! CHECK: lhi.bi $r0, [$r1], 4 ! encoding: [0x0a,0x00,0x80,0x02] +! CHECK: lh.bi $r0, [$r1], $r2 ! encoding: [0x38,0x00,0x88,0x05] +! CHECK: lbi.bi $r0, [$r1], 4 ! encoding: [0x08,0x00,0x80,0x04] +! CHECK: lb.bi $r0, [$r1], $r2 ! encoding: [0x38,0x00,0x88,0x04] + +!------------------------------------------------------------------------------ +! Store instructions +!------------------------------------------------------------------------------ + swi $r0, [$r1 + 4] + sw $r0, [$r1 + $r2] + shi $r0, [$r1 + 4] + sh $r0, [$r1 + $r2] + sbi $r0, [$r1 + 4] + sb $r0, [$r1 + $r2] + +! CHECK: swi $r0, [$r1 + (4)] ! encoding: [0x14,0x00,0x80,0x01] +! CHECK: sw $r0, [$r1 + $r2] ! encoding: [0x38,0x00,0x88,0x0a] +! CHECK: shi $r0, [$r1 + (4)] ! encoding: [0x12,0x00,0x80,0x02] +! CHECK: sh $r0, [$r1 + $r2] ! encoding: [0x38,0x00,0x88,0x09] +! CHECK: sbi $r0, [$r1 + (4)] ! encoding: [0x10,0x00,0x80,0x04] +! CHECK: sb $r0, [$r1 + $r2] ! encoding: [0x38,0x00,0x88,0x08] + +!------------------------------------------------------------------------------ +! Post-indexed Store instructions +!------------------------------------------------------------------------------ + swi.bi $r0, [$r1], 4 + sw.bi $r0, [$r1], $r2 + shi.bi $r0, [$r1], 4 + sh.bi $r0, [$r1], $r2 + sbi.bi $r0, [$r1], 4 + sb.bi $r0, [$r1], $r2 + +! CHECK: swi.bi $r0, [$r1], 4 ! encoding: [0x1c,0x00,0x80,0x01] +! CHECK: sw.bi $r0, [$r1], $r2 ! encoding: [0x38,0x00,0x88,0x0e] +! CHECK: shi.bi $r0, [$r1], 4 ! encoding: [0x1a,0x00,0x80,0x02] +! CHECK: sh.bi $r0, [$r1], $r2 ! encoding: [0x38,0x00,0x88,0x0d] +! CHECK: sbi.bi $r0, [$r1], 4 ! encoding: [0x18,0x00,0x80,0x04] +! CHECK: sb.bi $r0, [$r1], $r2 ! encoding: [0x38,0x00,0x88,0x0c] Index: test/MC/NDS32/reloc-call.s =================================================================== --- /dev/null +++ test/MC/NDS32/reloc-call.s @@ -0,0 +1,11 @@ +! RUN: llvm-mc -triple=nds32 -filetype=obj %s -o - | \ +! RUN: llvm-readobj -r | FileCheck -check-prefix=OBJ %s + .globl bar + .type bar,@function +bar: + jal foo +! OBJ: Relocations [ +! OBJ: Section {{.*}} .rela.text { +! OBJ-NEXT: 0x{{[0-9,A-F]+}} R_NDS32_25_PCREL_RELA foo 0x0 +! OBJ: } +! OBJ: ]