about summary refs log tree commit diff
path: root/src/rustllvm/RustWrapper.cpp
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2013-03-12 07:51:54 -0700
committerbors <bors@rust-lang.org>2013-03-12 07:51:54 -0700
commit34aaf350c2c38435a3b20d454b17f8fbbd2a1d8a (patch)
tree080d38a2c80450e956bffb75267deb1a114fed2e /src/rustllvm/RustWrapper.cpp
parent014620af902c4798ede78462b2d0e3b749fb2fff (diff)
parent18b71a78314505b4dd3816f9662709860aafaf4c (diff)
downloadrust-34aaf350c2c38435a3b20d454b17f8fbbd2a1d8a.tar.gz
rust-34aaf350c2c38435a3b20d454b17f8fbbd2a1d8a.zip
auto merge of #5317 : luqmana/rust/inline-asm, r=graydon
```Rust
#[cfg(target_os = "macos")]
fn helloworld() {
    unsafe {
        asm!(".pushsection __RODATA, __rodata
                  msg: .asciz \"Hello World!\"
              .popsection
              movq msg@GOTPCREL(%rip), %rdi
              call _puts");
    }
}

#[cfg(target_os = "linux")]
fn helloworld() {
    unsafe {
        asm!(".pushsection .rodata
                  msg: .asciz \"Hello World!\"
              .popsection
              movq msg@GOTPCREL(%rip), %rdi
              call puts");
    }
}

fn main() {
    helloworld();
}
```

```
% rustc foo.rs
% ./foo
Hello World!
```
Diffstat (limited to 'src/rustllvm/RustWrapper.cpp')
-rw-r--r--src/rustllvm/RustWrapper.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/rustllvm/RustWrapper.cpp b/src/rustllvm/RustWrapper.cpp
index 3af936d3461..7686dcd4ff4 100644
--- a/src/rustllvm/RustWrapper.cpp
+++ b/src/rustllvm/RustWrapper.cpp
@@ -15,6 +15,7 @@
 //
 //===----------------------------------------------------------------------===
 
+#include "llvm/InlineAsm.h"
 #include "llvm/LLVMContext.h"
 #include "llvm/Linker.h"
 #include "llvm/PassManager.h"
@@ -539,3 +540,14 @@ extern "C" void LLVMSetDebug(int Enabled) {
   DebugFlag = Enabled;
 #endif
 }
+
+extern "C" LLVMValueRef LLVMInlineAsm(LLVMTypeRef Ty,
+                                      char *AsmString,
+                                      char *Constraints,
+                                      LLVMBool HasSideEffects,
+                                      LLVMBool IsAlignStack,
+                                      InlineAsm::AsmDialect Dialect) {
+    return wrap(InlineAsm::get(unwrap<FunctionType>(Ty), AsmString,
+                               Constraints, HasSideEffects,
+                               IsAlignStack, Dialect));
+}