} elseif { [istarget *-*-darwin*] } {
set up_config(start) {
{^_([a-zA-Z_]\S*):$}
- {^LFB[0-9]+:}
+ {^LFS?B[0-9]+:$}
}
} else {
set up_config(start) {{^([a-zA-Z_]\S*):$}}
if { [istarget nvptx*-*-*] } {
set up_config(end) {^\}$}
} elseif { [istarget *-*-darwin*] } {
- set up_config(end) {^LFE[0-9]+}
+ set up_config(end) {^LFE[0-9]+:$}
} elseif { [istarget *-*-mingw32] } {
set up_config(end) {seh_endproc}
} else {
# example).
set up_config(fluff) {^\s*(?://)}
} elseif { [istarget *-*-darwin*] } {
- set up_config(fluff) {^\s*(?:\.|//|@)|^L[0-9ABCESV]}
+ set up_config(fluff) {^\s*(?:\.|//|@|#)|^L[ABCESV]}
} elseif { [istarget s390*-*-*] } {
# Additionally to the defaults skip lines beginning with a # resulting
# from inline asm.
} else {
set up_config(line_prefix) {\t}
}
+
+ # Set up regex lines that should be skipped for a given object format
+ set up_config(skip_regex_cases) ""
+ if { [istarget *-*-darwin*] } {
+ # Darwin already matches .LF* as part of start/end.
+ # Currently, .cfi_xxx instructions are not used.
+ set up_config(skip_regex_cases) {
+ {^\\?\.LF.*$}
+ {^.*\.cfi_.*$}
+ }
+ }
+
+ # Set up regex lines that should be copied verbatim for a given object
+ # format
+ if { [istarget *-*-darwin*] } {
+ # Lines starting with a label, for Darwin we accept ELF local labels
+ # (starting with .L) and Mach-O (starting with L). We also accept
+ # numeric assembler labels.
+ set up_config(verbatim_regex_cases) {
+ {^\\?\.?L\[?[0-9].*:$}
+ {^[0-9]+:.*$}
+ }
+ } else {
+ # Lines starting with a local code label ".L" (which are usually the
+ # only entries on a line - or numeric assembler labels, which are
+ # often followed by some instruction.
+ set up_config(verbatim_regex_cases) {
+ {^\\?\.L}
+ {^[0-9]+:.*$}
+ }
+ }
+
+ set up_config(regex_substitutions) ""
+ if { [istarget *-*-darwin*] } {
+ # Setup substitution pairs for body regexes
+ # the first entry is what should be matched, the second is what should
+ # replace it.
+ set up_config(regex_substitutions) {
+ { {\\?\.LC} {[lL]C} }
+ { {\\?\.L} "L" }
+ }
+ }
+
+}
+
+# Sometimes the function match regex might include directives that are not
+# used by a given binary format. Allow these to be skipped.
+proc target_regex_skip_line { config line } {
+ upvar $config up_config
+ foreach check $up_config(skip_regex_cases) {
+ if { [regexp $check $line] } {
+ return 1
+ }
+ }
+ return 0
+}
+
+# Some regex lines (mostly ones starting with a label) should be copied
+# verbatim (i.e. without prepending config(line_prefix)).
+
+proc target_regex_verbatim_line { config line } {
+ upvar $config up_config
+ foreach check $up_config(verbatim_regex_cases) {
+ if { [regexp $check $line] } {
+ return 1
+ }
+ }
+ return 0
+}
+
+# Apply global substitutions to the function body regex as needed by the
+# target ABI / assembler syntax.
+
+proc target_substitute_func_regex { config func_regex } {
+ upvar $config up_config
+ upvar $func_regex up_func_regex
+ foreach subs $up_config(regex_substitutions) {
+ regsub -all [lindex $subs 0] $up_func_regex [lindex $subs 1] up_func_regex
+ incr item
+ }
}
# Per CONFIG, read assembly file FILENAME and store a mapping from function
set function_name $maybe_function_name
set in_function 1
} elseif { [regexp $up_config(end) $line] } {
- verbose "parse_function_bodies: $function_name:\n$function_body"
+ verbose "parse_function_bodies: found end marker for $function_name:\n$function_body"
set up_result($function_name) $function_body
set in_function 0
} elseif { $up_config(matched) ne "" \
append function_regexp ")"
} elseif { [string equal $line "..."] } {
append function_regexp ".*"
- } elseif { [regexp {^\.L} $line] } {
- append function_regexp $line "\n"
- } elseif { [regexp {^[0-9]+:} $line] } {
- append function_regexp $line "\n"
+ } elseif { [target_regex_skip_line config $line] } {
+ # Drop this line.
+ continue
+ } elseif { [target_regex_verbatim_line config $line] } {
+ # Copy this through.
+ append function_regexp $line "\n"
} else {
+ # Copy but with a prefix (typically \t).
append function_regexp $config(line_prefix) $line "\n"
}
} elseif { [string equal -length $terminator_len $line $terminator] } {
+ # Do any global substitutions the target ABI/asm syntax needs.
+ target_substitute_func_regex config function_regexp
if { ![string equal $selector "N"] } {
if { $xfail_all || [string equal $selector "F"] } {
setup_xfail "*-*-*"