/src/test/codegen/global_asm_x2.rs

https://gitlab.com/rust-lang/rust · Rust · 83 lines · 27 code · 8 blank · 48 comment · 0 complexity · 61945c083c739e1fecf38d3ae4abb9e0 MD5 · raw file

  1. // ignore-aarch64
  2. // ignore-aarch64_be
  3. // ignore-arm
  4. // ignore-armeb
  5. // ignore-avr
  6. // ignore-bpfel
  7. // ignore-bpfeb
  8. // ignore-hexagon
  9. // ignore-mips
  10. // ignore-mips64
  11. // ignore-msp430
  12. // ignore-powerpc64
  13. // ignore-powerpc64le
  14. // ignore-powerpc
  15. // ignore-r600
  16. // ignore-amdgcn
  17. // ignore-sparc
  18. // ignore-sparcv9
  19. // ignore-sparcel
  20. // ignore-s390x
  21. // ignore-tce
  22. // ignore-thumb
  23. // ignore-thumbeb
  24. // ignore-xcore
  25. // ignore-nvptx
  26. // ignore-nvptx64
  27. // ignore-le32
  28. // ignore-le64
  29. // ignore-amdil
  30. // ignore-amdil64
  31. // ignore-hsail
  32. // ignore-hsail64
  33. // ignore-spir
  34. // ignore-spir64
  35. // ignore-kalimba
  36. // ignore-shave
  37. // ignore-wasm32
  38. // ignore-wasm64
  39. // ignore-emscripten
  40. // compile-flags: -C no-prepopulate-passes
  41. #![crate_type = "lib"]
  42. #![no_std]
  43. use core::arch::global_asm;
  44. // CHECK-LABEL: foo
  45. // CHECK: module asm
  46. // CHECK: module asm "{{[[:space:]]+}}jmp baz"
  47. // any other global_asm will be appended to this first block, so:
  48. // CHECK-LABEL: bar
  49. // CHECK: module asm "{{[[:space:]]+}}jmp quux"
  50. global_asm!(
  51. r#"
  52. .global foo
  53. foo:
  54. jmp baz
  55. "#
  56. );
  57. extern "C" {
  58. fn foo();
  59. }
  60. // CHECK-LABEL: @baz
  61. #[no_mangle]
  62. pub unsafe extern "C" fn baz() {}
  63. // no checks here; this has been appended to the first occurrence
  64. global_asm!(
  65. r#"
  66. .global bar
  67. bar:
  68. jmp quux
  69. "#
  70. );
  71. extern "C" {
  72. fn bar();
  73. }
  74. #[no_mangle]
  75. pub unsafe extern "C" fn quux() {}