/src/test/codegen/global_asm_x2.rs

https://gitlab.com/jianglu/rust · Rust · 88 lines · 23 code · 8 blank · 57 comment · 0 complexity · b46737cd9a9220316f959e8e14a1ac70 MD5 · raw file

  1. // Copyright 2017 The Rust Project Developers. See the COPYRIGHT
  2. // file at the top-level directory of this distribution and at
  3. // http://rust-lang.org/COPYRIGHT.
  4. //
  5. // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
  6. // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
  7. // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
  8. // option. This file may not be copied, modified, or distributed
  9. // except according to those terms.
  10. // ignore-aarch64
  11. // ignore-aarch64_be
  12. // ignore-arm
  13. // ignore-armeb
  14. // ignore-avr
  15. // ignore-bpfel
  16. // ignore-bpfeb
  17. // ignore-hexagon
  18. // ignore-mips
  19. // ignore-mips64
  20. // ignore-msp430
  21. // ignore-powerpc64
  22. // ignore-powerpc64le
  23. // ignore-powerpc
  24. // ignore-r600
  25. // ignore-amdgcn
  26. // ignore-sparc
  27. // ignore-sparcv9
  28. // ignore-sparcel
  29. // ignore-s390x
  30. // ignore-tce
  31. // ignore-thumb
  32. // ignore-thumbeb
  33. // ignore-xcore
  34. // ignore-nvptx
  35. // ignore-nvptx64
  36. // ignore-le32
  37. // ignore-le64
  38. // ignore-amdil
  39. // ignore-amdil64
  40. // ignore-hsail
  41. // ignore-hsail64
  42. // ignore-spir
  43. // ignore-spir64
  44. // ignore-kalimba
  45. // ignore-shave
  46. // ignore-wasm32
  47. // ignore-wasm64
  48. // ignore-emscripten
  49. // compile-flags: -C no-prepopulate-passes
  50. #![feature(global_asm)]
  51. #![crate_type = "lib"]
  52. #[no_std]
  53. // CHECK-LABEL: foo
  54. // CHECK: module asm
  55. // CHECK: module asm "{{[[:space:]]+}}jmp baz"
  56. // any other global_asm will be appended to this first block, so:
  57. // CHECK-LABEL: bar
  58. // CHECK: module asm "{{[[:space:]]+}}jmp quux"
  59. global_asm!(r#"
  60. .global foo
  61. foo:
  62. jmp baz
  63. "#);
  64. extern "C" {
  65. fn foo();
  66. }
  67. // CHECK-LABEL: @baz
  68. #[no_mangle]
  69. pub unsafe extern "C" fn baz() {}
  70. // no checks here; this has been appended to the first occurrence
  71. global_asm!(r#"
  72. .global bar
  73. bar:
  74. jmp quux
  75. "#);
  76. extern "C" {
  77. fn bar();
  78. }
  79. #[no_mangle]
  80. pub unsafe extern "C" fn quux() {}