mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
inline assembly uses -> instead of return
This commit is contained in:
parent
e21369a153
commit
9ce36ba0cc
4 changed files with 8 additions and 8 deletions
|
|
@ -84,7 +84,7 @@ AsmOutput : token(Colon) list(AsmOutputItem, token(Comma)) option(AsmInput)
|
|||
|
||||
AsmInput : token(Colon) list(AsmInputItem, token(Comma)) option(AsmClobbers)
|
||||
|
||||
AsmOutputItem : token(LBracket) token(Symbol) token(RBracket) token(String) token(LParen) (token(Symbol) | token(Return) Type) token(RParen)
|
||||
AsmOutputItem : token(LBracket) token(Symbol) token(RBracket) token(String) token(LParen) (token(Symbol) | token(Arrow) Type) token(RParen)
|
||||
|
||||
AsmInputItem : token(LBracket) token(Symbol) token(RBracket) token(String) token(LParen) Expression token(RParen)
|
||||
|
||||
|
|
|
|||
|
|
@ -1761,7 +1761,7 @@ static void ast_parse_asm_input_item(ParseContext *pc, int *token_index, AstNode
|
|||
}
|
||||
|
||||
/*
|
||||
AsmOutputItem : token(LBracket) token(Symbol) token(RBracket) token(String) token(LParen) (token(Symbol) | token(Return) Type) token(RParen)
|
||||
AsmOutputItem : token(LBracket) token(Symbol) token(RBracket) token(String) token(LParen) (token(Symbol) | token(Arrow) Type) token(RParen)
|
||||
*/
|
||||
static void ast_parse_asm_output_item(ParseContext *pc, int *token_index, AstNode *node) {
|
||||
ast_eat_token(pc, token_index, TokenIdLBracket);
|
||||
|
|
@ -1778,7 +1778,7 @@ static void ast_parse_asm_output_item(ParseContext *pc, int *token_index, AstNod
|
|||
*token_index += 1;
|
||||
if (token->id == TokenIdSymbol) {
|
||||
ast_buf_from_token(pc, token, &asm_output->variable_name);
|
||||
} else if (token->id == TokenIdKeywordReturn) {
|
||||
} else if (token->id == TokenIdArrow) {
|
||||
asm_output->return_type = ast_parse_type(pc, token_index);
|
||||
} else {
|
||||
ast_invalid_token_error(pc, token);
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ use "std.zig";
|
|||
|
||||
#attribute("naked")
|
||||
export fn _start() -> unreachable {
|
||||
const argc = asm("mov (%%rsp), %[argc]" : [argc] "=r" (return isize));
|
||||
const argv = asm("lea 0x8(%%rsp), %[argv]" : [argv] "=r" (return &&u8));
|
||||
const env = asm("lea 0x10(%%rsp,%%rdi,8), %[env]" : [env] "=r" (return &&u8));
|
||||
const argc = asm("mov (%%rsp), %[argc]" : [argc] "=r" (-> isize));
|
||||
const argv = asm("lea 0x8(%%rsp), %[argv]" : [argv] "=r" (-> &&u8));
|
||||
const env = asm("lea 0x10(%%rsp,%%rdi,8), %[env]" : [env] "=r" (-> &&u8));
|
||||
exit(main(argc, argv, env))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,14 +4,14 @@ const stdout_fileno : isize = 1;
|
|||
|
||||
fn syscall1(number: isize, arg1: isize) -> isize {
|
||||
asm volatile ("syscall"
|
||||
: [ret] "={rax}" (return isize)
|
||||
: [ret] "={rax}" (-> isize)
|
||||
: [number] "{rax}" (number), [arg1] "{rdi}" (arg1)
|
||||
: "rcx", "r11")
|
||||
}
|
||||
|
||||
fn syscall3(number: isize, arg1: isize, arg2: isize, arg3: isize) -> isize {
|
||||
asm volatile ("syscall"
|
||||
: [ret] "={rax}" (return isize)
|
||||
: [ret] "={rax}" (-> isize)
|
||||
: [number] "{rax}" (number), [arg1] "{rdi}" (arg1), [arg2] "{rsi}" (arg2), [arg3] "{rdx}" (arg3)
|
||||
: "rcx", "r11")
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue