0
@.str = private constant [34 x i8] c"<17 x i15><%i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i, %i>\0A\00", align 1
declare i32 @printf(i8*, ...)

define i32 @main() {
    %a = add <17 x i15> 
             <i15 3, i15 7, i15 11, i15 0, i15 12, i15 14, i15 3, i15 7, i15 11, i15 0, i15 12, i15 14, i15 3, i15 7, i15 11, i15 0, i15 12>, 
             <i15 4, i15 13, i15 15, i15 6, i15 22, i15 18, i15 14, i15 17, i15 12, i15 18, i15 13, i15 11, i15 61, i15 76, i15 -21, i15 15, i15 44>
    %1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i32 0, i32 0), i15 %a0, i15 %a1, i15 %a2, i15 %a3, i15 %a4, i15 %a5, i15 %a6, i15 %a7, i15 %a8, i15 %a9, i15 %a10, i15 %a11, i15 %a12, i15 %a13, i15 %a14, i15 %a15, i15 %a16)
    ret i32 0

}

When I try to run this llvm code, it said "constant expression type mismatch". I don't know the reason for that.

matcha latte
  • 185
  • 1
  • 12

1 Answers1

1

Your string is 80 characters long, so its type is [80 x i8], but you declare it as [34 x i8], causing the type mismatch1. Change the 34 to 80 (also in the places where you use the string) and it should work fine.

1 Which would be a whole lot more obvious if the error message was more specific. Something like "[34 x i8] expected, but [80 x i8] found" would be a major improvement in my book. Ah, well.

sepp2k
  • 363,768
  • 54
  • 674
  • 675