-
Notifications
You must be signed in to change notification settings - Fork 144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inline asm #2982
base: master
Are you sure you want to change the base?
Inline asm #2982
Conversation
5a0f0a9
to
69a06ce
Compare
6012f81
to
5af029d
Compare
gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (struct AsmParseError): title. (enum InlineAsmDirSpec): title. (enum InlineAsmOptions): title. (struct AsmArg): title. (parseAsmArg): title. (parse_global_asm): title. (parse_nonglobal_asm): title. (parse_asm): title. (parseDirSpec): title. (parse_format_string): title. (MacroBuiltin::global_asm_handler): title. (MacroBuiltin::nonglobal_asm_handler): title. * expand/rust-macro-builtins.cc: title. * expand/rust-macro-builtins.h: title.
gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (enum InlineAsmRegOrRegClass): title. (parseAsmArg): title. (check_identifier): title. (parse_operand): title. (parse_options): title. (parse_reg): title. (parseDirSpec): title. (parse_asm): title.
gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parse_clobber_abi): title. (parseAsmArg): title. * expand/rust-macro-builtins-asm.h (parse_clobber_abi): title.
gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parse_options): title.
gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parse_clobber_abi): title.
Finish up on parse_option, formatted parse_clobber_abi gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parse_clobber_abi): format (check_and_set): helper function, is try_set_option equivalent (parse_options): new function * expand/rust-macro-builtins-asm.h (enum InlineAsmOptions): removed (check_and_set): decl of helper function
gcc/rust/ChangeLog: * ast/rust-expr.h: Introduced is_global_asm to InlineAsm AST
gcc/rust/ChangeLog: * ast/rust-expr.h: Make InlineAsm non-abstract for usage in parsing.
Replace scaffolded InlineAsm with real InlineAsm node in rust-expr.h gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parseDirSpec): replace scaffolded InlineAsm with real InlineAsm. (parse_clobber_abi): likewise. (check_and_set): likewise. (parse_options): likewise. (parseAsmArg): likewise. (parse_asm): likewise. * expand/rust-macro-builtins-asm.h (struct AsmParseError): likewise. (enum InlineAsmDirSpec): likewise. (enum InlineAsmRegOrRegClass): likewise. (struct AsmArg): likewise. (parseAsmArg): likewise. (check_and_set): likewise. (parse_operand): likewise. (parse_options): likewise. (parse_reg): likewise. (parse_clobber_abi): likewise.
gcc/testsuite/ChangeLog: * rust/compile/inline_asm_nop.rs: Simple test for asm!
gcc/testsuite/ChangeLog: * rust/compile/inline_asm_ident_first.rs: New test.
gcc/testsuite/ChangeLog: * rust/compile/inline_asm_nop_2.rs: New test.
gcc/testsuite/ChangeLog: * rust/compile/inline_asm_faulty_clobber.rs: New test. * rust/compile/inline_asm_faulty_clobber_1.rs: New test. * rust/compile/inline_asm_faulty_clobber_2.rs: New test.
gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parse_clobber_abi): implemented parse_clobber_abi (parse_format_string): likewise. (parseAsmArg): likewise. (parse_asm): likewise. * expand/rust-macro-builtins-asm.h (parseAsmArg): likewise.
This is without any mutually exclusive options checked, or any relationship with reg_operands. Very primitive. gcc/rust/ChangeLog: * ast/rust-expr.h: parsing of options(...) * expand/rust-macro-builtins-asm.cc (check_and_set): likewise. (parse_options): likewise. (parseAsmArg): likewise. * expand/rust-macro-builtins-asm.h (check_and_set): likewise. gcc/testsuite/ChangeLog: * rust/compile/inline_asm_legal_options.rs: New test.
gcc/testsuite/ChangeLog: * rust/compile/inline_asm_faulty_clobber.rs: Wraps inline_asm tests in unsafe {} * rust/compile/inline_asm_faulty_clobber_1.rs: likewise. * rust/compile/inline_asm_faulty_clobber_2.rs: likewise. * rust/compile/inline_asm_ident_first.rs: likewise. * rust/compile/inline_asm_nop.rs: likewise. * rust/compile/inline_asm_nop_2.rs: likewise.
gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (check_and_set): Add checks for duplicate options in inline asm (parse_options): likewise. gcc/testsuite/ChangeLog: * rust/compile/inline_asm_illegal_options.rs: New test.
gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.h (parseAsmArg): Resolve static decl warning (parse_nonglobal_asm): Resolve static decl warning
gcc/rust/ChangeLog: * ast/rust-expr.h (struct InlineAsmRegOrRegClass): Scaffolding parse_reg * expand/rust-macro-builtins-asm.cc (parse_reg): Likewise. (parse_operand): Likewise. (parseAsmArg): Likewise.
Rename InlineAsmOptions to InlineAsmOption for clarity gcc/rust/ChangeLog: * ast/rust-ast-full-decls.h (enum class): Rename InlineAsmOptions to InlineAsmOption for clarity * ast/rust-expr.h (enum class): Likewise. * expand/rust-macro-builtins-asm.cc (check_and_set): Likewise. (parse_options): Likewise. * expand/rust-macro-builtins-asm.h (check_and_set): Likewise. * hir/tree/rust-hir-expr.h: Likewise.
Safegaurd InlineAsm's clone_expr_... with unreachable since we would never use them. gcc/rust/ChangeLog: * ast/rust-expr.h: Safegaurd InlineAsm's clone_expr_... with unreachable.
gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (MacroBuiltin::global_asm_handler): Remove global_asm and non_global_asm handler (MacroBuiltin::nonglobal_asm_handler): Likewise. (MacroBuiltin::asm_handler): Likewise. * expand/rust-macro-builtins.cc (enum class): Likewise. (inline_asm_maker): Likewise. * expand/rust-macro-builtins.h: Likewise.
gcc/rust/ChangeLog: * ast/rust-expr.h (struct InlineAsmRegOrRegClass): Remove union (struct InlineAsmOperand): Make instances of inside struct. * expand/rust-macro-builtins-asm.cc (parse_clobber_abi): Change signature with inlineAsmCtx. (parse_reg): Likewise. (parse_operand): Likewise. (parse_reg_operand): Likewise. (check_and_set): Likewise. (parse_options): Likewise. (parse_format_string): Likewise. (parseAsmArg): Likewise. (parse_asm): Likewise. * expand/rust-macro-builtins-asm.h (class InlineAsmContext): Likewise. (parseAsmArg): Likewise. (check_and_set): Likewise. (parse_reg_operand): Likewise. (parse_options): Likewise. (parse_reg): Likewise. (parse_clobber_abi): Likewise.
gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parseAsmArg): Renamed parseAsmArg to conform to other function names (parse_asm_arg): Likewise. (parse_asm): Likewise. * expand/rust-macro-builtins-asm.h (parseAsmArg): Likewise. (parse_asm_arg): Likewise.
gcc/rust/ChangeLog: * expand/rust-macro-builtins-asm.cc (parse_reg): Working towards parse_reg and parse_reg_operand (parse_reg_operand): Working towards parse_reg and parse_reg_operand (parse_asm_arg): Add todo about errors * expand/rust-macro-builtins-asm.h (parse_global_asm): remove dead code. (parse_nonglobal_asm): remove dead code.
gcc/rust/ChangeLog: * ast/rust-expr.h (struct AnonConst): Got AST::Fragment to be created from InlineAsm. (struct InlineAsmOperand): Likewise. (class InlineAsm): Likewise. * expand/rust-macro-builtins-asm.cc (parse_reg_operand): Likewise. (parse_asm): likewise
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is great progress :DD well done! a couple nitpicks and things to fix but we can merge this soon
if (!is_global_asm && check_identifier (parser, "in")) | ||
{ | ||
return tl::nullopt; | ||
} | ||
else if (!is_global_asm && check_identifier (parser, "out")) | ||
{ | ||
return tl::nullopt; | ||
} | ||
else if (!is_global_asm && check_identifier (parser, "lateout")) | ||
{ | ||
return tl::nullopt; | ||
} | ||
else if (!is_global_asm && check_identifier (parser, "inout")) | ||
{ | ||
return tl::nullopt; | ||
} | ||
else if (!is_global_asm && check_identifier (parser, "inlateout")) | ||
{ | ||
return tl::nullopt; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might be cleaner if it was turned into an array of strings to check for, and if any matches, return tl::nullopt
. what do we check here exactly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this will eventually construct instances of RegisterOperand class and here i'm just setting up the scaffolding to match rust's asm.rs for easier matching right now. Different lines of code should come out from these if statements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we're checking if the identifier matches each of the name, which stands for dir_spec := "in" / "out" / "lateout" / "inout" / "inlateout"
in the ABNF. i guess it also goes with whether the asm call is global or not too so we also need to check for that
gcc/rust/ChangeLog: * ast/rust-expr.h (struct AnonConst): major refactoring of inline asm, mostly concerns naming convention, trinary conditionals, warnings, adding rust_unreachables in not-yet supported errors. (struct InlineAsmRegOrRegClass): Likewise. (struct InlineAsmOperand): Likewise. * expand/rust-macro-builtins-asm.cc (parse_clobber_abi): Likewise. (parse_reg): Likewise. (parse_operand): Likewise. (parse_reg_operand): Likewise. (check_and_set): Likewise. (parse_options): Likewise. (parse_format_string): Likewise. (parse_asm_arg): Likewise. (parse_asm): Likewise. * expand/rust-macro-builtins-asm.h (parse_asm_arg): Likewise. (check_identifier): Likewise. (check_and_set): Likewise. (parse_operand): Likewise. (parse_reg_operand): Likewise. (parse_options): Likewise. (parse_reg): Likewise. (parse_clobber_abi): Likewise. * expand/rust-macro-builtins.cc (enum class): Likewise. (inline_asm_maker): Likewise. * checks/errors/borrowck/ffi-polonius/Cargo.lock: Removed. Likewise. gcc/testsuite/ChangeLog: * rust/compile/inline_asm_faulty_clobber.rs: Likewise. * rust/compile/inline_asm_faulty_clobber_1.rs: Likewise. * rust/compile/inline_asm_faulty_clobber_2.rs: Likewise. * rust/compile/inline_asm_illegal_options.rs: Likewise.
gcc/testsuite/ChangeLog: * rust/compile/inline_asm_faulty_clobber.rs: compress the test * rust/compile/inline_asm_nop.rs: compress the test * rust/compile/inline_asm_faulty_clobber_1.rs: Removed. * rust/compile/inline_asm_faulty_clobber_2.rs: Removed. * rust/compile/inline_asm_nop_2.rs: Removed.
Draft PR for my mentors