int.carbon 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // TIP: To test this file alone, run:
  7. // TIP: bazel test //toolchain/testing:file_test --test_arg=--file_tests=toolchain/lower/testdata/builtins/int.carbon
  8. // TIP: To dump output, run:
  9. // TIP: bazel run //toolchain/testing:file_test -- --dump_output --file_tests=toolchain/lower/testdata/builtins/int.carbon
  10. // --- basic.carbon
  11. library "[[@TEST_NAME]]";
  12. fn Negate(a: i32) -> i32 = "int.snegate";
  13. fn TestNegate(a: i32) -> i32 { return Negate(a); }
  14. fn Add(a: i32, b: i32) -> i32 = "int.sadd";
  15. fn TestAdd(a: i32, b: i32) -> i32 { return Add(a, b); }
  16. fn Sub(a: i32, b: i32) -> i32 = "int.ssub";
  17. fn TestSub(a: i32, b: i32) -> i32 { return Sub(a, b); }
  18. fn Mul(a: i32, b: i32) -> i32 = "int.smul";
  19. fn TestMul(a: i32, b: i32) -> i32 { return Mul(a, b); }
  20. fn Div(a: i32, b: i32) -> i32 = "int.sdiv";
  21. fn TestDiv(a: i32, b: i32) -> i32 { return Div(a, b); }
  22. fn Mod(a: i32, b: i32) -> i32 = "int.smod";
  23. fn TestMod(a: i32, b: i32) -> i32 { return Mod(a, b); }
  24. fn Complement(a: i32) -> i32 = "int.complement";
  25. fn TestComplement(a: i32) -> i32 { return Complement(a); }
  26. fn And(a: i32, b: i32) -> i32 = "int.and";
  27. fn TestAnd(a: i32, b: i32) -> i32 { return And(a, b); }
  28. fn Or(a: i32, b: i32) -> i32 = "int.or";
  29. fn TestOr(a: i32, b: i32) -> i32 { return Or(a, b); }
  30. fn Xor(a: i32, b: i32) -> i32 = "int.xor";
  31. fn TestXor(a: i32, b: i32) -> i32 { return Xor(a, b); }
  32. fn LeftShift(a: i32, b: i32) -> i32 = "int.left_shift";
  33. fn TestLeftShift(a: i32, b: i32) -> i32 { return LeftShift(a, b); }
  34. fn ArithmeticRightShift(a: i32, b: i32) -> i32 = "int.right_shift";
  35. fn TestArithmeticRightShift(a: i32, b: i32) -> i32 { return ArithmeticRightShift(a, b); }
  36. fn LogicalRightShift(a: u32, b: u32) -> u32 = "int.right_shift";
  37. fn TestLogicalRightShift(a: u32, b: u32) -> u32 { return LogicalRightShift(a, b); }
  38. fn Eq(a: i32, b: i32) -> bool = "int.eq";
  39. fn TestEq(a: i32, b: i32) -> bool { return Eq(a, b); }
  40. fn Neq(a: i32, b: i32) -> bool = "int.neq";
  41. fn TestNeq(a: i32, b: i32) -> bool { return Neq(a, b); }
  42. fn Less(a: i32, b: i32) -> bool = "int.less";
  43. fn TestLess(a: i32, b: i32) -> bool { return Less(a, b); }
  44. fn LessEq(a: i32, b: i32) -> bool = "int.less_eq";
  45. fn TestLessEq(a: i32, b: i32) -> bool { return LessEq(a, b); }
  46. fn Greater(a: i32, b: i32) -> bool = "int.greater";
  47. fn TestGreater(a: i32, b: i32) -> bool { return Greater(a, b); }
  48. fn GreaterEq(a: i32, b: i32) -> bool = "int.greater_eq";
  49. fn TestGreaterEq(a: i32, b: i32) -> bool { return GreaterEq(a, b); }
  50. // --- mixed_shift.carbon
  51. library "[[@TEST_NAME]]";
  52. fn LeftShiftSmaller(a: i32, b: i16) -> i32 = "int.left_shift";
  53. fn TestLeftShiftSmaller(a: i32, b: i16) -> i32 { return LeftShiftSmaller(a, b); }
  54. fn RightShiftSmaller(a: i32, b: i16) -> i32 = "int.right_shift";
  55. fn TestRightShiftSmaller(a: i32, b: i16) -> i32 { return RightShiftSmaller(a, b); }
  56. fn LeftShiftLargerII(a: i16, b: i32) -> i16 = "int.left_shift";
  57. fn TestLeftShiftLargerII(a: i16, b: i32) -> i16 { return LeftShiftLargerII(a, b); }
  58. fn RightShiftLargerII(a: i16, b: i32) -> i16 = "int.right_shift";
  59. fn TestRightShiftLargerII(a: i16, b: i32) -> i16 { return RightShiftLargerII(a, b); }
  60. fn LeftShiftLargerIU(a: i16, b: u32) -> i16 = "int.left_shift";
  61. fn TestLeftShiftLargerIU(a: i16, b: u32) -> i16 { return LeftShiftLargerIU(a, b); }
  62. fn RightShiftLargerIU(a: i16, b: u32) -> i16 = "int.right_shift";
  63. fn TestRightShiftLargerIU(a: i16, b: u32) -> i16 { return RightShiftLargerIU(a, b); }
  64. fn LeftShiftLargerUI(a: u16, b: i32) -> u16 = "int.left_shift";
  65. fn TestLeftShiftLargerUI(a: u16, b: i32) -> u16 { return LeftShiftLargerUI(a, b); }
  66. fn RightShiftLargerUI(a: u16, b: i32) -> u16 = "int.right_shift";
  67. fn TestRightShiftLargerUI(a: u16, b: i32) -> u16 { return RightShiftLargerUI(a, b); }
  68. fn LeftShiftLargerUU(a: u16, b: u32) -> u16 = "int.left_shift";
  69. fn TestLeftShiftLargerUU(a: u16, b: u32) -> u16 { return LeftShiftLargerUU(a, b); }
  70. fn RightShiftLargerUU(a: u16, b: u32) -> u16 = "int.right_shift";
  71. fn TestRightShiftLargerUU(a: u16, b: u32) -> u16 { return RightShiftLargerUU(a, b); }
  72. // --- mixed_compare.carbon
  73. library "[[@TEST_NAME]]";
  74. fn Eq_u16_u32(a: u16, b: u32) -> bool = "int.eq";
  75. fn Eq_i16_u32(a: i16, b: u32) -> bool = "int.eq";
  76. fn Eq_u16_i32(a: u16, b: i32) -> bool = "int.eq";
  77. fn Eq_i16_i32(a: i16, b: i32) -> bool = "int.eq";
  78. fn Eq_i32_u32(a: i32, b: u32) -> bool = "int.eq";
  79. fn TestEq_u16_u32(a: u16, b: u32) -> bool { return Eq_u16_u32(a, b); }
  80. fn TestEq_i16_u32(a: i16, b: u32) -> bool { return Eq_i16_u32(a, b); }
  81. fn TestEq_u16_i32(a: u16, b: i32) -> bool { return Eq_u16_i32(a, b); }
  82. fn TestEq_i16_i32(a: i16, b: i32) -> bool { return Eq_i16_i32(a, b); }
  83. fn TestEq_i32_u32(a: i32, b: u32) -> bool { return Eq_i32_u32(a, b); }
  84. fn Less_u16_u32(a: u16, b: u32) -> bool = "int.less";
  85. fn Less_i16_u32(a: i16, b: u32) -> bool = "int.less";
  86. fn Less_u16_i32(a: u16, b: i32) -> bool = "int.less";
  87. fn Less_i16_i32(a: i16, b: i32) -> bool = "int.less";
  88. fn Less_i32_u32(a: i32, b: u32) -> bool = "int.less";
  89. fn TestLess_u16_u32(a: u16, b: u32) -> bool { return Less_u16_u32(a, b); }
  90. fn TestLess_i16_u32(a: i16, b: u32) -> bool { return Less_i16_u32(a, b); }
  91. fn TestLess_u16_i32(a: u16, b: i32) -> bool { return Less_u16_i32(a, b); }
  92. fn TestLess_i16_i32(a: i16, b: i32) -> bool { return Less_i16_i32(a, b); }
  93. fn TestLess_i32_u32(a: i32, b: u32) -> bool { return Less_i32_u32(a, b); }
  94. // --- convert.carbon
  95. library "[[@TEST_NAME]]";
  96. // Size preserving
  97. fn Int32ToInt32(a: i32) -> i32 = "int.convert";
  98. fn Int32ToUint32(a: i32) -> u32 = "int.convert";
  99. fn Uint32ToInt32(a: u32) -> i32 = "int.convert";
  100. fn Uint32ToUint32(a: u32) -> u32 = "int.convert";
  101. fn TestInt32ToInt32(a: i32) -> i32 { return Int32ToInt32(a); }
  102. fn TestInt32ToUint32(a: i32) -> u32 { return Int32ToUint32(a); }
  103. fn TestUint32ToInt32(a: u32) -> i32 { return Uint32ToInt32(a); }
  104. fn TestUint32ToUint32(a: u32) -> u32 { return Uint32ToUint32(a); }
  105. // Narrowing
  106. fn Int32ToInt16(a: i32) -> i16 = "int.convert";
  107. fn Int32ToUint16(a: i32) -> u16 = "int.convert";
  108. fn Uint32ToInt16(a: u32) -> i16 = "int.convert";
  109. fn Uint32ToUint16(a: u32) -> u16 = "int.convert";
  110. fn TestInt32ToInt16(a: i32) -> i16 { return Int32ToInt16(a); }
  111. fn TestInt32ToUint16(a: i32) -> u16 { return Int32ToUint16(a); }
  112. fn TestUint32ToInt16(a: u32) -> i16 { return Uint32ToInt16(a); }
  113. fn TestUint32ToUint16(a: u32) -> u16 { return Uint32ToUint16(a); }
  114. // Widening
  115. fn Int32ToInt64(a: i32) -> i64 = "int.convert";
  116. fn Int32ToUint64(a: i32) -> u64 = "int.convert";
  117. fn Uint32ToInt64(a: u32) -> i64 = "int.convert";
  118. fn Uint32ToUint64(a: u32) -> u64 = "int.convert";
  119. fn TestInt32ToInt64(a: i32) -> i64 { return Int32ToInt64(a); }
  120. fn TestInt32ToUint64(a: i32) -> u64 { return Int32ToUint64(a); }
  121. fn TestUint32ToInt64(a: u32) -> i64 { return Uint32ToInt64(a); }
  122. fn TestUint32ToUint64(a: u32) -> u64 { return Uint32ToUint64(a); }
  123. // CHECK:STDOUT: ; ModuleID = 'basic.carbon'
  124. // CHECK:STDOUT: source_filename = "basic.carbon"
  125. // CHECK:STDOUT:
  126. // CHECK:STDOUT: define i32 @_CTestNegate.Main(i32 %a) !dbg !4 {
  127. // CHECK:STDOUT: entry:
  128. // CHECK:STDOUT: %int.snegate = sub i32 0, %a, !dbg !7
  129. // CHECK:STDOUT: ret i32 %int.snegate, !dbg !8
  130. // CHECK:STDOUT: }
  131. // CHECK:STDOUT:
  132. // CHECK:STDOUT: define i32 @_CTestAdd.Main(i32 %a, i32 %b) !dbg !9 {
  133. // CHECK:STDOUT: entry:
  134. // CHECK:STDOUT: %int.sadd = add i32 %a, %b, !dbg !10
  135. // CHECK:STDOUT: ret i32 %int.sadd, !dbg !11
  136. // CHECK:STDOUT: }
  137. // CHECK:STDOUT:
  138. // CHECK:STDOUT: define i32 @_CTestSub.Main(i32 %a, i32 %b) !dbg !12 {
  139. // CHECK:STDOUT: entry:
  140. // CHECK:STDOUT: %int.ssub = sub i32 %a, %b, !dbg !13
  141. // CHECK:STDOUT: ret i32 %int.ssub, !dbg !14
  142. // CHECK:STDOUT: }
  143. // CHECK:STDOUT:
  144. // CHECK:STDOUT: define i32 @_CTestMul.Main(i32 %a, i32 %b) !dbg !15 {
  145. // CHECK:STDOUT: entry:
  146. // CHECK:STDOUT: %int.smul = mul i32 %a, %b, !dbg !16
  147. // CHECK:STDOUT: ret i32 %int.smul, !dbg !17
  148. // CHECK:STDOUT: }
  149. // CHECK:STDOUT:
  150. // CHECK:STDOUT: define i32 @_CTestDiv.Main(i32 %a, i32 %b) !dbg !18 {
  151. // CHECK:STDOUT: entry:
  152. // CHECK:STDOUT: %int.sdiv = sdiv i32 %a, %b, !dbg !19
  153. // CHECK:STDOUT: ret i32 %int.sdiv, !dbg !20
  154. // CHECK:STDOUT: }
  155. // CHECK:STDOUT:
  156. // CHECK:STDOUT: define i32 @_CTestMod.Main(i32 %a, i32 %b) !dbg !21 {
  157. // CHECK:STDOUT: entry:
  158. // CHECK:STDOUT: %int.smod = srem i32 %a, %b, !dbg !22
  159. // CHECK:STDOUT: ret i32 %int.smod, !dbg !23
  160. // CHECK:STDOUT: }
  161. // CHECK:STDOUT:
  162. // CHECK:STDOUT: define i32 @_CTestComplement.Main(i32 %a) !dbg !24 {
  163. // CHECK:STDOUT: entry:
  164. // CHECK:STDOUT: %int.complement = xor i32 -1, %a, !dbg !25
  165. // CHECK:STDOUT: ret i32 %int.complement, !dbg !26
  166. // CHECK:STDOUT: }
  167. // CHECK:STDOUT:
  168. // CHECK:STDOUT: define i32 @_CTestAnd.Main(i32 %a, i32 %b) !dbg !27 {
  169. // CHECK:STDOUT: entry:
  170. // CHECK:STDOUT: %int.and = and i32 %a, %b, !dbg !28
  171. // CHECK:STDOUT: ret i32 %int.and, !dbg !29
  172. // CHECK:STDOUT: }
  173. // CHECK:STDOUT:
  174. // CHECK:STDOUT: define i32 @_CTestOr.Main(i32 %a, i32 %b) !dbg !30 {
  175. // CHECK:STDOUT: entry:
  176. // CHECK:STDOUT: %int.or = or i32 %a, %b, !dbg !31
  177. // CHECK:STDOUT: ret i32 %int.or, !dbg !32
  178. // CHECK:STDOUT: }
  179. // CHECK:STDOUT:
  180. // CHECK:STDOUT: define i32 @_CTestXor.Main(i32 %a, i32 %b) !dbg !33 {
  181. // CHECK:STDOUT: entry:
  182. // CHECK:STDOUT: %int.xor = xor i32 %a, %b, !dbg !34
  183. // CHECK:STDOUT: ret i32 %int.xor, !dbg !35
  184. // CHECK:STDOUT: }
  185. // CHECK:STDOUT:
  186. // CHECK:STDOUT: define i32 @_CTestLeftShift.Main(i32 %a, i32 %b) !dbg !36 {
  187. // CHECK:STDOUT: entry:
  188. // CHECK:STDOUT: %int.left_shift = shl i32 %a, %b, !dbg !37
  189. // CHECK:STDOUT: ret i32 %int.left_shift, !dbg !38
  190. // CHECK:STDOUT: }
  191. // CHECK:STDOUT:
  192. // CHECK:STDOUT: define i32 @_CTestArithmeticRightShift.Main(i32 %a, i32 %b) !dbg !39 {
  193. // CHECK:STDOUT: entry:
  194. // CHECK:STDOUT: %int.right_shift = ashr i32 %a, %b, !dbg !40
  195. // CHECK:STDOUT: ret i32 %int.right_shift, !dbg !41
  196. // CHECK:STDOUT: }
  197. // CHECK:STDOUT:
  198. // CHECK:STDOUT: define i32 @_CTestLogicalRightShift.Main(i32 %a, i32 %b) !dbg !42 {
  199. // CHECK:STDOUT: entry:
  200. // CHECK:STDOUT: %int.right_shift = lshr i32 %a, %b, !dbg !43
  201. // CHECK:STDOUT: ret i32 %int.right_shift, !dbg !44
  202. // CHECK:STDOUT: }
  203. // CHECK:STDOUT:
  204. // CHECK:STDOUT: define i1 @_CTestEq.Main(i32 %a, i32 %b) !dbg !45 {
  205. // CHECK:STDOUT: entry:
  206. // CHECK:STDOUT: %int.eq = icmp eq i32 %a, %b, !dbg !46
  207. // CHECK:STDOUT: ret i1 %int.eq, !dbg !47
  208. // CHECK:STDOUT: }
  209. // CHECK:STDOUT:
  210. // CHECK:STDOUT: define i1 @_CTestNeq.Main(i32 %a, i32 %b) !dbg !48 {
  211. // CHECK:STDOUT: entry:
  212. // CHECK:STDOUT: %int.neq = icmp ne i32 %a, %b, !dbg !49
  213. // CHECK:STDOUT: ret i1 %int.neq, !dbg !50
  214. // CHECK:STDOUT: }
  215. // CHECK:STDOUT:
  216. // CHECK:STDOUT: define i1 @_CTestLess.Main(i32 %a, i32 %b) !dbg !51 {
  217. // CHECK:STDOUT: entry:
  218. // CHECK:STDOUT: %int.less = icmp slt i32 %a, %b, !dbg !52
  219. // CHECK:STDOUT: ret i1 %int.less, !dbg !53
  220. // CHECK:STDOUT: }
  221. // CHECK:STDOUT:
  222. // CHECK:STDOUT: define i1 @_CTestLessEq.Main(i32 %a, i32 %b) !dbg !54 {
  223. // CHECK:STDOUT: entry:
  224. // CHECK:STDOUT: %int.less_eq = icmp sle i32 %a, %b, !dbg !55
  225. // CHECK:STDOUT: ret i1 %int.less_eq, !dbg !56
  226. // CHECK:STDOUT: }
  227. // CHECK:STDOUT:
  228. // CHECK:STDOUT: define i1 @_CTestGreater.Main(i32 %a, i32 %b) !dbg !57 {
  229. // CHECK:STDOUT: entry:
  230. // CHECK:STDOUT: %int.greater = icmp sgt i32 %a, %b, !dbg !58
  231. // CHECK:STDOUT: ret i1 %int.greater, !dbg !59
  232. // CHECK:STDOUT: }
  233. // CHECK:STDOUT:
  234. // CHECK:STDOUT: define i1 @_CTestGreaterEq.Main(i32 %a, i32 %b) !dbg !60 {
  235. // CHECK:STDOUT: entry:
  236. // CHECK:STDOUT: %int.greater_eq = icmp sge i32 %a, %b, !dbg !61
  237. // CHECK:STDOUT: ret i1 %int.greater_eq, !dbg !62
  238. // CHECK:STDOUT: }
  239. // CHECK:STDOUT:
  240. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
  241. // CHECK:STDOUT: !llvm.dbg.cu = !{!2}
  242. // CHECK:STDOUT:
  243. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  244. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  245. // CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  246. // CHECK:STDOUT: !3 = !DIFile(filename: "basic.carbon", directory: "")
  247. // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "TestNegate", linkageName: "_CTestNegate.Main", scope: null, file: !3, line: 5, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  248. // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
  249. // CHECK:STDOUT: !6 = !{}
  250. // CHECK:STDOUT: !7 = !DILocation(line: 5, column: 39, scope: !4)
  251. // CHECK:STDOUT: !8 = !DILocation(line: 5, column: 32, scope: !4)
  252. // CHECK:STDOUT: !9 = distinct !DISubprogram(name: "TestAdd", linkageName: "_CTestAdd.Main", scope: null, file: !3, line: 8, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  253. // CHECK:STDOUT: !10 = !DILocation(line: 8, column: 44, scope: !9)
  254. // CHECK:STDOUT: !11 = !DILocation(line: 8, column: 37, scope: !9)
  255. // CHECK:STDOUT: !12 = distinct !DISubprogram(name: "TestSub", linkageName: "_CTestSub.Main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  256. // CHECK:STDOUT: !13 = !DILocation(line: 11, column: 44, scope: !12)
  257. // CHECK:STDOUT: !14 = !DILocation(line: 11, column: 37, scope: !12)
  258. // CHECK:STDOUT: !15 = distinct !DISubprogram(name: "TestMul", linkageName: "_CTestMul.Main", scope: null, file: !3, line: 14, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  259. // CHECK:STDOUT: !16 = !DILocation(line: 14, column: 44, scope: !15)
  260. // CHECK:STDOUT: !17 = !DILocation(line: 14, column: 37, scope: !15)
  261. // CHECK:STDOUT: !18 = distinct !DISubprogram(name: "TestDiv", linkageName: "_CTestDiv.Main", scope: null, file: !3, line: 17, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  262. // CHECK:STDOUT: !19 = !DILocation(line: 17, column: 44, scope: !18)
  263. // CHECK:STDOUT: !20 = !DILocation(line: 17, column: 37, scope: !18)
  264. // CHECK:STDOUT: !21 = distinct !DISubprogram(name: "TestMod", linkageName: "_CTestMod.Main", scope: null, file: !3, line: 20, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  265. // CHECK:STDOUT: !22 = !DILocation(line: 20, column: 44, scope: !21)
  266. // CHECK:STDOUT: !23 = !DILocation(line: 20, column: 37, scope: !21)
  267. // CHECK:STDOUT: !24 = distinct !DISubprogram(name: "TestComplement", linkageName: "_CTestComplement.Main", scope: null, file: !3, line: 23, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  268. // CHECK:STDOUT: !25 = !DILocation(line: 23, column: 43, scope: !24)
  269. // CHECK:STDOUT: !26 = !DILocation(line: 23, column: 36, scope: !24)
  270. // CHECK:STDOUT: !27 = distinct !DISubprogram(name: "TestAnd", linkageName: "_CTestAnd.Main", scope: null, file: !3, line: 26, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  271. // CHECK:STDOUT: !28 = !DILocation(line: 26, column: 44, scope: !27)
  272. // CHECK:STDOUT: !29 = !DILocation(line: 26, column: 37, scope: !27)
  273. // CHECK:STDOUT: !30 = distinct !DISubprogram(name: "TestOr", linkageName: "_CTestOr.Main", scope: null, file: !3, line: 29, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  274. // CHECK:STDOUT: !31 = !DILocation(line: 29, column: 43, scope: !30)
  275. // CHECK:STDOUT: !32 = !DILocation(line: 29, column: 36, scope: !30)
  276. // CHECK:STDOUT: !33 = distinct !DISubprogram(name: "TestXor", linkageName: "_CTestXor.Main", scope: null, file: !3, line: 32, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  277. // CHECK:STDOUT: !34 = !DILocation(line: 32, column: 44, scope: !33)
  278. // CHECK:STDOUT: !35 = !DILocation(line: 32, column: 37, scope: !33)
  279. // CHECK:STDOUT: !36 = distinct !DISubprogram(name: "TestLeftShift", linkageName: "_CTestLeftShift.Main", scope: null, file: !3, line: 35, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  280. // CHECK:STDOUT: !37 = !DILocation(line: 35, column: 50, scope: !36)
  281. // CHECK:STDOUT: !38 = !DILocation(line: 35, column: 43, scope: !36)
  282. // CHECK:STDOUT: !39 = distinct !DISubprogram(name: "TestArithmeticRightShift", linkageName: "_CTestArithmeticRightShift.Main", scope: null, file: !3, line: 38, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  283. // CHECK:STDOUT: !40 = !DILocation(line: 38, column: 61, scope: !39)
  284. // CHECK:STDOUT: !41 = !DILocation(line: 38, column: 54, scope: !39)
  285. // CHECK:STDOUT: !42 = distinct !DISubprogram(name: "TestLogicalRightShift", linkageName: "_CTestLogicalRightShift.Main", scope: null, file: !3, line: 41, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  286. // CHECK:STDOUT: !43 = !DILocation(line: 41, column: 58, scope: !42)
  287. // CHECK:STDOUT: !44 = !DILocation(line: 41, column: 51, scope: !42)
  288. // CHECK:STDOUT: !45 = distinct !DISubprogram(name: "TestEq", linkageName: "_CTestEq.Main", scope: null, file: !3, line: 44, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  289. // CHECK:STDOUT: !46 = !DILocation(line: 44, column: 44, scope: !45)
  290. // CHECK:STDOUT: !47 = !DILocation(line: 44, column: 37, scope: !45)
  291. // CHECK:STDOUT: !48 = distinct !DISubprogram(name: "TestNeq", linkageName: "_CTestNeq.Main", scope: null, file: !3, line: 47, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  292. // CHECK:STDOUT: !49 = !DILocation(line: 47, column: 45, scope: !48)
  293. // CHECK:STDOUT: !50 = !DILocation(line: 47, column: 38, scope: !48)
  294. // CHECK:STDOUT: !51 = distinct !DISubprogram(name: "TestLess", linkageName: "_CTestLess.Main", scope: null, file: !3, line: 50, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  295. // CHECK:STDOUT: !52 = !DILocation(line: 50, column: 46, scope: !51)
  296. // CHECK:STDOUT: !53 = !DILocation(line: 50, column: 39, scope: !51)
  297. // CHECK:STDOUT: !54 = distinct !DISubprogram(name: "TestLessEq", linkageName: "_CTestLessEq.Main", scope: null, file: !3, line: 53, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  298. // CHECK:STDOUT: !55 = !DILocation(line: 53, column: 48, scope: !54)
  299. // CHECK:STDOUT: !56 = !DILocation(line: 53, column: 41, scope: !54)
  300. // CHECK:STDOUT: !57 = distinct !DISubprogram(name: "TestGreater", linkageName: "_CTestGreater.Main", scope: null, file: !3, line: 56, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  301. // CHECK:STDOUT: !58 = !DILocation(line: 56, column: 49, scope: !57)
  302. // CHECK:STDOUT: !59 = !DILocation(line: 56, column: 42, scope: !57)
  303. // CHECK:STDOUT: !60 = distinct !DISubprogram(name: "TestGreaterEq", linkageName: "_CTestGreaterEq.Main", scope: null, file: !3, line: 59, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  304. // CHECK:STDOUT: !61 = !DILocation(line: 59, column: 51, scope: !60)
  305. // CHECK:STDOUT: !62 = !DILocation(line: 59, column: 44, scope: !60)
  306. // CHECK:STDOUT: ; ModuleID = 'mixed_shift.carbon'
  307. // CHECK:STDOUT: source_filename = "mixed_shift.carbon"
  308. // CHECK:STDOUT:
  309. // CHECK:STDOUT: define i32 @_CTestLeftShiftSmaller.Main(i32 %a, i16 %b) !dbg !4 {
  310. // CHECK:STDOUT: entry:
  311. // CHECK:STDOUT: %int.left_shift.rhs = zext i16 %b to i32, !dbg !7
  312. // CHECK:STDOUT: %int.left_shift = shl i32 %a, %int.left_shift.rhs, !dbg !7
  313. // CHECK:STDOUT: ret i32 %int.left_shift, !dbg !8
  314. // CHECK:STDOUT: }
  315. // CHECK:STDOUT:
  316. // CHECK:STDOUT: define i32 @_CTestRightShiftSmaller.Main(i32 %a, i16 %b) !dbg !9 {
  317. // CHECK:STDOUT: entry:
  318. // CHECK:STDOUT: %int.right_shift.rhs = zext i16 %b to i32, !dbg !10
  319. // CHECK:STDOUT: %int.right_shift = ashr i32 %a, %int.right_shift.rhs, !dbg !10
  320. // CHECK:STDOUT: ret i32 %int.right_shift, !dbg !11
  321. // CHECK:STDOUT: }
  322. // CHECK:STDOUT:
  323. // CHECK:STDOUT: define i16 @_CTestLeftShiftLargerII.Main(i16 %a, i32 %b) !dbg !12 {
  324. // CHECK:STDOUT: entry:
  325. // CHECK:STDOUT: %int.left_shift.rhs = trunc i32 %b to i16, !dbg !13
  326. // CHECK:STDOUT: %int.left_shift = shl i16 %a, %int.left_shift.rhs, !dbg !13
  327. // CHECK:STDOUT: ret i16 %int.left_shift, !dbg !14
  328. // CHECK:STDOUT: }
  329. // CHECK:STDOUT:
  330. // CHECK:STDOUT: define i16 @_CTestRightShiftLargerII.Main(i16 %a, i32 %b) !dbg !15 {
  331. // CHECK:STDOUT: entry:
  332. // CHECK:STDOUT: %int.right_shift.rhs = trunc i32 %b to i16, !dbg !16
  333. // CHECK:STDOUT: %int.right_shift = ashr i16 %a, %int.right_shift.rhs, !dbg !16
  334. // CHECK:STDOUT: ret i16 %int.right_shift, !dbg !17
  335. // CHECK:STDOUT: }
  336. // CHECK:STDOUT:
  337. // CHECK:STDOUT: define i16 @_CTestLeftShiftLargerIU.Main(i16 %a, i32 %b) !dbg !18 {
  338. // CHECK:STDOUT: entry:
  339. // CHECK:STDOUT: %int.left_shift.rhs = trunc i32 %b to i16, !dbg !19
  340. // CHECK:STDOUT: %int.left_shift = shl i16 %a, %int.left_shift.rhs, !dbg !19
  341. // CHECK:STDOUT: ret i16 %int.left_shift, !dbg !20
  342. // CHECK:STDOUT: }
  343. // CHECK:STDOUT:
  344. // CHECK:STDOUT: define i16 @_CTestRightShiftLargerIU.Main(i16 %a, i32 %b) !dbg !21 {
  345. // CHECK:STDOUT: entry:
  346. // CHECK:STDOUT: %int.right_shift.rhs = trunc i32 %b to i16, !dbg !22
  347. // CHECK:STDOUT: %int.right_shift = ashr i16 %a, %int.right_shift.rhs, !dbg !22
  348. // CHECK:STDOUT: ret i16 %int.right_shift, !dbg !23
  349. // CHECK:STDOUT: }
  350. // CHECK:STDOUT:
  351. // CHECK:STDOUT: define i16 @_CTestLeftShiftLargerUI.Main(i16 %a, i32 %b) !dbg !24 {
  352. // CHECK:STDOUT: entry:
  353. // CHECK:STDOUT: %int.left_shift.rhs = trunc i32 %b to i16, !dbg !25
  354. // CHECK:STDOUT: %int.left_shift = shl i16 %a, %int.left_shift.rhs, !dbg !25
  355. // CHECK:STDOUT: ret i16 %int.left_shift, !dbg !26
  356. // CHECK:STDOUT: }
  357. // CHECK:STDOUT:
  358. // CHECK:STDOUT: define i16 @_CTestRightShiftLargerUI.Main(i16 %a, i32 %b) !dbg !27 {
  359. // CHECK:STDOUT: entry:
  360. // CHECK:STDOUT: %int.right_shift.rhs = trunc i32 %b to i16, !dbg !28
  361. // CHECK:STDOUT: %int.right_shift = lshr i16 %a, %int.right_shift.rhs, !dbg !28
  362. // CHECK:STDOUT: ret i16 %int.right_shift, !dbg !29
  363. // CHECK:STDOUT: }
  364. // CHECK:STDOUT:
  365. // CHECK:STDOUT: define i16 @_CTestLeftShiftLargerUU.Main(i16 %a, i32 %b) !dbg !30 {
  366. // CHECK:STDOUT: entry:
  367. // CHECK:STDOUT: %int.left_shift.rhs = trunc i32 %b to i16, !dbg !31
  368. // CHECK:STDOUT: %int.left_shift = shl i16 %a, %int.left_shift.rhs, !dbg !31
  369. // CHECK:STDOUT: ret i16 %int.left_shift, !dbg !32
  370. // CHECK:STDOUT: }
  371. // CHECK:STDOUT:
  372. // CHECK:STDOUT: define i16 @_CTestRightShiftLargerUU.Main(i16 %a, i32 %b) !dbg !33 {
  373. // CHECK:STDOUT: entry:
  374. // CHECK:STDOUT: %int.right_shift.rhs = trunc i32 %b to i16, !dbg !34
  375. // CHECK:STDOUT: %int.right_shift = lshr i16 %a, %int.right_shift.rhs, !dbg !34
  376. // CHECK:STDOUT: ret i16 %int.right_shift, !dbg !35
  377. // CHECK:STDOUT: }
  378. // CHECK:STDOUT:
  379. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
  380. // CHECK:STDOUT: !llvm.dbg.cu = !{!2}
  381. // CHECK:STDOUT:
  382. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  383. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  384. // CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  385. // CHECK:STDOUT: !3 = !DIFile(filename: "mixed_shift.carbon", directory: "")
  386. // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "TestLeftShiftSmaller", linkageName: "_CTestLeftShiftSmaller.Main", scope: null, file: !3, line: 5, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  387. // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
  388. // CHECK:STDOUT: !6 = !{}
  389. // CHECK:STDOUT: !7 = !DILocation(line: 5, column: 57, scope: !4)
  390. // CHECK:STDOUT: !8 = !DILocation(line: 5, column: 50, scope: !4)
  391. // CHECK:STDOUT: !9 = distinct !DISubprogram(name: "TestRightShiftSmaller", linkageName: "_CTestRightShiftSmaller.Main", scope: null, file: !3, line: 8, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  392. // CHECK:STDOUT: !10 = !DILocation(line: 8, column: 58, scope: !9)
  393. // CHECK:STDOUT: !11 = !DILocation(line: 8, column: 51, scope: !9)
  394. // CHECK:STDOUT: !12 = distinct !DISubprogram(name: "TestLeftShiftLargerII", linkageName: "_CTestLeftShiftLargerII.Main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  395. // CHECK:STDOUT: !13 = !DILocation(line: 11, column: 58, scope: !12)
  396. // CHECK:STDOUT: !14 = !DILocation(line: 11, column: 51, scope: !12)
  397. // CHECK:STDOUT: !15 = distinct !DISubprogram(name: "TestRightShiftLargerII", linkageName: "_CTestRightShiftLargerII.Main", scope: null, file: !3, line: 14, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  398. // CHECK:STDOUT: !16 = !DILocation(line: 14, column: 59, scope: !15)
  399. // CHECK:STDOUT: !17 = !DILocation(line: 14, column: 52, scope: !15)
  400. // CHECK:STDOUT: !18 = distinct !DISubprogram(name: "TestLeftShiftLargerIU", linkageName: "_CTestLeftShiftLargerIU.Main", scope: null, file: !3, line: 17, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  401. // CHECK:STDOUT: !19 = !DILocation(line: 17, column: 58, scope: !18)
  402. // CHECK:STDOUT: !20 = !DILocation(line: 17, column: 51, scope: !18)
  403. // CHECK:STDOUT: !21 = distinct !DISubprogram(name: "TestRightShiftLargerIU", linkageName: "_CTestRightShiftLargerIU.Main", scope: null, file: !3, line: 20, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  404. // CHECK:STDOUT: !22 = !DILocation(line: 20, column: 59, scope: !21)
  405. // CHECK:STDOUT: !23 = !DILocation(line: 20, column: 52, scope: !21)
  406. // CHECK:STDOUT: !24 = distinct !DISubprogram(name: "TestLeftShiftLargerUI", linkageName: "_CTestLeftShiftLargerUI.Main", scope: null, file: !3, line: 23, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  407. // CHECK:STDOUT: !25 = !DILocation(line: 23, column: 58, scope: !24)
  408. // CHECK:STDOUT: !26 = !DILocation(line: 23, column: 51, scope: !24)
  409. // CHECK:STDOUT: !27 = distinct !DISubprogram(name: "TestRightShiftLargerUI", linkageName: "_CTestRightShiftLargerUI.Main", scope: null, file: !3, line: 26, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  410. // CHECK:STDOUT: !28 = !DILocation(line: 26, column: 59, scope: !27)
  411. // CHECK:STDOUT: !29 = !DILocation(line: 26, column: 52, scope: !27)
  412. // CHECK:STDOUT: !30 = distinct !DISubprogram(name: "TestLeftShiftLargerUU", linkageName: "_CTestLeftShiftLargerUU.Main", scope: null, file: !3, line: 29, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  413. // CHECK:STDOUT: !31 = !DILocation(line: 29, column: 58, scope: !30)
  414. // CHECK:STDOUT: !32 = !DILocation(line: 29, column: 51, scope: !30)
  415. // CHECK:STDOUT: !33 = distinct !DISubprogram(name: "TestRightShiftLargerUU", linkageName: "_CTestRightShiftLargerUU.Main", scope: null, file: !3, line: 32, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  416. // CHECK:STDOUT: !34 = !DILocation(line: 32, column: 59, scope: !33)
  417. // CHECK:STDOUT: !35 = !DILocation(line: 32, column: 52, scope: !33)
  418. // CHECK:STDOUT: ; ModuleID = 'mixed_compare.carbon'
  419. // CHECK:STDOUT: source_filename = "mixed_compare.carbon"
  420. // CHECK:STDOUT:
  421. // CHECK:STDOUT: define i1 @_CTestEq_u16_u32.Main(i16 %a, i32 %b) !dbg !4 {
  422. // CHECK:STDOUT: entry:
  423. // CHECK:STDOUT: %int.eq.lhs = zext i16 %a to i32, !dbg !7
  424. // CHECK:STDOUT: %int.eq = icmp eq i32 %int.eq.lhs, %b, !dbg !7
  425. // CHECK:STDOUT: ret i1 %int.eq, !dbg !8
  426. // CHECK:STDOUT: }
  427. // CHECK:STDOUT:
  428. // CHECK:STDOUT: define i1 @_CTestEq_i16_u32.Main(i16 %a, i32 %b) !dbg !9 {
  429. // CHECK:STDOUT: entry:
  430. // CHECK:STDOUT: %int.eq.lhs = sext i16 %a to i33, !dbg !10
  431. // CHECK:STDOUT: %int.eq.rhs = zext i32 %b to i33, !dbg !10
  432. // CHECK:STDOUT: %int.eq = icmp eq i33 %int.eq.lhs, %int.eq.rhs, !dbg !10
  433. // CHECK:STDOUT: ret i1 %int.eq, !dbg !11
  434. // CHECK:STDOUT: }
  435. // CHECK:STDOUT:
  436. // CHECK:STDOUT: define i1 @_CTestEq_u16_i32.Main(i16 %a, i32 %b) !dbg !12 {
  437. // CHECK:STDOUT: entry:
  438. // CHECK:STDOUT: %int.eq.lhs = zext i16 %a to i32, !dbg !13
  439. // CHECK:STDOUT: %int.eq = icmp eq i32 %int.eq.lhs, %b, !dbg !13
  440. // CHECK:STDOUT: ret i1 %int.eq, !dbg !14
  441. // CHECK:STDOUT: }
  442. // CHECK:STDOUT:
  443. // CHECK:STDOUT: define i1 @_CTestEq_i16_i32.Main(i16 %a, i32 %b) !dbg !15 {
  444. // CHECK:STDOUT: entry:
  445. // CHECK:STDOUT: %int.eq.lhs = sext i16 %a to i32, !dbg !16
  446. // CHECK:STDOUT: %int.eq = icmp eq i32 %int.eq.lhs, %b, !dbg !16
  447. // CHECK:STDOUT: ret i1 %int.eq, !dbg !17
  448. // CHECK:STDOUT: }
  449. // CHECK:STDOUT:
  450. // CHECK:STDOUT: define i1 @_CTestEq_i32_u32.Main(i32 %a, i32 %b) !dbg !18 {
  451. // CHECK:STDOUT: entry:
  452. // CHECK:STDOUT: %int.eq.lhs = sext i32 %a to i33, !dbg !19
  453. // CHECK:STDOUT: %int.eq.rhs = zext i32 %b to i33, !dbg !19
  454. // CHECK:STDOUT: %int.eq = icmp eq i33 %int.eq.lhs, %int.eq.rhs, !dbg !19
  455. // CHECK:STDOUT: ret i1 %int.eq, !dbg !20
  456. // CHECK:STDOUT: }
  457. // CHECK:STDOUT:
  458. // CHECK:STDOUT: define i1 @_CTestLess_u16_u32.Main(i16 %a, i32 %b) !dbg !21 {
  459. // CHECK:STDOUT: entry:
  460. // CHECK:STDOUT: %int.less.lhs = zext i16 %a to i32, !dbg !22
  461. // CHECK:STDOUT: %int.less = icmp ult i32 %int.less.lhs, %b, !dbg !22
  462. // CHECK:STDOUT: ret i1 %int.less, !dbg !23
  463. // CHECK:STDOUT: }
  464. // CHECK:STDOUT:
  465. // CHECK:STDOUT: define i1 @_CTestLess_i16_u32.Main(i16 %a, i32 %b) !dbg !24 {
  466. // CHECK:STDOUT: entry:
  467. // CHECK:STDOUT: %int.less.lhs = sext i16 %a to i33, !dbg !25
  468. // CHECK:STDOUT: %int.less.rhs = zext i32 %b to i33, !dbg !25
  469. // CHECK:STDOUT: %int.less = icmp slt i33 %int.less.lhs, %int.less.rhs, !dbg !25
  470. // CHECK:STDOUT: ret i1 %int.less, !dbg !26
  471. // CHECK:STDOUT: }
  472. // CHECK:STDOUT:
  473. // CHECK:STDOUT: define i1 @_CTestLess_u16_i32.Main(i16 %a, i32 %b) !dbg !27 {
  474. // CHECK:STDOUT: entry:
  475. // CHECK:STDOUT: %int.less.lhs = zext i16 %a to i32, !dbg !28
  476. // CHECK:STDOUT: %int.less = icmp slt i32 %int.less.lhs, %b, !dbg !28
  477. // CHECK:STDOUT: ret i1 %int.less, !dbg !29
  478. // CHECK:STDOUT: }
  479. // CHECK:STDOUT:
  480. // CHECK:STDOUT: define i1 @_CTestLess_i16_i32.Main(i16 %a, i32 %b) !dbg !30 {
  481. // CHECK:STDOUT: entry:
  482. // CHECK:STDOUT: %int.less.lhs = sext i16 %a to i32, !dbg !31
  483. // CHECK:STDOUT: %int.less = icmp slt i32 %int.less.lhs, %b, !dbg !31
  484. // CHECK:STDOUT: ret i1 %int.less, !dbg !32
  485. // CHECK:STDOUT: }
  486. // CHECK:STDOUT:
  487. // CHECK:STDOUT: define i1 @_CTestLess_i32_u32.Main(i32 %a, i32 %b) !dbg !33 {
  488. // CHECK:STDOUT: entry:
  489. // CHECK:STDOUT: %int.less.lhs = sext i32 %a to i33, !dbg !34
  490. // CHECK:STDOUT: %int.less.rhs = zext i32 %b to i33, !dbg !34
  491. // CHECK:STDOUT: %int.less = icmp slt i33 %int.less.lhs, %int.less.rhs, !dbg !34
  492. // CHECK:STDOUT: ret i1 %int.less, !dbg !35
  493. // CHECK:STDOUT: }
  494. // CHECK:STDOUT:
  495. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
  496. // CHECK:STDOUT: !llvm.dbg.cu = !{!2}
  497. // CHECK:STDOUT:
  498. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  499. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  500. // CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  501. // CHECK:STDOUT: !3 = !DIFile(filename: "mixed_compare.carbon", directory: "")
  502. // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "TestEq_u16_u32", linkageName: "_CTestEq_u16_u32.Main", scope: null, file: !3, line: 10, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  503. // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
  504. // CHECK:STDOUT: !6 = !{}
  505. // CHECK:STDOUT: !7 = !DILocation(line: 10, column: 52, scope: !4)
  506. // CHECK:STDOUT: !8 = !DILocation(line: 10, column: 45, scope: !4)
  507. // CHECK:STDOUT: !9 = distinct !DISubprogram(name: "TestEq_i16_u32", linkageName: "_CTestEq_i16_u32.Main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  508. // CHECK:STDOUT: !10 = !DILocation(line: 11, column: 52, scope: !9)
  509. // CHECK:STDOUT: !11 = !DILocation(line: 11, column: 45, scope: !9)
  510. // CHECK:STDOUT: !12 = distinct !DISubprogram(name: "TestEq_u16_i32", linkageName: "_CTestEq_u16_i32.Main", scope: null, file: !3, line: 12, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  511. // CHECK:STDOUT: !13 = !DILocation(line: 12, column: 52, scope: !12)
  512. // CHECK:STDOUT: !14 = !DILocation(line: 12, column: 45, scope: !12)
  513. // CHECK:STDOUT: !15 = distinct !DISubprogram(name: "TestEq_i16_i32", linkageName: "_CTestEq_i16_i32.Main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  514. // CHECK:STDOUT: !16 = !DILocation(line: 13, column: 52, scope: !15)
  515. // CHECK:STDOUT: !17 = !DILocation(line: 13, column: 45, scope: !15)
  516. // CHECK:STDOUT: !18 = distinct !DISubprogram(name: "TestEq_i32_u32", linkageName: "_CTestEq_i32_u32.Main", scope: null, file: !3, line: 14, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  517. // CHECK:STDOUT: !19 = !DILocation(line: 14, column: 52, scope: !18)
  518. // CHECK:STDOUT: !20 = !DILocation(line: 14, column: 45, scope: !18)
  519. // CHECK:STDOUT: !21 = distinct !DISubprogram(name: "TestLess_u16_u32", linkageName: "_CTestLess_u16_u32.Main", scope: null, file: !3, line: 22, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  520. // CHECK:STDOUT: !22 = !DILocation(line: 22, column: 54, scope: !21)
  521. // CHECK:STDOUT: !23 = !DILocation(line: 22, column: 47, scope: !21)
  522. // CHECK:STDOUT: !24 = distinct !DISubprogram(name: "TestLess_i16_u32", linkageName: "_CTestLess_i16_u32.Main", scope: null, file: !3, line: 23, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  523. // CHECK:STDOUT: !25 = !DILocation(line: 23, column: 54, scope: !24)
  524. // CHECK:STDOUT: !26 = !DILocation(line: 23, column: 47, scope: !24)
  525. // CHECK:STDOUT: !27 = distinct !DISubprogram(name: "TestLess_u16_i32", linkageName: "_CTestLess_u16_i32.Main", scope: null, file: !3, line: 24, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  526. // CHECK:STDOUT: !28 = !DILocation(line: 24, column: 54, scope: !27)
  527. // CHECK:STDOUT: !29 = !DILocation(line: 24, column: 47, scope: !27)
  528. // CHECK:STDOUT: !30 = distinct !DISubprogram(name: "TestLess_i16_i32", linkageName: "_CTestLess_i16_i32.Main", scope: null, file: !3, line: 25, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  529. // CHECK:STDOUT: !31 = !DILocation(line: 25, column: 54, scope: !30)
  530. // CHECK:STDOUT: !32 = !DILocation(line: 25, column: 47, scope: !30)
  531. // CHECK:STDOUT: !33 = distinct !DISubprogram(name: "TestLess_i32_u32", linkageName: "_CTestLess_i32_u32.Main", scope: null, file: !3, line: 26, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  532. // CHECK:STDOUT: !34 = !DILocation(line: 26, column: 54, scope: !33)
  533. // CHECK:STDOUT: !35 = !DILocation(line: 26, column: 47, scope: !33)
  534. // CHECK:STDOUT: ; ModuleID = 'convert.carbon'
  535. // CHECK:STDOUT: source_filename = "convert.carbon"
  536. // CHECK:STDOUT:
  537. // CHECK:STDOUT: define i32 @_CTestInt32ToInt32.Main(i32 %a) !dbg !4 {
  538. // CHECK:STDOUT: entry:
  539. // CHECK:STDOUT: ret i32 %a, !dbg !7
  540. // CHECK:STDOUT: }
  541. // CHECK:STDOUT:
  542. // CHECK:STDOUT: define i32 @_CTestInt32ToUint32.Main(i32 %a) !dbg !8 {
  543. // CHECK:STDOUT: entry:
  544. // CHECK:STDOUT: ret i32 %a, !dbg !9
  545. // CHECK:STDOUT: }
  546. // CHECK:STDOUT:
  547. // CHECK:STDOUT: define i32 @_CTestUint32ToInt32.Main(i32 %a) !dbg !10 {
  548. // CHECK:STDOUT: entry:
  549. // CHECK:STDOUT: ret i32 %a, !dbg !11
  550. // CHECK:STDOUT: }
  551. // CHECK:STDOUT:
  552. // CHECK:STDOUT: define i32 @_CTestUint32ToUint32.Main(i32 %a) !dbg !12 {
  553. // CHECK:STDOUT: entry:
  554. // CHECK:STDOUT: ret i32 %a, !dbg !13
  555. // CHECK:STDOUT: }
  556. // CHECK:STDOUT:
  557. // CHECK:STDOUT: define i16 @_CTestInt32ToInt16.Main(i32 %a) !dbg !14 {
  558. // CHECK:STDOUT: entry:
  559. // CHECK:STDOUT: %int.convert = trunc i32 %a to i16, !dbg !15
  560. // CHECK:STDOUT: ret i16 %int.convert, !dbg !16
  561. // CHECK:STDOUT: }
  562. // CHECK:STDOUT:
  563. // CHECK:STDOUT: define i16 @_CTestInt32ToUint16.Main(i32 %a) !dbg !17 {
  564. // CHECK:STDOUT: entry:
  565. // CHECK:STDOUT: %int.convert = trunc i32 %a to i16, !dbg !18
  566. // CHECK:STDOUT: ret i16 %int.convert, !dbg !19
  567. // CHECK:STDOUT: }
  568. // CHECK:STDOUT:
  569. // CHECK:STDOUT: define i16 @_CTestUint32ToInt16.Main(i32 %a) !dbg !20 {
  570. // CHECK:STDOUT: entry:
  571. // CHECK:STDOUT: %int.convert = trunc i32 %a to i16, !dbg !21
  572. // CHECK:STDOUT: ret i16 %int.convert, !dbg !22
  573. // CHECK:STDOUT: }
  574. // CHECK:STDOUT:
  575. // CHECK:STDOUT: define i16 @_CTestUint32ToUint16.Main(i32 %a) !dbg !23 {
  576. // CHECK:STDOUT: entry:
  577. // CHECK:STDOUT: %int.convert = trunc i32 %a to i16, !dbg !24
  578. // CHECK:STDOUT: ret i16 %int.convert, !dbg !25
  579. // CHECK:STDOUT: }
  580. // CHECK:STDOUT:
  581. // CHECK:STDOUT: define i64 @_CTestInt32ToInt64.Main(i32 %a) !dbg !26 {
  582. // CHECK:STDOUT: entry:
  583. // CHECK:STDOUT: %int.convert = sext i32 %a to i64, !dbg !27
  584. // CHECK:STDOUT: ret i64 %int.convert, !dbg !28
  585. // CHECK:STDOUT: }
  586. // CHECK:STDOUT:
  587. // CHECK:STDOUT: define i64 @_CTestInt32ToUint64.Main(i32 %a) !dbg !29 {
  588. // CHECK:STDOUT: entry:
  589. // CHECK:STDOUT: %int.convert = sext i32 %a to i64, !dbg !30
  590. // CHECK:STDOUT: ret i64 %int.convert, !dbg !31
  591. // CHECK:STDOUT: }
  592. // CHECK:STDOUT:
  593. // CHECK:STDOUT: define i64 @_CTestUint32ToInt64.Main(i32 %a) !dbg !32 {
  594. // CHECK:STDOUT: entry:
  595. // CHECK:STDOUT: %int.convert = zext i32 %a to i64, !dbg !33
  596. // CHECK:STDOUT: ret i64 %int.convert, !dbg !34
  597. // CHECK:STDOUT: }
  598. // CHECK:STDOUT:
  599. // CHECK:STDOUT: define i64 @_CTestUint32ToUint64.Main(i32 %a) !dbg !35 {
  600. // CHECK:STDOUT: entry:
  601. // CHECK:STDOUT: %int.convert = zext i32 %a to i64, !dbg !36
  602. // CHECK:STDOUT: ret i64 %int.convert, !dbg !37
  603. // CHECK:STDOUT: }
  604. // CHECK:STDOUT:
  605. // CHECK:STDOUT: !llvm.module.flags = !{!0, !1}
  606. // CHECK:STDOUT: !llvm.dbg.cu = !{!2}
  607. // CHECK:STDOUT:
  608. // CHECK:STDOUT: !0 = !{i32 7, !"Dwarf Version", i32 5}
  609. // CHECK:STDOUT: !1 = !{i32 2, !"Debug Info Version", i32 3}
  610. // CHECK:STDOUT: !2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "carbon", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
  611. // CHECK:STDOUT: !3 = !DIFile(filename: "convert.carbon", directory: "")
  612. // CHECK:STDOUT: !4 = distinct !DISubprogram(name: "TestInt32ToInt32", linkageName: "_CTestInt32ToInt32.Main", scope: null, file: !3, line: 10, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  613. // CHECK:STDOUT: !5 = !DISubroutineType(types: !6)
  614. // CHECK:STDOUT: !6 = !{}
  615. // CHECK:STDOUT: !7 = !DILocation(line: 10, column: 38, scope: !4)
  616. // CHECK:STDOUT: !8 = distinct !DISubprogram(name: "TestInt32ToUint32", linkageName: "_CTestInt32ToUint32.Main", scope: null, file: !3, line: 11, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  617. // CHECK:STDOUT: !9 = !DILocation(line: 11, column: 39, scope: !8)
  618. // CHECK:STDOUT: !10 = distinct !DISubprogram(name: "TestUint32ToInt32", linkageName: "_CTestUint32ToInt32.Main", scope: null, file: !3, line: 12, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  619. // CHECK:STDOUT: !11 = !DILocation(line: 12, column: 39, scope: !10)
  620. // CHECK:STDOUT: !12 = distinct !DISubprogram(name: "TestUint32ToUint32", linkageName: "_CTestUint32ToUint32.Main", scope: null, file: !3, line: 13, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  621. // CHECK:STDOUT: !13 = !DILocation(line: 13, column: 40, scope: !12)
  622. // CHECK:STDOUT: !14 = distinct !DISubprogram(name: "TestInt32ToInt16", linkageName: "_CTestInt32ToInt16.Main", scope: null, file: !3, line: 21, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  623. // CHECK:STDOUT: !15 = !DILocation(line: 21, column: 45, scope: !14)
  624. // CHECK:STDOUT: !16 = !DILocation(line: 21, column: 38, scope: !14)
  625. // CHECK:STDOUT: !17 = distinct !DISubprogram(name: "TestInt32ToUint16", linkageName: "_CTestInt32ToUint16.Main", scope: null, file: !3, line: 22, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  626. // CHECK:STDOUT: !18 = !DILocation(line: 22, column: 46, scope: !17)
  627. // CHECK:STDOUT: !19 = !DILocation(line: 22, column: 39, scope: !17)
  628. // CHECK:STDOUT: !20 = distinct !DISubprogram(name: "TestUint32ToInt16", linkageName: "_CTestUint32ToInt16.Main", scope: null, file: !3, line: 23, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  629. // CHECK:STDOUT: !21 = !DILocation(line: 23, column: 46, scope: !20)
  630. // CHECK:STDOUT: !22 = !DILocation(line: 23, column: 39, scope: !20)
  631. // CHECK:STDOUT: !23 = distinct !DISubprogram(name: "TestUint32ToUint16", linkageName: "_CTestUint32ToUint16.Main", scope: null, file: !3, line: 24, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  632. // CHECK:STDOUT: !24 = !DILocation(line: 24, column: 47, scope: !23)
  633. // CHECK:STDOUT: !25 = !DILocation(line: 24, column: 40, scope: !23)
  634. // CHECK:STDOUT: !26 = distinct !DISubprogram(name: "TestInt32ToInt64", linkageName: "_CTestInt32ToInt64.Main", scope: null, file: !3, line: 32, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  635. // CHECK:STDOUT: !27 = !DILocation(line: 32, column: 45, scope: !26)
  636. // CHECK:STDOUT: !28 = !DILocation(line: 32, column: 38, scope: !26)
  637. // CHECK:STDOUT: !29 = distinct !DISubprogram(name: "TestInt32ToUint64", linkageName: "_CTestInt32ToUint64.Main", scope: null, file: !3, line: 33, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  638. // CHECK:STDOUT: !30 = !DILocation(line: 33, column: 46, scope: !29)
  639. // CHECK:STDOUT: !31 = !DILocation(line: 33, column: 39, scope: !29)
  640. // CHECK:STDOUT: !32 = distinct !DISubprogram(name: "TestUint32ToInt64", linkageName: "_CTestUint32ToInt64.Main", scope: null, file: !3, line: 34, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  641. // CHECK:STDOUT: !33 = !DILocation(line: 34, column: 46, scope: !32)
  642. // CHECK:STDOUT: !34 = !DILocation(line: 34, column: 39, scope: !32)
  643. // CHECK:STDOUT: !35 = distinct !DISubprogram(name: "TestUint32ToUint64", linkageName: "_CTestUint32ToUint64.Main", scope: null, file: !3, line: 35, type: !5, spFlags: DISPFlagDefinition, unit: !2)
  644. // CHECK:STDOUT: !36 = !DILocation(line: 35, column: 47, scope: !35)
  645. // CHECK:STDOUT: !37 = !DILocation(line: 35, column: 40, scope: !35)