diff --git a/external/gpl2/gmake/patches/0000-gmake-nbsd.patch b/external/gpl2/gmake/patches/0000-gmake-nbsd.patch deleted file mode 100644 index cbccd9bb5..000000000 --- a/external/gpl2/gmake/patches/0000-gmake-nbsd.patch +++ /dev/null @@ -1,11980 +0,0 @@ -diff -rNU3 dist.orig/Makefile.in dist/Makefile.in ---- dist.orig/Makefile.in 2006-04-01 08:40:04.000000000 +0200 -+++ dist/Makefile.in 2014-08-18 08:57:25.000000000 +0200 -@@ -330,6 +330,8 @@ - am--refresh: - @: - $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_Makefile.in: - @for dep in $?; do \ - case '$(am__configure_deps)' in \ - *$$dep*) \ -@@ -357,6 +359,8 @@ - $(SHELL) ./config.status --recheck - - $(top_srcdir)/configure: $(am__configure_deps) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_configure: - cd $(srcdir) && $(AUTOCONF) - $(ACLOCAL_M4): $(am__aclocal_m4_deps) - cd $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS) -@@ -371,6 +375,8 @@ - @rm -f stamp-h1 - cd $(top_builddir) && $(SHELL) ./config.status config.h - $(srcdir)/config.h.in: $(am__configure_deps) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_config.h.in: - cd $(top_srcdir) && $(AUTOHEADER) - rm -f stamp-h1 - touch $@ -diff -rNU3 dist.orig/ansi2knr.c dist/ansi2knr.c ---- dist.orig/ansi2knr.c 2006-04-01 08:40:04.000000000 +0200 -+++ dist/ansi2knr.c 2014-08-18 08:46:57.000000000 +0200 -@@ -1,6 +1,6 @@ - /* Copyright (C) 1989, 2000 Aladdin Enterprises. All rights reserved. */ - --/*$Id: ansi2knr.c,v 1.3 2000/04/13 03:41:48 lpd Exp $*/ -+/*$Id: ansi2knr.c,v 1.1.1.1 2014/08/18 06:46:57 christos Exp $*/ - /* Convert ANSI C function definitions to K&R ("traditional C") syntax */ - - /* -diff -rNU3 dist.orig/config/config.guess dist/config/config.guess ---- dist.orig/config/config.guess 2006-04-01 08:41:00.000000000 +0200 -+++ dist/config/config.guess 2014-08-18 09:12:47.000000000 +0200 -@@ -939,6 +939,9 @@ - sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit ;; -+ tile*:Linux:*:*) -+ echo ${UNAME_MACHINE}-unknown-linux-gnu -+ exit 0 ;; - vax:Linux:*:*) - echo ${UNAME_MACHINE}-dec-linux-gnu - exit ;; -diff -rNU3 dist.orig/configure.in dist/configure.in ---- dist.orig/configure.in 2006-04-01 08:36:40.000000000 +0200 -+++ dist/configure.in 2014-08-18 08:46:47.000000000 +0200 -@@ -19,7 +19,7 @@ - AC_INIT([GNU make],[3.81],[bug-make@gnu.org]) - - AC_PREREQ(2.59) --AC_REVISION([[$Id: configure.in,v 1.142 2006/04/01 06:36:40 psmith Exp $]]) -+AC_REVISION([[$Id: configure.in,v 1.1.1.1 2014/08/18 06:46:47 christos Exp $]]) - - # Autoconf setup - AC_CONFIG_AUX_DIR(config) -diff -rNU3 dist.orig/doc/make.info dist/doc/make.info ---- dist.orig/doc/make.info 2006-04-01 08:41:04.000000000 +0200 -+++ dist/doc/make.info 1970-01-01 01:00:00.000000000 +0100 -@@ -1,184 +0,0 @@ --This is make.info, produced by makeinfo version 4.8 from make.texi. -- -- This file documents the GNU `make' utility, which determines --automatically which pieces of a large program need to be recompiled, --and issues the commands to recompile them. -- -- This is Edition 0.70, last updated 1 April 2006, of `The GNU Make --Manual', for GNU `make' version 3.81. -- -- Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, --1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006 Free Software --Foundation, Inc. -- -- Permission is granted to copy, distribute and/or modify this -- document under the terms of the GNU Free Documentation License, -- Version 1.2 or any later version published by the Free Software -- Foundation; with no Invariant Sections, with the Front-Cover Texts -- being "A GNU Manual," and with the Back-Cover Texts as in (a) -- below. A copy of the license is included in the section entitled -- "GNU Free Documentation License." -- -- (a) The FSF's Back-Cover Text is: "You have freedom to copy and -- modify this GNU Manual, like GNU software. Copies published by -- the Free Software Foundation raise funds for GNU development." -- --INFO-DIR-SECTION GNU Packages --START-INFO-DIR-ENTRY --* Make: (make). Remake files automatically. --END-INFO-DIR-ENTRY -- -- --Indirect: --make.info-1: 1297 --make.info-2: 301265 -- --Tag Table: --(Indirect) --Node: Top1297 --Node: Overview14702 --Node: Preparing15712 --Node: Reading16684 --Node: Bugs17611 --Node: Introduction19441 --Node: Rule Introduction21033 --Node: Simple Makefile22777 --Node: How Make Works26406 --Node: Variables Simplify29061 --Node: make Deduces31267 --Node: Combine By Prerequisite33007 --Node: Cleanup34036 --Node: Makefiles35455 --Node: Makefile Contents36421 --Node: Makefile Names39376 --Node: Include40987 --Ref: Include-Footnote-144619 --Node: MAKEFILES Variable44753 --Node: MAKEFILE_LIST Variable46263 --Node: Special Variables47531 --Node: Remaking Makefiles51038 --Node: Overriding Makefiles55287 --Node: Reading Makefiles57340 --Node: Secondary Expansion60244 --Node: Rules67678 --Node: Rule Example70350 --Node: Rule Syntax71207 --Node: Prerequisite Types73710 --Node: Wildcards75486 --Node: Wildcard Examples77204 --Node: Wildcard Pitfall78460 --Node: Wildcard Function80249 --Node: Directory Search82033 --Node: General Search83175 --Node: Selective Search84890 --Node: Search Algorithm87878 --Node: Commands/Search90397 --Node: Implicit/Search91743 --Node: Libraries/Search92687 --Node: Phony Targets94779 --Node: Force Targets99865 --Node: Empty Targets100910 --Node: Special Targets102208 --Node: Multiple Targets109382 --Node: Multiple Rules111257 --Node: Static Pattern113493 --Node: Static Usage114145 --Node: Static versus Implicit117866 --Node: Double-Colon119610 --Node: Automatic Prerequisites121267 --Node: Commands125545 --Node: Command Syntax126753 --Node: Splitting Lines128778 --Node: Variables in Commands131759 --Node: Echoing133086 --Node: Execution134378 --Ref: Execution-Footnote-1135629 --Node: Choosing the Shell135775 --Node: Parallel139744 --Node: Errors143337 --Node: Interrupts146983 --Node: Recursion148570 --Node: MAKE Variable150664 --Node: Variables/Recursion152931 --Node: Options/Recursion158372 --Node: -w Option163537 --Node: Sequences164532 --Node: Empty Commands167544 --Node: Using Variables168718 --Node: Reference171831 --Node: Flavors173390 --Node: Advanced179128 --Node: Substitution Refs179633 --Node: Computed Names181186 --Node: Values185730 --Node: Setting186643 --Node: Appending188679 --Node: Override Directive192605 --Node: Defining193989 --Node: Environment196453 --Node: Target-specific198702 --Node: Pattern-specific201669 --Node: Conditionals203071 --Node: Conditional Example203781 --Node: Conditional Syntax206358 --Node: Testing Flags212083 --Node: Functions213185 --Node: Syntax of Functions214605 --Node: Text Functions216804 --Node: File Name Functions225375 --Node: Conditional Functions230597 --Node: Foreach Function232971 --Node: Call Function236183 --Node: Value Function239068 --Node: Eval Function240505 --Node: Origin Function242779 --Node: Flavor Function245997 --Node: Shell Function247063 --Node: Make Control Functions248697 --Node: Running250366 --Node: Makefile Arguments252355 --Node: Goals253071 --Node: Instead of Execution257812 --Node: Avoiding Compilation261098 --Node: Overriding263073 --Node: Testing265371 --Node: Options Summary267256 --Node: Implicit Rules277382 --Node: Using Implicit279530 --Node: Catalogue of Rules283069 --Node: Implicit Variables292419 --Node: Chained Rules297254 --Node: Pattern Rules301265 --Node: Pattern Intro302801 --Node: Pattern Examples305698 --Node: Automatic Variables307507 --Node: Pattern Match314878 --Node: Match-Anything Rules316514 --Node: Canceling Rules320389 --Node: Last Resort321105 --Node: Suffix Rules322952 --Node: Implicit Rule Search326681 --Node: Archives330200 --Node: Archive Members330898 --Node: Archive Update332511 --Node: Archive Symbols334425 --Node: Archive Pitfalls335659 --Node: Archive Suffix Rules336382 --Node: Features337929 --Node: Missing346484 --Node: Makefile Conventions350222 --Node: Makefile Basics351008 --Node: Utilities in Makefiles354175 --Node: Command Variables356313 --Node: Directory Variables359883 --Node: Standard Targets374023 --Ref: Standard Targets-Footnote-1387142 --Node: Install Command Categories387242 --Node: Quick Reference391768 --Node: Error Messages402464 --Node: Complex Makefile410154 --Node: GNU Free Documentation License418872 --Node: Concept Index441321 --Node: Name Index506510 -- --End Tag Table -diff -rNU3 dist.orig/doc/make.info-1 dist/doc/make.info-1 ---- dist.orig/doc/make.info-1 2006-04-01 08:41:04.000000000 +0200 -+++ dist/doc/make.info-1 1970-01-01 01:00:00.000000000 +0100 -@@ -1,7261 +0,0 @@ --This is make.info, produced by makeinfo version 4.8 from make.texi. -- -- This file documents the GNU `make' utility, which determines --automatically which pieces of a large program need to be recompiled, --and issues the commands to recompile them. -- -- This is Edition 0.70, last updated 1 April 2006, of `The GNU Make --Manual', for GNU `make' version 3.81. -- -- Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, --1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006 Free Software --Foundation, Inc. -- -- Permission is granted to copy, distribute and/or modify this -- document under the terms of the GNU Free Documentation License, -- Version 1.2 or any later version published by the Free Software -- Foundation; with no Invariant Sections, with the Front-Cover Texts -- being "A GNU Manual," and with the Back-Cover Texts as in (a) -- below. A copy of the license is included in the section entitled -- "GNU Free Documentation License." -- -- (a) The FSF's Back-Cover Text is: "You have freedom to copy and -- modify this GNU Manual, like GNU software. Copies published by -- the Free Software Foundation raise funds for GNU development." -- --INFO-DIR-SECTION GNU Packages --START-INFO-DIR-ENTRY --* Make: (make). Remake files automatically. --END-INFO-DIR-ENTRY -- -- --File: make.info, Node: Top, Next: Overview, Prev: (dir), Up: (dir) -- --GNU `make' --********** -- --This file documents the GNU `make' utility, which determines --automatically which pieces of a large program need to be recompiled, --and issues the commands to recompile them. -- -- This is Edition 0.70, last updated 1 April 2006, of `The GNU Make --Manual', for GNU `make' version 3.81. -- -- Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, --1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006 Free Software --Foundation, Inc. -- -- Permission is granted to copy, distribute and/or modify this -- document under the terms of the GNU Free Documentation License, -- Version 1.2 or any later version published by the Free Software -- Foundation; with no Invariant Sections, with the Front-Cover Texts -- being "A GNU Manual," and with the Back-Cover Texts as in (a) -- below. A copy of the license is included in the section entitled -- "GNU Free Documentation License." -- -- (a) The FSF's Back-Cover Text is: "You have freedom to copy and -- modify this GNU Manual, like GNU software. Copies published by -- the Free Software Foundation raise funds for GNU development." -- --* Menu: -- --* Overview:: Overview of `make'. --* Introduction:: An introduction to `make'. --* Makefiles:: Makefiles tell `make' what to do. --* Rules:: Rules describe when a file must be remade. --* Commands:: Commands say how to remake a file. --* Using Variables:: You can use variables to avoid repetition. --* Conditionals:: Use or ignore parts of the makefile based -- on the values of variables. --* Functions:: Many powerful ways to manipulate text. --* Invoking make: Running. How to invoke `make' on the command line. --* Implicit Rules:: Use implicit rules to treat many files alike, -- based on their file names. --* Archives:: How `make' can update library archives. --* Features:: Features GNU `make' has over other `make's. --* Missing:: What GNU `make' lacks from other `make's. --* Makefile Conventions:: Conventions for writing makefiles for -- GNU programs. --* Quick Reference:: A quick reference for experienced users. --* Error Messages:: A list of common errors generated by `make'. --* Complex Makefile:: A real example of a straightforward, -- but nontrivial, makefile. -- --* GNU Free Documentation License:: License for copying this manual --* Concept Index:: Index of Concepts --* Name Index:: Index of Functions, Variables, & Directives -- -- --- The Detailed Node Listing --- -- --Overview of `make' -- --* Preparing:: Preparing and Running Make --* Reading:: On Reading this Text --* Bugs:: Problems and Bugs -- --An Introduction to Makefiles -- --* Rule Introduction:: What a rule looks like. --* Simple Makefile:: A Simple Makefile --* How Make Works:: How `make' Processes This Makefile --* Variables Simplify:: Variables Make Makefiles Simpler --* make Deduces:: Letting `make' Deduce the Commands --* Combine By Prerequisite:: Another Style of Makefile --* Cleanup:: Rules for Cleaning the Directory -- --Writing Makefiles -- --* Makefile Contents:: What makefiles contain. --* Makefile Names:: How to name your makefile. --* Include:: How one makefile can use another makefile. --* MAKEFILES Variable:: The environment can specify extra makefiles. --* MAKEFILE_LIST Variable:: Discover which makefiles have been read. --* Special Variables:: Other special variables. --* Remaking Makefiles:: How makefiles get remade. --* Overriding Makefiles:: How to override part of one makefile -- with another makefile. --* Reading Makefiles:: How makefiles are parsed. --* Secondary Expansion:: How and when secondary expansion is performed. -- --Writing Rules -- --* Rule Example:: An example explained. --* Rule Syntax:: General syntax explained. --* Prerequisite Types:: There are two types of prerequisites. --* Wildcards:: Using wildcard characters such as `*'. --* Directory Search:: Searching other directories for source files. --* Phony Targets:: Using a target that is not a real file's name. --* Force Targets:: You can use a target without commands -- or prerequisites to mark other targets -- as phony. --* Empty Targets:: When only the date matters and the -- files are empty. --* Special Targets:: Targets with special built-in meanings. --* Multiple Targets:: When to make use of several targets in a rule. --* Multiple Rules:: How to use several rules with the same target. --* Static Pattern:: Static pattern rules apply to multiple targets -- and can vary the prerequisites according to -- the target name. --* Double-Colon:: How to use a special kind of rule to allow -- several independent rules for one target. --* Automatic Prerequisites:: How to automatically generate rules giving -- prerequisites from source files themselves. -- --Using Wildcard Characters in File Names -- --* Wildcard Examples:: Several examples --* Wildcard Pitfall:: Problems to avoid. --* Wildcard Function:: How to cause wildcard expansion where -- it does not normally take place. -- --Searching Directories for Prerequisites -- --* General Search:: Specifying a search path that applies -- to every prerequisite. --* Selective Search:: Specifying a search path -- for a specified class of names. --* Search Algorithm:: When and how search paths are applied. --* Commands/Search:: How to write shell commands that work together -- with search paths. --* Implicit/Search:: How search paths affect implicit rules. --* Libraries/Search:: Directory search for link libraries. -- --Static Pattern Rules -- --* Static Usage:: The syntax of static pattern rules. --* Static versus Implicit:: When are they better than implicit rules? -- --Writing the Commands in Rules -- --* Command Syntax:: Command syntax features and pitfalls. --* Echoing:: How to control when commands are echoed. --* Execution:: How commands are executed. --* Parallel:: How commands can be executed in parallel. --* Errors:: What happens after a command execution error. --* Interrupts:: What happens when a command is interrupted. --* Recursion:: Invoking `make' from makefiles. --* Sequences:: Defining canned sequences of commands. --* Empty Commands:: Defining useful, do-nothing commands. -- --Command Syntax -- --* Splitting Lines:: Breaking long command lines for readability. --* Variables in Commands:: Using `make' variables in commands. -- --Command Execution -- --* Choosing the Shell:: How `make' chooses the shell used -- to run commands. -- --Recursive Use of `make' -- --* MAKE Variable:: The special effects of using `$(MAKE)'. --* Variables/Recursion:: How to communicate variables to a sub-`make'. --* Options/Recursion:: How to communicate options to a sub-`make'. --* -w Option:: How the `-w' or `--print-directory' option -- helps debug use of recursive `make' commands. -- --How to Use Variables -- --* Reference:: How to use the value of a variable. --* Flavors:: Variables come in two flavors. --* Advanced:: Advanced features for referencing a variable. --* Values:: All the ways variables get their values. --* Setting:: How to set a variable in the makefile. --* Appending:: How to append more text to the old value -- of a variable. --* Override Directive:: How to set a variable in the makefile even if -- the user has set it with a command argument. --* Defining:: An alternate way to set a variable -- to a verbatim string. --* Environment:: Variable values can come from the environment. --* Target-specific:: Variable values can be defined on a per-target -- basis. --* Pattern-specific:: Target-specific variable values can be applied -- to a group of targets that match a pattern. -- --Advanced Features for Reference to Variables -- --* Substitution Refs:: Referencing a variable with -- substitutions on the value. --* Computed Names:: Computing the name of the variable to refer to. -- --Conditional Parts of Makefiles -- --* Conditional Example:: Example of a conditional --* Conditional Syntax:: The syntax of conditionals. --* Testing Flags:: Conditionals that test flags. -- --Functions for Transforming Text -- --* Syntax of Functions:: How to write a function call. --* Text Functions:: General-purpose text manipulation functions. --* File Name Functions:: Functions for manipulating file names. --* Conditional Functions:: Functions that implement conditions. --* Foreach Function:: Repeat some text with controlled variation. --* Call Function:: Expand a user-defined function. --* Value Function:: Return the un-expanded value of a variable. --* Eval Function:: Evaluate the arguments as makefile syntax. --* Origin Function:: Find where a variable got its value. --* Flavor Function:: Find out the flavor of a variable. --* Shell Function:: Substitute the output of a shell command. --* Make Control Functions:: Functions that control how make runs. -- --How to Run `make' -- --* Makefile Arguments:: How to specify which makefile to use. --* Goals:: How to use goal arguments to specify which -- parts of the makefile to use. --* Instead of Execution:: How to use mode flags to specify what -- kind of thing to do with the commands -- in the makefile other than simply -- execute them. --* Avoiding Compilation:: How to avoid recompiling certain files. --* Overriding:: How to override a variable to specify -- an alternate compiler and other things. --* Testing:: How to proceed past some errors, to -- test compilation. --* Options Summary:: Summary of Options -- --Using Implicit Rules -- --* Using Implicit:: How to use an existing implicit rule -- to get the commands for updating a file. --* Catalogue of Rules:: A list of built-in implicit rules. --* Implicit Variables:: How to change what predefined rules do. --* Chained Rules:: How to use a chain of implicit rules. --* Pattern Rules:: How to define new implicit rules. --* Last Resort:: How to define commands for rules which -- cannot find any. --* Suffix Rules:: The old-fashioned style of implicit rule. --* Implicit Rule Search:: The precise algorithm for applying -- implicit rules. -- --Defining and Redefining Pattern Rules -- --* Pattern Intro:: An introduction to pattern rules. --* Pattern Examples:: Examples of pattern rules. --* Automatic Variables:: How to use automatic variables in the -- commands of implicit rules. --* Pattern Match:: How patterns match. --* Match-Anything Rules:: Precautions you should take prior to -- defining rules that can match any -- target file whatever. --* Canceling Rules:: How to override or cancel built-in rules. -- --Using `make' to Update Archive Files -- --* Archive Members:: Archive members as targets. --* Archive Update:: The implicit rule for archive member targets. --* Archive Pitfalls:: Dangers to watch out for when using archives. --* Archive Suffix Rules:: You can write a special kind of suffix rule -- for updating archives. -- --Implicit Rule for Archive Member Targets -- --* Archive Symbols:: How to update archive symbol directories. -- -- --File: make.info, Node: Overview, Next: Introduction, Prev: Top, Up: Top -- --1 Overview of `make' --******************** -- --The `make' utility automatically determines which pieces of a large --program need to be recompiled, and issues commands to recompile them. --This manual describes GNU `make', which was implemented by Richard --Stallman and Roland McGrath. Development since Version 3.76 has been --handled by Paul D. Smith. -- -- GNU `make' conforms to section 6.2 of `IEEE Standard 1003.2-1992' --(POSIX.2). -- -- Our examples show C programs, since they are most common, but you --can use `make' with any programming language whose compiler can be run --with a shell command. Indeed, `make' is not limited to programs. You --can use it to describe any task where some files must be updated --automatically from others whenever the others change. -- --* Menu: -- --* Preparing:: Preparing and Running Make --* Reading:: On Reading this Text --* Bugs:: Problems and Bugs -- -- --File: make.info, Node: Preparing, Next: Reading, Prev: Overview, Up: Overview -- --Preparing and Running Make --========================== -- -- To prepare to use `make', you must write a file called the --"makefile" that describes the relationships among files in your program --and provides commands for updating each file. In a program, typically, --the executable file is updated from object files, which are in turn --made by compiling source files. -- -- Once a suitable makefile exists, each time you change some source --files, this simple shell command: -- -- make -- --suffices to perform all necessary recompilations. The `make' program --uses the makefile data base and the last-modification times of the --files to decide which of the files need to be updated. For each of --those files, it issues the commands recorded in the data base. -- -- You can provide command line arguments to `make' to control which --files should be recompiled, or how. *Note How to Run `make': Running. -- -- --File: make.info, Node: Reading, Next: Bugs, Prev: Preparing, Up: Overview -- --1.1 How to Read This Manual --=========================== -- --If you are new to `make', or are looking for a general introduction, --read the first few sections of each chapter, skipping the later --sections. In each chapter, the first few sections contain introductory --or general information and the later sections contain specialized or --technical information. The exception is the second chapter, *Note An --Introduction to Makefiles: Introduction, all of which is introductory. -- -- If you are familiar with other `make' programs, see *Note Features --of GNU `make': Features, which lists the enhancements GNU `make' has, --and *Note Incompatibilities and Missing Features: Missing, which --explains the few things GNU `make' lacks that others have. -- -- For a quick summary, see *Note Options Summary::, *Note Quick --Reference::, and *Note Special Targets::. -- -- --File: make.info, Node: Bugs, Prev: Reading, Up: Overview -- --1.2 Problems and Bugs --===================== -- --If you have problems with GNU `make' or think you've found a bug, --please report it to the developers; we cannot promise to do anything but --we might well want to fix it. -- -- Before reporting a bug, make sure you've actually found a real bug. --Carefully reread the documentation and see if it really says you can do --what you're trying to do. If it's not clear whether you should be able --to do something or not, report that too; it's a bug in the --documentation! -- -- Before reporting a bug or trying to fix it yourself, try to isolate --it to the smallest possible makefile that reproduces the problem. Then --send us the makefile and the exact results `make' gave you, including --any error or warning messages. Please don't paraphrase these messages: --it's best to cut and paste them into your report. When generating this --small makefile, be sure to not use any non-free or unusual tools in --your commands: you can almost always emulate what such a tool would do --with simple shell commands. Finally, be sure to explain what you --expected to occur; this will help us decide whether the problem was --really in the documentation. -- -- Once you have a precise problem you can report it in one of two ways. --Either send electronic mail to: -- -- bug-make@gnu.org -- --or use our Web-based project management tool, at: -- -- http://savannah.gnu.org/projects/make/ -- --In addition to the information above, please be careful to include the --version number of `make' you are using. You can get this information --with the command `make --version'. Be sure also to include the type of --machine and operating system you are using. One way to obtain this --information is by looking at the final lines of output from the command --`make --help'. -- -- --File: make.info, Node: Introduction, Next: Makefiles, Prev: Overview, Up: Top -- --2 An Introduction to Makefiles --****************************** -- --You need a file called a "makefile" to tell `make' what to do. Most --often, the makefile tells `make' how to compile and link a program. -- -- In this chapter, we will discuss a simple makefile that describes --how to compile and link a text editor which consists of eight C source --files and three header files. The makefile can also tell `make' how to --run miscellaneous commands when explicitly asked (for example, to remove --certain files as a clean-up operation). To see a more complex example --of a makefile, see *Note Complex Makefile::. -- -- When `make' recompiles the editor, each changed C source file must --be recompiled. If a header file has changed, each C source file that --includes the header file must be recompiled to be safe. Each --compilation produces an object file corresponding to the source file. --Finally, if any source file has been recompiled, all the object files, --whether newly made or saved from previous compilations, must be linked --together to produce the new executable editor. -- --* Menu: -- --* Rule Introduction:: What a rule looks like. --* Simple Makefile:: A Simple Makefile --* How Make Works:: How `make' Processes This Makefile --* Variables Simplify:: Variables Make Makefiles Simpler --* make Deduces:: Letting `make' Deduce the Commands --* Combine By Prerequisite:: Another Style of Makefile --* Cleanup:: Rules for Cleaning the Directory -- -- --File: make.info, Node: Rule Introduction, Next: Simple Makefile, Prev: Introduction, Up: Introduction -- --2.1 What a Rule Looks Like --========================== -- --A simple makefile consists of "rules" with the following shape: -- -- TARGET ... : PREREQUISITES ... -- COMMAND -- ... -- ... -- -- A "target" is usually the name of a file that is generated by a --program; examples of targets are executable or object files. A target --can also be the name of an action to carry out, such as `clean' (*note --Phony Targets::). -- -- A "prerequisite" is a file that is used as input to create the --target. A target often depends on several files. -- -- A "command" is an action that `make' carries out. A rule may have --more than one command, each on its own line. *Please note:* you need --to put a tab character at the beginning of every command line! This is --an obscurity that catches the unwary. -- -- Usually a command is in a rule with prerequisites and serves to --create a target file if any of the prerequisites change. However, the --rule that specifies commands for the target need not have --prerequisites. For example, the rule containing the delete command --associated with the target `clean' does not have prerequisites. -- -- A "rule", then, explains how and when to remake certain files which --are the targets of the particular rule. `make' carries out the --commands on the prerequisites to create or update the target. A rule --can also explain how and when to carry out an action. *Note Writing --Rules: Rules. -- -- A makefile may contain other text besides rules, but a simple --makefile need only contain rules. Rules may look somewhat more --complicated than shown in this template, but all fit the pattern more --or less. -- -- --File: make.info, Node: Simple Makefile, Next: How Make Works, Prev: Rule Introduction, Up: Introduction -- --2.2 A Simple Makefile --===================== -- --Here is a straightforward makefile that describes the way an executable --file called `edit' depends on eight object files which, in turn, depend --on eight C source and three header files. -- -- In this example, all the C files include `defs.h', but only those --defining editing commands include `command.h', and only low level files --that change the editor buffer include `buffer.h'. -- -- edit : main.o kbd.o command.o display.o \ -- insert.o search.o files.o utils.o -- cc -o edit main.o kbd.o command.o display.o \ -- insert.o search.o files.o utils.o -- -- main.o : main.c defs.h -- cc -c main.c -- kbd.o : kbd.c defs.h command.h -- cc -c kbd.c -- command.o : command.c defs.h command.h -- cc -c command.c -- display.o : display.c defs.h buffer.h -- cc -c display.c -- insert.o : insert.c defs.h buffer.h -- cc -c insert.c -- search.o : search.c defs.h buffer.h -- cc -c search.c -- files.o : files.c defs.h buffer.h command.h -- cc -c files.c -- utils.o : utils.c defs.h -- cc -c utils.c -- clean : -- rm edit main.o kbd.o command.o display.o \ -- insert.o search.o files.o utils.o -- --We split each long line into two lines using backslash-newline; this is --like using one long line, but is easier to read. -- -- To use this makefile to create the executable file called `edit', --type: -- -- make -- -- To use this makefile to delete the executable file and all the object --files from the directory, type: -- -- make clean -- -- In the example makefile, the targets include the executable file --`edit', and the object files `main.o' and `kbd.o'. The prerequisites --are files such as `main.c' and `defs.h'. In fact, each `.o' file is --both a target and a prerequisite. Commands include `cc -c main.c' and --`cc -c kbd.c'. -- -- When a target is a file, it needs to be recompiled or relinked if any --of its prerequisites change. In addition, any prerequisites that are --themselves automatically generated should be updated first. In this --example, `edit' depends on each of the eight object files; the object --file `main.o' depends on the source file `main.c' and on the header --file `defs.h'. -- -- A shell command follows each line that contains a target and --prerequisites. These shell commands say how to update the target file. --A tab character must come at the beginning of every command line to --distinguish command lines from other lines in the makefile. (Bear in --mind that `make' does not know anything about how the commands work. --It is up to you to supply commands that will update the target file --properly. All `make' does is execute the commands in the rule you have --specified when the target file needs to be updated.) -- -- The target `clean' is not a file, but merely the name of an action. --Since you normally do not want to carry out the actions in this rule, --`clean' is not a prerequisite of any other rule. Consequently, `make' --never does anything with it unless you tell it specifically. Note that --this rule not only is not a prerequisite, it also does not have any --prerequisites, so the only purpose of the rule is to run the specified --commands. Targets that do not refer to files but are just actions are --called "phony targets". *Note Phony Targets::, for information about --this kind of target. *Note Errors in Commands: Errors, to see how to --cause `make' to ignore errors from `rm' or any other command. -- -- --File: make.info, Node: How Make Works, Next: Variables Simplify, Prev: Simple Makefile, Up: Introduction -- --2.3 How `make' Processes a Makefile --=================================== -- --By default, `make' starts with the first target (not targets whose --names start with `.'). This is called the "default goal". ("Goals" --are the targets that `make' strives ultimately to update. You can --override this behavior using the command line (*note Arguments to --Specify the Goals: Goals.) or with the `.DEFAULT_GOAL' special variable --(*note Other Special Variables: Special Variables.). -- -- In the simple example of the previous section, the default goal is to --update the executable program `edit'; therefore, we put that rule first. -- -- Thus, when you give the command: -- -- make -- --`make' reads the makefile in the current directory and begins by --processing the first rule. In the example, this rule is for relinking --`edit'; but before `make' can fully process this rule, it must process --the rules for the files that `edit' depends on, which in this case are --the object files. Each of these files is processed according to its --own rule. These rules say to update each `.o' file by compiling its --source file. The recompilation must be done if the source file, or any --of the header files named as prerequisites, is more recent than the --object file, or if the object file does not exist. -- -- The other rules are processed because their targets appear as --prerequisites of the goal. If some other rule is not depended on by the --goal (or anything it depends on, etc.), that rule is not processed, --unless you tell `make' to do so (with a command such as `make clean'). -- -- Before recompiling an object file, `make' considers updating its --prerequisites, the source file and header files. This makefile does not --specify anything to be done for them--the `.c' and `.h' files are not --the targets of any rules--so `make' does nothing for these files. But --`make' would update automatically generated C programs, such as those --made by Bison or Yacc, by their own rules at this time. -- -- After recompiling whichever object files need it, `make' decides --whether to relink `edit'. This must be done if the file `edit' does --not exist, or if any of the object files are newer than it. If an --object file was just recompiled, it is now newer than `edit', so `edit' --is relinked. -- -- Thus, if we change the file `insert.c' and run `make', `make' will --compile that file to update `insert.o', and then link `edit'. If we --change the file `command.h' and run `make', `make' will recompile the --object files `kbd.o', `command.o' and `files.o' and then link the file --`edit'. -- -- --File: make.info, Node: Variables Simplify, Next: make Deduces, Prev: How Make Works, Up: Introduction -- --2.4 Variables Make Makefiles Simpler --==================================== -- --In our example, we had to list all the object files twice in the rule --for `edit' (repeated here): -- -- edit : main.o kbd.o command.o display.o \ -- insert.o search.o files.o utils.o -- cc -o edit main.o kbd.o command.o display.o \ -- insert.o search.o files.o utils.o -- -- Such duplication is error-prone; if a new object file is added to the --system, we might add it to one list and forget the other. We can --eliminate the risk and simplify the makefile by using a variable. --"Variables" allow a text string to be defined once and substituted in --multiple places later (*note How to Use Variables: Using Variables.). -- -- It is standard practice for every makefile to have a variable named --`objects', `OBJECTS', `objs', `OBJS', `obj', or `OBJ' which is a list --of all object file names. We would define such a variable `objects' --with a line like this in the makefile: -- -- objects = main.o kbd.o command.o display.o \ -- insert.o search.o files.o utils.o -- --Then, each place we want to put a list of the object file names, we can --substitute the variable's value by writing `$(objects)' (*note How to --Use Variables: Using Variables.). -- -- Here is how the complete simple makefile looks when you use a --variable for the object files: -- -- objects = main.o kbd.o command.o display.o \ -- insert.o search.o files.o utils.o -- -- edit : $(objects) -- cc -o edit $(objects) -- main.o : main.c defs.h -- cc -c main.c -- kbd.o : kbd.c defs.h command.h -- cc -c kbd.c -- command.o : command.c defs.h command.h -- cc -c command.c -- display.o : display.c defs.h buffer.h -- cc -c display.c -- insert.o : insert.c defs.h buffer.h -- cc -c insert.c -- search.o : search.c defs.h buffer.h -- cc -c search.c -- files.o : files.c defs.h buffer.h command.h -- cc -c files.c -- utils.o : utils.c defs.h -- cc -c utils.c -- clean : -- rm edit $(objects) -- -- --File: make.info, Node: make Deduces, Next: Combine By Prerequisite, Prev: Variables Simplify, Up: Introduction -- --2.5 Letting `make' Deduce the Commands --====================================== -- --It is not necessary to spell out the commands for compiling the --individual C source files, because `make' can figure them out: it has an --"implicit rule" for updating a `.o' file from a correspondingly named --`.c' file using a `cc -c' command. For example, it will use the --command `cc -c main.c -o main.o' to compile `main.c' into `main.o'. We --can therefore omit the commands from the rules for the object files. --*Note Using Implicit Rules: Implicit Rules. -- -- When a `.c' file is used automatically in this way, it is also --automatically added to the list of prerequisites. We can therefore omit --the `.c' files from the prerequisites, provided we omit the commands. -- -- Here is the entire example, with both of these changes, and a --variable `objects' as suggested above: -- -- objects = main.o kbd.o command.o display.o \ -- insert.o search.o files.o utils.o -- -- edit : $(objects) -- cc -o edit $(objects) -- -- main.o : defs.h -- kbd.o : defs.h command.h -- command.o : defs.h command.h -- display.o : defs.h buffer.h -- insert.o : defs.h buffer.h -- search.o : defs.h buffer.h -- files.o : defs.h buffer.h command.h -- utils.o : defs.h -- -- .PHONY : clean -- clean : -- rm edit $(objects) -- --This is how we would write the makefile in actual practice. (The --complications associated with `clean' are described elsewhere. See --*Note Phony Targets::, and *Note Errors in Commands: Errors.) -- -- Because implicit rules are so convenient, they are important. You --will see them used frequently. -- -- --File: make.info, Node: Combine By Prerequisite, Next: Cleanup, Prev: make Deduces, Up: Introduction -- --2.6 Another Style of Makefile --============================= -- --When the objects of a makefile are created only by implicit rules, an --alternative style of makefile is possible. In this style of makefile, --you group entries by their prerequisites instead of by their targets. --Here is what one looks like: -- -- objects = main.o kbd.o command.o display.o \ -- insert.o search.o files.o utils.o -- -- edit : $(objects) -- cc -o edit $(objects) -- -- $(objects) : defs.h -- kbd.o command.o files.o : command.h -- display.o insert.o search.o files.o : buffer.h -- --Here `defs.h' is given as a prerequisite of all the object files; --`command.h' and `buffer.h' are prerequisites of the specific object --files listed for them. -- -- Whether this is better is a matter of taste: it is more compact, but --some people dislike it because they find it clearer to put all the --information about each target in one place. -- -- --File: make.info, Node: Cleanup, Prev: Combine By Prerequisite, Up: Introduction -- --2.7 Rules for Cleaning the Directory --==================================== -- --Compiling a program is not the only thing you might want to write rules --for. Makefiles commonly tell how to do a few other things besides --compiling a program: for example, how to delete all the object files --and executables so that the directory is `clean'. -- -- Here is how we could write a `make' rule for cleaning our example --editor: -- -- clean: -- rm edit $(objects) -- -- In practice, we might want to write the rule in a somewhat more --complicated manner to handle unanticipated situations. We would do --this: -- -- .PHONY : clean -- clean : -- -rm edit $(objects) -- --This prevents `make' from getting confused by an actual file called --`clean' and causes it to continue in spite of errors from `rm'. (See --*Note Phony Targets::, and *Note Errors in Commands: Errors.) -- --A rule such as this should not be placed at the beginning of the --makefile, because we do not want it to run by default! Thus, in the --example makefile, we want the rule for `edit', which recompiles the --editor, to remain the default goal. -- -- Since `clean' is not a prerequisite of `edit', this rule will not --run at all if we give the command `make' with no arguments. In order --to make the rule run, we have to type `make clean'. *Note How to Run --`make': Running. -- -- --File: make.info, Node: Makefiles, Next: Rules, Prev: Introduction, Up: Top -- --3 Writing Makefiles --******************* -- --The information that tells `make' how to recompile a system comes from --reading a data base called the "makefile". -- --* Menu: -- --* Makefile Contents:: What makefiles contain. --* Makefile Names:: How to name your makefile. --* Include:: How one makefile can use another makefile. --* MAKEFILES Variable:: The environment can specify extra makefiles. --* MAKEFILE_LIST Variable:: Discover which makefiles have been read. --* Special Variables:: Other special variables. --* Remaking Makefiles:: How makefiles get remade. --* Overriding Makefiles:: How to override part of one makefile -- with another makefile. --* Reading Makefiles:: How makefiles are parsed. --* Secondary Expansion:: How and when secondary expansion is performed. -- -- --File: make.info, Node: Makefile Contents, Next: Makefile Names, Prev: Makefiles, Up: Makefiles -- --3.1 What Makefiles Contain --========================== -- --Makefiles contain five kinds of things: "explicit rules", "implicit --rules", "variable definitions", "directives", and "comments". Rules, --variables, and directives are described at length in later chapters. -- -- * An "explicit rule" says when and how to remake one or more files, -- called the rule's "targets". It lists the other files that the -- targets depend on, called the "prerequisites" of the target, and -- may also give commands to use to create or update the targets. -- *Note Writing Rules: Rules. -- -- * An "implicit rule" says when and how to remake a class of files -- based on their names. It describes how a target may depend on a -- file with a name similar to the target and gives commands to -- create or update such a target. *Note Using Implicit Rules: -- Implicit Rules. -- -- * A "variable definition" is a line that specifies a text string -- value for a variable that can be substituted into the text later. -- The simple makefile example shows a variable definition for -- `objects' as a list of all object files (*note Variables Make -- Makefiles Simpler: Variables Simplify.). -- -- * A "directive" is a command for `make' to do something special while -- reading the makefile. These include: -- -- * Reading another makefile (*note Including Other Makefiles: -- Include.). -- -- * Deciding (based on the values of variables) whether to use or -- ignore a part of the makefile (*note Conditional Parts of -- Makefiles: Conditionals.). -- -- * Defining a variable from a verbatim string containing -- multiple lines (*note Defining Variables Verbatim: Defining.). -- -- * `#' in a line of a makefile starts a "comment". It and the rest -- of the line are ignored, except that a trailing backslash not -- escaped by another backslash will continue the comment across -- multiple lines. A line containing just a comment (with perhaps -- spaces before it) is effectively blank, and is ignored. If you -- want a literal `#', escape it with a backslash (e.g., `\#'). -- Comments may appear on any line in the makefile, although they are -- treated specially in certain situations. -- -- Within a command script (if the line begins with a TAB character) -- the entire line is passed to the shell, just as with any other -- line that begins with a TAB. The shell decides how to interpret -- the text: whether or not this is a comment is up to the shell. -- -- Within a `define' directive, comments are not ignored during the -- definition of the variable, but rather kept intact in the value of -- the variable. When the variable is expanded they will either be -- treated as `make' comments or as command script text, depending on -- the context in which the variable is evaluated. -- -- --File: make.info, Node: Makefile Names, Next: Include, Prev: Makefile Contents, Up: Makefiles -- --3.2 What Name to Give Your Makefile --=================================== -- --By default, when `make' looks for the makefile, it tries the following --names, in order: `GNUmakefile', `makefile' and `Makefile'. -- -- Normally you should call your makefile either `makefile' or --`Makefile'. (We recommend `Makefile' because it appears prominently --near the beginning of a directory listing, right near other important --files such as `README'.) The first name checked, `GNUmakefile', is not --recommended for most makefiles. You should use this name if you have a --makefile that is specific to GNU `make', and will not be understood by --other versions of `make'. Other `make' programs look for `makefile' and --`Makefile', but not `GNUmakefile'. -- -- If `make' finds none of these names, it does not use any makefile. --Then you must specify a goal with a command argument, and `make' will --attempt to figure out how to remake it using only its built-in implicit --rules. *Note Using Implicit Rules: Implicit Rules. -- -- If you want to use a nonstandard name for your makefile, you can --specify the makefile name with the `-f' or `--file' option. The --arguments `-f NAME' or `--file=NAME' tell `make' to read the file NAME --as the makefile. If you use more than one `-f' or `--file' option, you --can specify several makefiles. All the makefiles are effectively --concatenated in the order specified. The default makefile names --`GNUmakefile', `makefile' and `Makefile' are not checked automatically --if you specify `-f' or `--file'. -- -- --File: make.info, Node: Include, Next: MAKEFILES Variable, Prev: Makefile Names, Up: Makefiles -- --3.3 Including Other Makefiles --============================= -- --The `include' directive tells `make' to suspend reading the current --makefile and read one or more other makefiles before continuing. The --directive is a line in the makefile that looks like this: -- -- include FILENAMES... -- --FILENAMES can contain shell file name patterns. If FILENAMES is empty, --nothing is included and no error is printed. -- -- Extra spaces are allowed and ignored at the beginning of the line, --but a tab is not allowed. (If the line begins with a tab, it will be --considered a command line.) Whitespace is required between `include' --and the file names, and between file names; extra whitespace is ignored --there and at the end of the directive. A comment starting with `#' is --allowed at the end of the line. If the file names contain any variable --or function references, they are expanded. *Note How to Use Variables: --Using Variables. -- -- For example, if you have three `.mk' files, `a.mk', `b.mk', and --`c.mk', and `$(bar)' expands to `bish bash', then the following --expression -- -- include foo *.mk $(bar) -- -- is equivalent to -- -- include foo a.mk b.mk c.mk bish bash -- -- When `make' processes an `include' directive, it suspends reading of --the containing makefile and reads from each listed file in turn. When --that is finished, `make' resumes reading the makefile in which the --directive appears. -- -- One occasion for using `include' directives is when several programs, --handled by individual makefiles in various directories, need to use a --common set of variable definitions (*note Setting Variables: Setting.) --or pattern rules (*note Defining and Redefining Pattern Rules: Pattern --Rules.). -- -- Another such occasion is when you want to generate prerequisites from --source files automatically; the prerequisites can be put in a file that --is included by the main makefile. This practice is generally cleaner --than that of somehow appending the prerequisites to the end of the main --makefile as has been traditionally done with other versions of `make'. --*Note Automatic Prerequisites::. -- -- If the specified name does not start with a slash, and the file is --not found in the current directory, several other directories are --searched. First, any directories you have specified with the `-I' or --`--include-dir' option are searched (*note Summary of Options: Options --Summary.). Then the following directories (if they exist) are --searched, in this order: `PREFIX/include' (normally `/usr/local/include' --(1)) `/usr/gnu/include', `/usr/local/include', `/usr/include'. -- -- If an included makefile cannot be found in any of these directories, --a warning message is generated, but it is not an immediately fatal --error; processing of the makefile containing the `include' continues. --Once it has finished reading makefiles, `make' will try to remake any --that are out of date or don't exist. *Note How Makefiles Are Remade: --Remaking Makefiles. Only after it has tried to find a way to remake a --makefile and failed, will `make' diagnose the missing makefile as a --fatal error. -- -- If you want `make' to simply ignore a makefile which does not exist --and cannot be remade, with no error message, use the `-include' --directive instead of `include', like this: -- -- -include FILENAMES... -- -- This acts like `include' in every way except that there is no error --(not even a warning) if any of the FILENAMES do not exist. For --compatibility with some other `make' implementations, `sinclude' is --another name for `-include'. -- -- ---------- Footnotes ---------- -- -- (1) GNU Make compiled for MS-DOS and MS-Windows behaves as if PREFIX --has been defined to be the root of the DJGPP tree hierarchy. -- -- --File: make.info, Node: MAKEFILES Variable, Next: MAKEFILE_LIST Variable, Prev: Include, Up: Makefiles -- --3.4 The Variable `MAKEFILES' --============================ -- --If the environment variable `MAKEFILES' is defined, `make' considers --its value as a list of names (separated by whitespace) of additional --makefiles to be read before the others. This works much like the --`include' directive: various directories are searched for those files --(*note Including Other Makefiles: Include.). In addition, the default --goal is never taken from one of these makefiles and it is not an error --if the files listed in `MAKEFILES' are not found. -- -- The main use of `MAKEFILES' is in communication between recursive --invocations of `make' (*note Recursive Use of `make': Recursion.). It --usually is not desirable to set the environment variable before a --top-level invocation of `make', because it is usually better not to --mess with a makefile from outside. However, if you are running `make' --without a specific makefile, a makefile in `MAKEFILES' can do useful --things to help the built-in implicit rules work better, such as --defining search paths (*note Directory Search::). -- -- Some users are tempted to set `MAKEFILES' in the environment --automatically on login, and program makefiles to expect this to be done. --This is a very bad idea, because such makefiles will fail to work if --run by anyone else. It is much better to write explicit `include' --directives in the makefiles. *Note Including Other Makefiles: Include. -- -- --File: make.info, Node: MAKEFILE_LIST Variable, Next: Special Variables, Prev: MAKEFILES Variable, Up: Makefiles -- --3.5 The Variable `MAKEFILE_LIST' --================================ -- --As `make' reads various makefiles, including any obtained from the --`MAKEFILES' variable, the command line, the default files, or from --`include' directives, their names will be automatically appended to the --`MAKEFILE_LIST' variable. They are added right before `make' begins to --parse them. -- -- This means that if the first thing a makefile does is examine the --last word in this variable, it will be the name of the current makefile. --Once the current makefile has used `include', however, the last word --will be the just-included makefile. -- -- If a makefile named `Makefile' has this content: -- -- name1 := $(lastword $(MAKEFILE_LIST)) -- -- include inc.mk -- -- name2 := $(lastword $(MAKEFILE_LIST)) -- -- all: -- @echo name1 = $(name1) -- @echo name2 = $(name2) -- --then you would expect to see this output: -- -- name1 = Makefile -- name2 = inc.mk -- -- *Note Text Functions::, for more information on the `word' and --`words' functions used above. *Note The Two Flavors of Variables: --Flavors, for more information on simply-expanded (`:=') variable --definitions. -- -- --File: make.info, Node: Special Variables, Next: Remaking Makefiles, Prev: MAKEFILE_LIST Variable, Up: Makefiles -- --3.6 Other Special Variables --=========================== -- --GNU `make' also supports other special variables. Unless otherwise --documented here, these values lose their special properties if they are --set by a makefile or on the command line. -- --`.DEFAULT_GOAL' -- Sets the default goal to be used if no targets were specified on -- the command line (*note Arguments to Specify the Goals: Goals.). -- The `.DEFAULT_GOAL' variable allows you to discover the current -- default goal, restart the default goal selection algorithm by -- clearing its value, or to explicitly set the default goal. The -- following example illustrates these cases: -- -- # Query the default goal. -- ifeq ($(.DEFAULT_GOAL),) -- $(warning no default goal is set) -- endif -- -- .PHONY: foo -- foo: ; @echo $@ -- -- $(warning default goal is $(.DEFAULT_GOAL)) -- -- # Reset the default goal. -- .DEFAULT_GOAL := -- -- .PHONY: bar -- bar: ; @echo $@ -- -- $(warning default goal is $(.DEFAULT_GOAL)) -- -- # Set our own. -- .DEFAULT_GOAL := foo -- -- This makefile prints: -- -- no default goal is set -- default goal is foo -- default goal is bar -- foo -- -- Note that assigning more than one target name to `.DEFAULT_GOAL' is -- illegal and will result in an error. -- --`MAKE_RESTARTS' -- This variable is set only if this instance of `make' has restarted -- (*note How Makefiles Are Remade: Remaking Makefiles.): it will -- contain the number of times this instance has restarted. Note -- this is not the same as recursion (counted by the `MAKELEVEL' -- variable). You should not set, modify, or export this variable. -- --`.VARIABLES' -- Expands to a list of the _names_ of all global variables defined -- so far. This includes variables which have empty values, as well -- as built-in variables (*note Variables Used by Implicit Rules: -- Implicit Variables.), but does not include any variables which are -- only defined in a target-specific context. Note that any value -- you assign to this variable will be ignored; it will always return -- its special value. -- --`.FEATURES' -- Expands to a list of special features supported by this version of -- `make'. Possible values include: -- -- `archives' -- Supports `ar' (archive) files using special filename syntax. -- *Note Using `make' to Update Archive Files: Archives. -- -- `check-symlink' -- Supports the `-L' (`--check-symlink-times') flag. *Note -- Summary of Options: Options Summary. -- -- `else-if' -- Supports "else if" non-nested conditionals. *Note Syntax of -- Conditionals: Conditional Syntax. -- -- `jobserver' -- Supports "job server" enhanced parallel builds. *Note -- Parallel Execution: Parallel. -- -- `second-expansion' -- Supports secondary expansion of prerequisite lists. -- -- `order-only' -- Supports order-only prerequisites. *Note Types of -- Prerequisites: Prerequisite Types. -- -- `target-specific' -- Supports target-specific and pattern-specific variable -- assignments. *Note Target-specific Variable Values: -- Target-specific. -- -- --`.INCLUDE_DIRS' -- Expands to a list of directories that `make' searches for included -- makefiles (*note Including Other Makefiles: Include.). -- -- -- --File: make.info, Node: Remaking Makefiles, Next: Overriding Makefiles, Prev: Special Variables, Up: Makefiles -- --3.7 How Makefiles Are Remade --============================ -- --Sometimes makefiles can be remade from other files, such as RCS or SCCS --files. If a makefile can be remade from other files, you probably want --`make' to get an up-to-date version of the makefile to read in. -- -- To this end, after reading in all makefiles, `make' will consider --each as a goal target and attempt to update it. If a makefile has a --rule which says how to update it (found either in that very makefile or --in another one) or if an implicit rule applies to it (*note Using --Implicit Rules: Implicit Rules.), it will be updated if necessary. --After all makefiles have been checked, if any have actually been --changed, `make' starts with a clean slate and reads all the makefiles --over again. (It will also attempt to update each of them over again, --but normally this will not change them again, since they are already up --to date.) -- -- If you know that one or more of your makefiles cannot be remade and --you want to keep `make' from performing an implicit rule search on --them, perhaps for efficiency reasons, you can use any normal method of --preventing implicit rule lookup to do so. For example, you can write an --explicit rule with the makefile as the target, and an empty command --string (*note Using Empty Commands: Empty Commands.). -- -- If the makefiles specify a double-colon rule to remake a file with --commands but no prerequisites, that file will always be remade (*note --Double-Colon::). In the case of makefiles, a makefile that has a --double-colon rule with commands but no prerequisites will be remade --every time `make' is run, and then again after `make' starts over and --reads the makefiles in again. This would cause an infinite loop: --`make' would constantly remake the makefile, and never do anything --else. So, to avoid this, `make' will *not* attempt to remake makefiles --which are specified as targets of a double-colon rule with commands but --no prerequisites. -- -- If you do not specify any makefiles to be read with `-f' or `--file' --options, `make' will try the default makefile names; *note What Name to --Give Your Makefile: Makefile Names. Unlike makefiles explicitly --requested with `-f' or `--file' options, `make' is not certain that --these makefiles should exist. However, if a default makefile does not --exist but can be created by running `make' rules, you probably want the --rules to be run so that the makefile can be used. -- -- Therefore, if none of the default makefiles exists, `make' will try --to make each of them in the same order in which they are searched for --(*note What Name to Give Your Makefile: Makefile Names.) until it --succeeds in making one, or it runs out of names to try. Note that it --is not an error if `make' cannot find or make any makefile; a makefile --is not always necessary. -- -- When you use the `-t' or `--touch' option (*note Instead of --Executing the Commands: Instead of Execution.), you would not want to --use an out-of-date makefile to decide which targets to touch. So the --`-t' option has no effect on updating makefiles; they are really --updated even if `-t' is specified. Likewise, `-q' (or `--question') --and `-n' (or `--just-print') do not prevent updating of makefiles, --because an out-of-date makefile would result in the wrong output for --other targets. Thus, `make -f mfile -n foo' will update `mfile', read --it in, and then print the commands to update `foo' and its prerequisites --without running them. The commands printed for `foo' will be those --specified in the updated contents of `mfile'. -- -- However, on occasion you might actually wish to prevent updating of --even the makefiles. You can do this by specifying the makefiles as --goals in the command line as well as specifying them as makefiles. --When the makefile name is specified explicitly as a goal, the options --`-t' and so on do apply to them. -- -- Thus, `make -f mfile -n mfile foo' would read the makefile `mfile', --print the commands needed to update it without actually running them, --and then print the commands needed to update `foo' without running --them. The commands for `foo' will be those specified by the existing --contents of `mfile'. -- -- --File: make.info, Node: Overriding Makefiles, Next: Reading Makefiles, Prev: Remaking Makefiles, Up: Makefiles -- --3.8 Overriding Part of Another Makefile --======================================= -- --Sometimes it is useful to have a makefile that is mostly just like --another makefile. You can often use the `include' directive to include --one in the other, and add more targets or variable definitions. --However, if the two makefiles give different commands for the same --target, `make' will not let you just do this. But there is another way. -- -- In the containing makefile (the one that wants to include the other), --you can use a match-anything pattern rule to say that to remake any --target that cannot be made from the information in the containing --makefile, `make' should look in another makefile. *Note Pattern --Rules::, for more information on pattern rules. -- -- For example, if you have a makefile called `Makefile' that says how --to make the target `foo' (and other targets), you can write a makefile --called `GNUmakefile' that contains: -- -- foo: -- frobnicate > foo -- -- %: force -- @$(MAKE) -f Makefile $@ -- force: ; -- -- If you say `make foo', `make' will find `GNUmakefile', read it, and --see that to make `foo', it needs to run the command `frobnicate > foo'. --If you say `make bar', `make' will find no way to make `bar' in --`GNUmakefile', so it will use the commands from the pattern rule: `make ---f Makefile bar'. If `Makefile' provides a rule for updating `bar', --`make' will apply the rule. And likewise for any other target that --`GNUmakefile' does not say how to make. -- -- The way this works is that the pattern rule has a pattern of just --`%', so it matches any target whatever. The rule specifies a --prerequisite `force', to guarantee that the commands will be run even --if the target file already exists. We give `force' target empty --commands to prevent `make' from searching for an implicit rule to build --it--otherwise it would apply the same match-anything rule to `force' --itself and create a prerequisite loop! -- -- --File: make.info, Node: Reading Makefiles, Next: Secondary Expansion, Prev: Overriding Makefiles, Up: Makefiles -- --3.9 How `make' Reads a Makefile --=============================== -- --GNU `make' does its work in two distinct phases. During the first --phase it reads all the makefiles, included makefiles, etc. and --internalizes all the variables and their values, implicit and explicit --rules, and constructs a dependency graph of all the targets and their --prerequisites. During the second phase, `make' uses these internal --structures to determine what targets will need to be rebuilt and to --invoke the rules necessary to do so. -- -- It's important to understand this two-phase approach because it has a --direct impact on how variable and function expansion happens; this is --often a source of some confusion when writing makefiles. Here we will --present a summary of the phases in which expansion happens for different --constructs within the makefile. We say that expansion is "immediate" --if it happens during the first phase: in this case `make' will expand --any variables or functions in that section of a construct as the --makefile is parsed. We say that expansion is "deferred" if expansion --is not performed immediately. Expansion of deferred construct is not --performed until either the construct appears later in an immediate --context, or until the second phase. -- -- You may not be familiar with some of these constructs yet. You can --reference this section as you become familiar with them, in later --chapters. -- --Variable Assignment --------------------- -- --Variable definitions are parsed as follows: -- -- IMMEDIATE = DEFERRED -- IMMEDIATE ?= DEFERRED -- IMMEDIATE := IMMEDIATE -- IMMEDIATE += DEFERRED or IMMEDIATE -- -- define IMMEDIATE -- DEFERRED -- endef -- -- For the append operator, `+=', the right-hand side is considered --immediate if the variable was previously set as a simple variable --(`:='), and deferred otherwise. -- --Conditional Statements ------------------------ -- --All instances of conditional syntax are parsed immediately, in their --entirety; this includes the `ifdef', `ifeq', `ifndef', and `ifneq' --forms. Of course this means that automatic variables cannot be used in --conditional statements, as automatic variables are not set until the --command script for that rule is invoked. If you need to use automatic --variables in a conditional you _must_ use shell conditional syntax, in --your command script proper, for these tests, not `make' conditionals. -- --Rule Definition ----------------- -- --A rule is always expanded the same way, regardless of the form: -- -- IMMEDIATE : IMMEDIATE ; DEFERRED -- DEFERRED -- -- That is, the target and prerequisite sections are expanded --immediately, and the commands used to construct the target are always --deferred. This general rule is true for explicit rules, pattern rules, --suffix rules, static pattern rules, and simple prerequisite definitions. -- -- --File: make.info, Node: Secondary Expansion, Prev: Reading Makefiles, Up: Makefiles -- --3.10 Secondary Expansion --======================== -- --In the previous section we learned that GNU `make' works in two --distinct phases: a read-in phase and a target-update phase (*note How --`make' Reads a Makefile: Reading Makefiles.). GNU make also has the --ability to enable a _second expansion_ of the prerequisites (only) for --some or all targets defined in the makefile. In order for this second --expansion to occur, the special target `.SECONDEXPANSION' must be --defined before the first prerequisite list that makes use of this --feature. -- -- If that special target is defined then in between the two phases --mentioned above, right at the end of the read-in phase, all the --prerequisites of the targets defined after the special target are --expanded a _second time_. In most circumstances this secondary --expansion will have no effect, since all variable and function --references will have been expanded during the initial parsing of the --makefiles. In order to take advantage of the secondary expansion phase --of the parser, then, it's necessary to _escape_ the variable or --function reference in the makefile. In this case the first expansion --merely un-escapes the reference but doesn't expand it, and expansion is --left to the secondary expansion phase. For example, consider this --makefile: -- -- .SECONDEXPANSION: -- ONEVAR = onefile -- TWOVAR = twofile -- myfile: $(ONEVAR) $$(TWOVAR) -- -- After the first expansion phase the prerequisites list of the --`myfile' target will be `onefile' and `$(TWOVAR)'; the first --(unescaped) variable reference to ONEVAR is expanded, while the second --(escaped) variable reference is simply unescaped, without being --recognized as a variable reference. Now during the secondary expansion --the first word is expanded again but since it contains no variable or --function references it remains the static value `onefile', while the --second word is now a normal reference to the variable TWOVAR, which is --expanded to the value `twofile'. The final result is that there are --two prerequisites, `onefile' and `twofile'. -- -- Obviously, this is not a very interesting case since the same result --could more easily have been achieved simply by having both variables --appear, unescaped, in the prerequisites list. One difference becomes --apparent if the variables are reset; consider this example: -- -- .SECONDEXPANSION: -- AVAR = top -- onefile: $(AVAR) -- twofile: $$(AVAR) -- AVAR = bottom -- -- Here the prerequisite of `onefile' will be expanded immediately, and --resolve to the value `top', while the prerequisite of `twofile' will --not be full expanded until the secondary expansion and yield a value of --`bottom'. -- -- This is marginally more exciting, but the true power of this feature --only becomes apparent when you discover that secondary expansions --always take place within the scope of the automatic variables for that --target. This means that you can use variables such as `$@', `$*', etc. --during the second expansion and they will have their expected values, --just as in the command script. All you have to do is defer the --expansion by escaping the `$'. Also, secondary expansion occurs for --both explicit and implicit (pattern) rules. Knowing this, the possible --uses for this feature increase dramatically. For example: -- -- .SECONDEXPANSION: -- main_OBJS := main.o try.o test.o -- lib_OBJS := lib.o api.o -- -- main lib: $$($$@_OBJS) -- -- Here, after the initial expansion the prerequisites of both the --`main' and `lib' targets will be `$($@_OBJS)'. During the secondary --expansion, the `$@' variable is set to the name of the target and so --the expansion for the `main' target will yield `$(main_OBJS)', or --`main.o try.o test.o', while the secondary expansion for the `lib' --target will yield `$(lib_OBJS)', or `lib.o api.o'. -- -- You can also mix functions here, as long as they are properly --escaped: -- -- main_SRCS := main.c try.c test.c -- lib_SRCS := lib.c api.c -- -- .SECONDEXPANSION: -- main lib: $$(patsubst %.c,%.o,$$($$@_SRCS)) -- -- This version allows users to specify source files rather than object --files, but gives the same resulting prerequisites list as the previous --example. -- -- Evaluation of automatic variables during the secondary expansion --phase, especially of the target name variable `$$@', behaves similarly --to evaluation within command scripts. However, there are some subtle --differences and "corner cases" which come into play for the different --types of rule definitions that `make' understands. The subtleties of --using the different automatic variables are described below. -- --Secondary Expansion of Explicit Rules --------------------------------------- -- --During the secondary expansion of explicit rules, `$$@' and `$$%' --evaluate, respectively, to the file name of the target and, when the --target is an archive member, the target member name. The `$$<' --variable evaluates to the first prerequisite in the first rule for this --target. `$$^' and `$$+' evaluate to the list of all prerequisites of --rules _that have already appeared_ for the same target (`$$+' with --repetitions and `$$^' without). The following example will help --illustrate these behaviors: -- -- .SECONDEXPANSION: -- -- foo: foo.1 bar.1 $$< $$^ $$+ # line #1 -- -- foo: foo.2 bar.2 $$< $$^ $$+ # line #2 -- -- foo: foo.3 bar.3 $$< $$^ $$+ # line #3 -- -- In the first prerequisite list, all three variables (`$$<', `$$^', --and `$$+') expand to the empty string. In the second, they will have --values `foo.1', `foo.1 bar.1', and `foo.1 bar.1' respectively. In the --third they will have values `foo.1', `foo.1 bar.1 foo.2 bar.2', and --`foo.1 bar.1 foo.2 bar.2' respectively. -- -- Rules undergo secondary expansion in makefile order, except that the --rule with the command script is always evaluated last. -- -- The variables `$$?' and `$$*' are not available and expand to the --empty string. -- --Secondary Expansion of Static Pattern Rules --------------------------------------------- -- --Rules for secondary expansion of static pattern rules are identical to --those for explicit rules, above, with one exception: for static pattern --rules the `$$*' variable is set to the pattern stem. As with explicit --rules, `$$?' is not available and expands to the empty string. -- --Secondary Expansion of Implicit Rules --------------------------------------- -- --As `make' searches for an implicit rule, it substitutes the stem and --then performs secondary expansion for every rule with a matching target --pattern. The value of the automatic variables is derived in the same --fashion as for static pattern rules. As an example: -- -- .SECONDEXPANSION: -- -- foo: bar -- -- foo foz: fo%: bo% -- -- %oo: $$< $$^ $$+ $$* -- -- When the implicit rule is tried for target `foo', `$$<' expands to --`bar', `$$^' expands to `bar boo', `$$+' also expands to `bar boo', and --`$$*' expands to `f'. -- -- Note that the directory prefix (D), as described in *Note Implicit --Rule Search Algorithm: Implicit Rule Search, is appended (after --expansion) to all the patterns in the prerequisites list. As an --example: -- -- .SECONDEXPANSION: -- -- /tmp/foo.o: -- -- %.o: $$(addsuffix /%.c,foo bar) foo.h -- -- The prerequisite list after the secondary expansion and directory --prefix reconstruction will be `/tmp/foo/foo.c /tmp/var/bar/foo.c --foo.h'. If you are not interested in this reconstruction, you can use --`$$*' instead of `%' in the prerequisites list. -- -- --File: make.info, Node: Rules, Next: Commands, Prev: Makefiles, Up: Top -- --4 Writing Rules --*************** -- --A "rule" appears in the makefile and says when and how to remake --certain files, called the rule's "targets" (most often only one per --rule). It lists the other files that are the "prerequisites" of the --target, and "commands" to use to create or update the target. -- -- The order of rules is not significant, except for determining the --"default goal": the target for `make' to consider, if you do not --otherwise specify one. The default goal is the target of the first --rule in the first makefile. If the first rule has multiple targets, --only the first target is taken as the default. There are two --exceptions: a target starting with a period is not a default unless it --contains one or more slashes, `/', as well; and, a target that defines --a pattern rule has no effect on the default goal. (*Note Defining and --Redefining Pattern Rules: Pattern Rules.) -- -- Therefore, we usually write the makefile so that the first rule is --the one for compiling the entire program or all the programs described --by the makefile (often with a target called `all'). *Note Arguments to --Specify the Goals: Goals. -- --* Menu: -- --* Rule Example:: An example explained. --* Rule Syntax:: General syntax explained. --* Prerequisite Types:: There are two types of prerequisites. --* Wildcards:: Using wildcard characters such as `*'. --* Directory Search:: Searching other directories for source files. --* Phony Targets:: Using a target that is not a real file's name. --* Force Targets:: You can use a target without commands -- or prerequisites to mark other targets -- as phony. --* Empty Targets:: When only the date matters and the -- files are empty. --* Special Targets:: Targets with special built-in meanings. --* Multiple Targets:: When to make use of several targets in a rule. --* Multiple Rules:: How to use several rules with the same target. --* Static Pattern:: Static pattern rules apply to multiple targets -- and can vary the prerequisites according to -- the target name. --* Double-Colon:: How to use a special kind of rule to allow -- several independent rules for one target. --* Automatic Prerequisites:: How to automatically generate rules giving -- prerequisites from source files themselves. -- -- --File: make.info, Node: Rule Example, Next: Rule Syntax, Prev: Rules, Up: Rules -- --4.1 Rule Example --================ -- --Here is an example of a rule: -- -- foo.o : foo.c defs.h # module for twiddling the frobs -- cc -c -g foo.c -- -- Its target is `foo.o' and its prerequisites are `foo.c' and --`defs.h'. It has one command, which is `cc -c -g foo.c'. The command --line starts with a tab to identify it as a command. -- -- This rule says two things: -- -- * How to decide whether `foo.o' is out of date: it is out of date if -- it does not exist, or if either `foo.c' or `defs.h' is more recent -- than it. -- -- * How to update the file `foo.o': by running `cc' as stated. The -- command does not explicitly mention `defs.h', but we presume that -- `foo.c' includes it, and that that is why `defs.h' was added to -- the prerequisites. -- -- --File: make.info, Node: Rule Syntax, Next: Prerequisite Types, Prev: Rule Example, Up: Rules -- --4.2 Rule Syntax --=============== -- --In general, a rule looks like this: -- -- TARGETS : PREREQUISITES -- COMMAND -- ... -- --or like this: -- -- TARGETS : PREREQUISITES ; COMMAND -- COMMAND -- ... -- -- The TARGETS are file names, separated by spaces. Wildcard --characters may be used (*note Using Wildcard Characters in File Names: --Wildcards.) and a name of the form `A(M)' represents member M in --archive file A (*note Archive Members as Targets: Archive Members.). --Usually there is only one target per rule, but occasionally there is a --reason to have more (*note Multiple Targets in a Rule: Multiple --Targets.). -- -- The COMMAND lines start with a tab character. The first command may --appear on the line after the prerequisites, with a tab character, or may --appear on the same line, with a semicolon. Either way, the effect is --the same. There are other differences in the syntax of command lines. --*Note Writing the Commands in Rules: Commands. -- -- Because dollar signs are used to start `make' variable references, --if you really want a dollar sign in a target or prerequisite you must --write two of them, `$$' (*note How to Use Variables: Using Variables.). --If you have enabled secondary expansion (*note Secondary Expansion::) --and you want a literal dollar sign in the prerequisites lise, you must --actually write _four_ dollar signs (`$$$$'). -- -- You may split a long line by inserting a backslash followed by a --newline, but this is not required, as `make' places no limit on the --length of a line in a makefile. -- -- A rule tells `make' two things: when the targets are out of date, --and how to update them when necessary. -- -- The criterion for being out of date is specified in terms of the --PREREQUISITES, which consist of file names separated by spaces. --(Wildcards and archive members (*note Archives::) are allowed here too.) --A target is out of date if it does not exist or if it is older than any --of the prerequisites (by comparison of last-modification times). The --idea is that the contents of the target file are computed based on --information in the prerequisites, so if any of the prerequisites --changes, the contents of the existing target file are no longer --necessarily valid. -- -- How to update is specified by COMMANDS. These are lines to be --executed by the shell (normally `sh'), but with some extra features --(*note Writing the Commands in Rules: Commands.). -- -- --File: make.info, Node: Prerequisite Types, Next: Wildcards, Prev: Rule Syntax, Up: Rules -- --4.3 Types of Prerequisites --========================== -- --There are actually two different types of prerequisites understood by --GNU `make': normal prerequisites such as described in the previous --section, and "order-only" prerequisites. A normal prerequisite makes --two statements: first, it imposes an order of execution of build --commands: any commands necessary to build any of a target's --prerequisites will be fully executed before any commands necessary to --build the target. Second, it imposes a dependency relationship: if any --prerequisite is newer than the target, then the target is considered --out-of-date and must be rebuilt. -- -- Normally, this is exactly what you want: if a target's prerequisite --is updated, then the target should also be updated. -- -- Occasionally, however, you have a situation where you want to impose --a specific ordering on the rules to be invoked _without_ forcing the --target to be updated if one of those rules is executed. In that case, --you want to define "order-only" prerequisites. Order-only --prerequisites can be specified by placing a pipe symbol (`|') in the --prerequisites list: any prerequisites to the left of the pipe symbol --are normal; any prerequisites to the right are order-only: -- -- TARGETS : NORMAL-PREREQUISITES | ORDER-ONLY-PREREQUISITES -- -- The normal prerequisites section may of course be empty. Also, you --may still declare multiple lines of prerequisites for the same target: --they are appended appropriately. Note that if you declare the same --file to be both a normal and an order-only prerequisite, the normal --prerequisite takes precedence (since they are a strict superset of the --behavior of an order-only prerequisite). -- -- --File: make.info, Node: Wildcards, Next: Directory Search, Prev: Prerequisite Types, Up: Rules -- --4.4 Using Wildcard Characters in File Names --=========================================== -- --A single file name can specify many files using "wildcard characters". --The wildcard characters in `make' are `*', `?' and `[...]', the same as --in the Bourne shell. For example, `*.c' specifies a list of all the --files (in the working directory) whose names end in `.c'. -- -- The character `~' at the beginning of a file name also has special --significance. If alone, or followed by a slash, it represents your home --directory. For example `~/bin' expands to `/home/you/bin'. If the `~' --is followed by a word, the string represents the home directory of the --user named by that word. For example `~john/bin' expands to --`/home/john/bin'. On systems which don't have a home directory for --each user (such as MS-DOS or MS-Windows), this functionality can be --simulated by setting the environment variable HOME. -- -- Wildcard expansion is performed by `make' automatically in targets --and in prerequisites. In commands the shell is responsible for --wildcard expansion. In other contexts, wildcard expansion happens only --if you request it explicitly with the `wildcard' function. -- -- The special significance of a wildcard character can be turned off by --preceding it with a backslash. Thus, `foo\*bar' would refer to a --specific file whose name consists of `foo', an asterisk, and `bar'. -- --* Menu: -- --* Wildcard Examples:: Several examples --* Wildcard Pitfall:: Problems to avoid. --* Wildcard Function:: How to cause wildcard expansion where -- it does not normally take place. -- -- --File: make.info, Node: Wildcard Examples, Next: Wildcard Pitfall, Prev: Wildcards, Up: Wildcards -- --4.4.1 Wildcard Examples ------------------------- -- --Wildcards can be used in the commands of a rule, where they are expanded --by the shell. For example, here is a rule to delete all the object --files: -- -- clean: -- rm -f *.o -- -- Wildcards are also useful in the prerequisites of a rule. With the --following rule in the makefile, `make print' will print all the `.c' --files that have changed since the last time you printed them: -- -- print: *.c -- lpr -p $? -- touch print -- --This rule uses `print' as an empty target file; see *Note Empty Target --Files to Record Events: Empty Targets. (The automatic variable `$?' is --used to print only those files that have changed; see *Note Automatic --Variables::.) -- -- Wildcard expansion does not happen when you define a variable. --Thus, if you write this: -- -- objects = *.o -- --then the value of the variable `objects' is the actual string `*.o'. --However, if you use the value of `objects' in a target, prerequisite or --command, wildcard expansion will take place at that time. To set --`objects' to the expansion, instead use: -- -- objects := $(wildcard *.o) -- --*Note Wildcard Function::. -- -- --File: make.info, Node: Wildcard Pitfall, Next: Wildcard Function, Prev: Wildcard Examples, Up: Wildcards -- --4.4.2 Pitfalls of Using Wildcards ----------------------------------- -- --Now here is an example of a naive way of using wildcard expansion, that --does not do what you would intend. Suppose you would like to say that --the executable file `foo' is made from all the object files in the --directory, and you write this: -- -- objects = *.o -- -- foo : $(objects) -- cc -o foo $(CFLAGS) $(objects) -- --The value of `objects' is the actual string `*.o'. Wildcard expansion --happens in the rule for `foo', so that each _existing_ `.o' file --becomes a prerequisite of `foo' and will be recompiled if necessary. -- -- But what if you delete all the `.o' files? When a wildcard matches --no files, it is left as it is, so then `foo' will depend on the --oddly-named file `*.o'. Since no such file is likely to exist, `make' --will give you an error saying it cannot figure out how to make `*.o'. --This is not what you want! -- -- Actually it is possible to obtain the desired result with wildcard --expansion, but you need more sophisticated techniques, including the --`wildcard' function and string substitution. *Note The Function --`wildcard': Wildcard Function. -- -- Microsoft operating systems (MS-DOS and MS-Windows) use backslashes --to separate directories in pathnames, like so: -- -- c:\foo\bar\baz.c -- -- This is equivalent to the Unix-style `c:/foo/bar/baz.c' (the `c:' --part is the so-called drive letter). When `make' runs on these --systems, it supports backslashes as well as the Unix-style forward --slashes in pathnames. However, this support does _not_ include the --wildcard expansion, where backslash is a quote character. Therefore, --you _must_ use Unix-style slashes in these cases. -- -- --File: make.info, Node: Wildcard Function, Prev: Wildcard Pitfall, Up: Wildcards -- --4.4.3 The Function `wildcard' ------------------------------- -- --Wildcard expansion happens automatically in rules. But wildcard --expansion does not normally take place when a variable is set, or --inside the arguments of a function. If you want to do wildcard --expansion in such places, you need to use the `wildcard' function, like --this: -- -- $(wildcard PATTERN...) -- --This string, used anywhere in a makefile, is replaced by a --space-separated list of names of existing files that match one of the --given file name patterns. If no existing file name matches a pattern, --then that pattern is omitted from the output of the `wildcard' --function. Note that this is different from how unmatched wildcards --behave in rules, where they are used verbatim rather than ignored --(*note Wildcard Pitfall::). -- -- One use of the `wildcard' function is to get a list of all the C --source files in a directory, like this: -- -- $(wildcard *.c) -- -- We can change the list of C source files into a list of object files --by replacing the `.c' suffix with `.o' in the result, like this: -- -- $(patsubst %.c,%.o,$(wildcard *.c)) -- --(Here we have used another function, `patsubst'. *Note Functions for --String Substitution and Analysis: Text Functions.) -- -- Thus, a makefile to compile all C source files in the directory and --then link them together could be written as follows: -- -- objects := $(patsubst %.c,%.o,$(wildcard *.c)) -- -- foo : $(objects) -- cc -o foo $(objects) -- --(This takes advantage of the implicit rule for compiling C programs, so --there is no need to write explicit rules for compiling the files. --*Note The Two Flavors of Variables: Flavors, for an explanation of --`:=', which is a variant of `='.) -- -- --File: make.info, Node: Directory Search, Next: Phony Targets, Prev: Wildcards, Up: Rules -- --4.5 Searching Directories for Prerequisites --=========================================== -- --For large systems, it is often desirable to put sources in a separate --directory from the binaries. The "directory search" features of `make' --facilitate this by searching several directories automatically to find --a prerequisite. When you redistribute the files among directories, you --do not need to change the individual rules, just the search paths. -- --* Menu: -- --* General Search:: Specifying a search path that applies -- to every prerequisite. --* Selective Search:: Specifying a search path -- for a specified class of names. --* Search Algorithm:: When and how search paths are applied. --* Commands/Search:: How to write shell commands that work together -- with search paths. --* Implicit/Search:: How search paths affect implicit rules. --* Libraries/Search:: Directory search for link libraries. -- -- --File: make.info, Node: General Search, Next: Selective Search, Prev: Directory Search, Up: Directory Search -- --4.5.1 `VPATH': Search Path for All Prerequisites -------------------------------------------------- -- --The value of the `make' variable `VPATH' specifies a list of --directories that `make' should search. Most often, the directories are --expected to contain prerequisite files that are not in the current --directory; however, `make' uses `VPATH' as a search list for both --prerequisites and targets of rules. -- -- Thus, if a file that is listed as a target or prerequisite does not --exist in the current directory, `make' searches the directories listed --in `VPATH' for a file with that name. If a file is found in one of --them, that file may become the prerequisite (see below). Rules may then --specify the names of files in the prerequisite list as if they all --existed in the current directory. *Note Writing Shell Commands with --Directory Search: Commands/Search. -- -- In the `VPATH' variable, directory names are separated by colons or --blanks. The order in which directories are listed is the order followed --by `make' in its search. (On MS-DOS and MS-Windows, semi-colons are --used as separators of directory names in `VPATH', since the colon can --be used in the pathname itself, after the drive letter.) -- -- For example, -- -- VPATH = src:../headers -- --specifies a path containing two directories, `src' and `../headers', --which `make' searches in that order. -- -- With this value of `VPATH', the following rule, -- -- foo.o : foo.c -- --is interpreted as if it were written like this: -- -- foo.o : src/foo.c -- --assuming the file `foo.c' does not exist in the current directory but --is found in the directory `src'. -- -- --File: make.info, Node: Selective Search, Next: Search Algorithm, Prev: General Search, Up: Directory Search -- --4.5.2 The `vpath' Directive ----------------------------- -- --Similar to the `VPATH' variable, but more selective, is the `vpath' --directive (note lower case), which allows you to specify a search path --for a particular class of file names: those that match a particular --pattern. Thus you can supply certain search directories for one class --of file names and other directories (or none) for other file names. -- -- There are three forms of the `vpath' directive: -- --`vpath PATTERN DIRECTORIES' -- Specify the search path DIRECTORIES for file names that match -- PATTERN. -- -- The search path, DIRECTORIES, is a list of directories to be -- searched, separated by colons (semi-colons on MS-DOS and -- MS-Windows) or blanks, just like the search path used in the -- `VPATH' variable. -- --`vpath PATTERN' -- Clear out the search path associated with PATTERN. -- --`vpath' -- Clear all search paths previously specified with `vpath' -- directives. -- -- A `vpath' pattern is a string containing a `%' character. The --string must match the file name of a prerequisite that is being searched --for, the `%' character matching any sequence of zero or more characters --(as in pattern rules; *note Defining and Redefining Pattern Rules: --Pattern Rules.). For example, `%.h' matches files that end in `.h'. --(If there is no `%', the pattern must match the prerequisite exactly, --which is not useful very often.) -- -- `%' characters in a `vpath' directive's pattern can be quoted with --preceding backslashes (`\'). Backslashes that would otherwise quote --`%' characters can be quoted with more backslashes. Backslashes that --quote `%' characters or other backslashes are removed from the pattern --before it is compared to file names. Backslashes that are not in --danger of quoting `%' characters go unmolested. -- -- When a prerequisite fails to exist in the current directory, if the --PATTERN in a `vpath' directive matches the name of the prerequisite --file, then the DIRECTORIES in that directive are searched just like --(and before) the directories in the `VPATH' variable. -- -- For example, -- -- vpath %.h ../headers -- --tells `make' to look for any prerequisite whose name ends in `.h' in --the directory `../headers' if the file is not found in the current --directory. -- -- If several `vpath' patterns match the prerequisite file's name, then --`make' processes each matching `vpath' directive one by one, searching --all the directories mentioned in each directive. `make' handles --multiple `vpath' directives in the order in which they appear in the --makefile; multiple directives with the same pattern are independent of --each other. -- -- Thus, -- -- vpath %.c foo -- vpath % blish -- vpath %.c bar -- --will look for a file ending in `.c' in `foo', then `blish', then `bar', --while -- -- vpath %.c foo:bar -- vpath % blish -- --will look for a file ending in `.c' in `foo', then `bar', then `blish'. -- -- --File: make.info, Node: Search Algorithm, Next: Commands/Search, Prev: Selective Search, Up: Directory Search -- --4.5.3 How Directory Searches are Performed -------------------------------------------- -- --When a prerequisite is found through directory search, regardless of --type (general or selective), the pathname located may not be the one --that `make' actually provides you in the prerequisite list. Sometimes --the path discovered through directory search is thrown away. -- -- The algorithm `make' uses to decide whether to keep or abandon a --path found via directory search is as follows: -- -- 1. If a target file does not exist at the path specified in the -- makefile, directory search is performed. -- -- 2. If the directory search is successful, that path is kept and this -- file is tentatively stored as the target. -- -- 3. All prerequisites of this target are examined using this same -- method. -- -- 4. After processing the prerequisites, the target may or may not need -- to be rebuilt: -- -- a. If the target does _not_ need to be rebuilt, the path to the -- file found during directory search is used for any -- prerequisite lists which contain this target. In short, if -- `make' doesn't need to rebuild the target then you use the -- path found via directory search. -- -- b. If the target _does_ need to be rebuilt (is out-of-date), the -- pathname found during directory search is _thrown away_, and -- the target is rebuilt using the file name specified in the -- makefile. In short, if `make' must rebuild, then the target -- is rebuilt locally, not in the directory found via directory -- search. -- -- This algorithm may seem complex, but in practice it is quite often --exactly what you want. -- -- Other versions of `make' use a simpler algorithm: if the file does --not exist, and it is found via directory search, then that pathname is --always used whether or not the target needs to be built. Thus, if the --target is rebuilt it is created at the pathname discovered during --directory search. -- -- If, in fact, this is the behavior you want for some or all of your --directories, you can use the `GPATH' variable to indicate this to --`make'. -- -- `GPATH' has the same syntax and format as `VPATH' (that is, a space- --or colon-delimited list of pathnames). If an out-of-date target is --found by directory search in a directory that also appears in `GPATH', --then that pathname is not thrown away. The target is rebuilt using the --expanded path. -- -- --File: make.info, Node: Commands/Search, Next: Implicit/Search, Prev: Search Algorithm, Up: Directory Search -- --4.5.4 Writing Shell Commands with Directory Search ---------------------------------------------------- -- --When a prerequisite is found in another directory through directory --search, this cannot change the commands of the rule; they will execute --as written. Therefore, you must write the commands with care so that --they will look for the prerequisite in the directory where `make' finds --it. -- -- This is done with the "automatic variables" such as `$^' (*note --Automatic Variables::). For instance, the value of `$^' is a list of --all the prerequisites of the rule, including the names of the --directories in which they were found, and the value of `$@' is the --target. Thus: -- -- foo.o : foo.c -- cc -c $(CFLAGS) $^ -o $@ -- --(The variable `CFLAGS' exists so you can specify flags for C --compilation by implicit rules; we use it here for consistency so it will --affect all C compilations uniformly; *note Variables Used by Implicit --Rules: Implicit Variables.) -- -- Often the prerequisites include header files as well, which you do --not want to mention in the commands. The automatic variable `$<' is --just the first prerequisite: -- -- VPATH = src:../headers -- foo.o : foo.c defs.h hack.h -- cc -c $(CFLAGS) $< -o $@ -- -- --File: make.info, Node: Implicit/Search, Next: Libraries/Search, Prev: Commands/Search, Up: Directory Search -- --4.5.5 Directory Search and Implicit Rules ------------------------------------------- -- --The search through the directories specified in `VPATH' or with `vpath' --also happens during consideration of implicit rules (*note Using --Implicit Rules: Implicit Rules.). -- -- For example, when a file `foo.o' has no explicit rule, `make' --considers implicit rules, such as the built-in rule to compile `foo.c' --if that file exists. If such a file is lacking in the current --directory, the appropriate directories are searched for it. If `foo.c' --exists (or is mentioned in the makefile) in any of the directories, the --implicit rule for C compilation is applied. -- -- The commands of implicit rules normally use automatic variables as a --matter of necessity; consequently they will use the file names found by --directory search with no extra effort. -- -- --File: make.info, Node: Libraries/Search, Prev: Implicit/Search, Up: Directory Search -- --4.5.6 Directory Search for Link Libraries ------------------------------------------- -- --Directory search applies in a special way to libraries used with the --linker. This special feature comes into play when you write a --prerequisite whose name is of the form `-lNAME'. (You can tell --something strange is going on here because the prerequisite is normally --the name of a file, and the _file name_ of a library generally looks --like `libNAME.a', not like `-lNAME'.) -- -- When a prerequisite's name has the form `-lNAME', `make' handles it --specially by searching for the file `libNAME.so' in the current --directory, in directories specified by matching `vpath' search paths --and the `VPATH' search path, and then in the directories `/lib', --`/usr/lib', and `PREFIX/lib' (normally `/usr/local/lib', but --MS-DOS/MS-Windows versions of `make' behave as if PREFIX is defined to --be the root of the DJGPP installation tree). -- -- If that file is not found, then the file `libNAME.a' is searched --for, in the same directories as above. -- -- For example, if there is a `/usr/lib/libcurses.a' library on your --system (and no `/usr/lib/libcurses.so' file), then -- -- foo : foo.c -lcurses -- cc $^ -o $@ -- --would cause the command `cc foo.c /usr/lib/libcurses.a -o foo' to be --executed when `foo' is older than `foo.c' or than --`/usr/lib/libcurses.a'. -- -- Although the default set of files to be searched for is `libNAME.so' --and `libNAME.a', this is customizable via the `.LIBPATTERNS' variable. --Each word in the value of this variable is a pattern string. When a --prerequisite like `-lNAME' is seen, `make' will replace the percent in --each pattern in the list with NAME and perform the above directory --searches using that library filename. If no library is found, the next --word in the list will be used. -- -- The default value for `.LIBPATTERNS' is `lib%.so lib%.a', which --provides the default behavior described above. -- -- You can turn off link library expansion completely by setting this --variable to an empty value. -- -- --File: make.info, Node: Phony Targets, Next: Force Targets, Prev: Directory Search, Up: Rules -- --4.6 Phony Targets --================= -- --A phony target is one that is not really the name of a file. It is --just a name for some commands to be executed when you make an explicit --request. There are two reasons to use a phony target: to avoid a --conflict with a file of the same name, and to improve performance. -- -- If you write a rule whose commands will not create the target file, --the commands will be executed every time the target comes up for --remaking. Here is an example: -- -- clean: -- rm *.o temp -- --Because the `rm' command does not create a file named `clean', probably --no such file will ever exist. Therefore, the `rm' command will be --executed every time you say `make clean'. -- -- The phony target will cease to work if anything ever does create a --file named `clean' in this directory. Since it has no prerequisites, --the file `clean' would inevitably be considered up to date, and its --commands would not be executed. To avoid this problem, you can --explicitly declare the target to be phony, using the special target --`.PHONY' (*note Special Built-in Target Names: Special Targets.) as --follows: -- -- .PHONY : clean -- --Once this is done, `make clean' will run the commands regardless of --whether there is a file named `clean'. -- -- Since it knows that phony targets do not name actual files that --could be remade from other files, `make' skips the implicit rule search --for phony targets (*note Implicit Rules::). This is why declaring a --target phony is good for performance, even if you are not worried about --the actual file existing. -- -- Thus, you first write the line that states that `clean' is a phony --target, then you write the rule, like this: -- -- .PHONY: clean -- clean: -- rm *.o temp -- -- Another example of the usefulness of phony targets is in conjunction --with recursive invocations of `make' (for more information, see *Note --Recursive Use of `make': Recursion.). In this case the makefile will --often contain a variable which lists a number of subdirectories to be --built. One way to handle this is with one rule whose command is a --shell loop over the subdirectories, like this: -- -- SUBDIRS = foo bar baz -- -- subdirs: -- for dir in $(SUBDIRS); do \ -- $(MAKE) -C $$dir; \ -- done -- -- There are a few problems with this method, however. First, any error --detected in a submake is not noted by this rule, so it will continue to --build the rest of the directories even when one fails. This can be --overcome by adding shell commands to note the error and exit, but then --it will do so even if `make' is invoked with the `-k' option, which is --unfortunate. Second, and perhaps more importantly, you cannot take --advantage of `make''s ability to build targets in parallel (*note --Parallel Execution: Parallel.), since there is only one rule. -- -- By declaring the subdirectories as phony targets (you must do this as --the subdirectory obviously always exists; otherwise it won't be built) --you can remove these problems: -- -- SUBDIRS = foo bar baz -- -- .PHONY: subdirs $(SUBDIRS) -- -- subdirs: $(SUBDIRS) -- -- $(SUBDIRS): -- $(MAKE) -C $@ -- -- foo: baz -- -- Here we've also declared that the `foo' subdirectory cannot be built --until after the `baz' subdirectory is complete; this kind of --relationship declaration is particularly important when attempting --parallel builds. -- -- A phony target should not be a prerequisite of a real target file; --if it is, its commands are run every time `make' goes to update that --file. As long as a phony target is never a prerequisite of a real --target, the phony target commands will be executed only when the phony --target is a specified goal (*note Arguments to Specify the Goals: --Goals.). -- -- Phony targets can have prerequisites. When one directory contains --multiple programs, it is most convenient to describe all of the --programs in one makefile `./Makefile'. Since the target remade by --default will be the first one in the makefile, it is common to make --this a phony target named `all' and give it, as prerequisites, all the --individual programs. For example: -- -- all : prog1 prog2 prog3 -- .PHONY : all -- -- prog1 : prog1.o utils.o -- cc -o prog1 prog1.o utils.o -- -- prog2 : prog2.o -- cc -o prog2 prog2.o -- -- prog3 : prog3.o sort.o utils.o -- cc -o prog3 prog3.o sort.o utils.o -- --Now you can say just `make' to remake all three programs, or specify as --arguments the ones to remake (as in `make prog1 prog3'). Phoniness is --not inherited: the prerequisites of a phony target are not themselves --phony, unless explicitly declared to be so. -- -- When one phony target is a prerequisite of another, it serves as a --subroutine of the other. For example, here `make cleanall' will delete --the object files, the difference files, and the file `program': -- -- .PHONY: cleanall cleanobj cleandiff -- -- cleanall : cleanobj cleandiff -- rm program -- -- cleanobj : -- rm *.o -- -- cleandiff : -- rm *.diff -- -- --File: make.info, Node: Force Targets, Next: Empty Targets, Prev: Phony Targets, Up: Rules -- --4.7 Rules without Commands or Prerequisites --=========================================== -- --If a rule has no prerequisites or commands, and the target of the rule --is a nonexistent file, then `make' imagines this target to have been --updated whenever its rule is run. This implies that all targets --depending on this one will always have their commands run. -- -- An example will illustrate this: -- -- clean: FORCE -- rm $(objects) -- FORCE: -- -- Here the target `FORCE' satisfies the special conditions, so the --target `clean' that depends on it is forced to run its commands. There --is nothing special about the name `FORCE', but that is one name --commonly used this way. -- -- As you can see, using `FORCE' this way has the same results as using --`.PHONY: clean'. -- -- Using `.PHONY' is more explicit and more efficient. However, other --versions of `make' do not support `.PHONY'; thus `FORCE' appears in --many makefiles. *Note Phony Targets::. -- -- --File: make.info, Node: Empty Targets, Next: Special Targets, Prev: Force Targets, Up: Rules -- --4.8 Empty Target Files to Record Events --======================================= -- --The "empty target" is a variant of the phony target; it is used to hold --commands for an action that you request explicitly from time to time. --Unlike a phony target, this target file can really exist; but the file's --contents do not matter, and usually are empty. -- -- The purpose of the empty target file is to record, with its --last-modification time, when the rule's commands were last executed. It --does so because one of the commands is a `touch' command to update the --target file. -- -- The empty target file should have some prerequisites (otherwise it --doesn't make sense). When you ask to remake the empty target, the --commands are executed if any prerequisite is more recent than the --target; in other words, if a prerequisite has changed since the last --time you remade the target. Here is an example: -- -- print: foo.c bar.c -- lpr -p $? -- touch print -- --With this rule, `make print' will execute the `lpr' command if either --source file has changed since the last `make print'. The automatic --variable `$?' is used to print only those files that have changed --(*note Automatic Variables::). -- -- --File: make.info, Node: Special Targets, Next: Multiple Targets, Prev: Empty Targets, Up: Rules -- --4.9 Special Built-in Target Names --================================= -- --Certain names have special meanings if they appear as targets. -- --`.PHONY' -- The prerequisites of the special target `.PHONY' are considered to -- be phony targets. When it is time to consider such a target, -- `make' will run its commands unconditionally, regardless of -- whether a file with that name exists or what its last-modification -- time is. *Note Phony Targets: Phony Targets. -- --`.SUFFIXES' -- The prerequisites of the special target `.SUFFIXES' are the list -- of suffixes to be used in checking for suffix rules. *Note -- Old-Fashioned Suffix Rules: Suffix Rules. -- --`.DEFAULT' -- The commands specified for `.DEFAULT' are used for any target for -- which no rules are found (either explicit rules or implicit rules). -- *Note Last Resort::. If `.DEFAULT' commands are specified, every -- file mentioned as a prerequisite, but not as a target in a rule, -- will have these commands executed on its behalf. *Note Implicit -- Rule Search Algorithm: Implicit Rule Search. -- --`.PRECIOUS' -- The targets which `.PRECIOUS' depends on are given the following -- special treatment: if `make' is killed or interrupted during the -- execution of their commands, the target is not deleted. *Note -- Interrupting or Killing `make': Interrupts. Also, if the target -- is an intermediate file, it will not be deleted after it is no -- longer needed, as is normally done. *Note Chains of Implicit -- Rules: Chained Rules. In this latter respect it overlaps with the -- `.SECONDARY' special target. -- -- You can also list the target pattern of an implicit rule (such as -- `%.o') as a prerequisite file of the special target `.PRECIOUS' to -- preserve intermediate files created by rules whose target patterns -- match that file's name. -- --`.INTERMEDIATE' -- The targets which `.INTERMEDIATE' depends on are treated as -- intermediate files. *Note Chains of Implicit Rules: Chained Rules. -- `.INTERMEDIATE' with no prerequisites has no effect. -- --`.SECONDARY' -- The targets which `.SECONDARY' depends on are treated as -- intermediate files, except that they are never automatically -- deleted. *Note Chains of Implicit Rules: Chained Rules. -- -- `.SECONDARY' with no prerequisites causes all targets to be treated -- as secondary (i.e., no target is removed because it is considered -- intermediate). -- --`.SECONDEXPANSION' -- If `.SECONDEXPANSION' is mentioned as a target anywhere in the -- makefile, then all prerequisite lists defined _after_ it appears -- will be expanded a second time after all makefiles have been read -- in. *Note Secondary Expansion: Secondary Expansion. -- -- The prerequisites of the special target `.SUFFIXES' are the list -- of suffixes to be used in checking for suffix rules. *Note -- Old-Fashioned Suffix Rules: Suffix Rules. -- --`.DELETE_ON_ERROR' -- If `.DELETE_ON_ERROR' is mentioned as a target anywhere in the -- makefile, then `make' will delete the target of a rule if it has -- changed and its commands exit with a nonzero exit status, just as -- it does when it receives a signal. *Note Errors in Commands: -- Errors. -- --`.IGNORE' -- If you specify prerequisites for `.IGNORE', then `make' will -- ignore errors in execution of the commands run for those particular -- files. The commands for `.IGNORE' are not meaningful. -- -- If mentioned as a target with no prerequisites, `.IGNORE' says to -- ignore errors in execution of commands for all files. This usage -- of `.IGNORE' is supported only for historical compatibility. Since -- this affects every command in the makefile, it is not very useful; -- we recommend you use the more selective ways to ignore errors in -- specific commands. *Note Errors in Commands: Errors. -- --`.LOW_RESOLUTION_TIME' -- If you specify prerequisites for `.LOW_RESOLUTION_TIME', `make' -- assumes that these files are created by commands that generate low -- resolution time stamps. The commands for `.LOW_RESOLUTION_TIME' -- are not meaningful. -- -- The high resolution file time stamps of many modern hosts lessen -- the chance of `make' incorrectly concluding that a file is up to -- date. Unfortunately, these hosts provide no way to set a high -- resolution file time stamp, so commands like `cp -p' that -- explicitly set a file's time stamp must discard its subsecond -- part. If a file is created by such a command, you should list it -- as a prerequisite of `.LOW_RESOLUTION_TIME' so that `make' does -- not mistakenly conclude that the file is out of date. For example: -- -- .LOW_RESOLUTION_TIME: dst -- dst: src -- cp -p src dst -- -- Since `cp -p' discards the subsecond part of `src''s time stamp, -- `dst' is typically slightly older than `src' even when it is up to -- date. The `.LOW_RESOLUTION_TIME' line causes `make' to consider -- `dst' to be up to date if its time stamp is at the start of the -- same second that `src''s time stamp is in. -- -- Due to a limitation of the archive format, archive member time -- stamps are always low resolution. You need not list archive -- members as prerequisites of `.LOW_RESOLUTION_TIME', as `make' does -- this automatically. -- --`.SILENT' -- If you specify prerequisites for `.SILENT', then `make' will not -- print the commands to remake those particular files before -- executing them. The commands for `.SILENT' are not meaningful. -- -- If mentioned as a target with no prerequisites, `.SILENT' says not -- to print any commands before executing them. This usage of -- `.SILENT' is supported only for historical compatibility. We -- recommend you use the more selective ways to silence specific -- commands. *Note Command Echoing: Echoing. If you want to silence -- all commands for a particular run of `make', use the `-s' or -- `--silent' option (*note Options Summary::). -- --`.EXPORT_ALL_VARIABLES' -- Simply by being mentioned as a target, this tells `make' to export -- all variables to child processes by default. *Note Communicating -- Variables to a Sub-`make': Variables/Recursion. -- --`.NOTPARALLEL' -- If `.NOTPARALLEL' is mentioned as a target, then this invocation of -- `make' will be run serially, even if the `-j' option is given. -- Any recursively invoked `make' command will still be run in -- parallel (unless its makefile contains this target). Any -- prerequisites on this target are ignored. -- -- Any defined implicit rule suffix also counts as a special target if --it appears as a target, and so does the concatenation of two suffixes, --such as `.c.o'. These targets are suffix rules, an obsolete way of --defining implicit rules (but a way still widely used). In principle, --any target name could be special in this way if you break it in two and --add both pieces to the suffix list. In practice, suffixes normally --begin with `.', so these special target names also begin with `.'. --*Note Old-Fashioned Suffix Rules: Suffix Rules. -- -- --File: make.info, Node: Multiple Targets, Next: Multiple Rules, Prev: Special Targets, Up: Rules -- --4.10 Multiple Targets in a Rule --=============================== -- --A rule with multiple targets is equivalent to writing many rules, each --with one target, and all identical aside from that. The same commands --apply to all the targets, but their effects may vary because you can --substitute the actual target name into the command using `$@'. The --rule contributes the same prerequisites to all the targets also. -- -- This is useful in two cases. -- -- * You want just prerequisites, no commands. For example: -- -- kbd.o command.o files.o: command.h -- -- gives an additional prerequisite to each of the three object files -- mentioned. -- -- * Similar commands work for all the targets. The commands do not -- need to be absolutely identical, since the automatic variable `$@' -- can be used to substitute the particular target to be remade into -- the commands (*note Automatic Variables::). For example: -- -- bigoutput littleoutput : text.g -- generate text.g -$(subst output,,$@) > $@ -- -- is equivalent to -- -- bigoutput : text.g -- generate text.g -big > bigoutput -- littleoutput : text.g -- generate text.g -little > littleoutput -- -- Here we assume the hypothetical program `generate' makes two types -- of output, one if given `-big' and one if given `-little'. *Note -- Functions for String Substitution and Analysis: Text Functions, -- for an explanation of the `subst' function. -- -- Suppose you would like to vary the prerequisites according to the --target, much as the variable `$@' allows you to vary the commands. You --cannot do this with multiple targets in an ordinary rule, but you can --do it with a "static pattern rule". *Note Static Pattern Rules: Static --Pattern. -- -- --File: make.info, Node: Multiple Rules, Next: Static Pattern, Prev: Multiple Targets, Up: Rules -- --4.11 Multiple Rules for One Target --================================== -- --One file can be the target of several rules. All the prerequisites --mentioned in all the rules are merged into one list of prerequisites for --the target. If the target is older than any prerequisite from any rule, --the commands are executed. -- -- There can only be one set of commands to be executed for a file. If --more than one rule gives commands for the same file, `make' uses the --last set given and prints an error message. (As a special case, if the --file's name begins with a dot, no error message is printed. This odd --behavior is only for compatibility with other implementations of --`make'... you should avoid using it). Occasionally it is useful to --have the same target invoke multiple commands which are defined in --different parts of your makefile; you can use "double-colon rules" --(*note Double-Colon::) for this. -- -- An extra rule with just prerequisites can be used to give a few extra --prerequisites to many files at once. For example, makefiles often have --a variable, such as `objects', containing a list of all the compiler --output files in the system being made. An easy way to say that all of --them must be recompiled if `config.h' changes is to write the following: -- -- objects = foo.o bar.o -- foo.o : defs.h -- bar.o : defs.h test.h -- $(objects) : config.h -- -- This could be inserted or taken out without changing the rules that --really specify how to make the object files, making it a convenient --form to use if you wish to add the additional prerequisite --intermittently. -- -- Another wrinkle is that the additional prerequisites could be --specified with a variable that you set with a command argument to `make' --(*note Overriding Variables: Overriding.). For example, -- -- extradeps= -- $(objects) : $(extradeps) -- --means that the command `make extradeps=foo.h' will consider `foo.h' as --a prerequisite of each object file, but plain `make' will not. -- -- If none of the explicit rules for a target has commands, then `make' --searches for an applicable implicit rule to find some commands *note --Using Implicit Rules: Implicit Rules.). -- -- --File: make.info, Node: Static Pattern, Next: Double-Colon, Prev: Multiple Rules, Up: Rules -- --4.12 Static Pattern Rules --========================= -- --"Static pattern rules" are rules which specify multiple targets and --construct the prerequisite names for each target based on the target --name. They are more general than ordinary rules with multiple targets --because the targets do not have to have identical prerequisites. Their --prerequisites must be _analogous_, but not necessarily _identical_. -- --* Menu: -- --* Static Usage:: The syntax of static pattern rules. --* Static versus Implicit:: When are they better than implicit rules? -- -- --File: make.info, Node: Static Usage, Next: Static versus Implicit, Prev: Static Pattern, Up: Static Pattern -- --4.12.1 Syntax of Static Pattern Rules --------------------------------------- -- --Here is the syntax of a static pattern rule: -- -- TARGETS ...: TARGET-PATTERN: PREREQ-PATTERNS ... -- COMMANDS -- ... -- --The TARGETS list specifies the targets that the rule applies to. The --targets can contain wildcard characters, just like the targets of --ordinary rules (*note Using Wildcard Characters in File Names: --Wildcards.). -- -- The TARGET-PATTERN and PREREQ-PATTERNS say how to compute the --prerequisites of each target. Each target is matched against the --TARGET-PATTERN to extract a part of the target name, called the "stem". --This stem is substituted into each of the PREREQ-PATTERNS to make the --prerequisite names (one from each PREREQ-PATTERN). -- -- Each pattern normally contains the character `%' just once. When the --TARGET-PATTERN matches a target, the `%' can match any part of the --target name; this part is called the "stem". The rest of the pattern --must match exactly. For example, the target `foo.o' matches the --pattern `%.o', with `foo' as the stem. The targets `foo.c' and --`foo.out' do not match that pattern. -- -- The prerequisite names for each target are made by substituting the --stem for the `%' in each prerequisite pattern. For example, if one --prerequisite pattern is `%.c', then substitution of the stem `foo' --gives the prerequisite name `foo.c'. It is legitimate to write a --prerequisite pattern that does not contain `%'; then this prerequisite --is the same for all targets. -- -- `%' characters in pattern rules can be quoted with preceding --backslashes (`\'). Backslashes that would otherwise quote `%' --characters can be quoted with more backslashes. Backslashes that quote --`%' characters or other backslashes are removed from the pattern before --it is compared to file names or has a stem substituted into it. --Backslashes that are not in danger of quoting `%' characters go --unmolested. For example, the pattern `the\%weird\\%pattern\\' has --`the%weird\' preceding the operative `%' character, and `pattern\\' --following it. The final two backslashes are left alone because they --cannot affect any `%' character. -- -- Here is an example, which compiles each of `foo.o' and `bar.o' from --the corresponding `.c' file: -- -- objects = foo.o bar.o -- -- all: $(objects) -- -- $(objects): %.o: %.c -- $(CC) -c $(CFLAGS) $< -o $@ -- --Here `$<' is the automatic variable that holds the name of the --prerequisite and `$@' is the automatic variable that holds the name of --the target; see *Note Automatic Variables::. -- -- Each target specified must match the target pattern; a warning is --issued for each target that does not. If you have a list of files, --only some of which will match the pattern, you can use the `filter' --function to remove nonmatching file names (*note Functions for String --Substitution and Analysis: Text Functions.): -- -- files = foo.elc bar.o lose.o -- -- $(filter %.o,$(files)): %.o: %.c -- $(CC) -c $(CFLAGS) $< -o $@ -- $(filter %.elc,$(files)): %.elc: %.el -- emacs -f batch-byte-compile $< -- --In this example the result of `$(filter %.o,$(files))' is `bar.o --lose.o', and the first static pattern rule causes each of these object --files to be updated by compiling the corresponding C source file. The --result of `$(filter %.elc,$(files))' is `foo.elc', so that file is made --from `foo.el'. -- -- Another example shows how to use `$*' in static pattern rules: -- -- bigoutput littleoutput : %output : text.g -- generate text.g -$* > $@ -- --When the `generate' command is run, `$*' will expand to the stem, --either `big' or `little'. -- -- --File: make.info, Node: Static versus Implicit, Prev: Static Usage, Up: Static Pattern -- --4.12.2 Static Pattern Rules versus Implicit Rules --------------------------------------------------- -- --A static pattern rule has much in common with an implicit rule defined --as a pattern rule (*note Defining and Redefining Pattern Rules: Pattern --Rules.). Both have a pattern for the target and patterns for --constructing the names of prerequisites. The difference is in how --`make' decides _when_ the rule applies. -- -- An implicit rule _can_ apply to any target that matches its pattern, --but it _does_ apply only when the target has no commands otherwise --specified, and only when the prerequisites can be found. If more than --one implicit rule appears applicable, only one applies; the choice --depends on the order of rules. -- -- By contrast, a static pattern rule applies to the precise list of --targets that you specify in the rule. It cannot apply to any other --target and it invariably does apply to each of the targets specified. --If two conflicting rules apply, and both have commands, that's an error. -- -- The static pattern rule can be better than an implicit rule for these --reasons: -- -- * You may wish to override the usual implicit rule for a few files -- whose names cannot be categorized syntactically but can be given -- in an explicit list. -- -- * If you cannot be sure of the precise contents of the directories -- you are using, you may not be sure which other irrelevant files -- might lead `make' to use the wrong implicit rule. The choice -- might depend on the order in which the implicit rule search is -- done. With static pattern rules, there is no uncertainty: each -- rule applies to precisely the targets specified. -- -- --File: make.info, Node: Double-Colon, Next: Automatic Prerequisites, Prev: Static Pattern, Up: Rules -- --4.13 Double-Colon Rules --======================= -- --"Double-colon" rules are rules written with `::' instead of `:' after --the target names. They are handled differently from ordinary rules --when the same target appears in more than one rule. -- -- When a target appears in multiple rules, all the rules must be the --same type: all ordinary, or all double-colon. If they are --double-colon, each of them is independent of the others. Each --double-colon rule's commands are executed if the target is older than --any prerequisites of that rule. If there are no prerequisites for that --rule, its commands are always executed (even if the target already --exists). This can result in executing none, any, or all of the --double-colon rules. -- -- Double-colon rules with the same target are in fact completely --separate from one another. Each double-colon rule is processed --individually, just as rules with different targets are processed. -- -- The double-colon rules for a target are executed in the order they --appear in the makefile. However, the cases where double-colon rules --really make sense are those where the order of executing the commands --would not matter. -- -- Double-colon rules are somewhat obscure and not often very useful; --they provide a mechanism for cases in which the method used to update a --target differs depending on which prerequisite files caused the update, --and such cases are rare. -- -- Each double-colon rule should specify commands; if it does not, an --implicit rule will be used if one applies. *Note Using Implicit Rules: --Implicit Rules. -- -- --File: make.info, Node: Automatic Prerequisites, Prev: Double-Colon, Up: Rules -- --4.14 Generating Prerequisites Automatically --=========================================== -- --In the makefile for a program, many of the rules you need to write often --say only that some object file depends on some header file. For --example, if `main.c' uses `defs.h' via an `#include', you would write: -- -- main.o: defs.h -- --You need this rule so that `make' knows that it must remake `main.o' --whenever `defs.h' changes. You can see that for a large program you --would have to write dozens of such rules in your makefile. And, you --must always be very careful to update the makefile every time you add --or remove an `#include'. -- -- To avoid this hassle, most modern C compilers can write these rules --for you, by looking at the `#include' lines in the source files. --Usually this is done with the `-M' option to the compiler. For --example, the command: -- -- cc -M main.c -- --generates the output: -- -- main.o : main.c defs.h -- --Thus you no longer have to write all those rules yourself. The --compiler will do it for you. -- -- Note that such a prerequisite constitutes mentioning `main.o' in a --makefile, so it can never be considered an intermediate file by implicit --rule search. This means that `make' won't ever remove the file after --using it; *note Chains of Implicit Rules: Chained Rules. -- -- With old `make' programs, it was traditional practice to use this --compiler feature to generate prerequisites on demand with a command like --`make depend'. That command would create a file `depend' containing --all the automatically-generated prerequisites; then the makefile could --use `include' to read them in (*note Include::). -- -- In GNU `make', the feature of remaking makefiles makes this practice --obsolete--you need never tell `make' explicitly to regenerate the --prerequisites, because it always regenerates any makefile that is out --of date. *Note Remaking Makefiles::. -- -- The practice we recommend for automatic prerequisite generation is --to have one makefile corresponding to each source file. For each --source file `NAME.c' there is a makefile `NAME.d' which lists what --files the object file `NAME.o' depends on. That way only the source --files that have changed need to be rescanned to produce the new --prerequisites. -- -- Here is the pattern rule to generate a file of prerequisites (i.e., --a makefile) called `NAME.d' from a C source file called `NAME.c': -- -- %.d: %.c -- @set -e; rm -f $@; \ -- $(CC) -M $(CPPFLAGS) $< > $@.$$$$; \ -- sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \ -- rm -f $@.$$$$ -- --*Note Pattern Rules::, for information on defining pattern rules. The --`-e' flag to the shell causes it to exit immediately if the `$(CC)' --command (or any other command) fails (exits with a nonzero status). -- -- With the GNU C compiler, you may wish to use the `-MM' flag instead --of `-M'. This omits prerequisites on system header files. *Note --Options Controlling the Preprocessor: (gcc.info)Preprocessor Options, --for details. -- -- The purpose of the `sed' command is to translate (for example): -- -- main.o : main.c defs.h -- --into: -- -- main.o main.d : main.c defs.h -- --This makes each `.d' file depend on all the source and header files --that the corresponding `.o' file depends on. `make' then knows it must --regenerate the prerequisites whenever any of the source or header files --changes. -- -- Once you've defined the rule to remake the `.d' files, you then use --the `include' directive to read them all in. *Note Include::. For --example: -- -- sources = foo.c bar.c -- -- include $(sources:.c=.d) -- --(This example uses a substitution variable reference to translate the --list of source files `foo.c bar.c' into a list of prerequisite --makefiles, `foo.d bar.d'. *Note Substitution Refs::, for full --information on substitution references.) Since the `.d' files are --makefiles like any others, `make' will remake them as necessary with no --further work from you. *Note Remaking Makefiles::. -- -- Note that the `.d' files contain target definitions; you should be --sure to place the `include' directive _after_ the first, default goal --in your makefiles or run the risk of having a random object file become --the default goal. *Note How Make Works::. -- -- --File: make.info, Node: Commands, Next: Using Variables, Prev: Rules, Up: Top -- --5 Writing the Commands in Rules --******************************* -- --The commands of a rule consist of one or more shell command lines to be --executed, one at a time, in the order they appear. Typically, the --result of executing these commands is that the target of the rule is --brought up to date. -- -- Users use many different shell programs, but commands in makefiles --are always interpreted by `/bin/sh' unless the makefile specifies --otherwise. *Note Command Execution: Execution. -- --* Menu: -- --* Command Syntax:: Command syntax features and pitfalls. --* Echoing:: How to control when commands are echoed. --* Execution:: How commands are executed. --* Parallel:: How commands can be executed in parallel. --* Errors:: What happens after a command execution error. --* Interrupts:: What happens when a command is interrupted. --* Recursion:: Invoking `make' from makefiles. --* Sequences:: Defining canned sequences of commands. --* Empty Commands:: Defining useful, do-nothing commands. -- -- --File: make.info, Node: Command Syntax, Next: Echoing, Prev: Commands, Up: Commands -- --5.1 Command Syntax --================== -- --Makefiles have the unusual property that there are really two distinct --syntaxes in one file. Most of the makefile uses `make' syntax (*note --Writing Makefiles: Makefiles.). However, commands are meant to be --interpreted by the shell and so they are written using shell syntax. --The `make' program does not try to understand shell syntax: it performs --only a very few specific translations on the content of the command --before handing it to the shell. -- -- Each command line must start with a tab, except that the first --command line may be attached to the target-and-prerequisites line with a --semicolon in between. _Any_ line in the makefile that begins with a --tab and appears in a "rule context" (that is, after a rule has been --started until another rule or variable definition) will be considered a --command line for that rule. Blank lines and lines of just comments may --appear among the command lines; they are ignored. -- -- Some consequences of these rules include: -- -- * A blank line that begins with a tab is not blank: it's an empty -- command (*note Empty Commands::). -- -- * A comment in a command line is not a `make' comment; it will be -- passed to the shell as-is. Whether the shell treats it as a -- comment or not depends on your shell. -- -- * A variable definition in a "rule context" which is indented by a -- tab as the first character on the line, will be considered a -- command line, not a `make' variable definition, and passed to the -- shell. -- -- * A conditional expression (`ifdef', `ifeq', etc. *note Syntax of -- Conditionals: Conditional Syntax.) in a "rule context" which is -- indented by a tab as the first character on the line, will be -- considered a command line and be passed to the shell. -- -- --* Menu: -- --* Splitting Lines:: Breaking long command lines for readability. --* Variables in Commands:: Using `make' variables in commands. -- -- --File: make.info, Node: Splitting Lines, Next: Variables in Commands, Prev: Command Syntax, Up: Command Syntax -- --5.1.1 Splitting Command Lines ------------------------------- -- --One of the few ways in which `make' does interpret command lines is --checking for a backslash just before the newline. As in normal --makefile syntax, a single command can be split into multiple lines in --the makefile by placing a backslash before each newline. A sequence of --lines like this is considered a single command, and one instance of the --shell will be invoked to run it. -- -- However, in contrast to how they are treated in other places in a --makefile, backslash-newline pairs are _not_ removed from the command. --Both the backslash and the newline characters are preserved and passed --to the shell. How the backslash-newline is interpreted depends on your --shell. If the first character of the next line after the --backslash-newline is a tab, then that tab (and only that tab) is --removed. Whitespace is never added to the command. -- -- For example, this makefile: -- -- all : -- @echo no\ -- space -- @echo no\ -- space -- @echo one \ -- space -- @echo one\ -- space -- --consists of four separate shell commands where the output is: -- -- nospace -- nospace -- one space -- one space -- -- As a more complex example, this makefile: -- -- all : ; @echo 'hello \ -- world' ; echo "hello \ -- world" -- --will run one shell with a command script of: -- -- echo 'hello \ -- world' ; echo "hello \ -- world" -- --which, according to shell quoting rules, will yield the following --output: -- -- hello \ -- world -- hello world -- --Notice how the backslash/newline pair was removed inside the string --quoted with double quotes (`"..."'), but not from the string quoted --with single quotes (`'...''). This is the way the default shell --(`/bin/sh') handles backslash/newline pairs. If you specify a --different shell in your makefiles it may treat them differently. -- -- Sometimes you want to split a long line inside of single quotes, but --you don't want the backslash-newline to appear in the quoted content. --This is often the case when passing scripts to languages such as Perl, --where extraneous backslashes inside the script can change its meaning --or even be a syntax error. One simple way of handling this is to place --the quoted string, or even the entire command, into a `make' variable --then use the variable in the command. In this situation the newline --quoting rules for makefiles will be used, and the backslash-newline --will be removed. If we rewrite our example above using this method: -- -- HELLO = 'hello \ -- world' -- -- all : ; @echo $(HELLO) -- --we will get output like this: -- -- hello world -- -- If you like, you can also use target-specific variables (*note --Target-specific Variable Values: Target-specific.) to obtain a tighter --correspondence between the variable and the command that uses it. -- -- --File: make.info, Node: Variables in Commands, Prev: Splitting Lines, Up: Command Syntax -- --5.1.2 Using Variables in Commands ----------------------------------- -- --The other way in which `make' processes commands is by expanding any --variable references in them (*note Basics of Variable References: --Reference.). This occurs after make has finished reading all the --makefiles and the target is determined to be out of date; so, the --commands for targets which are not rebuilt are never expanded. -- -- Variable and function references in commands have identical syntax --and semantics to references elsewhere in the makefile. They also have --the same quoting rules: if you want a dollar sign to appear in your --command, you must double it (`$$'). For shells like the default shell, --that use dollar signs to introduce variables, it's important to keep --clear in your mind whether the variable you want to reference is a --`make' variable (use a single dollar sign) or a shell variable (use two --dollar signs). For example: -- -- LIST = one two three -- all: -- for i in $(LIST); do \ -- echo $$i; \ -- done -- --results in the following command being passed to the shell: -- -- for i in one two three; do \ -- echo $i; \ -- done -- --which generates the expected result: -- -- one -- two -- three -- -- --File: make.info, Node: Echoing, Next: Execution, Prev: Command Syntax, Up: Commands -- --5.2 Command Echoing --=================== -- --Normally `make' prints each command line before it is executed. We --call this "echoing" because it gives the appearance that you are typing --the commands yourself. -- -- When a line starts with `@', the echoing of that line is suppressed. --The `@' is discarded before the command is passed to the shell. --Typically you would use this for a command whose only effect is to print --something, such as an `echo' command to indicate progress through the --makefile: -- -- @echo About to make distribution files -- -- When `make' is given the flag `-n' or `--just-print' it only echoes --commands, it won't execute them. *Note Summary of Options: Options --Summary. In this case and only this case, even the commands starting --with `@' are printed. This flag is useful for finding out which --commands `make' thinks are necessary without actually doing them. -- -- The `-s' or `--silent' flag to `make' prevents all echoing, as if --all commands started with `@'. A rule in the makefile for the special --target `.SILENT' without prerequisites has the same effect (*note --Special Built-in Target Names: Special Targets.). `.SILENT' is --essentially obsolete since `@' is more flexible. -- -- --File: make.info, Node: Execution, Next: Parallel, Prev: Echoing, Up: Commands -- --5.3 Command Execution --===================== -- --When it is time to execute commands to update a target, they are --executed by invoking a new subshell for each command line. (In --practice, `make' may take shortcuts that do not affect the results.) -- -- *Please note:* this implies that setting shell variables and --invoking shell commands such as `cd' that set a context local to each --process will not affect the following command lines.(1) If you want to --use `cd' to affect the next statement, put both statements in a single --command line. Then `make' will invoke one shell to run the entire --line, and the shell will execute the statements in sequence. For --example: -- -- foo : bar/lose -- cd $(@D) && gobble $(@F) > ../$@ -- --Here we use the shell AND operator (`&&') so that if the `cd' command --fails, the script will fail without trying to invoke the `gobble' --command in the wrong directory, which could cause problems (in this --case it would certainly cause `../foo' to be truncated, at least). -- --* Menu: -- --* Choosing the Shell:: How `make' chooses the shell used -- to run commands. -- -- ---------- Footnotes ---------- -- -- (1) On MS-DOS, the value of current working directory is *global*, so --changing it _will_ affect the following command lines on those systems. -- -- --File: make.info, Node: Choosing the Shell, Prev: Execution, Up: Execution -- --5.3.1 Choosing the Shell -------------------------- -- --The program used as the shell is taken from the variable `SHELL'. If --this variable is not set in your makefile, the program `/bin/sh' is --used as the shell. -- -- Unlike most variables, the variable `SHELL' is never set from the --environment. This is because the `SHELL' environment variable is used --to specify your personal choice of shell program for interactive use. --It would be very bad for personal choices like this to affect the --functioning of makefiles. *Note Variables from the Environment: --Environment. -- -- Furthermore, when you do set `SHELL' in your makefile that value is --_not_ exported in the environment to commands that `make' invokes. --Instead, the value inherited from the user's environment, if any, is --exported. You can override this behavior by explicitly exporting --`SHELL' (*note Communicating Variables to a Sub-`make': --Variables/Recursion.), forcing it to be passed in the environment to --commands. -- -- However, on MS-DOS and MS-Windows the value of `SHELL' in the --environment *is* used, since on those systems most users do not set --this variable, and therefore it is most likely set specifically to be --used by `make'. On MS-DOS, if the setting of `SHELL' is not suitable --for `make', you can set the variable `MAKESHELL' to the shell that --`make' should use; if set it will be used as the shell instead of the --value of `SHELL'. -- --Choosing a Shell in DOS and Windows --................................... -- --Choosing a shell in MS-DOS and MS-Windows is much more complex than on --other systems. -- -- On MS-DOS, if `SHELL' is not set, the value of the variable --`COMSPEC' (which is always set) is used instead. -- -- The processing of lines that set the variable `SHELL' in Makefiles --is different on MS-DOS. The stock shell, `command.com', is --ridiculously limited in its functionality and many users of `make' tend --to install a replacement shell. Therefore, on MS-DOS, `make' examines --the value of `SHELL', and changes its behavior based on whether it --points to a Unix-style or DOS-style shell. This allows reasonable --functionality even if `SHELL' points to `command.com'. -- -- If `SHELL' points to a Unix-style shell, `make' on MS-DOS --additionally checks whether that shell can indeed be found; if not, it --ignores the line that sets `SHELL'. In MS-DOS, GNU `make' searches for --the shell in the following places: -- -- 1. In the precise place pointed to by the value of `SHELL'. For -- example, if the makefile specifies `SHELL = /bin/sh', `make' will -- look in the directory `/bin' on the current drive. -- -- 2. In the current directory. -- -- 3. In each of the directories in the `PATH' variable, in order. -- -- -- In every directory it examines, `make' will first look for the --specific file (`sh' in the example above). If this is not found, it --will also look in that directory for that file with one of the known --extensions which identify executable files. For example `.exe', --`.com', `.bat', `.btm', `.sh', and some others. -- -- If any of these attempts is successful, the value of `SHELL' will be --set to the full pathname of the shell as found. However, if none of --these is found, the value of `SHELL' will not be changed, and thus the --line that sets it will be effectively ignored. This is so `make' will --only support features specific to a Unix-style shell if such a shell is --actually installed on the system where `make' runs. -- -- Note that this extended search for the shell is limited to the cases --where `SHELL' is set from the Makefile; if it is set in the environment --or command line, you are expected to set it to the full pathname of the --shell, exactly as things are on Unix. -- -- The effect of the above DOS-specific processing is that a Makefile --that contains `SHELL = /bin/sh' (as many Unix makefiles do), will work --on MS-DOS unaltered if you have e.g. `sh.exe' installed in some --directory along your `PATH'. -- -- --File: make.info, Node: Parallel, Next: Errors, Prev: Execution, Up: Commands -- --5.4 Parallel Execution --====================== -- --GNU `make' knows how to execute several commands at once. Normally, --`make' will execute only one command at a time, waiting for it to --finish before executing the next. However, the `-j' or `--jobs' option --tells `make' to execute many commands simultaneously. -- -- On MS-DOS, the `-j' option has no effect, since that system doesn't --support multi-processing. -- -- If the `-j' option is followed by an integer, this is the number of --commands to execute at once; this is called the number of "job slots". --If there is nothing looking like an integer after the `-j' option, --there is no limit on the number of job slots. The default number of job --slots is one, which means serial execution (one thing at a time). -- -- One unpleasant consequence of running several commands --simultaneously is that output generated by the commands appears --whenever each command sends it, so messages from different commands may --be interspersed. -- -- Another problem is that two processes cannot both take input from the --same device; so to make sure that only one command tries to take input --from the terminal at once, `make' will invalidate the standard input --streams of all but one running command. This means that attempting to --read from standard input will usually be a fatal error (a `Broken pipe' --signal) for most child processes if there are several. -- -- It is unpredictable which command will have a valid standard input --stream (which will come from the terminal, or wherever you redirect the --standard input of `make'). The first command run will always get it --first, and the first command started after that one finishes will get --it next, and so on. -- -- We will change how this aspect of `make' works if we find a better --alternative. In the mean time, you should not rely on any command using --standard input at all if you are using the parallel execution feature; --but if you are not using this feature, then standard input works --normally in all commands. -- -- Finally, handling recursive `make' invocations raises issues. For --more information on this, see *Note Communicating Options to a --Sub-`make': Options/Recursion. -- -- If a command fails (is killed by a signal or exits with a nonzero --status), and errors are not ignored for that command (*note Errors in --Commands: Errors.), the remaining command lines to remake the same --target will not be run. If a command fails and the `-k' or --`--keep-going' option was not given (*note Summary of Options: Options --Summary.), `make' aborts execution. If make terminates for any reason --(including a signal) with child processes running, it waits for them to --finish before actually exiting. -- -- When the system is heavily loaded, you will probably want to run --fewer jobs than when it is lightly loaded. You can use the `-l' option --to tell `make' to limit the number of jobs to run at once, based on the --load average. The `-l' or `--max-load' option is followed by a --floating-point number. For example, -- -- -l 2.5 -- --will not let `make' start more than one job if the load average is --above 2.5. The `-l' option with no following number removes the load --limit, if one was given with a previous `-l' option. -- -- More precisely, when `make' goes to start up a job, and it already --has at least one job running, it checks the current load average; if it --is not lower than the limit given with `-l', `make' waits until the load --average goes below that limit, or until all the other jobs finish. -- -- By default, there is no load limit. -- -- --File: make.info, Node: Errors, Next: Interrupts, Prev: Parallel, Up: Commands -- --5.5 Errors in Commands --====================== -- --After each shell command returns, `make' looks at its exit status. If --the command completed successfully, the next command line is executed --in a new shell; after the last command line is finished, the rule is --finished. -- -- If there is an error (the exit status is nonzero), `make' gives up on --the current rule, and perhaps on all rules. -- -- Sometimes the failure of a certain command does not indicate a --problem. For example, you may use the `mkdir' command to ensure that a --directory exists. If the directory already exists, `mkdir' will report --an error, but you probably want `make' to continue regardless. -- -- To ignore errors in a command line, write a `-' at the beginning of --the line's text (after the initial tab). The `-' is discarded before --the command is passed to the shell for execution. -- -- For example, -- -- clean: -- -rm -f *.o -- --This causes `rm' to continue even if it is unable to remove a file. -- -- When you run `make' with the `-i' or `--ignore-errors' flag, errors --are ignored in all commands of all rules. A rule in the makefile for --the special target `.IGNORE' has the same effect, if there are no --prerequisites. These ways of ignoring errors are obsolete because `-' --is more flexible. -- -- When errors are to be ignored, because of either a `-' or the `-i' --flag, `make' treats an error return just like success, except that it --prints out a message that tells you the status code the command exited --with, and says that the error has been ignored. -- -- When an error happens that `make' has not been told to ignore, it --implies that the current target cannot be correctly remade, and neither --can any other that depends on it either directly or indirectly. No --further commands will be executed for these targets, since their --preconditions have not been achieved. -- -- Normally `make' gives up immediately in this circumstance, returning --a nonzero status. However, if the `-k' or `--keep-going' flag is --specified, `make' continues to consider the other prerequisites of the --pending targets, remaking them if necessary, before it gives up and --returns nonzero status. For example, after an error in compiling one --object file, `make -k' will continue compiling other object files even --though it already knows that linking them will be impossible. *Note --Summary of Options: Options Summary. -- -- The usual behavior assumes that your purpose is to get the specified --targets up to date; once `make' learns that this is impossible, it --might as well report the failure immediately. The `-k' option says --that the real purpose is to test as many of the changes made in the --program as possible, perhaps to find several independent problems so --that you can correct them all before the next attempt to compile. This --is why Emacs' `compile' command passes the `-k' flag by default. -- -- Usually when a command fails, if it has changed the target file at --all, the file is corrupted and cannot be used--or at least it is not --completely updated. Yet the file's time stamp says that it is now up to --date, so the next time `make' runs, it will not try to update that --file. The situation is just the same as when the command is killed by a --signal; *note Interrupts::. So generally the right thing to do is to --delete the target file if the command fails after beginning to change --the file. `make' will do this if `.DELETE_ON_ERROR' appears as a --target. This is almost always what you want `make' to do, but it is --not historical practice; so for compatibility, you must explicitly --request it. -- -- --File: make.info, Node: Interrupts, Next: Recursion, Prev: Errors, Up: Commands -- --5.6 Interrupting or Killing `make' --================================== -- --If `make' gets a fatal signal while a command is executing, it may --delete the target file that the command was supposed to update. This is --done if the target file's last-modification time has changed since --`make' first checked it. -- -- The purpose of deleting the target is to make sure that it is remade --from scratch when `make' is next run. Why is this? Suppose you type --`Ctrl-c' while a compiler is running, and it has begun to write an --object file `foo.o'. The `Ctrl-c' kills the compiler, resulting in an --incomplete file whose last-modification time is newer than the source --file `foo.c'. But `make' also receives the `Ctrl-c' signal and deletes --this incomplete file. If `make' did not do this, the next invocation --of `make' would think that `foo.o' did not require updating--resulting --in a strange error message from the linker when it tries to link an --object file half of which is missing. -- -- You can prevent the deletion of a target file in this way by making --the special target `.PRECIOUS' depend on it. Before remaking a target, --`make' checks to see whether it appears on the prerequisites of --`.PRECIOUS', and thereby decides whether the target should be deleted --if a signal happens. Some reasons why you might do this are that the --target is updated in some atomic fashion, or exists only to record a --modification-time (its contents do not matter), or must exist at all --times to prevent other sorts of trouble. -- -- --File: make.info, Node: Recursion, Next: Sequences, Prev: Interrupts, Up: Commands -- --5.7 Recursive Use of `make' --=========================== -- --Recursive use of `make' means using `make' as a command in a makefile. --This technique is useful when you want separate makefiles for various --subsystems that compose a larger system. For example, suppose you have --a subdirectory `subdir' which has its own makefile, and you would like --the containing directory's makefile to run `make' on the subdirectory. --You can do it by writing this: -- -- subsystem: -- cd subdir && $(MAKE) -- --or, equivalently, this (*note Summary of Options: Options Summary.): -- -- subsystem: -- $(MAKE) -C subdir -- -- You can write recursive `make' commands just by copying this example, --but there are many things to know about how they work and why, and about --how the sub-`make' relates to the top-level `make'. You may also find --it useful to declare targets that invoke recursive `make' commands as --`.PHONY' (for more discussion on when this is useful, see *Note Phony --Targets::). -- -- For your convenience, when GNU `make' starts (after it has processed --any `-C' options) it sets the variable `CURDIR' to the pathname of the --current working directory. This value is never touched by `make' --again: in particular note that if you include files from other --directories the value of `CURDIR' does not change. The value has the --same precedence it would have if it were set in the makefile (by --default, an environment variable `CURDIR' will not override this --value). Note that setting this variable has no impact on the operation --of `make' (it does not cause `make' to change its working directory, --for example). -- --* Menu: -- --* MAKE Variable:: The special effects of using `$(MAKE)'. --* Variables/Recursion:: How to communicate variables to a sub-`make'. --* Options/Recursion:: How to communicate options to a sub-`make'. --* -w Option:: How the `-w' or `--print-directory' option -- helps debug use of recursive `make' commands. -- -- --File: make.info, Node: MAKE Variable, Next: Variables/Recursion, Prev: Recursion, Up: Recursion -- --5.7.1 How the `MAKE' Variable Works ------------------------------------- -- --Recursive `make' commands should always use the variable `MAKE', not --the explicit command name `make', as shown here: -- -- subsystem: -- cd subdir && $(MAKE) -- -- The value of this variable is the file name with which `make' was --invoked. If this file name was `/bin/make', then the command executed --is `cd subdir && /bin/make'. If you use a special version of `make' to --run the top-level makefile, the same special version will be executed --for recursive invocations. -- -- As a special feature, using the variable `MAKE' in the commands of a --rule alters the effects of the `-t' (`--touch'), `-n' (`--just-print'), --or `-q' (`--question') option. Using the `MAKE' variable has the same --effect as using a `+' character at the beginning of the command line. --*Note Instead of Executing the Commands: Instead of Execution. This --special feature is only enabled if the `MAKE' variable appears directly --in the command script: it does not apply if the `MAKE' variable is --referenced through expansion of another variable. In the latter case --you must use the `+' token to get these special effects. -- -- Consider the command `make -t' in the above example. (The `-t' --option marks targets as up to date without actually running any --commands; see *Note Instead of Execution::.) Following the usual --definition of `-t', a `make -t' command in the example would create a --file named `subsystem' and do nothing else. What you really want it to --do is run `cd subdir && make -t'; but that would require executing the --command, and `-t' says not to execute commands. -- -- The special feature makes this do what you want: whenever a command --line of a rule contains the variable `MAKE', the flags `-t', `-n' and --`-q' do not apply to that line. Command lines containing `MAKE' are --executed normally despite the presence of a flag that causes most --commands not to be run. The usual `MAKEFLAGS' mechanism passes the --flags to the sub-`make' (*note Communicating Options to a Sub-`make': --Options/Recursion.), so your request to touch the files, or print the --commands, is propagated to the subsystem. -- -- --File: make.info, Node: Variables/Recursion, Next: Options/Recursion, Prev: MAKE Variable, Up: Recursion -- --5.7.2 Communicating Variables to a Sub-`make' ----------------------------------------------- -- --Variable values of the top-level `make' can be passed to the sub-`make' --through the environment by explicit request. These variables are --defined in the sub-`make' as defaults, but do not override what is --specified in the makefile used by the sub-`make' makefile unless you --use the `-e' switch (*note Summary of Options: Options Summary.). -- -- To pass down, or "export", a variable, `make' adds the variable and --its value to the environment for running each command. The sub-`make', --in turn, uses the environment to initialize its table of variable --values. *Note Variables from the Environment: Environment. -- -- Except by explicit request, `make' exports a variable only if it is --either defined in the environment initially or set on the command line, --and if its name consists only of letters, numbers, and underscores. --Some shells cannot cope with environment variable names consisting of --characters other than letters, numbers, and underscores. -- -- The value of the `make' variable `SHELL' is not exported. Instead, --the value of the `SHELL' variable from the invoking environment is --passed to the sub-`make'. You can force `make' to export its value for --`SHELL' by using the `export' directive, described below. *Note --Choosing the Shell::. -- -- The special variable `MAKEFLAGS' is always exported (unless you --unexport it). `MAKEFILES' is exported if you set it to anything. -- -- `make' automatically passes down variable values that were defined --on the command line, by putting them in the `MAKEFLAGS' variable. --*Note Options/Recursion::. -- -- Variables are _not_ normally passed down if they were created by --default by `make' (*note Variables Used by Implicit Rules: Implicit --Variables.). The sub-`make' will define these for itself. -- -- If you want to export specific variables to a sub-`make', use the --`export' directive, like this: -- -- export VARIABLE ... -- --If you want to _prevent_ a variable from being exported, use the --`unexport' directive, like this: -- -- unexport VARIABLE ... -- --In both of these forms, the arguments to `export' and `unexport' are --expanded, and so could be variables or functions which expand to a --(list of) variable names to be (un)exported. -- -- As a convenience, you can define a variable and export it at the same --time by doing: -- -- export VARIABLE = value -- --has the same result as: -- -- VARIABLE = value -- export VARIABLE -- --and -- -- export VARIABLE := value -- --has the same result as: -- -- VARIABLE := value -- export VARIABLE -- -- Likewise, -- -- export VARIABLE += value -- --is just like: -- -- VARIABLE += value -- export VARIABLE -- --*Note Appending More Text to Variables: Appending. -- -- You may notice that the `export' and `unexport' directives work in --`make' in the same way they work in the shell, `sh'. -- -- If you want all variables to be exported by default, you can use --`export' by itself: -- -- export -- --This tells `make' that variables which are not explicitly mentioned in --an `export' or `unexport' directive should be exported. Any variable --given in an `unexport' directive will still _not_ be exported. If you --use `export' by itself to export variables by default, variables whose --names contain characters other than alphanumerics and underscores will --not be exported unless specifically mentioned in an `export' directive. -- -- The behavior elicited by an `export' directive by itself was the --default in older versions of GNU `make'. If your makefiles depend on --this behavior and you want to be compatible with old versions of --`make', you can write a rule for the special target --`.EXPORT_ALL_VARIABLES' instead of using the `export' directive. This --will be ignored by old `make's, while the `export' directive will cause --a syntax error. -- -- Likewise, you can use `unexport' by itself to tell `make' _not_ to --export variables by default. Since this is the default behavior, you --would only need to do this if `export' had been used by itself earlier --(in an included makefile, perhaps). You *cannot* use `export' and --`unexport' by themselves to have variables exported for some commands --and not for others. The last `export' or `unexport' directive that --appears by itself determines the behavior for the entire run of `make'. -- -- As a special feature, the variable `MAKELEVEL' is changed when it is --passed down from level to level. This variable's value is a string --which is the depth of the level as a decimal number. The value is `0' --for the top-level `make'; `1' for a sub-`make', `2' for a --sub-sub-`make', and so on. The incrementation happens when `make' sets --up the environment for a command. -- -- The main use of `MAKELEVEL' is to test it in a conditional directive --(*note Conditional Parts of Makefiles: Conditionals.); this way you can --write a makefile that behaves one way if run recursively and another --way if run directly by you. -- -- You can use the variable `MAKEFILES' to cause all sub-`make' --commands to use additional makefiles. The value of `MAKEFILES' is a --whitespace-separated list of file names. This variable, if defined in --the outer-level makefile, is passed down through the environment; then --it serves as a list of extra makefiles for the sub-`make' to read --before the usual or specified ones. *Note The Variable `MAKEFILES': --MAKEFILES Variable. -- -- --File: make.info, Node: Options/Recursion, Next: -w Option, Prev: Variables/Recursion, Up: Recursion -- --5.7.3 Communicating Options to a Sub-`make' --------------------------------------------- -- --Flags such as `-s' and `-k' are passed automatically to the sub-`make' --through the variable `MAKEFLAGS'. This variable is set up --automatically by `make' to contain the flag letters that `make' --received. Thus, if you do `make -ks' then `MAKEFLAGS' gets the value --`ks'. -- -- As a consequence, every sub-`make' gets a value for `MAKEFLAGS' in --its environment. In response, it takes the flags from that value and --processes them as if they had been given as arguments. *Note Summary --of Options: Options Summary. -- -- Likewise variables defined on the command line are passed to the --sub-`make' through `MAKEFLAGS'. Words in the value of `MAKEFLAGS' that --contain `=', `make' treats as variable definitions just as if they --appeared on the command line. *Note Overriding Variables: Overriding. -- -- The options `-C', `-f', `-o', and `-W' are not put into `MAKEFLAGS'; --these options are not passed down. -- -- The `-j' option is a special case (*note Parallel Execution: --Parallel.). If you set it to some numeric value `N' and your operating --system supports it (most any UNIX system will; others typically won't), --the parent `make' and all the sub-`make's will communicate to ensure --that there are only `N' jobs running at the same time between them all. --Note that any job that is marked recursive (*note Instead of Executing --the Commands: Instead of Execution.) doesn't count against the total --jobs (otherwise we could get `N' sub-`make's running and have no slots --left over for any real work!) -- -- If your operating system doesn't support the above communication, --then `-j 1' is always put into `MAKEFLAGS' instead of the value you --specified. This is because if the `-j' option were passed down to --sub-`make's, you would get many more jobs running in parallel than you --asked for. If you give `-j' with no numeric argument, meaning to run --as many jobs as possible in parallel, this is passed down, since --multiple infinities are no more than one. -- -- If you do not want to pass the other flags down, you must change the --value of `MAKEFLAGS', like this: -- -- subsystem: -- cd subdir && $(MAKE) MAKEFLAGS= -- -- The command line variable definitions really appear in the variable --`MAKEOVERRIDES', and `MAKEFLAGS' contains a reference to this variable. --If you do want to pass flags down normally, but don't want to pass --down the command line variable definitions, you can reset --`MAKEOVERRIDES' to empty, like this: -- -- MAKEOVERRIDES = -- --This is not usually useful to do. However, some systems have a small --fixed limit on the size of the environment, and putting so much --information into the value of `MAKEFLAGS' can exceed it. If you see --the error message `Arg list too long', this may be the problem. (For --strict compliance with POSIX.2, changing `MAKEOVERRIDES' does not --affect `MAKEFLAGS' if the special target `.POSIX' appears in the --makefile. You probably do not care about this.) -- -- A similar variable `MFLAGS' exists also, for historical --compatibility. It has the same value as `MAKEFLAGS' except that it --does not contain the command line variable definitions, and it always --begins with a hyphen unless it is empty (`MAKEFLAGS' begins with a --hyphen only when it begins with an option that has no single-letter --version, such as `--warn-undefined-variables'). `MFLAGS' was --traditionally used explicitly in the recursive `make' command, like --this: -- -- subsystem: -- cd subdir && $(MAKE) $(MFLAGS) -- --but now `MAKEFLAGS' makes this usage redundant. If you want your --makefiles to be compatible with old `make' programs, use this --technique; it will work fine with more modern `make' versions too. -- -- The `MAKEFLAGS' variable can also be useful if you want to have --certain options, such as `-k' (*note Summary of Options: Options --Summary.), set each time you run `make'. You simply put a value for --`MAKEFLAGS' in your environment. You can also set `MAKEFLAGS' in a --makefile, to specify additional flags that should also be in effect for --that makefile. (Note that you cannot use `MFLAGS' this way. That --variable is set only for compatibility; `make' does not interpret a --value you set for it in any way.) -- -- When `make' interprets the value of `MAKEFLAGS' (either from the --environment or from a makefile), it first prepends a hyphen if the value --does not already begin with one. Then it chops the value into words --separated by blanks, and parses these words as if they were options --given on the command line (except that `-C', `-f', `-h', `-o', `-W', --and their long-named versions are ignored; and there is no error for an --invalid option). -- -- If you do put `MAKEFLAGS' in your environment, you should be sure not --to include any options that will drastically affect the actions of --`make' and undermine the purpose of makefiles and of `make' itself. --For instance, the `-t', `-n', and `-q' options, if put in one of these --variables, could have disastrous consequences and would certainly have --at least surprising and probably annoying effects. -- -- --File: make.info, Node: -w Option, Prev: Options/Recursion, Up: Recursion -- --5.7.4 The `--print-directory' Option -------------------------------------- -- --If you use several levels of recursive `make' invocations, the `-w' or --`--print-directory' option can make the output a lot easier to --understand by showing each directory as `make' starts processing it and --as `make' finishes processing it. For example, if `make -w' is run in --the directory `/u/gnu/make', `make' will print a line of the form: -- -- make: Entering directory `/u/gnu/make'. -- --before doing anything else, and a line of the form: -- -- make: Leaving directory `/u/gnu/make'. -- --when processing is completed. -- -- Normally, you do not need to specify this option because `make' does --it for you: `-w' is turned on automatically when you use the `-C' --option, and in sub-`make's. `make' will not automatically turn on `-w' --if you also use `-s', which says to be silent, or if you use --`--no-print-directory' to explicitly disable it. -- -- --File: make.info, Node: Sequences, Next: Empty Commands, Prev: Recursion, Up: Commands -- --5.8 Defining Canned Command Sequences --===================================== -- --When the same sequence of commands is useful in making various targets, --you can define it as a canned sequence with the `define' directive, and --refer to the canned sequence from the rules for those targets. The --canned sequence is actually a variable, so the name must not conflict --with other variable names. -- -- Here is an example of defining a canned sequence of commands: -- -- define run-yacc -- yacc $(firstword $^) -- mv y.tab.c $@ -- endef -- --Here `run-yacc' is the name of the variable being defined; `endef' --marks the end of the definition; the lines in between are the commands. --The `define' directive does not expand variable references and --function calls in the canned sequence; the `$' characters, parentheses, --variable names, and so on, all become part of the value of the variable --you are defining. *Note Defining Variables Verbatim: Defining, for a --complete explanation of `define'. -- -- The first command in this example runs Yacc on the first --prerequisite of whichever rule uses the canned sequence. The output --file from Yacc is always named `y.tab.c'. The second command moves the --output to the rule's target file name. -- -- To use the canned sequence, substitute the variable into the --commands of a rule. You can substitute it like any other variable --(*note Basics of Variable References: Reference.). Because variables --defined by `define' are recursively expanded variables, all the --variable references you wrote inside the `define' are expanded now. --For example: -- -- foo.c : foo.y -- $(run-yacc) -- --`foo.y' will be substituted for the variable `$^' when it occurs in --`run-yacc''s value, and `foo.c' for `$@'. -- -- This is a realistic example, but this particular one is not needed in --practice because `make' has an implicit rule to figure out these --commands based on the file names involved (*note Using Implicit Rules: --Implicit Rules.). -- -- In command execution, each line of a canned sequence is treated just --as if the line appeared on its own in the rule, preceded by a tab. In --particular, `make' invokes a separate subshell for each line. You can --use the special prefix characters that affect command lines (`@', `-', --and `+') on each line of a canned sequence. *Note Writing the Commands --in Rules: Commands. For example, using this canned sequence: -- -- define frobnicate -- @echo "frobnicating target $@" -- frob-step-1 $< -o $@-step-1 -- frob-step-2 $@-step-1 -o $@ -- endef -- --`make' will not echo the first line, the `echo' command. But it _will_ --echo the following two command lines. -- -- On the other hand, prefix characters on the command line that refers --to a canned sequence apply to every line in the sequence. So the rule: -- -- frob.out: frob.in -- @$(frobnicate) -- --does not echo _any_ commands. (*Note Command Echoing: Echoing, for a --full explanation of `@'.) -- -- --File: make.info, Node: Empty Commands, Prev: Sequences, Up: Commands -- --5.9 Using Empty Commands --======================== -- --It is sometimes useful to define commands which do nothing. This is --done simply by giving a command that consists of nothing but --whitespace. For example: -- -- target: ; -- --defines an empty command string for `target'. You could also use a --line beginning with a tab character to define an empty command string, --but this would be confusing because such a line looks empty. -- -- You may be wondering why you would want to define a command string --that does nothing. The only reason this is useful is to prevent a --target from getting implicit commands (from implicit rules or the --`.DEFAULT' special target; *note Implicit Rules:: and *note Defining --Last-Resort Default Rules: Last Resort.). -- -- You may be inclined to define empty command strings for targets that --are not actual files, but only exist so that their prerequisites can be --remade. However, this is not the best way to do that, because the --prerequisites may not be remade properly if the target file actually --does exist. *Note Phony Targets: Phony Targets, for a better way to do --this. -- -- --File: make.info, Node: Using Variables, Next: Conditionals, Prev: Commands, Up: Top -- --6 How to Use Variables --********************** -- --A "variable" is a name defined in a makefile to represent a string of --text, called the variable's "value". These values are substituted by --explicit request into targets, prerequisites, commands, and other parts --of the makefile. (In some other versions of `make', variables are --called "macros".) -- -- Variables and functions in all parts of a makefile are expanded when --read, except for the shell commands in rules, the right-hand sides of --variable definitions using `=', and the bodies of variable definitions --using the `define' directive. -- -- Variables can represent lists of file names, options to pass to --compilers, programs to run, directories to look in for source files, --directories to write output in, or anything else you can imagine. -- -- A variable name may be any sequence of characters not containing `:', --`#', `=', or leading or trailing whitespace. However, variable names --containing characters other than letters, numbers, and underscores --should be avoided, as they may be given special meanings in the future, --and with some shells they cannot be passed through the environment to a --sub-`make' (*note Communicating Variables to a Sub-`make': --Variables/Recursion.). -- -- Variable names are case-sensitive. The names `foo', `FOO', and --`Foo' all refer to different variables. -- -- It is traditional to use upper case letters in variable names, but we --recommend using lower case letters for variable names that serve --internal purposes in the makefile, and reserving upper case for --parameters that control implicit rules or for parameters that the user --should override with command options (*note Overriding Variables: --Overriding.). -- -- A few variables have names that are a single punctuation character or --just a few characters. These are the "automatic variables", and they --have particular specialized uses. *Note Automatic Variables::. -- --* Menu: -- --* Reference:: How to use the value of a variable. --* Flavors:: Variables come in two flavors. --* Advanced:: Advanced features for referencing a variable. --* Values:: All the ways variables get their values. --* Setting:: How to set a variable in the makefile. --* Appending:: How to append more text to the old value -- of a variable. --* Override Directive:: How to set a variable in the makefile even if -- the user has set it with a command argument. --* Defining:: An alternate way to set a variable -- to a verbatim string. --* Environment:: Variable values can come from the environment. --* Target-specific:: Variable values can be defined on a per-target -- basis. --* Pattern-specific:: Target-specific variable values can be applied -- to a group of targets that match a pattern. -- -- --File: make.info, Node: Reference, Next: Flavors, Prev: Using Variables, Up: Using Variables -- --6.1 Basics of Variable References --================================= -- --To substitute a variable's value, write a dollar sign followed by the --name of the variable in parentheses or braces: either `$(foo)' or --`${foo}' is a valid reference to the variable `foo'. This special --significance of `$' is why you must write `$$' to have the effect of a --single dollar sign in a file name or command. -- -- Variable references can be used in any context: targets, --prerequisites, commands, most directives, and new variable values. --Here is an example of a common case, where a variable holds the names --of all the object files in a program: -- -- objects = program.o foo.o utils.o -- program : $(objects) -- cc -o program $(objects) -- -- $(objects) : defs.h -- -- Variable references work by strict textual substitution. Thus, the --rule -- -- foo = c -- prog.o : prog.$(foo) -- $(foo)$(foo) -$(foo) prog.$(foo) -- --could be used to compile a C program `prog.c'. Since spaces before the --variable value are ignored in variable assignments, the value of `foo' --is precisely `c'. (Don't actually write your makefiles this way!) -- -- A dollar sign followed by a character other than a dollar sign, --open-parenthesis or open-brace treats that single character as the --variable name. Thus, you could reference the variable `x' with `$x'. --However, this practice is strongly discouraged, except in the case of --the automatic variables (*note Automatic Variables::). -- -- --File: make.info, Node: Flavors, Next: Advanced, Prev: Reference, Up: Using Variables -- --6.2 The Two Flavors of Variables --================================ -- --There are two ways that a variable in GNU `make' can have a value; we --call them the two "flavors" of variables. The two flavors are --distinguished in how they are defined and in what they do when expanded. -- -- The first flavor of variable is a "recursively expanded" variable. --Variables of this sort are defined by lines using `=' (*note Setting --Variables: Setting.) or by the `define' directive (*note Defining --Variables Verbatim: Defining.). The value you specify is installed --verbatim; if it contains references to other variables, these --references are expanded whenever this variable is substituted (in the --course of expanding some other string). When this happens, it is --called "recursive expansion". -- -- For example, -- -- foo = $(bar) -- bar = $(ugh) -- ugh = Huh? -- -- all:;echo $(foo) -- --will echo `Huh?': `$(foo)' expands to `$(bar)' which expands to --`$(ugh)' which finally expands to `Huh?'. -- -- This flavor of variable is the only sort supported by other versions --of `make'. It has its advantages and its disadvantages. An advantage --(most would say) is that: -- -- CFLAGS = $(include_dirs) -O -- include_dirs = -Ifoo -Ibar -- --will do what was intended: when `CFLAGS' is expanded in a command, it --will expand to `-Ifoo -Ibar -O'. A major disadvantage is that you --cannot append something on the end of a variable, as in -- -- CFLAGS = $(CFLAGS) -O -- --because it will cause an infinite loop in the variable expansion. --(Actually `make' detects the infinite loop and reports an error.) -- -- Another disadvantage is that any functions (*note Functions for --Transforming Text: Functions.) referenced in the definition will be --executed every time the variable is expanded. This makes `make' run --slower; worse, it causes the `wildcard' and `shell' functions to give --unpredictable results because you cannot easily control when they are --called, or even how many times. -- -- To avoid all the problems and inconveniences of recursively expanded --variables, there is another flavor: simply expanded variables. -- -- "Simply expanded variables" are defined by lines using `:=' (*note --Setting Variables: Setting.). The value of a simply expanded variable --is scanned once and for all, expanding any references to other --variables and functions, when the variable is defined. The actual --value of the simply expanded variable is the result of expanding the --text that you write. It does not contain any references to other --variables; it contains their values _as of the time this variable was --defined_. Therefore, -- -- x := foo -- y := $(x) bar -- x := later -- --is equivalent to -- -- y := foo bar -- x := later -- -- When a simply expanded variable is referenced, its value is --substituted verbatim. -- -- Here is a somewhat more complicated example, illustrating the use of --`:=' in conjunction with the `shell' function. (*Note The `shell' --Function: Shell Function.) This example also shows use of the variable --`MAKELEVEL', which is changed when it is passed down from level to --level. (*Note Communicating Variables to a Sub-`make': --Variables/Recursion, for information about `MAKELEVEL'.) -- -- ifeq (0,${MAKELEVEL}) -- whoami := $(shell whoami) -- host-type := $(shell arch) -- MAKE := ${MAKE} host-type=${host-type} whoami=${whoami} -- endif -- --An advantage of this use of `:=' is that a typical `descend into a --directory' command then looks like this: -- -- ${subdirs}: -- ${MAKE} -C $@ all -- -- Simply expanded variables generally make complicated makefile --programming more predictable because they work like variables in most --programming languages. They allow you to redefine a variable using its --own value (or its value processed in some way by one of the expansion --functions) and to use the expansion functions much more efficiently --(*note Functions for Transforming Text: Functions.). -- -- You can also use them to introduce controlled leading whitespace into --variable values. Leading whitespace characters are discarded from your --input before substitution of variable references and function calls; --this means you can include leading spaces in a variable value by --protecting them with variable references, like this: -- -- nullstring := -- space := $(nullstring) # end of the line -- --Here the value of the variable `space' is precisely one space. The --comment `# end of the line' is included here just for clarity. Since --trailing space characters are _not_ stripped from variable values, just --a space at the end of the line would have the same effect (but be --rather hard to read). If you put whitespace at the end of a variable --value, it is a good idea to put a comment like that at the end of the --line to make your intent clear. Conversely, if you do _not_ want any --whitespace characters at the end of your variable value, you must --remember not to put a random comment on the end of the line after some --whitespace, such as this: -- -- dir := /foo/bar # directory to put the frobs in -- --Here the value of the variable `dir' is `/foo/bar ' (with four --trailing spaces), which was probably not the intention. (Imagine --something like `$(dir)/file' with this definition!) -- -- There is another assignment operator for variables, `?='. This is --called a conditional variable assignment operator, because it only has --an effect if the variable is not yet defined. This statement: -- -- FOO ?= bar -- --is exactly equivalent to this (*note The `origin' Function: Origin --Function.): -- -- ifeq ($(origin FOO), undefined) -- FOO = bar -- endif -- -- Note that a variable set to an empty value is still defined, so `?=' --will not set that variable. -- -- --File: make.info, Node: Advanced, Next: Values, Prev: Flavors, Up: Using Variables -- --6.3 Advanced Features for Reference to Variables --================================================ -- --This section describes some advanced features you can use to reference --variables in more flexible ways. -- --* Menu: -- --* Substitution Refs:: Referencing a variable with -- substitutions on the value. --* Computed Names:: Computing the name of the variable to refer to. -- -- --File: make.info, Node: Substitution Refs, Next: Computed Names, Prev: Advanced, Up: Advanced -- --6.3.1 Substitution References ------------------------------- -- --A "substitution reference" substitutes the value of a variable with --alterations that you specify. It has the form `$(VAR:A=B)' (or --`${VAR:A=B}') and its meaning is to take the value of the variable VAR, --replace every A at the end of a word with B in that value, and --substitute the resulting string. -- -- When we say "at the end of a word", we mean that A must appear --either followed by whitespace or at the end of the value in order to be --replaced; other occurrences of A in the value are unaltered. For --example: -- -- foo := a.o b.o c.o -- bar := $(foo:.o=.c) -- --sets `bar' to `a.c b.c c.c'. *Note Setting Variables: Setting. -- -- A substitution reference is actually an abbreviation for use of the --`patsubst' expansion function (*note Functions for String Substitution --and Analysis: Text Functions.). We provide substitution references as --well as `patsubst' for compatibility with other implementations of --`make'. -- -- Another type of substitution reference lets you use the full power of --the `patsubst' function. It has the same form `$(VAR:A=B)' described --above, except that now A must contain a single `%' character. This --case is equivalent to `$(patsubst A,B,$(VAR))'. *Note Functions for --String Substitution and Analysis: Text Functions, for a description of --the `patsubst' function. -- --For example: -- -- foo := a.o b.o c.o -- bar := $(foo:%.o=%.c) -- --sets `bar' to `a.c b.c c.c'. -- -- --File: make.info, Node: Computed Names, Prev: Substitution Refs, Up: Advanced -- --6.3.2 Computed Variable Names ------------------------------- -- --Computed variable names are a complicated concept needed only for --sophisticated makefile programming. For most purposes you need not --consider them, except to know that making a variable with a dollar sign --in its name might have strange results. However, if you are the type --that wants to understand everything, or you are actually interested in --what they do, read on. -- -- Variables may be referenced inside the name of a variable. This is --called a "computed variable name" or a "nested variable reference". --For example, -- -- x = y -- y = z -- a := $($(x)) -- --defines `a' as `z': the `$(x)' inside `$($(x))' expands to `y', so --`$($(x))' expands to `$(y)' which in turn expands to `z'. Here the --name of the variable to reference is not stated explicitly; it is --computed by expansion of `$(x)'. The reference `$(x)' here is nested --within the outer variable reference. -- -- The previous example shows two levels of nesting, but any number of --levels is possible. For example, here are three levels: -- -- x = y -- y = z -- z = u -- a := $($($(x))) -- --Here the innermost `$(x)' expands to `y', so `$($(x))' expands to --`$(y)' which in turn expands to `z'; now we have `$(z)', which becomes --`u'. -- -- References to recursively-expanded variables within a variable name --are reexpanded in the usual fashion. For example: -- -- x = $(y) -- y = z -- z = Hello -- a := $($(x)) -- --defines `a' as `Hello': `$($(x))' becomes `$($(y))' which becomes --`$(z)' which becomes `Hello'. -- -- Nested variable references can also contain modified references and --function invocations (*note Functions for Transforming Text: --Functions.), just like any other reference. For example, using the --`subst' function (*note Functions for String Substitution and Analysis: --Text Functions.): -- -- x = variable1 -- variable2 := Hello -- y = $(subst 1,2,$(x)) -- z = y -- a := $($($(z))) -- --eventually defines `a' as `Hello'. It is doubtful that anyone would --ever want to write a nested reference as convoluted as this one, but it --works: `$($($(z)))' expands to `$($(y))' which becomes `$($(subst --1,2,$(x)))'. This gets the value `variable1' from `x' and changes it --by substitution to `variable2', so that the entire string becomes --`$(variable2)', a simple variable reference whose value is `Hello'. -- -- A computed variable name need not consist entirely of a single --variable reference. It can contain several variable references, as --well as some invariant text. For example, -- -- a_dirs := dira dirb -- 1_dirs := dir1 dir2 -- -- a_files := filea fileb -- 1_files := file1 file2 -- -- ifeq "$(use_a)" "yes" -- a1 := a -- else -- a1 := 1 -- endif -- -- ifeq "$(use_dirs)" "yes" -- df := dirs -- else -- df := files -- endif -- -- dirs := $($(a1)_$(df)) -- --will give `dirs' the same value as `a_dirs', `1_dirs', `a_files' or --`1_files' depending on the settings of `use_a' and `use_dirs'. -- -- Computed variable names can also be used in substitution references: -- -- a_objects := a.o b.o c.o -- 1_objects := 1.o 2.o 3.o -- -- sources := $($(a1)_objects:.o=.c) -- --defines `sources' as either `a.c b.c c.c' or `1.c 2.c 3.c', depending --on the value of `a1'. -- -- The only restriction on this sort of use of nested variable --references is that they cannot specify part of the name of a function --to be called. This is because the test for a recognized function name --is done before the expansion of nested references. For example, -- -- ifdef do_sort -- func := sort -- else -- func := strip -- endif -- -- bar := a d b g q c -- -- foo := $($(func) $(bar)) -- --attempts to give `foo' the value of the variable `sort a d b g q c' or --`strip a d b g q c', rather than giving `a d b g q c' as the argument --to either the `sort' or the `strip' function. This restriction could --be removed in the future if that change is shown to be a good idea. -- -- You can also use computed variable names in the left-hand side of a --variable assignment, or in a `define' directive, as in: -- -- dir = foo -- $(dir)_sources := $(wildcard $(dir)/*.c) -- define $(dir)_print -- lpr $($(dir)_sources) -- endef -- --This example defines the variables `dir', `foo_sources', and --`foo_print'. -- -- Note that "nested variable references" are quite different from --"recursively expanded variables" (*note The Two Flavors of Variables: --Flavors.), though both are used together in complex ways when doing --makefile programming. -- -- --File: make.info, Node: Values, Next: Setting, Prev: Advanced, Up: Using Variables -- --6.4 How Variables Get Their Values --================================== -- --Variables can get values in several different ways: -- -- * You can specify an overriding value when you run `make'. *Note -- Overriding Variables: Overriding. -- -- * You can specify a value in the makefile, either with an assignment -- (*note Setting Variables: Setting.) or with a verbatim definition -- (*note Defining Variables Verbatim: Defining.). -- -- * Variables in the environment become `make' variables. *Note -- Variables from the Environment: Environment. -- -- * Several "automatic" variables are given new values for each rule. -- Each of these has a single conventional use. *Note Automatic -- Variables::. -- -- * Several variables have constant initial values. *Note Variables -- Used by Implicit Rules: Implicit Variables. -- -- --File: make.info, Node: Setting, Next: Appending, Prev: Values, Up: Using Variables -- --6.5 Setting Variables --===================== -- --To set a variable from the makefile, write a line starting with the --variable name followed by `=' or `:='. Whatever follows the `=' or --`:=' on the line becomes the value. For example, -- -- objects = main.o foo.o bar.o utils.o -- --defines a variable named `objects'. Whitespace around the variable --name and immediately after the `=' is ignored. -- -- Variables defined with `=' are "recursively expanded" variables. --Variables defined with `:=' are "simply expanded" variables; these --definitions can contain variable references which will be expanded --before the definition is made. *Note The Two Flavors of Variables: --Flavors. -- -- The variable name may contain function and variable references, which --are expanded when the line is read to find the actual variable name to --use. -- -- There is no limit on the length of the value of a variable except the --amount of swapping space on the computer. When a variable definition is --long, it is a good idea to break it into several lines by inserting --backslash-newline at convenient places in the definition. This will not --affect the functioning of `make', but it will make the makefile easier --to read. -- -- Most variable names are considered to have the empty string as a --value if you have never set them. Several variables have built-in --initial values that are not empty, but you can set them in the usual --ways (*note Variables Used by Implicit Rules: Implicit Variables.). --Several special variables are set automatically to a new value for each --rule; these are called the "automatic" variables (*note Automatic --Variables::). -- -- If you'd like a variable to be set to a value only if it's not --already set, then you can use the shorthand operator `?=' instead of --`='. These two settings of the variable `FOO' are identical (*note The --`origin' Function: Origin Function.): -- -- FOO ?= bar -- --and -- -- ifeq ($(origin FOO), undefined) -- FOO = bar -- endif -- -- --File: make.info, Node: Appending, Next: Override Directive, Prev: Setting, Up: Using Variables -- --6.6 Appending More Text to Variables --==================================== -- --Often it is useful to add more text to the value of a variable already --defined. You do this with a line containing `+=', like this: -- -- objects += another.o -- --This takes the value of the variable `objects', and adds the text --`another.o' to it (preceded by a single space). Thus: -- -- objects = main.o foo.o bar.o utils.o -- objects += another.o -- --sets `objects' to `main.o foo.o bar.o utils.o another.o'. -- -- Using `+=' is similar to: -- -- objects = main.o foo.o bar.o utils.o -- objects := $(objects) another.o -- --but differs in ways that become important when you use more complex --values. -- -- When the variable in question has not been defined before, `+=' acts --just like normal `=': it defines a recursively-expanded variable. --However, when there _is_ a previous definition, exactly what `+=' does --depends on what flavor of variable you defined originally. *Note The --Two Flavors of Variables: Flavors, for an explanation of the two --flavors of variables. -- -- When you add to a variable's value with `+=', `make' acts --essentially as if you had included the extra text in the initial --definition of the variable. If you defined it first with `:=', making --it a simply-expanded variable, `+=' adds to that simply-expanded --definition, and expands the new text before appending it to the old --value just as `:=' does (see *Note Setting Variables: Setting, for a --full explanation of `:='). In fact, -- -- variable := value -- variable += more -- --is exactly equivalent to: -- -- -- variable := value -- variable := $(variable) more -- -- On the other hand, when you use `+=' with a variable that you defined --first to be recursively-expanded using plain `=', `make' does something --a bit different. Recall that when you define a recursively-expanded --variable, `make' does not expand the value you set for variable and --function references immediately. Instead it stores the text verbatim, --and saves these variable and function references to be expanded later, --when you refer to the new variable (*note The Two Flavors of Variables: --Flavors.). When you use `+=' on a recursively-expanded variable, it is --this unexpanded text to which `make' appends the new text you specify. -- -- variable = value -- variable += more -- --is roughly equivalent to: -- -- temp = value -- variable = $(temp) more -- --except that of course it never defines a variable called `temp'. The --importance of this comes when the variable's old value contains --variable references. Take this common example: -- -- CFLAGS = $(includes) -O -- ... -- CFLAGS += -pg # enable profiling -- --The first line defines the `CFLAGS' variable with a reference to another --variable, `includes'. (`CFLAGS' is used by the rules for C --compilation; *note Catalogue of Implicit Rules: Catalogue of Rules.) --Using `=' for the definition makes `CFLAGS' a recursively-expanded --variable, meaning `$(includes) -O' is _not_ expanded when `make' --processes the definition of `CFLAGS'. Thus, `includes' need not be --defined yet for its value to take effect. It only has to be defined --before any reference to `CFLAGS'. If we tried to append to the value --of `CFLAGS' without using `+=', we might do it like this: -- -- CFLAGS := $(CFLAGS) -pg # enable profiling -- --This is pretty close, but not quite what we want. Using `:=' redefines --`CFLAGS' as a simply-expanded variable; this means `make' expands the --text `$(CFLAGS) -pg' before setting the variable. If `includes' is not --yet defined, we get ` -O -pg', and a later definition of `includes' --will have no effect. Conversely, by using `+=' we set `CFLAGS' to the --_unexpanded_ value `$(includes) -O -pg'. Thus we preserve the --reference to `includes', so if that variable gets defined at any later --point, a reference like `$(CFLAGS)' still uses its value. -- -- --File: make.info, Node: Override Directive, Next: Defining, Prev: Appending, Up: Using Variables -- --6.7 The `override' Directive --============================ -- --If a variable has been set with a command argument (*note Overriding --Variables: Overriding.), then ordinary assignments in the makefile are --ignored. If you want to set the variable in the makefile even though --it was set with a command argument, you can use an `override' --directive, which is a line that looks like this: -- -- override VARIABLE = VALUE -- --or -- -- override VARIABLE := VALUE -- -- To append more text to a variable defined on the command line, use: -- -- override VARIABLE += MORE TEXT -- --*Note Appending More Text to Variables: Appending. -- -- The `override' directive was not invented for escalation in the war --between makefiles and command arguments. It was invented so you can --alter and add to values that the user specifies with command arguments. -- -- For example, suppose you always want the `-g' switch when you run the --C compiler, but you would like to allow the user to specify the other --switches with a command argument just as usual. You could use this --`override' directive: -- -- override CFLAGS += -g -- -- You can also use `override' directives with `define' directives. --This is done as you might expect: -- -- override define foo -- bar -- endef -- --*Note Defining Variables Verbatim: Defining. -- -- --File: make.info, Node: Defining, Next: Environment, Prev: Override Directive, Up: Using Variables -- --6.8 Defining Variables Verbatim --=============================== -- --Another way to set the value of a variable is to use the `define' --directive. This directive has an unusual syntax which allows newline --characters to be included in the value, which is convenient for defining --both canned sequences of commands (*note Defining Canned Command --Sequences: Sequences.), and also sections of makefile syntax to use --with `eval' (*note Eval Function::). -- -- The `define' directive is followed on the same line by the name of --the variable and nothing more. The value to give the variable appears --on the following lines. The end of the value is marked by a line --containing just the word `endef'. Aside from this difference in --syntax, `define' works just like `=': it creates a recursively-expanded --variable (*note The Two Flavors of Variables: Flavors.). The variable --name may contain function and variable references, which are expanded --when the directive is read to find the actual variable name to use. -- -- You may nest `define' directives: `make' will keep track of nested --directives and report an error if they are not all properly closed with --`endef'. Note that lines beginning with tab characters are considered --part of a command script, so any `define' or `endef' strings appearing --on such a line will not be considered `make' operators. -- -- define two-lines -- echo foo -- echo $(bar) -- endef -- -- The value in an ordinary assignment cannot contain a newline; but the --newlines that separate the lines of the value in a `define' become part --of the variable's value (except for the final newline which precedes --the `endef' and is not considered part of the value). -- -- When used in a command script, the previous example is functionally --equivalent to this: -- -- two-lines = echo foo; echo $(bar) -- --since two commands separated by semicolon behave much like two separate --shell commands. However, note that using two separate lines means --`make' will invoke the shell twice, running an independent subshell for --each line. *Note Command Execution: Execution. -- -- If you want variable definitions made with `define' to take --precedence over command-line variable definitions, you can use the --`override' directive together with `define': -- -- override define two-lines -- foo -- $(bar) -- endef -- --*Note The `override' Directive: Override Directive. -- -- --File: make.info, Node: Environment, Next: Target-specific, Prev: Defining, Up: Using Variables -- --6.9 Variables from the Environment --================================== -- --Variables in `make' can come from the environment in which `make' is --run. Every environment variable that `make' sees when it starts up is --transformed into a `make' variable with the same name and value. --However, an explicit assignment in the makefile, or with a command --argument, overrides the environment. (If the `-e' flag is specified, --then values from the environment override assignments in the makefile. --*Note Summary of Options: Options Summary. But this is not recommended --practice.) -- -- Thus, by setting the variable `CFLAGS' in your environment, you can --cause all C compilations in most makefiles to use the compiler switches --you prefer. This is safe for variables with standard or conventional --meanings because you know that no makefile will use them for other --things. (Note this is not totally reliable; some makefiles set --`CFLAGS' explicitly and therefore are not affected by the value in the --environment.) -- -- When `make' runs a command script, variables defined in the makefile --are placed into the environment of that command. This allows you to --pass values to sub-`make' invocations (*note Recursive Use of `make': --Recursion.). By default, only variables that came from the environment --or the command line are passed to recursive invocations. You can use --the `export' directive to pass other variables. *Note Communicating --Variables to a Sub-`make': Variables/Recursion, for full details. -- -- Other use of variables from the environment is not recommended. It --is not wise for makefiles to depend for their functioning on --environment variables set up outside their control, since this would --cause different users to get different results from the same makefile. --This is against the whole purpose of most makefiles. -- -- Such problems would be especially likely with the variable `SHELL', --which is normally present in the environment to specify the user's --choice of interactive shell. It would be very undesirable for this --choice to affect `make'; so, `make' handles the `SHELL' environment --variable in a special way; see *Note Choosing the Shell::. -- -- --File: make.info, Node: Target-specific, Next: Pattern-specific, Prev: Environment, Up: Using Variables -- --6.10 Target-specific Variable Values --==================================== -- --Variable values in `make' are usually global; that is, they are the --same regardless of where they are evaluated (unless they're reset, of --course). One exception to that is automatic variables (*note Automatic --Variables::). -- -- The other exception is "target-specific variable values". This --feature allows you to define different values for the same variable, --based on the target that `make' is currently building. As with --automatic variables, these values are only available within the context --of a target's command script (and in other target-specific assignments). -- -- Set a target-specific variable value like this: -- -- TARGET ... : VARIABLE-ASSIGNMENT -- --or like this: -- -- TARGET ... : override VARIABLE-ASSIGNMENT -- --or like this: -- -- TARGET ... : export VARIABLE-ASSIGNMENT -- -- Multiple TARGET values create a target-specific variable value for --each member of the target list individually. -- -- The VARIABLE-ASSIGNMENT can be any valid form of assignment; --recursive (`='), static (`:='), appending (`+='), or conditional --(`?='). All variables that appear within the VARIABLE-ASSIGNMENT are --evaluated within the context of the target: thus, any --previously-defined target-specific variable values will be in effect. --Note that this variable is actually distinct from any "global" value: --the two variables do not have to have the same flavor (recursive vs. --static). -- -- Target-specific variables have the same priority as any other --makefile variable. Variables provided on the command-line (and in the --environment if the `-e' option is in force) will take precedence. --Specifying the `override' directive will allow the target-specific --variable value to be preferred. -- -- There is one more special feature of target-specific variables: when --you define a target-specific variable that variable value is also in --effect for all prerequisites of this target, and all their --prerequisites, etc. (unless those prerequisites override that variable --with their own target-specific variable value). So, for example, a --statement like this: -- -- prog : CFLAGS = -g -- prog : prog.o foo.o bar.o -- --will set `CFLAGS' to `-g' in the command script for `prog', but it will --also set `CFLAGS' to `-g' in the command scripts that create `prog.o', --`foo.o', and `bar.o', and any command scripts which create their --prerequisites. -- -- Be aware that a given prerequisite will only be built once per --invocation of make, at most. If the same file is a prerequisite of --multiple targets, and each of those targets has a different value for --the same target-specific variable, then the first target to be built --will cause that prerequisite to be built and the prerequisite will --inherit the target-specific value from the first target. It will --ignore the target-specific values from any other targets. -- -- --File: make.info, Node: Pattern-specific, Prev: Target-specific, Up: Using Variables -- --6.11 Pattern-specific Variable Values --===================================== -- --In addition to target-specific variable values (*note Target-specific --Variable Values: Target-specific.), GNU `make' supports --pattern-specific variable values. In this form, the variable is --defined for any target that matches the pattern specified. If a target --matches more than one pattern, all the matching pattern-specific --variables are interpreted in the order in which they were defined in --the makefile, and collected together into one set. Variables defined --in this way are searched after any target-specific variables defined --explicitly for that target, and before target-specific variables --defined for the parent target. -- -- Set a pattern-specific variable value like this: -- -- PATTERN ... : VARIABLE-ASSIGNMENT -- --or like this: -- -- PATTERN ... : override VARIABLE-ASSIGNMENT -- --where PATTERN is a %-pattern. As with target-specific variable values, --multiple PATTERN values create a pattern-specific variable value for --each pattern individually. The VARIABLE-ASSIGNMENT can be any valid --form of assignment. Any command-line variable setting will take --precedence, unless `override' is specified. -- -- For example: -- -- %.o : CFLAGS = -O -- --will assign `CFLAGS' the value of `-O' for all targets matching the --pattern `%.o'. -- -- --File: make.info, Node: Conditionals, Next: Functions, Prev: Using Variables, Up: Top -- --7 Conditional Parts of Makefiles --******************************** -- --A "conditional" causes part of a makefile to be obeyed or ignored --depending on the values of variables. Conditionals can compare the --value of one variable to another, or the value of a variable to a --constant string. Conditionals control what `make' actually "sees" in --the makefile, so they _cannot_ be used to control shell commands at the --time of execution. -- --* Menu: -- --* Conditional Example:: Example of a conditional --* Conditional Syntax:: The syntax of conditionals. --* Testing Flags:: Conditionals that test flags. -- -- --File: make.info, Node: Conditional Example, Next: Conditional Syntax, Prev: Conditionals, Up: Conditionals -- --7.1 Example of a Conditional --============================ -- --The following example of a conditional tells `make' to use one set of --libraries if the `CC' variable is `gcc', and a different set of --libraries otherwise. It works by controlling which of two command --lines will be used as the command for a rule. The result is that --`CC=gcc' as an argument to `make' changes not only which compiler is --used but also which libraries are linked. -- -- libs_for_gcc = -lgnu -- normal_libs = -- -- foo: $(objects) -- ifeq ($(CC),gcc) -- $(CC) -o foo $(objects) $(libs_for_gcc) -- else -- $(CC) -o foo $(objects) $(normal_libs) -- endif -- -- This conditional uses three directives: one `ifeq', one `else' and --one `endif'. -- -- The `ifeq' directive begins the conditional, and specifies the --condition. It contains two arguments, separated by a comma and --surrounded by parentheses. Variable substitution is performed on both --arguments and then they are compared. The lines of the makefile --following the `ifeq' are obeyed if the two arguments match; otherwise --they are ignored. -- -- The `else' directive causes the following lines to be obeyed if the --previous conditional failed. In the example above, this means that the --second alternative linking command is used whenever the first --alternative is not used. It is optional to have an `else' in a --conditional. -- -- The `endif' directive ends the conditional. Every conditional must --end with an `endif'. Unconditional makefile text follows. -- -- As this example illustrates, conditionals work at the textual level: --the lines of the conditional are treated as part of the makefile, or --ignored, according to the condition. This is why the larger syntactic --units of the makefile, such as rules, may cross the beginning or the --end of the conditional. -- -- When the variable `CC' has the value `gcc', the above example has --this effect: -- -- foo: $(objects) -- $(CC) -o foo $(objects) $(libs_for_gcc) -- --When the variable `CC' has any other value, the effect is this: -- -- foo: $(objects) -- $(CC) -o foo $(objects) $(normal_libs) -- -- Equivalent results can be obtained in another way by --conditionalizing a variable assignment and then using the variable --unconditionally: -- -- libs_for_gcc = -lgnu -- normal_libs = -- -- ifeq ($(CC),gcc) -- libs=$(libs_for_gcc) -- else -- libs=$(normal_libs) -- endif -- -- foo: $(objects) -- $(CC) -o foo $(objects) $(libs) -- -- --File: make.info, Node: Conditional Syntax, Next: Testing Flags, Prev: Conditional Example, Up: Conditionals -- --7.2 Syntax of Conditionals --========================== -- --The syntax of a simple conditional with no `else' is as follows: -- -- CONDITIONAL-DIRECTIVE -- TEXT-IF-TRUE -- endif -- --The TEXT-IF-TRUE may be any lines of text, to be considered as part of --the makefile if the condition is true. If the condition is false, no --text is used instead. -- -- The syntax of a complex conditional is as follows: -- -- CONDITIONAL-DIRECTIVE -- TEXT-IF-TRUE -- else -- TEXT-IF-FALSE -- endif -- -- or: -- -- CONDITIONAL-DIRECTIVE -- TEXT-IF-ONE-IS-TRUE -- else CONDITIONAL-DIRECTIVE -- TEXT-IF-TRUE -- else -- TEXT-IF-FALSE -- endif -- --There can be as many "`else' CONDITIONAL-DIRECTIVE" clauses as --necessary. Once a given condition is true, TEXT-IF-TRUE is used and no --other clause is used; if no condition is true then TEXT-IF-FALSE is --used. The TEXT-IF-TRUE and TEXT-IF-FALSE can be any number of lines of --text. -- -- The syntax of the CONDITIONAL-DIRECTIVE is the same whether the --conditional is simple or complex; after an `else' or not. There are --four different directives that test different conditions. Here is a --table of them: -- --`ifeq (ARG1, ARG2)' --`ifeq 'ARG1' 'ARG2'' --`ifeq "ARG1" "ARG2"' --`ifeq "ARG1" 'ARG2'' --`ifeq 'ARG1' "ARG2"' -- Expand all variable references in ARG1 and ARG2 and compare them. -- If they are identical, the TEXT-IF-TRUE is effective; otherwise, -- the TEXT-IF-FALSE, if any, is effective. -- -- Often you want to test if a variable has a non-empty value. When -- the value results from complex expansions of variables and -- functions, expansions you would consider empty may actually -- contain whitespace characters and thus are not seen as empty. -- However, you can use the `strip' function (*note Text Functions::) -- to avoid interpreting whitespace as a non-empty value. For -- example: -- -- ifeq ($(strip $(foo)),) -- TEXT-IF-EMPTY -- endif -- -- will evaluate TEXT-IF-EMPTY even if the expansion of `$(foo)' -- contains whitespace characters. -- --`ifneq (ARG1, ARG2)' --`ifneq 'ARG1' 'ARG2'' --`ifneq "ARG1" "ARG2"' --`ifneq "ARG1" 'ARG2'' --`ifneq 'ARG1' "ARG2"' -- Expand all variable references in ARG1 and ARG2 and compare them. -- If they are different, the TEXT-IF-TRUE is effective; otherwise, -- the TEXT-IF-FALSE, if any, is effective. -- --`ifdef VARIABLE-NAME' -- The `ifdef' form takes the _name_ of a variable as its argument, -- not a reference to a variable. The value of that variable has a -- non-empty value, the TEXT-IF-TRUE is effective; otherwise, the -- TEXT-IF-FALSE, if any, is effective. Variables that have never -- been defined have an empty value. The text VARIABLE-NAME is -- expanded, so it could be a variable or function that expands to -- the name of a variable. For example: -- -- bar = true -- foo = bar -- ifdef $(foo) -- frobozz = yes -- endif -- -- The variable reference `$(foo)' is expanded, yielding `bar', which -- is considered to be the name of a variable. The variable `bar' is -- not expanded, but its value is examined to determine if it is -- non-empty. -- -- Note that `ifdef' only tests whether a variable has a value. It -- does not expand the variable to see if that value is nonempty. -- Consequently, tests using `ifdef' return true for all definitions -- except those like `foo ='. To test for an empty value, use -- `ifeq ($(foo),)'. For example, -- -- bar = -- foo = $(bar) -- ifdef foo -- frobozz = yes -- else -- frobozz = no -- endif -- -- sets `frobozz' to `yes', while: -- -- foo = -- ifdef foo -- frobozz = yes -- else -- frobozz = no -- endif -- -- sets `frobozz' to `no'. -- --`ifndef VARIABLE-NAME' -- If the variable VARIABLE-NAME has an empty value, the TEXT-IF-TRUE -- is effective; otherwise, the TEXT-IF-FALSE, if any, is effective. -- The rules for expansion and testing of VARIABLE-NAME are identical -- to the `ifdef' directive. -- -- Extra spaces are allowed and ignored at the beginning of the --conditional directive line, but a tab is not allowed. (If the line --begins with a tab, it will be considered a command for a rule.) Aside --from this, extra spaces or tabs may be inserted with no effect anywhere --except within the directive name or within an argument. A comment --starting with `#' may appear at the end of the line. -- -- The other two directives that play a part in a conditional are `else' --and `endif'. Each of these directives is written as one word, with no --arguments. Extra spaces are allowed and ignored at the beginning of the --line, and spaces or tabs at the end. A comment starting with `#' may --appear at the end of the line. -- -- Conditionals affect which lines of the makefile `make' uses. If the --condition is true, `make' reads the lines of the TEXT-IF-TRUE as part --of the makefile; if the condition is false, `make' ignores those lines --completely. It follows that syntactic units of the makefile, such as --rules, may safely be split across the beginning or the end of the --conditional. -- -- `make' evaluates conditionals when it reads a makefile. --Consequently, you cannot use automatic variables in the tests of --conditionals because they are not defined until commands are run (*note --Automatic Variables::). -- -- To prevent intolerable confusion, it is not permitted to start a --conditional in one makefile and end it in another. However, you may --write an `include' directive within a conditional, provided you do not --attempt to terminate the conditional inside the included file. -- -- --File: make.info, Node: Testing Flags, Prev: Conditional Syntax, Up: Conditionals -- --7.3 Conditionals that Test Flags --================================ -- --You can write a conditional that tests `make' command flags such as --`-t' by using the variable `MAKEFLAGS' together with the `findstring' --function (*note Functions for String Substitution and Analysis: Text --Functions.). This is useful when `touch' is not enough to make a file --appear up to date. -- -- The `findstring' function determines whether one string appears as a --substring of another. If you want to test for the `-t' flag, use `t' --as the first string and the value of `MAKEFLAGS' as the other. -- -- For example, here is how to arrange to use `ranlib -t' to finish --marking an archive file up to date: -- -- archive.a: ... -- ifneq (,$(findstring t,$(MAKEFLAGS))) -- +touch archive.a -- +ranlib -t archive.a -- else -- ranlib archive.a -- endif -- --The `+' prefix marks those command lines as "recursive" so that they --will be executed despite use of the `-t' flag. *Note Recursive Use of --`make': Recursion. -- -- --File: make.info, Node: Functions, Next: Running, Prev: Conditionals, Up: Top -- --8 Functions for Transforming Text --********************************* -- --"Functions" allow you to do text processing in the makefile to compute --the files to operate on or the commands to use. You use a function in a --"function call", where you give the name of the function and some text --(the "arguments") for the function to operate on. The result of the --function's processing is substituted into the makefile at the point of --the call, just as a variable might be substituted. -- --* Menu: -- --* Syntax of Functions:: How to write a function call. --* Text Functions:: General-purpose text manipulation functions. --* File Name Functions:: Functions for manipulating file names. --* Conditional Functions:: Functions that implement conditions. --* Foreach Function:: Repeat some text with controlled variation. --* Call Function:: Expand a user-defined function. --* Value Function:: Return the un-expanded value of a variable. --* Eval Function:: Evaluate the arguments as makefile syntax. --* Origin Function:: Find where a variable got its value. --* Flavor Function:: Find out the flavor of a variable. --* Shell Function:: Substitute the output of a shell command. --* Make Control Functions:: Functions that control how make runs. -- -- --File: make.info, Node: Syntax of Functions, Next: Text Functions, Prev: Functions, Up: Functions -- --8.1 Function Call Syntax --======================== -- --A function call resembles a variable reference. It looks like this: -- -- $(FUNCTION ARGUMENTS) -- --or like this: -- -- ${FUNCTION ARGUMENTS} -- -- Here FUNCTION is a function name; one of a short list of names that --are part of `make'. You can also essentially create your own functions --by using the `call' builtin function. -- -- The ARGUMENTS are the arguments of the function. They are separated --from the function name by one or more spaces or tabs, and if there is --more than one argument, then they are separated by commas. Such --whitespace and commas are not part of an argument's value. The --delimiters which you use to surround the function call, whether --parentheses or braces, can appear in an argument only in matching pairs; --the other kind of delimiters may appear singly. If the arguments --themselves contain other function calls or variable references, it is --wisest to use the same kind of delimiters for all the references; write --`$(subst a,b,$(x))', not `$(subst a,b,${x})'. This is because it is --clearer, and because only one type of delimiter is matched to find the --end of the reference. -- -- The text written for each argument is processed by substitution of --variables and function calls to produce the argument value, which is --the text on which the function acts. The substitution is done in the --order in which the arguments appear. -- -- Commas and unmatched parentheses or braces cannot appear in the text --of an argument as written; leading spaces cannot appear in the text of --the first argument as written. These characters can be put into the --argument value by variable substitution. First define variables --`comma' and `space' whose values are isolated comma and space --characters, then substitute these variables where such characters are --wanted, like this: -- -- comma:= , -- empty:= -- space:= $(empty) $(empty) -- foo:= a b c -- bar:= $(subst $(space),$(comma),$(foo)) -- # bar is now `a,b,c'. -- --Here the `subst' function replaces each space with a comma, through the --value of `foo', and substitutes the result. -- -- --File: make.info, Node: Text Functions, Next: File Name Functions, Prev: Syntax of Functions, Up: Functions -- --8.2 Functions for String Substitution and Analysis --================================================== -- --Here are some functions that operate on strings: -- --`$(subst FROM,TO,TEXT)' -- Performs a textual replacement on the text TEXT: each occurrence -- of FROM is replaced by TO. The result is substituted for the -- function call. For example, -- -- $(subst ee,EE,feet on the street) -- -- substitutes the string `fEEt on the strEEt'. -- --`$(patsubst PATTERN,REPLACEMENT,TEXT)' -- Finds whitespace-separated words in TEXT that match PATTERN and -- replaces them with REPLACEMENT. Here PATTERN may contain a `%' -- which acts as a wildcard, matching any number of any characters -- within a word. If REPLACEMENT also contains a `%', the `%' is -- replaced by the text that matched the `%' in PATTERN. Only the -- first `%' in the PATTERN and REPLACEMENT is treated this way; any -- subsequent `%' is unchanged. -- -- `%' characters in `patsubst' function invocations can be quoted -- with preceding backslashes (`\'). Backslashes that would -- otherwise quote `%' characters can be quoted with more backslashes. -- Backslashes that quote `%' characters or other backslashes are -- removed from the pattern before it is compared file names or has a -- stem substituted into it. Backslashes that are not in danger of -- quoting `%' characters go unmolested. For example, the pattern -- `the\%weird\\%pattern\\' has `the%weird\' preceding the operative -- `%' character, and `pattern\\' following it. The final two -- backslashes are left alone because they cannot affect any `%' -- character. -- -- Whitespace between words is folded into single space characters; -- leading and trailing whitespace is discarded. -- -- For example, -- -- $(patsubst %.c,%.o,x.c.c bar.c) -- -- produces the value `x.c.o bar.o'. -- -- Substitution references (*note Substitution References: -- Substitution Refs.) are a simpler way to get the effect of the -- `patsubst' function: -- -- $(VAR:PATTERN=REPLACEMENT) -- -- is equivalent to -- -- $(patsubst PATTERN,REPLACEMENT,$(VAR)) -- -- The second shorthand simplifies one of the most common uses of -- `patsubst': replacing the suffix at the end of file names. -- -- $(VAR:SUFFIX=REPLACEMENT) -- -- is equivalent to -- -- $(patsubst %SUFFIX,%REPLACEMENT,$(VAR)) -- -- For example, you might have a list of object files: -- -- objects = foo.o bar.o baz.o -- -- To get the list of corresponding source files, you could simply -- write: -- -- $(objects:.o=.c) -- -- instead of using the general form: -- -- $(patsubst %.o,%.c,$(objects)) -- --`$(strip STRING)' -- Removes leading and trailing whitespace from STRING and replaces -- each internal sequence of one or more whitespace characters with a -- single space. Thus, `$(strip a b c )' results in `a b c'. -- -- The function `strip' can be very useful when used in conjunction -- with conditionals. When comparing something with the empty string -- `' using `ifeq' or `ifneq', you usually want a string of just -- whitespace to match the empty string (*note Conditionals::). -- -- Thus, the following may fail to have the desired results: -- -- .PHONY: all -- ifneq "$(needs_made)" "" -- all: $(needs_made) -- else -- all:;@echo 'Nothing to make!' -- endif -- -- Replacing the variable reference `$(needs_made)' with the function -- call `$(strip $(needs_made))' in the `ifneq' directive would make -- it more robust. -- --`$(findstring FIND,IN)' -- Searches IN for an occurrence of FIND. If it occurs, the value is -- FIND; otherwise, the value is empty. You can use this function in -- a conditional to test for the presence of a specific substring in -- a given string. Thus, the two examples, -- -- $(findstring a,a b c) -- $(findstring a,b c) -- -- produce the values `a' and `' (the empty string), respectively. -- *Note Testing Flags::, for a practical application of `findstring'. -- --`$(filter PATTERN...,TEXT)' -- Returns all whitespace-separated words in TEXT that _do_ match any -- of the PATTERN words, removing any words that _do not_ match. The -- patterns are written using `%', just like the patterns used in the -- `patsubst' function above. -- -- The `filter' function can be used to separate out different types -- of strings (such as file names) in a variable. For example: -- -- sources := foo.c bar.c baz.s ugh.h -- foo: $(sources) -- cc $(filter %.c %.s,$(sources)) -o foo -- -- says that `foo' depends of `foo.c', `bar.c', `baz.s' and `ugh.h' -- but only `foo.c', `bar.c' and `baz.s' should be specified in the -- command to the compiler. -- --`$(filter-out PATTERN...,TEXT)' -- Returns all whitespace-separated words in TEXT that _do not_ match -- any of the PATTERN words, removing the words that _do_ match one -- or more. This is the exact opposite of the `filter' function. -- -- For example, given: -- -- objects=main1.o foo.o main2.o bar.o -- mains=main1.o main2.o -- -- the following generates a list which contains all the object files -- not in `mains': -- -- $(filter-out $(mains),$(objects)) -- --`$(sort LIST)' -- Sorts the words of LIST in lexical order, removing duplicate -- words. The output is a list of words separated by single spaces. -- Thus, -- -- $(sort foo bar lose) -- -- returns the value `bar foo lose'. -- -- Incidentally, since `sort' removes duplicate words, you can use it -- for this purpose even if you don't care about the sort order. -- --`$(word N,TEXT)' -- Returns the Nth word of TEXT. The legitimate values of N start -- from 1. If N is bigger than the number of words in TEXT, the -- value is empty. For example, -- -- $(word 2, foo bar baz) -- -- returns `bar'. -- --`$(wordlist S,E,TEXT)' -- Returns the list of words in TEXT starting with word S and ending -- with word E (inclusive). The legitimate values of S start from 1; -- E may start from 0. If S is bigger than the number of words in -- TEXT, the value is empty. If E is bigger than the number of words -- in TEXT, words up to the end of TEXT are returned. If S is -- greater than E, nothing is returned. For example, -- -- $(wordlist 2, 3, foo bar baz) -- -- returns `bar baz'. -- --`$(words TEXT)' -- Returns the number of words in TEXT. Thus, the last word of TEXT -- is `$(word $(words TEXT),TEXT)'. -- --`$(firstword NAMES...)' -- The argument NAMES is regarded as a series of names, separated by -- whitespace. The value is the first name in the series. The rest -- of the names are ignored. -- -- For example, -- -- $(firstword foo bar) -- -- produces the result `foo'. Although `$(firstword TEXT)' is the -- same as `$(word 1,TEXT)', the `firstword' function is retained for -- its simplicity. -- --`$(lastword NAMES...)' -- The argument NAMES is regarded as a series of names, separated by -- whitespace. The value is the last name in the series. -- -- For example, -- -- $(lastword foo bar) -- -- produces the result `bar'. Although `$(lastword TEXT)' is the -- same as `$(word $(words TEXT),TEXT)', the `lastword' function was -- added for its simplicity and better performance. -- -- Here is a realistic example of the use of `subst' and `patsubst'. --Suppose that a makefile uses the `VPATH' variable to specify a list of --directories that `make' should search for prerequisite files (*note --`VPATH' Search Path for All Prerequisites: General Search.). This --example shows how to tell the C compiler to search for header files in --the same list of directories. -- -- The value of `VPATH' is a list of directories separated by colons, --such as `src:../headers'. First, the `subst' function is used to --change the colons to spaces: -- -- $(subst :, ,$(VPATH)) -- --This produces `src ../headers'. Then `patsubst' is used to turn each --directory name into a `-I' flag. These can be added to the value of --the variable `CFLAGS', which is passed automatically to the C compiler, --like this: -- -- override CFLAGS += $(patsubst %,-I%,$(subst :, ,$(VPATH))) -- --The effect is to append the text `-Isrc -I../headers' to the previously --given value of `CFLAGS'. The `override' directive is used so that the --new value is assigned even if the previous value of `CFLAGS' was --specified with a command argument (*note The `override' Directive: --Override Directive.). -- -- --File: make.info, Node: File Name Functions, Next: Conditional Functions, Prev: Text Functions, Up: Functions -- --8.3 Functions for File Names --============================ -- --Several of the built-in expansion functions relate specifically to --taking apart file names or lists of file names. -- -- Each of the following functions performs a specific transformation --on a file name. The argument of the function is regarded as a series --of file names, separated by whitespace. (Leading and trailing --whitespace is ignored.) Each file name in the series is transformed in --the same way and the results are concatenated with single spaces --between them. -- --`$(dir NAMES...)' -- Extracts the directory-part of each file name in NAMES. The -- directory-part of the file name is everything up through (and -- including) the last slash in it. If the file name contains no -- slash, the directory part is the string `./'. For example, -- -- $(dir src/foo.c hacks) -- -- produces the result `src/ ./'. -- --`$(notdir NAMES...)' -- Extracts all but the directory-part of each file name in NAMES. -- If the file name contains no slash, it is left unchanged. -- Otherwise, everything through the last slash is removed from it. -- -- A file name that ends with a slash becomes an empty string. This -- is unfortunate, because it means that the result does not always -- have the same number of whitespace-separated file names as the -- argument had; but we do not see any other valid alternative. -- -- For example, -- -- $(notdir src/foo.c hacks) -- -- produces the result `foo.c hacks'. -- --`$(suffix NAMES...)' -- Extracts the suffix of each file name in NAMES. If the file name -- contains a period, the suffix is everything starting with the last -- period. Otherwise, the suffix is the empty string. This -- frequently means that the result will be empty when NAMES is not, -- and if NAMES contains multiple file names, the result may contain -- fewer file names. -- -- For example, -- -- $(suffix src/foo.c src-1.0/bar.c hacks) -- -- produces the result `.c .c'. -- --`$(basename NAMES...)' -- Extracts all but the suffix of each file name in NAMES. If the -- file name contains a period, the basename is everything starting -- up to (and not including) the last period. Periods in the -- directory part are ignored. If there is no period, the basename -- is the entire file name. For example, -- -- $(basename src/foo.c src-1.0/bar hacks) -- -- produces the result `src/foo src-1.0/bar hacks'. -- --`$(addsuffix SUFFIX,NAMES...)' -- The argument NAMES is regarded as a series of names, separated by -- whitespace; SUFFIX is used as a unit. The value of SUFFIX is -- appended to the end of each individual name and the resulting -- larger names are concatenated with single spaces between them. -- For example, -- -- $(addsuffix .c,foo bar) -- -- produces the result `foo.c bar.c'. -- --`$(addprefix PREFIX,NAMES...)' -- The argument NAMES is regarded as a series of names, separated by -- whitespace; PREFIX is used as a unit. The value of PREFIX is -- prepended to the front of each individual name and the resulting -- larger names are concatenated with single spaces between them. -- For example, -- -- $(addprefix src/,foo bar) -- -- produces the result `src/foo src/bar'. -- --`$(join LIST1,LIST2)' -- Concatenates the two arguments word by word: the two first words -- (one from each argument) concatenated form the first word of the -- result, the two second words form the second word of the result, -- and so on. So the Nth word of the result comes from the Nth word -- of each argument. If one argument has more words that the other, -- the extra words are copied unchanged into the result. -- -- For example, `$(join a b,.c .o)' produces `a.c b.o'. -- -- Whitespace between the words in the lists is not preserved; it is -- replaced with a single space. -- -- This function can merge the results of the `dir' and `notdir' -- functions, to produce the original list of files which was given -- to those two functions. -- --`$(wildcard PATTERN)' -- The argument PATTERN is a file name pattern, typically containing -- wildcard characters (as in shell file name patterns). The result -- of `wildcard' is a space-separated list of the names of existing -- files that match the pattern. *Note Using Wildcard Characters in -- File Names: Wildcards. -- --`$(realpath NAMES...)' -- For each file name in NAMES return the canonical absolute name. A -- canonical name does not contain any `.' or `..' components, nor -- any repeated path separators (`/') or symlinks. In case of a -- failure the empty string is returned. Consult the `realpath(3)' -- documentation for a list of possible failure causes. -- --`$(abspath NAMES...)' -- For each file name in NAMES return an absolute name that does not -- contain any `.' or `..' components, nor any repeated path -- separators (`/'). Note that, in contrast to `realpath' function, -- `abspath' does not resolve symlinks and does not require the file -- names to refer to an existing file or directory. Use the -- `wildcard' function to test for existence. -- -- --File: make.info, Node: Conditional Functions, Next: Foreach Function, Prev: File Name Functions, Up: Functions -- --8.4 Functions for Conditionals --============================== -- --There are three functions that provide conditional expansion. A key --aspect of these functions is that not all of the arguments are expanded --initially. Only those arguments which need to be expanded, will be --expanded. -- --`$(if CONDITION,THEN-PART[,ELSE-PART])' -- The `if' function provides support for conditional expansion in a -- functional context (as opposed to the GNU `make' makefile -- conditionals such as `ifeq' (*note Syntax of Conditionals: -- Conditional Syntax.). -- -- The first argument, CONDITION, first has all preceding and -- trailing whitespace stripped, then is expanded. If it expands to -- any non-empty string, then the condition is considered to be true. -- If it expands to an empty string, the condition is considered to -- be false. -- -- If the condition is true then the second argument, THEN-PART, is -- evaluated and this is used as the result of the evaluation of the -- entire `if' function. -- -- If the condition is false then the third argument, ELSE-PART, is -- evaluated and this is the result of the `if' function. If there is -- no third argument, the `if' function evaluates to nothing (the -- empty string). -- -- Note that only one of the THEN-PART or the ELSE-PART will be -- evaluated, never both. Thus, either can contain side-effects -- (such as `shell' function calls, etc.) -- --`$(or CONDITION1[,CONDITION2[,CONDITION3...]])' -- The `or' function provides a "short-circuiting" OR operation. -- Each argument is expanded, in order. If an argument expands to a -- non-empty string the processing stops and the result of the -- expansion is that string. If, after all arguments are expanded, -- all of them are false (empty), then the result of the expansion is -- the empty string. -- --`$(and CONDITION1[,CONDITION2[,CONDITION3...]])' -- The `and' function provides a "short-circuiting" AND operation. -- Each argument is expanded, in order. If an argument expands to an -- empty string the processing stops and the result of the expansion -- is the empty string. If all arguments expand to a non-empty -- string then the result of the expansion is the expansion of the -- last argument. -- -- -- --File: make.info, Node: Foreach Function, Next: Call Function, Prev: Conditional Functions, Up: Functions -- --8.5 The `foreach' Function --========================== -- --The `foreach' function is very different from other functions. It --causes one piece of text to be used repeatedly, each time with a --different substitution performed on it. It resembles the `for' command --in the shell `sh' and the `foreach' command in the C-shell `csh'. -- -- The syntax of the `foreach' function is: -- -- $(foreach VAR,LIST,TEXT) -- --The first two arguments, VAR and LIST, are expanded before anything --else is done; note that the last argument, TEXT, is *not* expanded at --the same time. Then for each word of the expanded value of LIST, the --variable named by the expanded value of VAR is set to that word, and --TEXT is expanded. Presumably TEXT contains references to that --variable, so its expansion will be different each time. -- -- The result is that TEXT is expanded as many times as there are --whitespace-separated words in LIST. The multiple expansions of TEXT --are concatenated, with spaces between them, to make the result of --`foreach'. -- -- This simple example sets the variable `files' to the list of all --files in the directories in the list `dirs': -- -- dirs := a b c d -- files := $(foreach dir,$(dirs),$(wildcard $(dir)/*)) -- -- Here TEXT is `$(wildcard $(dir)/*)'. The first repetition finds the --value `a' for `dir', so it produces the same result as `$(wildcard --a/*)'; the second repetition produces the result of `$(wildcard b/*)'; --and the third, that of `$(wildcard c/*)'. -- -- This example has the same result (except for setting `dirs') as the --following example: -- -- files := $(wildcard a/* b/* c/* d/*) -- -- When TEXT is complicated, you can improve readability by giving it a --name, with an additional variable: -- -- find_files = $(wildcard $(dir)/*) -- dirs := a b c d -- files := $(foreach dir,$(dirs),$(find_files)) -- --Here we use the variable `find_files' this way. We use plain `=' to --define a recursively-expanding variable, so that its value contains an --actual function call to be reexpanded under the control of `foreach'; a --simply-expanded variable would not do, since `wildcard' would be called --only once at the time of defining `find_files'. -- -- The `foreach' function has no permanent effect on the variable VAR; --its value and flavor after the `foreach' function call are the same as --they were beforehand. The other values which are taken from LIST are --in effect only temporarily, during the execution of `foreach'. The --variable VAR is a simply-expanded variable during the execution of --`foreach'. If VAR was undefined before the `foreach' function call, it --is undefined after the call. *Note The Two Flavors of Variables: --Flavors. -- -- You must take care when using complex variable expressions that --result in variable names because many strange things are valid variable --names, but are probably not what you intended. For example, -- -- files := $(foreach Esta escrito en espanol!,b c ch,$(find_files)) -- --might be useful if the value of `find_files' references the variable --whose name is `Esta escrito en espanol!' (es un nombre bastante largo, --no?), but it is more likely to be a mistake. -- -- --File: make.info, Node: Call Function, Next: Value Function, Prev: Foreach Function, Up: Functions -- --8.6 The `call' Function --======================= -- --The `call' function is unique in that it can be used to create new --parameterized functions. You can write a complex expression as the --value of a variable, then use `call' to expand it with different values. -- -- The syntax of the `call' function is: -- -- $(call VARIABLE,PARAM,PARAM,...) -- -- When `make' expands this function, it assigns each PARAM to --temporary variables `$(1)', `$(2)', etc. The variable `$(0)' will --contain VARIABLE. There is no maximum number of parameter arguments. --There is no minimum, either, but it doesn't make sense to use `call' --with no parameters. -- -- Then VARIABLE is expanded as a `make' variable in the context of --these temporary assignments. Thus, any reference to `$(1)' in the --value of VARIABLE will resolve to the first PARAM in the invocation of --`call'. -- -- Note that VARIABLE is the _name_ of a variable, not a _reference_ to --that variable. Therefore you would not normally use a `$' or --parentheses when writing it. (You can, however, use a variable --reference in the name if you want the name not to be a constant.) -- -- If VARIABLE is the name of a builtin function, the builtin function --is always invoked (even if a `make' variable by that name also exists). -- -- The `call' function expands the PARAM arguments before assigning --them to temporary variables. This means that VARIABLE values --containing references to builtin functions that have special expansion --rules, like `foreach' or `if', may not work as you expect. -- -- Some examples may make this clearer. -- -- This macro simply reverses its arguments: -- -- reverse = $(2) $(1) -- -- foo = $(call reverse,a,b) -- --Here FOO will contain `b a'. -- -- This one is slightly more interesting: it defines a macro to search --for the first instance of a program in `PATH': -- -- pathsearch = $(firstword $(wildcard $(addsuffix /$(1),$(subst :, ,$(PATH))))) -- -- LS := $(call pathsearch,ls) -- --Now the variable LS contains `/bin/ls' or similar. -- -- The `call' function can be nested. Each recursive invocation gets --its own local values for `$(1)', etc. that mask the values of --higher-level `call'. For example, here is an implementation of a "map" --function: -- -- map = $(foreach a,$(2),$(call $(1),$(a))) -- -- Now you can MAP a function that normally takes only one argument, --such as `origin', to multiple values in one step: -- -- o = $(call map,origin,o map MAKE) -- -- and end up with O containing something like `file file default'. -- -- A final caution: be careful when adding whitespace to the arguments --to `call'. As with other functions, any whitespace contained in the --second and subsequent arguments is kept; this can cause strange --effects. It's generally safest to remove all extraneous whitespace when --providing parameters to `call'. -- -- --File: make.info, Node: Value Function, Next: Eval Function, Prev: Call Function, Up: Functions -- --8.7 The `value' Function --======================== -- --The `value' function provides a way for you to use the value of a --variable _without_ having it expanded. Please note that this does not --undo expansions which have already occurred; for example if you create --a simply expanded variable its value is expanded during the definition; --in that case the `value' function will return the same result as using --the variable directly. -- -- The syntax of the `value' function is: -- -- $(value VARIABLE) -- -- Note that VARIABLE is the _name_ of a variable; not a _reference_ to --that variable. Therefore you would not normally use a `$' or --parentheses when writing it. (You can, however, use a variable --reference in the name if you want the name not to be a constant.) -- -- The result of this function is a string containing the value of --VARIABLE, without any expansion occurring. For example, in this --makefile: -- -- FOO = $PATH -- -- all: -- @echo $(FOO) -- @echo $(value FOO) -- --The first output line would be `ATH', since the "$P" would be expanded --as a `make' variable, while the second output line would be the current --value of your `$PATH' environment variable, since the `value' function --avoided the expansion. -- -- The `value' function is most often used in conjunction with the --`eval' function (*note Eval Function::). -- -- --File: make.info, Node: Eval Function, Next: Origin Function, Prev: Value Function, Up: Functions -- --8.8 The `eval' Function --======================= -- --The `eval' function is very special: it allows you to define new --makefile constructs that are not constant; which are the result of --evaluating other variables and functions. The argument to the `eval' --function is expanded, then the results of that expansion are parsed as --makefile syntax. The expanded results can define new `make' variables, --targets, implicit or explicit rules, etc. -- -- The result of the `eval' function is always the empty string; thus, --it can be placed virtually anywhere in a makefile without causing --syntax errors. -- -- It's important to realize that the `eval' argument is expanded --_twice_; first by the `eval' function, then the results of that --expansion are expanded again when they are parsed as makefile syntax. --This means you may need to provide extra levels of escaping for "$" --characters when using `eval'. The `value' function (*note Value --Function::) can sometimes be useful in these situations, to circumvent --unwanted expansions. -- -- Here is an example of how `eval' can be used; this example combines --a number of concepts and other functions. Although it might seem --overly complex to use `eval' in this example, rather than just writing --out the rules, consider two things: first, the template definition (in --`PROGRAM_template') could need to be much more complex than it is here; --and second, you might put the complex, "generic" part of this example --into another makefile, then include it in all the individual makefiles. --Now your individual makefiles are quite straightforward. -- -- PROGRAMS = server client -- -- server_OBJS = server.o server_priv.o server_access.o -- server_LIBS = priv protocol -- -- client_OBJS = client.o client_api.o client_mem.o -- client_LIBS = protocol -- -- # Everything after this is generic -- -- .PHONY: all -- all: $(PROGRAMS) -- -- define PROGRAM_template -- $(1): $$($(1)_OBJS) $$($(1)_LIBS:%=-l%) -- ALL_OBJS += $$($(1)_OBJS) -- endef -- -- $(foreach prog,$(PROGRAMS),$(eval $(call PROGRAM_template,$(prog)))) -- -- $(PROGRAMS): -- $(LINK.o) $^ $(LDLIBS) -o $@ -- -- clean: -- rm -f $(ALL_OBJS) $(PROGRAMS) -- -- --File: make.info, Node: Origin Function, Next: Flavor Function, Prev: Eval Function, Up: Functions -- --8.9 The `origin' Function --========================= -- --The `origin' function is unlike most other functions in that it does --not operate on the values of variables; it tells you something _about_ --a variable. Specifically, it tells you where it came from. -- -- The syntax of the `origin' function is: -- -- $(origin VARIABLE) -- -- Note that VARIABLE is the _name_ of a variable to inquire about; not --a _reference_ to that variable. Therefore you would not normally use a --`$' or parentheses when writing it. (You can, however, use a variable --reference in the name if you want the name not to be a constant.) -- -- The result of this function is a string telling you how the variable --VARIABLE was defined: -- --`undefined' -- if VARIABLE was never defined. -- --`default' -- if VARIABLE has a default definition, as is usual with `CC' and so -- on. *Note Variables Used by Implicit Rules: Implicit Variables. -- Note that if you have redefined a default variable, the `origin' -- function will return the origin of the later definition. -- --`environment' -- if VARIABLE was defined as an environment variable and the `-e' -- option is _not_ turned on (*note Summary of Options: Options -- Summary.). -- --`environment override' -- if VARIABLE was defined as an environment variable and the `-e' -- option _is_ turned on (*note Summary of Options: Options Summary.). -- --`file' -- if VARIABLE was defined in a makefile. -- --`command line' -- if VARIABLE was defined on the command line. -- --`override' -- if VARIABLE was defined with an `override' directive in a makefile -- (*note The `override' Directive: Override Directive.). -- --`automatic' -- if VARIABLE is an automatic variable defined for the execution of -- the commands for each rule (*note Automatic Variables::). -- -- This information is primarily useful (other than for your curiosity) --to determine if you want to believe the value of a variable. For --example, suppose you have a makefile `foo' that includes another --makefile `bar'. You want a variable `bletch' to be defined in `bar' if --you run the command `make -f bar', even if the environment contains a --definition of `bletch'. However, if `foo' defined `bletch' before --including `bar', you do not want to override that definition. This --could be done by using an `override' directive in `foo', giving that --definition precedence over the later definition in `bar'; --unfortunately, the `override' directive would also override any command --line definitions. So, `bar' could include: -- -- ifdef bletch -- ifeq "$(origin bletch)" "environment" -- bletch = barf, gag, etc. -- endif -- endif -- --If `bletch' has been defined from the environment, this will redefine --it. -- -- If you want to override a previous definition of `bletch' if it came --from the environment, even under `-e', you could instead write: -- -- ifneq "$(findstring environment,$(origin bletch))" "" -- bletch = barf, gag, etc. -- endif -- -- Here the redefinition takes place if `$(origin bletch)' returns --either `environment' or `environment override'. *Note Functions for --String Substitution and Analysis: Text Functions. -- -- --File: make.info, Node: Flavor Function, Next: Shell Function, Prev: Origin Function, Up: Functions -- --8.10 The `flavor' Function --========================== -- --The `flavor' function is unlike most other functions (and like `origin' --function) in that it does not operate on the values of variables; it --tells you something _about_ a variable. Specifically, it tells you the --flavor of a variable (*note The Two Flavors of Variables: Flavors.). -- -- The syntax of the `flavor' function is: -- -- $(flavor VARIABLE) -- -- Note that VARIABLE is the _name_ of a variable to inquire about; not --a _reference_ to that variable. Therefore you would not normally use a --`$' or parentheses when writing it. (You can, however, use a variable --reference in the name if you want the name not to be a constant.) -- -- The result of this function is a string that identifies the flavor --of the variable VARIABLE: -- --`undefined' -- if VARIABLE was never defined. -- --`recursive' -- if VARIABLE is a recursively expanded variable. -- --`simple' -- if VARIABLE is a simply expanded variable. -- -- -- --File: make.info, Node: Shell Function, Next: Make Control Functions, Prev: Flavor Function, Up: Functions -- --8.11 The `shell' Function --========================= -- --The `shell' function is unlike any other function other than the --`wildcard' function (*note The Function `wildcard': Wildcard Function.) --in that it communicates with the world outside of `make'. -- -- The `shell' function performs the same function that backquotes --(``') perform in most shells: it does "command expansion". This means --that it takes as an argument a shell command and evaluates to the --output of the command. The only processing `make' does on the result --is to convert each newline (or carriage-return / newline pair) to a --single space. If there is a trailing (carriage-return and) newline it --will simply be removed. -- -- The commands run by calls to the `shell' function are run when the --function calls are expanded (*note How `make' Reads a Makefile: Reading --Makefiles.). Because this function involves spawning a new shell, you --should carefully consider the performance implications of using the --`shell' function within recursively expanded variables vs. simply --expanded variables (*note The Two Flavors of Variables: Flavors.). -- -- Here are some examples of the use of the `shell' function: -- -- contents := $(shell cat foo) -- --sets `contents' to the contents of the file `foo', with a space (rather --than a newline) separating each line. -- -- files := $(shell echo *.c) -- --sets `files' to the expansion of `*.c'. Unless `make' is using a very --strange shell, this has the same result as `$(wildcard *.c)' (as long --as at least one `.c' file exists). -- -- --File: make.info, Node: Make Control Functions, Prev: Shell Function, Up: Functions -- --8.12 Functions That Control Make --================================ -- --These functions control the way make runs. Generally, they are used to --provide information to the user of the makefile or to cause make to stop --if some sort of environmental error is detected. -- --`$(error TEXT...)' -- Generates a fatal error where the message is TEXT. Note that the -- error is generated whenever this function is evaluated. So, if -- you put it inside a command script or on the right side of a -- recursive variable assignment, it won't be evaluated until later. -- The TEXT will be expanded before the error is generated. -- -- For example, -- -- ifdef ERROR1 -- $(error error is $(ERROR1)) -- endif -- -- will generate a fatal error during the read of the makefile if the -- `make' variable `ERROR1' is defined. Or, -- -- ERR = $(error found an error!) -- -- .PHONY: err -- err: ; $(ERR) -- -- will generate a fatal error while `make' is running, if the `err' -- target is invoked. -- --`$(warning TEXT...)' -- This function works similarly to the `error' function, above, -- except that `make' doesn't exit. Instead, TEXT is expanded and -- the resulting message is displayed, but processing of the makefile -- continues. -- -- The result of the expansion of this function is the empty string. -- --`$(info TEXT...)' -- This function does nothing more than print its (expanded) -- argument(s) to standard output. No makefile name or line number -- is added. The result of the expansion of this function is the -- empty string. -- -- --File: make.info, Node: Running, Next: Implicit Rules, Prev: Functions, Up: Top -- --9 How to Run `make' --******************* -- --A makefile that says how to recompile a program can be used in more --than one way. The simplest use is to recompile every file that is out --of date. Usually, makefiles are written so that if you run `make' with --no arguments, it does just that. -- -- But you might want to update only some of the files; you might want --to use a different compiler or different compiler options; you might --want just to find out which files are out of date without changing them. -- -- By giving arguments when you run `make', you can do any of these --things and many others. -- -- The exit status of `make' is always one of three values: --`0' -- The exit status is zero if `make' is successful. -- --`2' -- The exit status is two if `make' encounters any errors. It will -- print messages describing the particular errors. -- --`1' -- The exit status is one if you use the `-q' flag and `make' -- determines that some target is not already up to date. *Note -- Instead of Executing the Commands: Instead of Execution. -- --* Menu: -- --* Makefile Arguments:: How to specify which makefile to use. --* Goals:: How to use goal arguments to specify which -- parts of the makefile to use. --* Instead of Execution:: How to use mode flags to specify what -- kind of thing to do with the commands -- in the makefile other than simply -- execute them. --* Avoiding Compilation:: How to avoid recompiling certain files. --* Overriding:: How to override a variable to specify -- an alternate compiler and other things. --* Testing:: How to proceed past some errors, to -- test compilation. --* Options Summary:: Summary of Options -- -- --File: make.info, Node: Makefile Arguments, Next: Goals, Prev: Running, Up: Running -- --9.1 Arguments to Specify the Makefile --===================================== -- --The way to specify the name of the makefile is with the `-f' or --`--file' option (`--makefile' also works). For example, `-f altmake' --says to use the file `altmake' as the makefile. -- -- If you use the `-f' flag several times and follow each `-f' with an --argument, all the specified files are used jointly as makefiles. -- -- If you do not use the `-f' or `--file' flag, the default is to try --`GNUmakefile', `makefile', and `Makefile', in that order, and use the --first of these three which exists or can be made (*note Writing --Makefiles: Makefiles.). -- -- --File: make.info, Node: Goals, Next: Instead of Execution, Prev: Makefile Arguments, Up: Running -- --9.2 Arguments to Specify the Goals --================================== -- --The "goals" are the targets that `make' should strive ultimately to --update. Other targets are updated as well if they appear as --prerequisites of goals, or prerequisites of prerequisites of goals, etc. -- -- By default, the goal is the first target in the makefile (not --counting targets that start with a period). Therefore, makefiles are --usually written so that the first target is for compiling the entire --program or programs they describe. If the first rule in the makefile --has several targets, only the first target in the rule becomes the --default goal, not the whole list. You can manage the selection of the --default goal from within your makefile using the `.DEFAULT_GOAL' --variable (*note Other Special Variables: Special Variables.). -- -- You can also specify a different goal or goals with command-line --arguments to `make'. Use the name of the goal as an argument. If you --specify several goals, `make' processes each of them in turn, in the --order you name them. -- -- Any target in the makefile may be specified as a goal (unless it --starts with `-' or contains an `=', in which case it will be parsed as --a switch or variable definition, respectively). Even targets not in --the makefile may be specified, if `make' can find implicit rules that --say how to make them. -- -- `Make' will set the special variable `MAKECMDGOALS' to the list of --goals you specified on the command line. If no goals were given on the --command line, this variable is empty. Note that this variable should --be used only in special circumstances. -- -- An example of appropriate use is to avoid including `.d' files --during `clean' rules (*note Automatic Prerequisites::), so `make' won't --create them only to immediately remove them again: -- -- sources = foo.c bar.c -- -- ifneq ($(MAKECMDGOALS),clean) -- include $(sources:.c=.d) -- endif -- -- One use of specifying a goal is if you want to compile only a part of --the program, or only one of several programs. Specify as a goal each --file that you wish to remake. For example, consider a directory --containing several programs, with a makefile that starts like this: -- -- .PHONY: all -- all: size nm ld ar as -- -- If you are working on the program `size', you might want to say --`make size' so that only the files of that program are recompiled. -- -- Another use of specifying a goal is to make files that are not --normally made. For example, there may be a file of debugging output, --or a version of the program that is compiled specially for testing, --which has a rule in the makefile but is not a prerequisite of the --default goal. -- -- Another use of specifying a goal is to run the commands associated --with a phony target (*note Phony Targets::) or empty target (*note --Empty Target Files to Record Events: Empty Targets.). Many makefiles --contain a phony target named `clean' which deletes everything except --source files. Naturally, this is done only if you request it --explicitly with `make clean'. Following is a list of typical phony and --empty target names. *Note Standard Targets::, for a detailed list of --all the standard target names which GNU software packages use. -- --`all' -- Make all the top-level targets the makefile knows about. -- --`clean' -- Delete all files that are normally created by running `make'. -- --`mostlyclean' -- Like `clean', but may refrain from deleting a few files that people -- normally don't want to recompile. For example, the `mostlyclean' -- target for GCC does not delete `libgcc.a', because recompiling it -- is rarely necessary and takes a lot of time. -- --`distclean' --`realclean' --`clobber' -- Any of these targets might be defined to delete _more_ files than -- `clean' does. For example, this would delete configuration files -- or links that you would normally create as preparation for -- compilation, even if the makefile itself cannot create these files. -- --`install' -- Copy the executable file into a directory that users typically -- search for commands; copy any auxiliary files that the executable -- uses into the directories where it will look for them. -- --`print' -- Print listings of the source files that have changed. -- --`tar' -- Create a tar file of the source files. -- --`shar' -- Create a shell archive (shar file) of the source files. -- --`dist' -- Create a distribution file of the source files. This might be a -- tar file, or a shar file, or a compressed version of one of the -- above, or even more than one of the above. -- --`TAGS' -- Update a tags table for this program. -- --`check' --`test' -- Perform self tests on the program this makefile builds. -- -- --File: make.info, Node: Instead of Execution, Next: Avoiding Compilation, Prev: Goals, Up: Running -- --9.3 Instead of Executing the Commands --===================================== -- --The makefile tells `make' how to tell whether a target is up to date, --and how to update each target. But updating the targets is not always --what you want. Certain options specify other activities for `make'. -- --`-n' --`--just-print' --`--dry-run' --`--recon' -- "No-op". The activity is to print what commands would be used to -- make the targets up to date, but not actually execute them. -- --`-t' --`--touch' -- "Touch". The activity is to mark the targets as up to date without -- actually changing them. In other words, `make' pretends to compile -- the targets but does not really change their contents. -- --`-q' --`--question' -- "Question". The activity is to find out silently whether the -- targets are up to date already; but execute no commands in either -- case. In other words, neither compilation nor output will occur. -- --`-W FILE' --`--what-if=FILE' --`--assume-new=FILE' --`--new-file=FILE' -- "What if". Each `-W' flag is followed by a file name. The given -- files' modification times are recorded by `make' as being the -- present time, although the actual modification times remain the -- same. You can use the `-W' flag in conjunction with the `-n' flag -- to see what would happen if you were to modify specific files. -- -- With the `-n' flag, `make' prints the commands that it would --normally execute but does not execute them. -- -- With the `-t' flag, `make' ignores the commands in the rules and --uses (in effect) the command `touch' for each target that needs to be --remade. The `touch' command is also printed, unless `-s' or `.SILENT' --is used. For speed, `make' does not actually invoke the program --`touch'. It does the work directly. -- -- With the `-q' flag, `make' prints nothing and executes no commands, --but the exit status code it returns is zero if and only if the targets --to be considered are already up to date. If the exit status is one, --then some updating needs to be done. If `make' encounters an error, --the exit status is two, so you can distinguish an error from a target --that is not up to date. -- -- It is an error to use more than one of these three flags in the same --invocation of `make'. -- -- The `-n', `-t', and `-q' options do not affect command lines that --begin with `+' characters or contain the strings `$(MAKE)' or --`${MAKE}'. Note that only the line containing the `+' character or the --strings `$(MAKE)' or `${MAKE}' is run regardless of these options. --Other lines in the same rule are not run unless they too begin with `+' --or contain `$(MAKE)' or `${MAKE}' (*Note How the `MAKE' Variable Works: --MAKE Variable.) -- -- The `-W' flag provides two features: -- -- * If you also use the `-n' or `-q' flag, you can see what `make' -- would do if you were to modify some files. -- -- * Without the `-n' or `-q' flag, when `make' is actually executing -- commands, the `-W' flag can direct `make' to act as if some files -- had been modified, without actually modifying the files. -- -- Note that the options `-p' and `-v' allow you to obtain other --information about `make' or about the makefiles in use (*note Summary --of Options: Options Summary.). -- -- --File: make.info, Node: Avoiding Compilation, Next: Overriding, Prev: Instead of Execution, Up: Running -- --9.4 Avoiding Recompilation of Some Files --======================================== -- --Sometimes you may have changed a source file but you do not want to --recompile all the files that depend on it. For example, suppose you add --a macro or a declaration to a header file that many other files depend --on. Being conservative, `make' assumes that any change in the header --file requires recompilation of all dependent files, but you know that --they do not need to be recompiled and you would rather not waste the --time waiting for them to compile. -- -- If you anticipate the problem before changing the header file, you --can use the `-t' flag. This flag tells `make' not to run the commands --in the rules, but rather to mark the target up to date by changing its --last-modification date. You would follow this procedure: -- -- 1. Use the command `make' to recompile the source files that really -- need recompilation, ensuring that the object files are up-to-date -- before you begin. -- -- 2. Make the changes in the header files. -- -- 3. Use the command `make -t' to mark all the object files as up to -- date. The next time you run `make', the changes in the header -- files will not cause any recompilation. -- -- If you have already changed the header file at a time when some files --do need recompilation, it is too late to do this. Instead, you can use --the `-o FILE' flag, which marks a specified file as "old" (*note --Summary of Options: Options Summary.). This means that the file itself --will not be remade, and nothing else will be remade on its account. --Follow this procedure: -- -- 1. Recompile the source files that need compilation for reasons -- independent of the particular header file, with `make -o -- HEADERFILE'. If several header files are involved, use a separate -- `-o' option for each header file. -- -- 2. Touch all the object files with `make -t'. -- -- --File: make.info, Node: Overriding, Next: Testing, Prev: Avoiding Compilation, Up: Running -- --9.5 Overriding Variables --======================== -- --An argument that contains `=' specifies the value of a variable: `V=X' --sets the value of the variable V to X. If you specify a value in this --way, all ordinary assignments of the same variable in the makefile are --ignored; we say they have been "overridden" by the command line --argument. -- -- The most common way to use this facility is to pass extra flags to --compilers. For example, in a properly written makefile, the variable --`CFLAGS' is included in each command that runs the C compiler, so a --file `foo.c' would be compiled something like this: -- -- cc -c $(CFLAGS) foo.c -- -- Thus, whatever value you set for `CFLAGS' affects each compilation --that occurs. The makefile probably specifies the usual value for --`CFLAGS', like this: -- -- CFLAGS=-g -- -- Each time you run `make', you can override this value if you wish. --For example, if you say `make CFLAGS='-g -O'', each C compilation will --be done with `cc -c -g -O'. (This also illustrates how you can use --quoting in the shell to enclose spaces and other special characters in --the value of a variable when you override it.) -- -- The variable `CFLAGS' is only one of many standard variables that --exist just so that you can change them this way. *Note Variables Used --by Implicit Rules: Implicit Variables, for a complete list. -- -- You can also program the makefile to look at additional variables of --your own, giving the user the ability to control other aspects of how --the makefile works by changing the variables. -- -- When you override a variable with a command argument, you can define --either a recursively-expanded variable or a simply-expanded variable. --The examples shown above make a recursively-expanded variable; to make a --simply-expanded variable, write `:=' instead of `='. But, unless you --want to include a variable reference or function call in the _value_ --that you specify, it makes no difference which kind of variable you --create. -- -- There is one way that the makefile can change a variable that you --have overridden. This is to use the `override' directive, which is a --line that looks like this: `override VARIABLE = VALUE' (*note The --`override' Directive: Override Directive.). -- -- --File: make.info, Node: Testing, Next: Options Summary, Prev: Overriding, Up: Running -- --9.6 Testing the Compilation of a Program --======================================== -- --Normally, when an error happens in executing a shell command, `make' --gives up immediately, returning a nonzero status. No further commands --are executed for any target. The error implies that the goal cannot be --correctly remade, and `make' reports this as soon as it knows. -- -- When you are compiling a program that you have just changed, this is --not what you want. Instead, you would rather that `make' try compiling --every file that can be tried, to show you as many compilation errors as --possible. -- -- On these occasions, you should use the `-k' or `--keep-going' flag. --This tells `make' to continue to consider the other prerequisites of --the pending targets, remaking them if necessary, before it gives up and --returns nonzero status. For example, after an error in compiling one --object file, `make -k' will continue compiling other object files even --though it already knows that linking them will be impossible. In --addition to continuing after failed shell commands, `make -k' will --continue as much as possible after discovering that it does not know --how to make a target or prerequisite file. This will always cause an --error message, but without `-k', it is a fatal error (*note Summary of --Options: Options Summary.). -- -- The usual behavior of `make' assumes that your purpose is to get the --goals up to date; once `make' learns that this is impossible, it might --as well report the failure immediately. The `-k' flag says that the --real purpose is to test as much as possible of the changes made in the --program, perhaps to find several independent problems so that you can --correct them all before the next attempt to compile. This is why Emacs' --`M-x compile' command passes the `-k' flag by default. -- -- --File: make.info, Node: Options Summary, Prev: Testing, Up: Running -- --9.7 Summary of Options --====================== -- --Here is a table of all the options `make' understands: -- --`-b' --`-m' -- These options are ignored for compatibility with other versions of -- `make'. -- --`-B' --`--always-make' -- Consider all targets out-of-date. GNU `make' proceeds to consider -- targets and their prerequisites using the normal algorithms; -- however, all targets so considered are always remade regardless of -- the status of their prerequisites. To avoid infinite recursion, if -- `MAKE_RESTARTS' (*note Other Special Variables: Special -- Variables.) is set to a number greater than 0 this option is -- disabled when considering whether to remake makefiles (*note How -- Makefiles Are Remade: Remaking Makefiles.). -- --`-C DIR' --`--directory=DIR' -- Change to directory DIR before reading the makefiles. If multiple -- `-C' options are specified, each is interpreted relative to the -- previous one: `-C / -C etc' is equivalent to `-C /etc'. This is -- typically used with recursive invocations of `make' (*note -- Recursive Use of `make': Recursion.). -- --`-d' -- Print debugging information in addition to normal processing. The -- debugging information says which files are being considered for -- remaking, which file-times are being compared and with what -- results, which files actually need to be remade, which implicit -- rules are considered and which are applied--everything interesting -- about how `make' decides what to do. The `-d' option is -- equivalent to `--debug=a' (see below). -- --`--debug[=OPTIONS]' -- Print debugging information in addition to normal processing. -- Various levels and types of output can be chosen. With no -- arguments, print the "basic" level of debugging. Possible -- arguments are below; only the first character is considered, and -- values must be comma- or space-separated. -- -- `a (all)' -- All types of debugging output are enabled. This is -- equivalent to using `-d'. -- -- `b (basic)' -- Basic debugging prints each target that was found to be -- out-of-date, and whether the build was successful or not. -- -- `v (verbose)' -- A level above `basic'; includes messages about which -- makefiles were parsed, prerequisites that did not need to be -- rebuilt, etc. This option also enables `basic' messages. -- -- `i (implicit)' -- Prints messages describing the implicit rule searches for -- each target. This option also enables `basic' messages. -- -- `j (jobs)' -- Prints messages giving details on the invocation of specific -- subcommands. -- -- `m (makefile)' -- By default, the above messages are not enabled while trying -- to remake the makefiles. This option enables messages while -- rebuilding makefiles, too. Note that the `all' option does -- enable this option. This option also enables `basic' -- messages. -- --`-e' --`--environment-overrides' -- Give variables taken from the environment precedence over -- variables from makefiles. *Note Variables from the Environment: -- Environment. -- --`-f FILE' --`--file=FILE' --`--makefile=FILE' -- Read the file named FILE as a makefile. *Note Writing Makefiles: -- Makefiles. -- --`-h' --`--help' -- Remind you of the options that `make' understands and then exit. -- --`-i' --`--ignore-errors' -- Ignore all errors in commands executed to remake files. *Note -- Errors in Commands: Errors. -- --`-I DIR' --`--include-dir=DIR' -- Specifies a directory DIR to search for included makefiles. *Note -- Including Other Makefiles: Include. If several `-I' options are -- used to specify several directories, the directories are searched -- in the order specified. -- --`-j [JOBS]' --`--jobs[=JOBS]' -- Specifies the number of jobs (commands) to run simultaneously. -- With no argument, `make' runs as many jobs simultaneously as -- possible. If there is more than one `-j' option, the last one is -- effective. *Note Parallel Execution: Parallel, for more -- information on how commands are run. Note that this option is -- ignored on MS-DOS. -- --`-k' --`--keep-going' -- Continue as much as possible after an error. While the target that -- failed, and those that depend on it, cannot be remade, the other -- prerequisites of these targets can be processed all the same. -- *Note Testing the Compilation of a Program: Testing. -- --`-l [LOAD]' --`--load-average[=LOAD]' --`--max-load[=LOAD]' -- Specifies that no new jobs (commands) should be started if there -- are other jobs running and the load average is at least LOAD (a -- floating-point number). With no argument, removes a previous load -- limit. *Note Parallel Execution: Parallel. -- --`-L' --`--check-symlink-times' -- On systems that support symbolic links, this option causes `make' -- to consider the timestamps on any symbolic links in addition to the -- timestamp on the file referenced by those links. When this option -- is provided, the most recent timestamp among the file and the -- symbolic links is taken as the modification time for this target -- file. -- --`-n' --`--just-print' --`--dry-run' --`--recon' -- Print the commands that would be executed, but do not execute them. -- *Note Instead of Executing the Commands: Instead of Execution. -- --`-o FILE' --`--old-file=FILE' --`--assume-old=FILE' -- Do not remake the file FILE even if it is older than its -- prerequisites, and do not remake anything on account of changes in -- FILE. Essentially the file is treated as very old and its rules -- are ignored. *Note Avoiding Recompilation of Some Files: Avoiding -- Compilation. -- --`-p' --`--print-data-base' -- Print the data base (rules and variable values) that results from -- reading the makefiles; then execute as usual or as otherwise -- specified. This also prints the version information given by the -- `-v' switch (see below). To print the data base without trying to -- remake any files, use `make -qp'. To print the data base of -- predefined rules and variables, use `make -p -f /dev/null'. The -- data base output contains filename and linenumber information for -- command and variable definitions, so it can be a useful debugging -- tool in complex environments. -- --`-q' --`--question' -- "Question mode". Do not run any commands, or print anything; just -- return an exit status that is zero if the specified targets are -- already up to date, one if any remaking is required, or two if an -- error is encountered. *Note Instead of Executing the Commands: -- Instead of Execution. -- --`-r' --`--no-builtin-rules' -- Eliminate use of the built-in implicit rules (*note Using Implicit -- Rules: Implicit Rules.). You can still define your own by writing -- pattern rules (*note Defining and Redefining Pattern Rules: -- Pattern Rules.). The `-r' option also clears out the default list -- of suffixes for suffix rules (*note Old-Fashioned Suffix Rules: -- Suffix Rules.). But you can still define your own suffixes with a -- rule for `.SUFFIXES', and then define your own suffix rules. Note -- that only _rules_ are affected by the `-r' option; default -- variables remain in effect (*note Variables Used by Implicit -- Rules: Implicit Variables.); see the `-R' option below. -- --`-R' --`--no-builtin-variables' -- Eliminate use of the built-in rule-specific variables (*note -- Variables Used by Implicit Rules: Implicit Variables.). You can -- still define your own, of course. The `-R' option also -- automatically enables the `-r' option (see above), since it -- doesn't make sense to have implicit rules without any definitions -- for the variables that they use. -- --`-s' --`--silent' --`--quiet' -- Silent operation; do not print the commands as they are executed. -- *Note Command Echoing: Echoing. -- --`-S' --`--no-keep-going' --`--stop' -- Cancel the effect of the `-k' option. This is never necessary -- except in a recursive `make' where `-k' might be inherited from -- the top-level `make' via `MAKEFLAGS' (*note Recursive Use of -- `make': Recursion.) or if you set `-k' in `MAKEFLAGS' in your -- environment. -- --`-t' --`--touch' -- Touch files (mark them up to date without really changing them) -- instead of running their commands. This is used to pretend that -- the commands were done, in order to fool future invocations of -- `make'. *Note Instead of Executing the Commands: Instead of -- Execution. -- --`-v' --`--version' -- Print the version of the `make' program plus a copyright, a list -- of authors, and a notice that there is no warranty; then exit. -- --`-w' --`--print-directory' -- Print a message containing the working directory both before and -- after executing the makefile. This may be useful for tracking -- down errors from complicated nests of recursive `make' commands. -- *Note Recursive Use of `make': Recursion. (In practice, you -- rarely need to specify this option since `make' does it for you; -- see *Note The `--print-directory' Option: -w Option.) -- --`--no-print-directory' -- Disable printing of the working directory under `-w'. This option -- is useful when `-w' is turned on automatically, but you do not -- want to see the extra messages. *Note The `--print-directory' -- Option: -w Option. -- --`-W FILE' --`--what-if=FILE' --`--new-file=FILE' --`--assume-new=FILE' -- Pretend that the target FILE has just been modified. When used -- with the `-n' flag, this shows you what would happen if you were -- to modify that file. Without `-n', it is almost the same as -- running a `touch' command on the given file before running `make', -- except that the modification time is changed only in the -- imagination of `make'. *Note Instead of Executing the Commands: -- Instead of Execution. -- --`--warn-undefined-variables' -- Issue a warning message whenever `make' sees a reference to an -- undefined variable. This can be helpful when you are trying to -- debug makefiles which use variables in complex ways. -- -- --File: make.info, Node: Implicit Rules, Next: Archives, Prev: Running, Up: Top -- --10 Using Implicit Rules --*********************** -- --Certain standard ways of remaking target files are used very often. For --example, one customary way to make an object file is from a C source --file using the C compiler, `cc'. -- -- "Implicit rules" tell `make' how to use customary techniques so that --you do not have to specify them in detail when you want to use them. --For example, there is an implicit rule for C compilation. File names --determine which implicit rules are run. For example, C compilation --typically takes a `.c' file and makes a `.o' file. So `make' applies --the implicit rule for C compilation when it sees this combination of --file name endings. -- -- A chain of implicit rules can apply in sequence; for example, `make' --will remake a `.o' file from a `.y' file by way of a `.c' file. -- -- The built-in implicit rules use several variables in their commands --so that, by changing the values of the variables, you can change the --way the implicit rule works. For example, the variable `CFLAGS' --controls the flags given to the C compiler by the implicit rule for C --compilation. -- -- You can define your own implicit rules by writing "pattern rules". -- -- "Suffix rules" are a more limited way to define implicit rules. --Pattern rules are more general and clearer, but suffix rules are --retained for compatibility. -- --* Menu: -- --* Using Implicit:: How to use an existing implicit rule -- to get the commands for updating a file. --* Catalogue of Rules:: A list of built-in implicit rules. --* Implicit Variables:: How to change what predefined rules do. --* Chained Rules:: How to use a chain of implicit rules. --* Pattern Rules:: How to define new implicit rules. --* Last Resort:: How to define commands for rules which -- cannot find any. --* Suffix Rules:: The old-fashioned style of implicit rule. --* Implicit Rule Search:: The precise algorithm for applying -- implicit rules. -- -- --File: make.info, Node: Using Implicit, Next: Catalogue of Rules, Prev: Implicit Rules, Up: Implicit Rules -- --10.1 Using Implicit Rules --========================= -- --To allow `make' to find a customary method for updating a target file, --all you have to do is refrain from specifying commands yourself. Either --write a rule with no command lines, or don't write a rule at all. Then --`make' will figure out which implicit rule to use based on which kind --of source file exists or can be made. -- -- For example, suppose the makefile looks like this: -- -- foo : foo.o bar.o -- cc -o foo foo.o bar.o $(CFLAGS) $(LDFLAGS) -- --Because you mention `foo.o' but do not give a rule for it, `make' will --automatically look for an implicit rule that tells how to update it. --This happens whether or not the file `foo.o' currently exists. -- -- If an implicit rule is found, it can supply both commands and one or --more prerequisites (the source files). You would want to write a rule --for `foo.o' with no command lines if you need to specify additional --prerequisites, such as header files, that the implicit rule cannot --supply. -- -- Each implicit rule has a target pattern and prerequisite patterns. --There may be many implicit rules with the same target pattern. For --example, numerous rules make `.o' files: one, from a `.c' file with the --C compiler; another, from a `.p' file with the Pascal compiler; and so --on. The rule that actually applies is the one whose prerequisites --exist or can be made. So, if you have a file `foo.c', `make' will run --the C compiler; otherwise, if you have a file `foo.p', `make' will run --the Pascal compiler; and so on. -- -- Of course, when you write the makefile, you know which implicit rule --you want `make' to use, and you know it will choose that one because you --know which possible prerequisite files are supposed to exist. *Note --Catalogue of Implicit Rules: Catalogue of Rules, for a catalogue of all --the predefined implicit rules. -- -- Above, we said an implicit rule applies if the required --prerequisites "exist or can be made". A file "can be made" if it is --mentioned explicitly in the makefile as a target or a prerequisite, or --if an implicit rule can be recursively found for how to make it. When --an implicit prerequisite is the result of another implicit rule, we say --that "chaining" is occurring. *Note Chains of Implicit Rules: Chained --Rules. -- -- In general, `make' searches for an implicit rule for each target, and --for each double-colon rule, that has no commands. A file that is --mentioned only as a prerequisite is considered a target whose rule --specifies nothing, so implicit rule search happens for it. *Note --Implicit Rule Search Algorithm: Implicit Rule Search, for the details --of how the search is done. -- -- Note that explicit prerequisites do not influence implicit rule --search. For example, consider this explicit rule: -- -- foo.o: foo.p -- --The prerequisite on `foo.p' does not necessarily mean that `make' will --remake `foo.o' according to the implicit rule to make an object file, a --`.o' file, from a Pascal source file, a `.p' file. For example, if --`foo.c' also exists, the implicit rule to make an object file from a C --source file is used instead, because it appears before the Pascal rule --in the list of predefined implicit rules (*note Catalogue of Implicit --Rules: Catalogue of Rules.). -- -- If you do not want an implicit rule to be used for a target that has --no commands, you can give that target empty commands by writing a --semicolon (*note Defining Empty Commands: Empty Commands.). -- -- --File: make.info, Node: Catalogue of Rules, Next: Implicit Variables, Prev: Using Implicit, Up: Implicit Rules -- --10.2 Catalogue of Implicit Rules --================================ -- --Here is a catalogue of predefined implicit rules which are always --available unless the makefile explicitly overrides or cancels them. --*Note Canceling Implicit Rules: Canceling Rules, for information on --canceling or overriding an implicit rule. The `-r' or --`--no-builtin-rules' option cancels all predefined rules. -- -- This manual only documents the default rules available on POSIX-based --operating systems. Other operating systems, such as VMS, Windows, --OS/2, etc. may have different sets of default rules. To see the full --list of default rules and variables available in your version of GNU --`make', run `make -p' in a directory with no makefile. -- -- Not all of these rules will always be defined, even when the `-r' --option is not given. Many of the predefined implicit rules are --implemented in `make' as suffix rules, so which ones will be defined --depends on the "suffix list" (the list of prerequisites of the special --target `.SUFFIXES'). The default suffix list is: `.out', `.a', `.ln', --`.o', `.c', `.cc', `.C', `.cpp', `.p', `.f', `.F', `.r', `.y', `.l', --`.s', `.S', `.mod', `.sym', `.def', `.h', `.info', `.dvi', `.tex', --`.texinfo', `.texi', `.txinfo', `.w', `.ch' `.web', `.sh', `.elc', --`.el'. All of the implicit rules described below whose prerequisites --have one of these suffixes are actually suffix rules. If you modify --the suffix list, the only predefined suffix rules in effect will be --those named by one or two of the suffixes that are on the list you --specify; rules whose suffixes fail to be on the list are disabled. --*Note Old-Fashioned Suffix Rules: Suffix Rules, for full details on --suffix rules. -- --Compiling C programs -- `N.o' is made automatically from `N.c' with a command of the form -- `$(CC) -c $(CPPFLAGS) $(CFLAGS)'. -- --Compiling C++ programs -- `N.o' is made automatically from `N.cc', `N.cpp', or `N.C' with a -- command of the form `$(CXX) -c $(CPPFLAGS) $(CXXFLAGS)'. We -- encourage you to use the suffix `.cc' for C++ source files instead -- of `.C'. -- --Compiling Pascal programs -- `N.o' is made automatically from `N.p' with the command `$(PC) -c -- $(PFLAGS)'. -- --Compiling Fortran and Ratfor programs -- `N.o' is made automatically from `N.r', `N.F' or `N.f' by running -- the Fortran compiler. The precise command used is as follows: -- -- `.f' -- `$(FC) -c $(FFLAGS)'. -- -- `.F' -- `$(FC) -c $(FFLAGS) $(CPPFLAGS)'. -- -- `.r' -- `$(FC) -c $(FFLAGS) $(RFLAGS)'. -- --Preprocessing Fortran and Ratfor programs -- `N.f' is made automatically from `N.r' or `N.F'. This rule runs -- just the preprocessor to convert a Ratfor or preprocessable -- Fortran program into a strict Fortran program. The precise -- command used is as follows: -- -- `.F' -- `$(FC) -F $(CPPFLAGS) $(FFLAGS)'. -- -- `.r' -- `$(FC) -F $(FFLAGS) $(RFLAGS)'. -- --Compiling Modula-2 programs -- `N.sym' is made from `N.def' with a command of the form `$(M2C) -- $(M2FLAGS) $(DEFFLAGS)'. `N.o' is made from `N.mod'; the form is: -- `$(M2C) $(M2FLAGS) $(MODFLAGS)'. -- --Assembling and preprocessing assembler programs -- `N.o' is made automatically from `N.s' by running the assembler, -- `as'. The precise command is `$(AS) $(ASFLAGS)'. -- -- `N.s' is made automatically from `N.S' by running the C -- preprocessor, `cpp'. The precise command is `$(CPP) $(CPPFLAGS)'. -- --Linking a single object file -- `N' is made automatically from `N.o' by running the linker -- (usually called `ld') via the C compiler. The precise command -- used is `$(CC) $(LDFLAGS) N.o $(LOADLIBES) $(LDLIBS)'. -- -- This rule does the right thing for a simple program with only one -- source file. It will also do the right thing if there are multiple -- object files (presumably coming from various other source files), -- one of which has a name matching that of the executable file. -- Thus, -- -- x: y.o z.o -- -- when `x.c', `y.c' and `z.c' all exist will execute: -- -- cc -c x.c -o x.o -- cc -c y.c -o y.o -- cc -c z.c -o z.o -- cc x.o y.o z.o -o x -- rm -f x.o -- rm -f y.o -- rm -f z.o -- -- In more complicated cases, such as when there is no object file -- whose name derives from the executable file name, you must write -- an explicit command for linking. -- -- Each kind of file automatically made into `.o' object files will -- be automatically linked by using the compiler (`$(CC)', `$(FC)' or -- `$(PC)'; the C compiler `$(CC)' is used to assemble `.s' files) -- without the `-c' option. This could be done by using the `.o' -- object files as intermediates, but it is faster to do the -- compiling and linking in one step, so that's how it's done. -- --Yacc for C programs -- `N.c' is made automatically from `N.y' by running Yacc with the -- command `$(YACC) $(YFLAGS)'. -- --Lex for C programs -- `N.c' is made automatically from `N.l' by running Lex. The actual -- command is `$(LEX) $(LFLAGS)'. -- --Lex for Ratfor programs -- `N.r' is made automatically from `N.l' by running Lex. The actual -- command is `$(LEX) $(LFLAGS)'. -- -- The convention of using the same suffix `.l' for all Lex files -- regardless of whether they produce C code or Ratfor code makes it -- impossible for `make' to determine automatically which of the two -- languages you are using in any particular case. If `make' is -- called upon to remake an object file from a `.l' file, it must -- guess which compiler to use. It will guess the C compiler, because -- that is more common. If you are using Ratfor, make sure `make' -- knows this by mentioning `N.r' in the makefile. Or, if you are -- using Ratfor exclusively, with no C files, remove `.c' from the -- list of implicit rule suffixes with: -- -- .SUFFIXES: -- .SUFFIXES: .o .r .f .l ... -- --Making Lint Libraries from C, Yacc, or Lex programs -- `N.ln' is made from `N.c' by running `lint'. The precise command -- is `$(LINT) $(LINTFLAGS) $(CPPFLAGS) -i'. The same command is -- used on the C code produced from `N.y' or `N.l'. -- --TeX and Web -- `N.dvi' is made from `N.tex' with the command `$(TEX)'. `N.tex' -- is made from `N.web' with `$(WEAVE)', or from `N.w' (and from -- `N.ch' if it exists or can be made) with `$(CWEAVE)'. `N.p' is -- made from `N.web' with `$(TANGLE)' and `N.c' is made from `N.w' -- (and from `N.ch' if it exists or can be made) with `$(CTANGLE)'. -- --Texinfo and Info -- `N.dvi' is made from `N.texinfo', `N.texi', or `N.txinfo', with -- the command `$(TEXI2DVI) $(TEXI2DVI_FLAGS)'. `N.info' is made from -- `N.texinfo', `N.texi', or `N.txinfo', with the command -- `$(MAKEINFO) $(MAKEINFO_FLAGS)'. -- --RCS -- Any file `N' is extracted if necessary from an RCS file named -- either `N,v' or `RCS/N,v'. The precise command used is -- `$(CO) $(COFLAGS)'. `N' will not be extracted from RCS if it -- already exists, even if the RCS file is newer. The rules for RCS -- are terminal (*note Match-Anything Pattern Rules: Match-Anything -- Rules.), so RCS files cannot be generated from another source; -- they must actually exist. -- --SCCS -- Any file `N' is extracted if necessary from an SCCS file named -- either `s.N' or `SCCS/s.N'. The precise command used is -- `$(GET) $(GFLAGS)'. The rules for SCCS are terminal (*note -- Match-Anything Pattern Rules: Match-Anything Rules.), so SCCS -- files cannot be generated from another source; they must actually -- exist. -- -- For the benefit of SCCS, a file `N' is copied from `N.sh' and made -- executable (by everyone). This is for shell scripts that are -- checked into SCCS. Since RCS preserves the execution permission -- of a file, you do not need to use this feature with RCS. -- -- We recommend that you avoid using of SCCS. RCS is widely held to -- be superior, and is also free. By choosing free software in place -- of comparable (or inferior) proprietary software, you support the -- free software movement. -- -- Usually, you want to change only the variables listed in the table --above, which are documented in the following section. -- -- However, the commands in built-in implicit rules actually use --variables such as `COMPILE.c', `LINK.p', and `PREPROCESS.S', whose --values contain the commands listed above. -- -- `make' follows the convention that the rule to compile a `.X' source --file uses the variable `COMPILE.X'. Similarly, the rule to produce an --executable from a `.X' file uses `LINK.X'; and the rule to preprocess a --`.X' file uses `PREPROCESS.X'. -- -- Every rule that produces an object file uses the variable --`OUTPUT_OPTION'. `make' defines this variable either to contain `-o --$@', or to be empty, depending on a compile-time option. You need the --`-o' option to ensure that the output goes into the right file when the --source file is in a different directory, as when using `VPATH' (*note --Directory Search::). However, compilers on some systems do not accept --a `-o' switch for object files. If you use such a system, and use --`VPATH', some compilations will put their output in the wrong place. A --possible workaround for this problem is to give `OUTPUT_OPTION' the --value `; mv $*.o $@'. -- -- --File: make.info, Node: Implicit Variables, Next: Chained Rules, Prev: Catalogue of Rules, Up: Implicit Rules -- --10.3 Variables Used by Implicit Rules --===================================== -- --The commands in built-in implicit rules make liberal use of certain --predefined variables. You can alter the values of these variables in --the makefile, with arguments to `make', or in the environment to alter --how the implicit rules work without redefining the rules themselves. --You can cancel all variables used by implicit rules with the `-R' or --`--no-builtin-variables' option. -- -- For example, the command used to compile a C source file actually --says `$(CC) -c $(CFLAGS) $(CPPFLAGS)'. The default values of the --variables used are `cc' and nothing, resulting in the command `cc -c'. --By redefining `CC' to `ncc', you could cause `ncc' to be used for all C --compilations performed by the implicit rule. By redefining `CFLAGS' to --be `-g', you could pass the `-g' option to each compilation. _All_ --implicit rules that do C compilation use `$(CC)' to get the program --name for the compiler and _all_ include `$(CFLAGS)' among the arguments --given to the compiler. -- -- The variables used in implicit rules fall into two classes: those --that are names of programs (like `CC') and those that contain arguments --for the programs (like `CFLAGS'). (The "name of a program" may also --contain some command arguments, but it must start with an actual --executable program name.) If a variable value contains more than one --argument, separate them with spaces. -- -- The following tables describe of some of the more commonly-used --predefined variables. This list is not exhaustive, and the default --values shown here may not be what are selected by `make' for your --environment. To see the complete list of predefined variables for your --instance of GNU `make' you can run `make -p' in a directory with no --makefiles. -- -- Here is a table of some of the more common variables used as names of --programs in built-in rules: makefiles. -- --`AR' -- Archive-maintaining program; default `ar'. -- --`AS' -- Program for compiling assembly files; default `as'. -- --`CC' -- Program for compiling C programs; default `cc'. -- --`CO' -- Program for checking out files from RCS; default `co'. -- --`CXX' -- Program for compiling C++ programs; default `g++'. -- --`CO' -- Program for extracting a file from RCS; default `co'. -- --`CPP' -- Program for running the C preprocessor, with results to standard -- output; default `$(CC) -E'. -- --`FC' -- Program for compiling or preprocessing Fortran and Ratfor programs; -- default `f77'. -- --`GET' -- Program for extracting a file from SCCS; default `get'. -- --`LEX' -- Program to use to turn Lex grammars into source code; default -- `lex'. -- --`YACC' -- Program to use to turn Yacc grammars into source code; default -- `yacc'. -- --`LINT' -- Program to use to run lint on source code; default `lint'. -- --`M2C' -- Program to use to compile Modula-2 source code; default `m2c'. -- --`PC' -- Program for compiling Pascal programs; default `pc'. -- --`MAKEINFO' -- Program to convert a Texinfo source file into an Info file; default -- `makeinfo'. -- --`TEX' -- Program to make TeX DVI files from TeX source; default `tex'. -- --`TEXI2DVI' -- Program to make TeX DVI files from Texinfo source; default -- `texi2dvi'. -- --`WEAVE' -- Program to translate Web into TeX; default `weave'. -- --`CWEAVE' -- Program to translate C Web into TeX; default `cweave'. -- --`TANGLE' -- Program to translate Web into Pascal; default `tangle'. -- --`CTANGLE' -- Program to translate C Web into C; default `ctangle'. -- --`RM' -- Command to remove a file; default `rm -f'. -- -- Here is a table of variables whose values are additional arguments --for the programs above. The default values for all of these is the --empty string, unless otherwise noted. -- --`ARFLAGS' -- Flags to give the archive-maintaining program; default `rv'. -- --`ASFLAGS' -- Extra flags to give to the assembler (when explicitly invoked on a -- `.s' or `.S' file). -- --`CFLAGS' -- Extra flags to give to the C compiler. -- --`CXXFLAGS' -- Extra flags to give to the C++ compiler. -- --`COFLAGS' -- Extra flags to give to the RCS `co' program. -- --`CPPFLAGS' -- Extra flags to give to the C preprocessor and programs that use it -- (the C and Fortran compilers). -- --`FFLAGS' -- Extra flags to give to the Fortran compiler. -- --`GFLAGS' -- Extra flags to give to the SCCS `get' program. -- --`LDFLAGS' -- Extra flags to give to compilers when they are supposed to invoke -- the linker, `ld'. -- --`LFLAGS' -- Extra flags to give to Lex. -- --`YFLAGS' -- Extra flags to give to Yacc. -- --`PFLAGS' -- Extra flags to give to the Pascal compiler. -- --`RFLAGS' -- Extra flags to give to the Fortran compiler for Ratfor programs. -- --`LINTFLAGS' -- Extra flags to give to lint. -- -- --File: make.info, Node: Chained Rules, Next: Pattern Rules, Prev: Implicit Variables, Up: Implicit Rules -- --10.4 Chains of Implicit Rules --============================= -- --Sometimes a file can be made by a sequence of implicit rules. For --example, a file `N.o' could be made from `N.y' by running first Yacc --and then `cc'. Such a sequence is called a "chain". -- -- If the file `N.c' exists, or is mentioned in the makefile, no --special searching is required: `make' finds that the object file can be --made by C compilation from `N.c'; later on, when considering how to --make `N.c', the rule for running Yacc is used. Ultimately both `N.c' --and `N.o' are updated. -- -- However, even if `N.c' does not exist and is not mentioned, `make' --knows how to envision it as the missing link between `N.o' and `N.y'! --In this case, `N.c' is called an "intermediate file". Once `make' has --decided to use the intermediate file, it is entered in the data base as --if it had been mentioned in the makefile, along with the implicit rule --that says how to create it. -- -- Intermediate files are remade using their rules just like all other --files. But intermediate files are treated differently in two ways. -- -- The first difference is what happens if the intermediate file does --not exist. If an ordinary file B does not exist, and `make' considers --a target that depends on B, it invariably creates B and then updates --the target from B. But if B is an intermediate file, then `make' can --leave well enough alone. It won't bother updating B, or the ultimate --target, unless some prerequisite of B is newer than that target or --there is some other reason to update that target. -- -- The second difference is that if `make' _does_ create B in order to --update something else, it deletes B later on after it is no longer --needed. Therefore, an intermediate file which did not exist before --`make' also does not exist after `make'. `make' reports the deletion --to you by printing a `rm -f' command showing which file it is deleting. -- -- Ordinarily, a file cannot be intermediate if it is mentioned in the --makefile as a target or prerequisite. However, you can explicitly mark --a file as intermediate by listing it as a prerequisite of the special --target `.INTERMEDIATE'. This takes effect even if the file is mentioned --explicitly in some other way. -- -- You can prevent automatic deletion of an intermediate file by --marking it as a "secondary" file. To do this, list it as a --prerequisite of the special target `.SECONDARY'. When a file is --secondary, `make' will not create the file merely because it does not --already exist, but `make' does not automatically delete the file. --Marking a file as secondary also marks it as intermediate. -- -- You can list the target pattern of an implicit rule (such as `%.o') --as a prerequisite of the special target `.PRECIOUS' to preserve --intermediate files made by implicit rules whose target patterns match --that file's name; see *Note Interrupts::. -- -- A chain can involve more than two implicit rules. For example, it is --possible to make a file `foo' from `RCS/foo.y,v' by running RCS, Yacc --and `cc'. Then both `foo.y' and `foo.c' are intermediate files that --are deleted at the end. -- -- No single implicit rule can appear more than once in a chain. This --means that `make' will not even consider such a ridiculous thing as --making `foo' from `foo.o.o' by running the linker twice. This --constraint has the added benefit of preventing any infinite loop in the --search for an implicit rule chain. -- -- There are some special implicit rules to optimize certain cases that --would otherwise be handled by rule chains. For example, making `foo' --from `foo.c' could be handled by compiling and linking with separate --chained rules, using `foo.o' as an intermediate file. But what --actually happens is that a special rule for this case does the --compilation and linking with a single `cc' command. The optimized rule --is used in preference to the step-by-step chain because it comes --earlier in the ordering of rules. -- -diff -rNU3 dist.orig/doc/make.info-2 dist/doc/make.info-2 ---- dist.orig/doc/make.info-2 2006-04-01 08:41:04.000000000 +0200 -+++ dist/doc/make.info-2 1970-01-01 01:00:00.000000000 +0100 -@@ -1,4393 +0,0 @@ --This is make.info, produced by makeinfo version 4.8 from make.texi. -- -- This file documents the GNU `make' utility, which determines --automatically which pieces of a large program need to be recompiled, --and issues the commands to recompile them. -- -- This is Edition 0.70, last updated 1 April 2006, of `The GNU Make --Manual', for GNU `make' version 3.81. -- -- Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, --1997, 1998, 1999, 2000, 2002, 2003, 2004, 2005, 2006 Free Software --Foundation, Inc. -- -- Permission is granted to copy, distribute and/or modify this -- document under the terms of the GNU Free Documentation License, -- Version 1.2 or any later version published by the Free Software -- Foundation; with no Invariant Sections, with the Front-Cover Texts -- being "A GNU Manual," and with the Back-Cover Texts as in (a) -- below. A copy of the license is included in the section entitled -- "GNU Free Documentation License." -- -- (a) The FSF's Back-Cover Text is: "You have freedom to copy and -- modify this GNU Manual, like GNU software. Copies published by -- the Free Software Foundation raise funds for GNU development." -- --INFO-DIR-SECTION GNU Packages --START-INFO-DIR-ENTRY --* Make: (make). Remake files automatically. --END-INFO-DIR-ENTRY -- -- --File: make.info, Node: Pattern Rules, Next: Last Resort, Prev: Chained Rules, Up: Implicit Rules -- --10.5 Defining and Redefining Pattern Rules --========================================== -- --You define an implicit rule by writing a "pattern rule". A pattern --rule looks like an ordinary rule, except that its target contains the --character `%' (exactly one of them). The target is considered a --pattern for matching file names; the `%' can match any nonempty --substring, while other characters match only themselves. The --prerequisites likewise use `%' to show how their names relate to the --target name. -- -- Thus, a pattern rule `%.o : %.c' says how to make any file `STEM.o' --from another file `STEM.c'. -- -- Note that expansion using `%' in pattern rules occurs *after* any --variable or function expansions, which take place when the makefile is --read. *Note How to Use Variables: Using Variables, and *Note Functions --for Transforming Text: Functions. -- --* Menu: -- --* Pattern Intro:: An introduction to pattern rules. --* Pattern Examples:: Examples of pattern rules. --* Automatic Variables:: How to use automatic variables in the -- commands of implicit rules. --* Pattern Match:: How patterns match. --* Match-Anything Rules:: Precautions you should take prior to -- defining rules that can match any -- target file whatever. --* Canceling Rules:: How to override or cancel built-in rules. -- -- --File: make.info, Node: Pattern Intro, Next: Pattern Examples, Prev: Pattern Rules, Up: Pattern Rules -- --10.5.1 Introduction to Pattern Rules -------------------------------------- -- --A pattern rule contains the character `%' (exactly one of them) in the --target; otherwise, it looks exactly like an ordinary rule. The target --is a pattern for matching file names; the `%' matches any nonempty --substring, while other characters match only themselves. -- -- For example, `%.c' as a pattern matches any file name that ends in --`.c'. `s.%.c' as a pattern matches any file name that starts with --`s.', ends in `.c' and is at least five characters long. (There must --be at least one character to match the `%'.) The substring that the --`%' matches is called the "stem". -- -- `%' in a prerequisite of a pattern rule stands for the same stem --that was matched by the `%' in the target. In order for the pattern --rule to apply, its target pattern must match the file name under --consideration and all of its prerequisites (after pattern substitution) --must name files that exist or can be made. These files become --prerequisites of the target. -- -- Thus, a rule of the form -- -- %.o : %.c ; COMMAND... -- --specifies how to make a file `N.o', with another file `N.c' as its --prerequisite, provided that `N.c' exists or can be made. -- -- There may also be prerequisites that do not use `%'; such a --prerequisite attaches to every file made by this pattern rule. These --unvarying prerequisites are useful occasionally. -- -- A pattern rule need not have any prerequisites that contain `%', or --in fact any prerequisites at all. Such a rule is effectively a general --wildcard. It provides a way to make any file that matches the target --pattern. *Note Last Resort::. -- -- Pattern rules may have more than one target. Unlike normal rules, --this does not act as many different rules with the same prerequisites --and commands. If a pattern rule has multiple targets, `make' knows that --the rule's commands are responsible for making all of the targets. The --commands are executed only once to make all the targets. When searching --for a pattern rule to match a target, the target patterns of a rule --other than the one that matches the target in need of a rule are --incidental: `make' worries only about giving commands and prerequisites --to the file presently in question. However, when this file's commands --are run, the other targets are marked as having been updated themselves. -- -- The order in which pattern rules appear in the makefile is important --since this is the order in which they are considered. Of equally --applicable rules, only the first one found is used. The rules you --write take precedence over those that are built in. Note however, that --a rule whose prerequisites actually exist or are mentioned always takes --priority over a rule with prerequisites that must be made by chaining --other implicit rules. -- -- --File: make.info, Node: Pattern Examples, Next: Automatic Variables, Prev: Pattern Intro, Up: Pattern Rules -- --10.5.2 Pattern Rule Examples ------------------------------ -- --Here are some examples of pattern rules actually predefined in `make'. --First, the rule that compiles `.c' files into `.o' files: -- -- %.o : %.c -- $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ -- --defines a rule that can make any file `X.o' from `X.c'. The command --uses the automatic variables `$@' and `$<' to substitute the names of --the target file and the source file in each case where the rule applies --(*note Automatic Variables::). -- -- Here is a second built-in rule: -- -- % :: RCS/%,v -- $(CO) $(COFLAGS) $< -- --defines a rule that can make any file `X' whatsoever from a --corresponding file `X,v' in the subdirectory `RCS'. Since the target --is `%', this rule will apply to any file whatever, provided the --appropriate prerequisite file exists. The double colon makes the rule --"terminal", which means that its prerequisite may not be an intermediate --file (*note Match-Anything Pattern Rules: Match-Anything Rules.). -- -- This pattern rule has two targets: -- -- %.tab.c %.tab.h: %.y -- bison -d $< -- --This tells `make' that the command `bison -d X.y' will make both --`X.tab.c' and `X.tab.h'. If the file `foo' depends on the files --`parse.tab.o' and `scan.o' and the file `scan.o' depends on the file --`parse.tab.h', when `parse.y' is changed, the command `bison -d parse.y' --will be executed only once, and the prerequisites of both `parse.tab.o' --and `scan.o' will be satisfied. (Presumably the file `parse.tab.o' --will be recompiled from `parse.tab.c' and the file `scan.o' from --`scan.c', while `foo' is linked from `parse.tab.o', `scan.o', and its --other prerequisites, and it will execute happily ever after.) -- -- --File: make.info, Node: Automatic Variables, Next: Pattern Match, Prev: Pattern Examples, Up: Pattern Rules -- --10.5.3 Automatic Variables ---------------------------- -- --Suppose you are writing a pattern rule to compile a `.c' file into a --`.o' file: how do you write the `cc' command so that it operates on the --right source file name? You cannot write the name in the command, --because the name is different each time the implicit rule is applied. -- -- What you do is use a special feature of `make', the "automatic --variables". These variables have values computed afresh for each rule --that is executed, based on the target and prerequisites of the rule. --In this example, you would use `$@' for the object file name and `$<' --for the source file name. -- -- It's very important that you recognize the limited scope in which --automatic variable values are available: they only have values within --the command script. In particular, you cannot use them anywhere within --the target list of a rule; they have no value there and will expand to --the empty string. Also, they cannot be accessed directly within the --prerequisite list of a rule. A common mistake is attempting to use --`$@' within the prerequisites list; this will not work. However, there --is a special feature of GNU `make', secondary expansion (*note --Secondary Expansion::), which will allow automatic variable values to --be used in prerequisite lists. -- -- Here is a table of automatic variables: -- --`$@' -- The file name of the target of the rule. If the target is an -- archive member, then `$@' is the name of the archive file. In a -- pattern rule that has multiple targets (*note Introduction to -- Pattern Rules: Pattern Intro.), `$@' is the name of whichever -- target caused the rule's commands to be run. -- --`$%' -- The target member name, when the target is an archive member. -- *Note Archives::. For example, if the target is `foo.a(bar.o)' -- then `$%' is `bar.o' and `$@' is `foo.a'. `$%' is empty when the -- target is not an archive member. -- --`$<' -- The name of the first prerequisite. If the target got its -- commands from an implicit rule, this will be the first -- prerequisite added by the implicit rule (*note Implicit Rules::). -- --`$?' -- The names of all the prerequisites that are newer than the target, -- with spaces between them. For prerequisites which are archive -- members, only the member named is used (*note Archives::). -- --`$^' -- The names of all the prerequisites, with spaces between them. For -- prerequisites which are archive members, only the member named is -- used (*note Archives::). A target has only one prerequisite on -- each other file it depends on, no matter how many times each file -- is listed as a prerequisite. So if you list a prerequisite more -- than once for a target, the value of `$^' contains just one copy -- of the name. This list does *not* contain any of the order-only -- prerequisites; for those see the `$|' variable, below. -- --`$+' -- This is like `$^', but prerequisites listed more than once are -- duplicated in the order they were listed in the makefile. This is -- primarily useful for use in linking commands where it is -- meaningful to repeat library file names in a particular order. -- --`$|' -- The names of all the order-only prerequisites, with spaces between -- them. -- --`$*' -- The stem with which an implicit rule matches (*note How Patterns -- Match: Pattern Match.). If the target is `dir/a.foo.b' and the -- target pattern is `a.%.b' then the stem is `dir/foo'. The stem is -- useful for constructing names of related files. -- -- In a static pattern rule, the stem is part of the file name that -- matched the `%' in the target pattern. -- -- In an explicit rule, there is no stem; so `$*' cannot be determined -- in that way. Instead, if the target name ends with a recognized -- suffix (*note Old-Fashioned Suffix Rules: Suffix Rules.), `$*' is -- set to the target name minus the suffix. For example, if the -- target name is `foo.c', then `$*' is set to `foo', since `.c' is a -- suffix. GNU `make' does this bizarre thing only for compatibility -- with other implementations of `make'. You should generally avoid -- using `$*' except in implicit rules or static pattern rules. -- -- If the target name in an explicit rule does not end with a -- recognized suffix, `$*' is set to the empty string for that rule. -- -- `$?' is useful even in explicit rules when you wish to operate on --only the prerequisites that have changed. For example, suppose that an --archive named `lib' is supposed to contain copies of several object --files. This rule copies just the changed object files into the archive: -- -- lib: foo.o bar.o lose.o win.o -- ar r lib $? -- -- Of the variables listed above, four have values that are single file --names, and three have values that are lists of file names. These seven --have variants that get just the file's directory name or just the file --name within the directory. The variant variables' names are formed by --appending `D' or `F', respectively. These variants are semi-obsolete --in GNU `make' since the functions `dir' and `notdir' can be used to get --a similar effect (*note Functions for File Names: File Name --Functions.). Note, however, that the `D' variants all omit the --trailing slash which always appears in the output of the `dir' --function. Here is a table of the variants: -- --`$(@D)' -- The directory part of the file name of the target, with the -- trailing slash removed. If the value of `$@' is `dir/foo.o' then -- `$(@D)' is `dir'. This value is `.' if `$@' does not contain a -- slash. -- --`$(@F)' -- The file-within-directory part of the file name of the target. If -- the value of `$@' is `dir/foo.o' then `$(@F)' is `foo.o'. `$(@F)' -- is equivalent to `$(notdir $@)'. -- --`$(*D)' --`$(*F)' -- The directory part and the file-within-directory part of the stem; -- `dir' and `foo' in this example. -- --`$(%D)' --`$(%F)' -- The directory part and the file-within-directory part of the target -- archive member name. This makes sense only for archive member -- targets of the form `ARCHIVE(MEMBER)' and is useful only when -- MEMBER may contain a directory name. (*Note Archive Members as -- Targets: Archive Members.) -- --`$( foo.1 -- --will fail when the build directory is not the source directory, because --`foo.man' and `sedscript' are in the source directory. -- -- When using GNU `make', relying on `VPATH' to find the source file --will work in the case where there is a single dependency file, since --the `make' automatic variable `$<' will represent the source file --wherever it is. (Many versions of `make' set `$<' only in implicit --rules.) A Makefile target like -- -- foo.o : bar.c -- $(CC) -I. -I$(srcdir) $(CFLAGS) -c bar.c -o foo.o -- --should instead be written as -- -- foo.o : bar.c -- $(CC) -I. -I$(srcdir) $(CFLAGS) -c $< -o $@ -- --in order to allow `VPATH' to work correctly. When the target has --multiple dependencies, using an explicit `$(srcdir)' is the easiest way --to make the rule work well. For example, the target above for `foo.1' --is best written as: -- -- foo.1 : foo.man sedscript -- sed -e $(srcdir)/sedscript $(srcdir)/foo.man > $@ -- -- GNU distributions usually contain some files which are not source --files--for example, Info files, and the output from Autoconf, Automake, --Bison or Flex. Since these files normally appear in the source --directory, they should always appear in the source directory, not in the --build directory. So Makefile rules to update them should put the --updated files in the source directory. -- -- However, if a file does not appear in the distribution, then the --Makefile should not put it in the source directory, because building a --program in ordinary circumstances should not modify the source directory --in any way. -- -- Try to make the build and installation targets, at least (and all --their subtargets) work correctly with a parallel `make'. -- -- --File: make.info, Node: Utilities in Makefiles, Next: Command Variables, Prev: Makefile Basics, Up: Makefile Conventions -- --14.2 Utilities in Makefiles --=========================== -- --Write the Makefile commands (and any shell scripts, such as --`configure') to run in `sh', not in `csh'. Don't use any special --features of `ksh' or `bash'. -- -- The `configure' script and the Makefile rules for building and --installation should not use any utilities directly except these: -- -- cat cmp cp diff echo egrep expr false grep install-info -- ln ls mkdir mv pwd rm rmdir sed sleep sort tar test touch true -- -- The compression program `gzip' can be used in the `dist' rule. -- -- Stick to the generally supported options for these programs. For --example, don't use `mkdir -p', convenient as it may be, because most --systems don't support it. -- -- It is a good idea to avoid creating symbolic links in makefiles, --since a few systems don't support them. -- -- The Makefile rules for building and installation can also use --compilers and related programs, but should do so via `make' variables --so that the user can substitute alternatives. Here are some of the --programs we mean: -- -- ar bison cc flex install ld ldconfig lex -- make makeinfo ranlib texi2dvi yacc -- -- Use the following `make' variables to run those programs: -- -- $(AR) $(BISON) $(CC) $(FLEX) $(INSTALL) $(LD) $(LDCONFIG) $(LEX) -- $(MAKE) $(MAKEINFO) $(RANLIB) $(TEXI2DVI) $(YACC) -- -- When you use `ranlib' or `ldconfig', you should make sure nothing --bad happens if the system does not have the program in question. --Arrange to ignore an error from that command, and print a message before --the command to tell the user that failure of this command does not mean --a problem. (The Autoconf `AC_PROG_RANLIB' macro can help with this.) -- -- If you use symbolic links, you should implement a fallback for --systems that don't have symbolic links. -- -- Additional utilities that can be used via Make variables are: -- -- chgrp chmod chown mknod -- -- It is ok to use other utilities in Makefile portions (or scripts) --intended only for particular systems where you know those utilities --exist. -- -- --File: make.info, Node: Command Variables, Next: Directory Variables, Prev: Utilities in Makefiles, Up: Makefile Conventions -- --14.3 Variables for Specifying Commands --====================================== -- --Makefiles should provide variables for overriding certain commands, --options, and so on. -- -- In particular, you should run most utility programs via variables. --Thus, if you use Bison, have a variable named `BISON' whose default --value is set with `BISON = bison', and refer to it with `$(BISON)' --whenever you need to use Bison. -- -- File management utilities such as `ln', `rm', `mv', and so on, need --not be referred to through variables in this way, since users don't --need to replace them with other programs. -- -- Each program-name variable should come with an options variable that --is used to supply options to the program. Append `FLAGS' to the --program-name variable name to get the options variable name--for --example, `BISONFLAGS'. (The names `CFLAGS' for the C compiler, --`YFLAGS' for yacc, and `LFLAGS' for lex, are exceptions to this rule, --but we keep them because they are standard.) Use `CPPFLAGS' in any --compilation command that runs the preprocessor, and use `LDFLAGS' in --any compilation command that does linking as well as in any direct use --of `ld'. -- -- If there are C compiler options that _must_ be used for proper --compilation of certain files, do not include them in `CFLAGS'. Users --expect to be able to specify `CFLAGS' freely themselves. Instead, --arrange to pass the necessary options to the C compiler independently --of `CFLAGS', by writing them explicitly in the compilation commands or --by defining an implicit rule, like this: -- -- CFLAGS = -g -- ALL_CFLAGS = -I. $(CFLAGS) -- .c.o: -- $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $< -- -- Do include the `-g' option in `CFLAGS', because that is not --_required_ for proper compilation. You can consider it a default that --is only recommended. If the package is set up so that it is compiled --with GCC by default, then you might as well include `-O' in the default --value of `CFLAGS' as well. -- -- Put `CFLAGS' last in the compilation command, after other variables --containing compiler options, so the user can use `CFLAGS' to override --the others. -- -- `CFLAGS' should be used in every invocation of the C compiler, both --those which do compilation and those which do linking. -- -- Every Makefile should define the variable `INSTALL', which is the --basic command for installing a file into the system. -- -- Every Makefile should also define the variables `INSTALL_PROGRAM' --and `INSTALL_DATA'. (The default for `INSTALL_PROGRAM' should be --`$(INSTALL)'; the default for `INSTALL_DATA' should be `${INSTALL} -m --644'.) Then it should use those variables as the commands for actual --installation, for executables and nonexecutables respectively. Use --these variables as follows: -- -- $(INSTALL_PROGRAM) foo $(bindir)/foo -- $(INSTALL_DATA) libfoo.a $(libdir)/libfoo.a -- -- Optionally, you may prepend the value of `DESTDIR' to the target --filename. Doing this allows the installer to create a snapshot of the --installation to be copied onto the real target filesystem later. Do not --set the value of `DESTDIR' in your Makefile, and do not include it in --any installed files. With support for `DESTDIR', the above examples --become: -- -- $(INSTALL_PROGRAM) foo $(DESTDIR)$(bindir)/foo -- $(INSTALL_DATA) libfoo.a $(DESTDIR)$(libdir)/libfoo.a -- --Always use a file name, not a directory name, as the second argument of --the installation commands. Use a separate command for each file to be --installed. -- -- --File: make.info, Node: Directory Variables, Next: Standard Targets, Prev: Command Variables, Up: Makefile Conventions -- --14.4 Variables for Installation Directories --=========================================== -- --Installation directories should always be named by variables, so it is --easy to install in a nonstandard place. The standard names for these --variables and the values they should have in GNU packages are described --below. They are based on a standard filesystem layout; variants of it --are used in GNU/Linux and other modern operating systems. -- -- Installers are expected to override these values when calling `make' --(e.g., `make prefix=/usr install' or `configure' (e.g., `configure ----prefix=/usr'). GNU packages should not try to guess which value --should be appropriate for these variables on the system they are being --installed onto: use the default settings specified here so that all GNU --packages behave identically, allowing the installer to achieve any --desired layout. -- -- These two variables set the root for the installation. All the other --installation directories should be subdirectories of one of these two, --and nothing should be directly installed into these two directories. -- --`prefix' -- A prefix used in constructing the default values of the variables -- listed below. The default value of `prefix' should be -- `/usr/local'. When building the complete GNU system, the prefix -- will be empty and `/usr' will be a symbolic link to `/'. (If you -- are using Autoconf, write it as `@prefix@'.) -- -- Running `make install' with a different value of `prefix' from the -- one used to build the program should _not_ recompile the program. -- --`exec_prefix' -- A prefix used in constructing the default values of some of the -- variables listed below. The default value of `exec_prefix' should -- be `$(prefix)'. (If you are using Autoconf, write it as -- `@exec_prefix@'.) -- -- Generally, `$(exec_prefix)' is used for directories that contain -- machine-specific files (such as executables and subroutine -- libraries), while `$(prefix)' is used directly for other -- directories. -- -- Running `make install' with a different value of `exec_prefix' -- from the one used to build the program should _not_ recompile the -- program. -- -- Executable programs are installed in one of the following --directories. -- --`bindir' -- The directory for installing executable programs that users can -- run. This should normally be `/usr/local/bin', but write it as -- `$(exec_prefix)/bin'. (If you are using Autoconf, write it as -- `@bindir@'.) -- --`sbindir' -- The directory for installing executable programs that can be run -- from the shell, but are only generally useful to system -- administrators. This should normally be `/usr/local/sbin', but -- write it as `$(exec_prefix)/sbin'. (If you are using Autoconf, -- write it as `@sbindir@'.) -- --`libexecdir' -- The directory for installing executable programs to be run by other -- programs rather than by users. This directory should normally be -- `/usr/local/libexec', but write it as `$(exec_prefix)/libexec'. -- (If you are using Autoconf, write it as `@libexecdir@'.) -- -- The definition of `libexecdir' is the same for all packages, so -- you should install your data in a subdirectory thereof. Most -- packages install their data under `$(libexecdir)/PACKAGE-NAME/', -- possibly within additional subdirectories thereof, such as -- `$(libexecdir)/PACKAGE-NAME/MACHINE/VERSION'. -- -- Data files used by the program during its execution are divided into --categories in two ways. -- -- * Some files are normally modified by programs; others are never -- normally modified (though users may edit some of these). -- -- * Some files are architecture-independent and can be shared by all -- machines at a site; some are architecture-dependent and can be -- shared only by machines of the same kind and operating system; -- others may never be shared between two machines. -- -- This makes for six different possibilities. However, we want to --discourage the use of architecture-dependent files, aside from object --files and libraries. It is much cleaner to make other data files --architecture-independent, and it is generally not hard. -- -- Here are the variables Makefiles should use to specify directories --to put these various kinds of files in: -- --`datarootdir' -- The root of the directory tree for read-only -- architecture-independent data files. This should normally be -- `/usr/local/share', but write it as `$(prefix)/share'. (If you -- are using Autoconf, write it as `@datarootdir@'.) `datadir''s -- default value is based on this variable; so are `infodir', -- `mandir', and others. -- --`datadir' -- The directory for installing idiosyncratic read-only -- architecture-independent data files for this program. This is -- usually the same place as `datarootdir', but we use the two -- separate variables so that you can move these program-specific -- files without altering the location for Info files, man pages, etc. -- -- This should normally be `/usr/local/share', but write it as -- `$(datarootdir)'. (If you are using Autoconf, write it as -- `@datadir@'.) -- -- The definition of `datadir' is the same for all packages, so you -- should install your data in a subdirectory thereof. Most packages -- install their data under `$(datadir)/PACKAGE-NAME/'. -- --`sysconfdir' -- The directory for installing read-only data files that pertain to a -- single machine-that is to say, files for configuring a host. -- Mailer and network configuration files, `/etc/passwd', and so -- forth belong here. All the files in this directory should be -- ordinary ASCII text files. This directory should normally be -- `/usr/local/etc', but write it as `$(prefix)/etc'. (If you are -- using Autoconf, write it as `@sysconfdir@'.) -- -- Do not install executables here in this directory (they probably -- belong in `$(libexecdir)' or `$(sbindir)'). Also do not install -- files that are modified in the normal course of their use (programs -- whose purpose is to change the configuration of the system -- excluded). Those probably belong in `$(localstatedir)'. -- --`sharedstatedir' -- The directory for installing architecture-independent data files -- which the programs modify while they run. This should normally be -- `/usr/local/com', but write it as `$(prefix)/com'. (If you are -- using Autoconf, write it as `@sharedstatedir@'.) -- --`localstatedir' -- The directory for installing data files which the programs modify -- while they run, and that pertain to one specific machine. Users -- should never need to modify files in this directory to configure -- the package's operation; put such configuration information in -- separate files that go in `$(datadir)' or `$(sysconfdir)'. -- `$(localstatedir)' should normally be `/usr/local/var', but write -- it as `$(prefix)/var'. (If you are using Autoconf, write it as -- `@localstatedir@'.) -- -- These variables specify the directory for installing certain specific --types of files, if your program has them. Every GNU package should --have Info files, so every program needs `infodir', but not all need --`libdir' or `lispdir'. -- --`includedir' -- The directory for installing header files to be included by user -- programs with the C `#include' preprocessor directive. This -- should normally be `/usr/local/include', but write it as -- `$(prefix)/include'. (If you are using Autoconf, write it as -- `@includedir@'.) -- -- Most compilers other than GCC do not look for header files in -- directory `/usr/local/include'. So installing the header files -- this way is only useful with GCC. Sometimes this is not a problem -- because some libraries are only really intended to work with GCC. -- But some libraries are intended to work with other compilers. -- They should install their header files in two places, one -- specified by `includedir' and one specified by `oldincludedir'. -- --`oldincludedir' -- The directory for installing `#include' header files for use with -- compilers other than GCC. This should normally be `/usr/include'. -- (If you are using Autoconf, you can write it as `@oldincludedir@'.) -- -- The Makefile commands should check whether the value of -- `oldincludedir' is empty. If it is, they should not try to use -- it; they should cancel the second installation of the header files. -- -- A package should not replace an existing header in this directory -- unless the header came from the same package. Thus, if your Foo -- package provides a header file `foo.h', then it should install the -- header file in the `oldincludedir' directory if either (1) there -- is no `foo.h' there or (2) the `foo.h' that exists came from the -- Foo package. -- -- To tell whether `foo.h' came from the Foo package, put a magic -- string in the file--part of a comment--and `grep' for that string. -- --`docdir' -- The directory for installing documentation files (other than Info) -- for this package. By default, it should be -- `/usr/local/share/doc/YOURPKG', but it should be written as -- `$(datarootdir)/doc/YOURPKG'. (If you are using Autoconf, write -- it as `@docdir@'.) The YOURPKG subdirectory, which may include a -- version number, prevents collisions among files with common names, -- such as `README'. -- --`infodir' -- The directory for installing the Info files for this package. By -- default, it should be `/usr/local/share/info', but it should be -- written as `$(datarootdir)/info'. (If you are using Autoconf, -- write it as `@infodir@'.) `infodir' is separate from `docdir' for -- compatibility with existing practice. -- --`htmldir' --`dvidir' --`pdfdir' --`psdir' -- Directories for installing documentation files in the particular -- format. (It is not required to support documentation in all these -- formats.) They should all be set to `$(docdir)' by default. (If -- you are using Autoconf, write them as `@htmldir@', `@dvidir@', -- etc.) Packages which supply several translations of their -- documentation should install them in `$(htmldir)/'LL, -- `$(pdfdir)/'LL, etc. where LL is a locale abbreviation such as -- `en' or `pt_BR'. -- --`libdir' -- The directory for object files and libraries of object code. Do -- not install executables here, they probably ought to go in -- `$(libexecdir)' instead. The value of `libdir' should normally be -- `/usr/local/lib', but write it as `$(exec_prefix)/lib'. (If you -- are using Autoconf, write it as `@libdir@'.) -- --`lispdir' -- The directory for installing any Emacs Lisp files in this package. -- By default, it should be `/usr/local/share/emacs/site-lisp', but -- it should be written as `$(datarootdir)/emacs/site-lisp'. -- -- If you are using Autoconf, write the default as `@lispdir@'. In -- order to make `@lispdir@' work, you need the following lines in -- your `configure.in' file: -- -- lispdir='${datarootdir}/emacs/site-lisp' -- AC_SUBST(lispdir) -- --`localedir' -- The directory for installing locale-specific message catalogs for -- this package. By default, it should be `/usr/local/share/locale', -- but it should be written as `$(datarootdir)/locale'. (If you are -- using Autoconf, write it as `@localedir@'.) This directory -- usually has a subdirectory per locale. -- -- Unix-style man pages are installed in one of the following: -- --`mandir' -- The top-level directory for installing the man pages (if any) for -- this package. It will normally be `/usr/local/share/man', but you -- should write it as `$(datarootdir)/man'. (If you are using -- Autoconf, write it as `@mandir@'.) -- --`man1dir' -- The directory for installing section 1 man pages. Write it as -- `$(mandir)/man1'. -- --`man2dir' -- The directory for installing section 2 man pages. Write it as -- `$(mandir)/man2' -- --`...' -- *Don't make the primary documentation for any GNU software be a -- man page. Write a manual in Texinfo instead. Man pages are just -- for the sake of people running GNU software on Unix, which is a -- secondary application only.* -- --`manext' -- The file name extension for the installed man page. This should -- contain a period followed by the appropriate digit; it should -- normally be `.1'. -- --`man1ext' -- The file name extension for installed section 1 man pages. -- --`man2ext' -- The file name extension for installed section 2 man pages. -- --`...' -- Use these names instead of `manext' if the package needs to -- install man pages in more than one section of the manual. -- -- And finally, you should set the following variable: -- --`srcdir' -- The directory for the sources being compiled. The value of this -- variable is normally inserted by the `configure' shell script. -- (If you are using Autconf, use `srcdir = @srcdir@'.) -- -- For example: -- -- # Common prefix for installation directories. -- # NOTE: This directory must exist when you start the install. -- prefix = /usr/local -- datarootdir = $(prefix)/share -- datadir = $(datarootdir) -- exec_prefix = $(prefix) -- # Where to put the executable for the command `gcc'. -- bindir = $(exec_prefix)/bin -- # Where to put the directories used by the compiler. -- libexecdir = $(exec_prefix)/libexec -- # Where to put the Info files. -- infodir = $(datarootdir)/info -- -- If your program installs a large number of files into one of the --standard user-specified directories, it might be useful to group them --into a subdirectory particular to that program. If you do this, you --should write the `install' rule to create these subdirectories. -- -- Do not expect the user to include the subdirectory name in the value --of any of the variables listed above. The idea of having a uniform set --of variable names for installation directories is to enable the user to --specify the exact same values for several different GNU packages. In --order for this to be useful, all the packages must be designed so that --they will work sensibly when the user does so. -- -- --File: make.info, Node: Standard Targets, Next: Install Command Categories, Prev: Directory Variables, Up: Makefile Conventions -- --14.5 Standard Targets for Users --=============================== -- --All GNU programs should have the following targets in their Makefiles: -- --`all' -- Compile the entire program. This should be the default target. -- This target need not rebuild any documentation files; Info files -- should normally be included in the distribution, and DVI files -- should be made only when explicitly asked for. -- -- By default, the Make rules should compile and link with `-g', so -- that executable programs have debugging symbols. Users who don't -- mind being helpless can strip the executables later if they wish. -- --`install' -- Compile the program and copy the executables, libraries, and so on -- to the file names where they should reside for actual use. If -- there is a simple test to verify that a program is properly -- installed, this target should run that test. -- -- Do not strip executables when installing them. Devil-may-care -- users can use the `install-strip' target to do that. -- -- If possible, write the `install' target rule so that it does not -- modify anything in the directory where the program was built, -- provided `make all' has just been done. This is convenient for -- building the program under one user name and installing it under -- another. -- -- The commands should create all the directories in which files are -- to be installed, if they don't already exist. This includes the -- directories specified as the values of the variables `prefix' and -- `exec_prefix', as well as all subdirectories that are needed. One -- way to do this is by means of an `installdirs' target as described -- below. -- -- Use `-' before any command for installing a man page, so that -- `make' will ignore any errors. This is in case there are systems -- that don't have the Unix man page documentation system installed. -- -- The way to install Info files is to copy them into `$(infodir)' -- with `$(INSTALL_DATA)' (*note Command Variables::), and then run -- the `install-info' program if it is present. `install-info' is a -- program that edits the Info `dir' file to add or update the menu -- entry for the given Info file; it is part of the Texinfo package. -- Here is a sample rule to install an Info file: -- -- $(DESTDIR)$(infodir)/foo.info: foo.info -- $(POST_INSTALL) -- # There may be a newer info file in . than in srcdir. -- -if test -f foo.info; then d=.; \ -- else d=$(srcdir); fi; \ -- $(INSTALL_DATA) $$d/foo.info $(DESTDIR)$@; \ -- # Run install-info only if it exists. -- # Use `if' instead of just prepending `-' to the -- # line so we notice real errors from install-info. -- # We use `$(SHELL) -c' because some shells do not -- # fail gracefully when there is an unknown command. -- if $(SHELL) -c 'install-info --version' \ -- >/dev/null 2>&1; then \ -- install-info --dir-file=$(DESTDIR)$(infodir)/dir \ -- $(DESTDIR)$(infodir)/foo.info; \ -- else true; fi -- -- When writing the `install' target, you must classify all the -- commands into three categories: normal ones, "pre-installation" -- commands and "post-installation" commands. *Note Install Command -- Categories::. -- --`install-html' --`install-dvi' --`install-pdf' --`install-ps' -- These targets install documentation in formats other than Info; -- they're intended to be called explicitly by the person installing -- the package, if that format is desired. GNU prefers Info files, -- so these must be installed by the `install' target. -- -- When you have many documentation files to install, we recommend -- that you avoid collisions and clutter by arranging for these -- targets to install in subdirectories of the appropriate -- installation directory, such as `htmldir'. As one example, if -- your package has multiple manuals, and you wish to install HTML -- documentation with many files (such as the "split" mode output by -- `makeinfo --html'), you'll certainly want to use subdirectories, -- or two nodes with the same name in different manuals will -- overwrite each other. -- --`uninstall' -- Delete all the installed files--the copies that the `install' and -- `install-*' targets create. -- -- This rule should not modify the directories where compilation is -- done, only the directories where files are installed. -- -- The uninstallation commands are divided into three categories, -- just like the installation commands. *Note Install Command -- Categories::. -- --`install-strip' -- Like `install', but strip the executable files while installing -- them. In simple cases, this target can use the `install' target in -- a simple way: -- -- install-strip: -- $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' \ -- install -- -- But if the package installs scripts as well as real executables, -- the `install-strip' target can't just refer to the `install' -- target; it has to strip the executables but not the scripts. -- -- `install-strip' should not strip the executables in the build -- directory which are being copied for installation. It should only -- strip the copies that are installed. -- -- Normally we do not recommend stripping an executable unless you -- are sure the program has no bugs. However, it can be reasonable -- to install a stripped executable for actual execution while saving -- the unstripped executable elsewhere in case there is a bug. -- --`clean' -- Delete all files in the current directory that are normally -- created by building the program. Also delete files in other -- directories if they are created by this makefile. However, don't -- delete the files that record the configuration. Also preserve -- files that could be made by building, but normally aren't because -- the distribution comes with them. There is no need to delete -- parent directories that were created with `mkdir -p', since they -- could have existed anyway. -- -- Delete `.dvi' files here if they are not part of the distribution. -- --`distclean' -- Delete all files in the current directory (or created by this -- makefile) that are created by configuring or building the program. -- If you have unpacked the source and built the program without -- creating any other files, `make distclean' should leave only the -- files that were in the distribution. However, there is no need to -- delete parent directories that were created with `mkdir -p', since -- they could have existed anyway. -- --`mostlyclean' -- Like `clean', but may refrain from deleting a few files that people -- normally don't want to recompile. For example, the `mostlyclean' -- target for GCC does not delete `libgcc.a', because recompiling it -- is rarely necessary and takes a lot of time. -- --`maintainer-clean' -- Delete almost everything that can be reconstructed with this -- Makefile. This typically includes everything deleted by -- `distclean', plus more: C source files produced by Bison, tags -- tables, Info files, and so on. -- -- The reason we say "almost everything" is that running the command -- `make maintainer-clean' should not delete `configure' even if -- `configure' can be remade using a rule in the Makefile. More -- generally, `make maintainer-clean' should not delete anything that -- needs to exist in order to run `configure' and then begin to build -- the program. Also, there is no need to delete parent directories -- that were created with `mkdir -p', since they could have existed -- anyway. These are the only exceptions; `maintainer-clean' should -- delete everything else that can be rebuilt. -- -- The `maintainer-clean' target is intended to be used by a -- maintainer of the package, not by ordinary users. You may need -- special tools to reconstruct some of the files that `make -- maintainer-clean' deletes. Since these files are normally -- included in the distribution, we don't take care to make them easy -- to reconstruct. If you find you need to unpack the full -- distribution again, don't blame us. -- -- To help make users aware of this, the commands for the special -- `maintainer-clean' target should start with these two: -- -- @echo 'This command is intended for maintainers to use; it' -- @echo 'deletes files that may need special tools to rebuild.' -- --`TAGS' -- Update a tags table for this program. -- --`info' -- Generate any Info files needed. The best way to write the rules -- is as follows: -- -- info: foo.info -- -- foo.info: foo.texi chap1.texi chap2.texi -- $(MAKEINFO) $(srcdir)/foo.texi -- -- You must define the variable `MAKEINFO' in the Makefile. It should -- run the `makeinfo' program, which is part of the Texinfo -- distribution. -- -- Normally a GNU distribution comes with Info files, and that means -- the Info files are present in the source directory. Therefore, -- the Make rule for an info file should update it in the source -- directory. When users build the package, ordinarily Make will not -- update the Info files because they will already be up to date. -- --`dvi' --`html' --`pdf' --`ps' -- Generate documentation files in the given format, if possible. -- Here's an example rule for generating DVI files from Texinfo: -- -- dvi: foo.dvi -- -- foo.dvi: foo.texi chap1.texi chap2.texi -- $(TEXI2DVI) $(srcdir)/foo.texi -- -- You must define the variable `TEXI2DVI' in the Makefile. It should -- run the program `texi2dvi', which is part of the Texinfo -- distribution.(1) Alternatively, write just the dependencies, and -- allow GNU `make' to provide the command. -- -- Here's another example, this one for generating HTML from Texinfo: -- -- html: foo.html -- -- foo.html: foo.texi chap1.texi chap2.texi -- $(TEXI2HTML) $(srcdir)/foo.texi -- -- Again, you would define the variable `TEXI2HTML' in the Makefile; -- for example, it might run `makeinfo --no-split --html' (`makeinfo' -- is part of the Texinfo distribution). -- --`dist' -- Create a distribution tar file for this program. The tar file -- should be set up so that the file names in the tar file start with -- a subdirectory name which is the name of the package it is a -- distribution for. This name can include the version number. -- -- For example, the distribution tar file of GCC version 1.40 unpacks -- into a subdirectory named `gcc-1.40'. -- -- The easiest way to do this is to create a subdirectory -- appropriately named, use `ln' or `cp' to install the proper files -- in it, and then `tar' that subdirectory. -- -- Compress the tar file with `gzip'. For example, the actual -- distribution file for GCC version 1.40 is called `gcc-1.40.tar.gz'. -- -- The `dist' target should explicitly depend on all non-source files -- that are in the distribution, to make sure they are up to date in -- the distribution. *Note Making Releases: (standards)Releases. -- --`check' -- Perform self-tests (if any). The user must build the program -- before running the tests, but need not install the program; you -- should write the self-tests so that they work when the program is -- built but not installed. -- -- The following targets are suggested as conventional names, for --programs in which they are useful. -- --`installcheck' -- Perform installation tests (if any). The user must build and -- install the program before running the tests. You should not -- assume that `$(bindir)' is in the search path. -- --`installdirs' -- It's useful to add a target named `installdirs' to create the -- directories where files are installed, and their parent -- directories. There is a script called `mkinstalldirs' which is -- convenient for this; you can find it in the Texinfo package. You -- can use a rule like this: -- -- # Make sure all installation directories (e.g. $(bindir)) -- # actually exist by making them if necessary. -- installdirs: mkinstalldirs -- $(srcdir)/mkinstalldirs $(bindir) $(datadir) \ -- $(libdir) $(infodir) \ -- $(mandir) -- -- or, if you wish to support `DESTDIR', -- -- # Make sure all installation directories (e.g. $(bindir)) -- # actually exist by making them if necessary. -- installdirs: mkinstalldirs -- $(srcdir)/mkinstalldirs \ -- $(DESTDIR)$(bindir) $(DESTDIR)$(datadir) \ -- $(DESTDIR)$(libdir) $(DESTDIR)$(infodir) \ -- $(DESTDIR)$(mandir) -- -- This rule should not modify the directories where compilation is -- done. It should do nothing but create installation directories. -- -- ---------- Footnotes ---------- -- -- (1) `texi2dvi' uses TeX to do the real work of formatting. TeX is --not distributed with Texinfo. -- -- --File: make.info, Node: Install Command Categories, Prev: Standard Targets, Up: Makefile Conventions -- --14.6 Install Command Categories --=============================== -- --When writing the `install' target, you must classify all the commands --into three categories: normal ones, "pre-installation" commands and --"post-installation" commands. -- -- Normal commands move files into their proper places, and set their --modes. They may not alter any files except the ones that come entirely --from the package they belong to. -- -- Pre-installation and post-installation commands may alter other --files; in particular, they can edit global configuration files or data --bases. -- -- Pre-installation commands are typically executed before the normal --commands, and post-installation commands are typically run after the --normal commands. -- -- The most common use for a post-installation command is to run --`install-info'. This cannot be done with a normal command, since it --alters a file (the Info directory) which does not come entirely and --solely from the package being installed. It is a post-installation --command because it needs to be done after the normal command which --installs the package's Info files. -- -- Most programs don't need any pre-installation commands, but we have --the feature just in case it is needed. -- -- To classify the commands in the `install' rule into these three --categories, insert "category lines" among them. A category line --specifies the category for the commands that follow. -- -- A category line consists of a tab and a reference to a special Make --variable, plus an optional comment at the end. There are three --variables you can use, one for each category; the variable name --specifies the category. Category lines are no-ops in ordinary execution --because these three Make variables are normally undefined (and you --_should not_ define them in the makefile). -- -- Here are the three possible category lines, each with a comment that --explains what it means: -- -- $(PRE_INSTALL) # Pre-install commands follow. -- $(POST_INSTALL) # Post-install commands follow. -- $(NORMAL_INSTALL) # Normal commands follow. -- -- If you don't use a category line at the beginning of the `install' --rule, all the commands are classified as normal until the first category --line. If you don't use any category lines, all the commands are --classified as normal. -- -- These are the category lines for `uninstall': -- -- $(PRE_UNINSTALL) # Pre-uninstall commands follow. -- $(POST_UNINSTALL) # Post-uninstall commands follow. -- $(NORMAL_UNINSTALL) # Normal commands follow. -- -- Typically, a pre-uninstall command would be used for deleting entries --from the Info directory. -- -- If the `install' or `uninstall' target has any dependencies which --act as subroutines of installation, then you should start _each_ --dependency's commands with a category line, and start the main target's --commands with a category line also. This way, you can ensure that each --command is placed in the right category regardless of which of the --dependencies actually run. -- -- Pre-installation and post-installation commands should not run any --programs except for these: -- -- [ basename bash cat chgrp chmod chown cmp cp dd diff echo -- egrep expand expr false fgrep find getopt grep gunzip gzip -- hostname install install-info kill ldconfig ln ls md5sum -- mkdir mkfifo mknod mv printenv pwd rm rmdir sed sort tee -- test touch true uname xargs yes -- -- The reason for distinguishing the commands in this way is for the --sake of making binary packages. Typically a binary package contains --all the executables and other files that need to be installed, and has --its own method of installing them--so it does not need to run the normal --installation commands. But installing the binary package does need to --execute the pre-installation and post-installation commands. -- -- Programs to build binary packages work by extracting the --pre-installation and post-installation commands. Here is one way of --extracting the pre-installation commands (the `-s' option to `make' is --needed to silence messages about entering subdirectories): -- -- make -s -n install -o all \ -- PRE_INSTALL=pre-install \ -- POST_INSTALL=post-install \ -- NORMAL_INSTALL=normal-install \ -- | gawk -f pre-install.awk -- --where the file `pre-install.awk' could contain this: -- -- $0 ~ /^(normal-install|post-install)[ \t]*$/ {on = 0} -- on {print $0} -- $0 ~ /^pre-install[ \t]*$/ {on = 1} -- -- --File: make.info, Node: Quick Reference, Next: Error Messages, Prev: Makefile Conventions, Up: Top -- --Appendix A Quick Reference --************************** -- --This appendix summarizes the directives, text manipulation functions, --and special variables which GNU `make' understands. *Note Special --Targets::, *Note Catalogue of Implicit Rules: Catalogue of Rules, and --*Note Summary of Options: Options Summary, for other summaries. -- -- Here is a summary of the directives GNU `make' recognizes: -- --`define VARIABLE' --`endef' -- Define a multi-line, recursively-expanded variable. -- *Note Sequences::. -- --`ifdef VARIABLE' --`ifndef VARIABLE' --`ifeq (A,B)' --`ifeq "A" "B"' --`ifeq 'A' 'B'' --`ifneq (A,B)' --`ifneq "A" "B"' --`ifneq 'A' 'B'' --`else' --`endif' -- Conditionally evaluate part of the makefile. -- *Note Conditionals::. -- --`include FILE' --`-include FILE' --`sinclude FILE' -- Include another makefile. -- *Note Including Other Makefiles: Include. -- --`override VARIABLE = VALUE' --`override VARIABLE := VALUE' --`override VARIABLE += VALUE' --`override VARIABLE ?= VALUE' --`override define VARIABLE' --`endef' -- Define a variable, overriding any previous definition, even one -- from the command line. -- *Note The `override' Directive: Override Directive. -- --`export' -- Tell `make' to export all variables to child processes by default. -- *Note Communicating Variables to a Sub-`make': Variables/Recursion. -- --`export VARIABLE' --`export VARIABLE = VALUE' --`export VARIABLE := VALUE' --`export VARIABLE += VALUE' --`export VARIABLE ?= VALUE' --`unexport VARIABLE' -- Tell `make' whether or not to export a particular variable to child -- processes. -- *Note Communicating Variables to a Sub-`make': Variables/Recursion. -- --`vpath PATTERN PATH' -- Specify a search path for files matching a `%' pattern. -- *Note The `vpath' Directive: Selective Search. -- --`vpath PATTERN' -- Remove all search paths previously specified for PATTERN. -- --`vpath' -- Remove all search paths previously specified in any `vpath' -- directive. -- -- Here is a summary of the built-in functions (*note Functions::): -- --`$(subst FROM,TO,TEXT)' -- Replace FROM with TO in TEXT. -- *Note Functions for String Substitution and Analysis: Text -- Functions. -- --`$(patsubst PATTERN,REPLACEMENT,TEXT)' -- Replace words matching PATTERN with REPLACEMENT in TEXT. -- *Note Functions for String Substitution and Analysis: Text -- Functions. -- --`$(strip STRING)' -- Remove excess whitespace characters from STRING. -- *Note Functions for String Substitution and Analysis: Text -- Functions. -- --`$(findstring FIND,TEXT)' -- Locate FIND in TEXT. -- *Note Functions for String Substitution and Analysis: Text -- Functions. -- --`$(filter PATTERN...,TEXT)' -- Select words in TEXT that match one of the PATTERN words. -- *Note Functions for String Substitution and Analysis: Text -- Functions. -- --`$(filter-out PATTERN...,TEXT)' -- Select words in TEXT that _do not_ match any of the PATTERN words. -- *Note Functions for String Substitution and Analysis: Text -- Functions. -- --`$(sort LIST)' -- Sort the words in LIST lexicographically, removing duplicates. -- *Note Functions for String Substitution and Analysis: Text -- Functions. -- --`$(word N,TEXT)' -- Extract the Nth word (one-origin) of TEXT. -- *Note Functions for String Substitution and Analysis: Text -- Functions. -- --`$(words TEXT)' -- Count the number of words in TEXT. -- *Note Functions for String Substitution and Analysis: Text -- Functions. -- --`$(wordlist S,E,TEXT)' -- Returns the list of words in TEXT from S to E. -- *Note Functions for String Substitution and Analysis: Text -- Functions. -- --`$(firstword NAMES...)' -- Extract the first word of NAMES. -- *Note Functions for String Substitution and Analysis: Text -- Functions. -- --`$(lastword NAMES...)' -- Extract the last word of NAMES. -- *Note Functions for String Substitution and Analysis: Text -- Functions. -- --`$(dir NAMES...)' -- Extract the directory part of each file name. -- *Note Functions for File Names: File Name Functions. -- --`$(notdir NAMES...)' -- Extract the non-directory part of each file name. -- *Note Functions for File Names: File Name Functions. -- --`$(suffix NAMES...)' -- Extract the suffix (the last `.' and following characters) of each -- file name. -- *Note Functions for File Names: File Name Functions. -- --`$(basename NAMES...)' -- Extract the base name (name without suffix) of each file name. -- *Note Functions for File Names: File Name Functions. -- --`$(addsuffix SUFFIX,NAMES...)' -- Append SUFFIX to each word in NAMES. -- *Note Functions for File Names: File Name Functions. -- --`$(addprefix PREFIX,NAMES...)' -- Prepend PREFIX to each word in NAMES. -- *Note Functions for File Names: File Name Functions. -- --`$(join LIST1,LIST2)' -- Join two parallel lists of words. -- *Note Functions for File Names: File Name Functions. -- --`$(wildcard PATTERN...)' -- Find file names matching a shell file name pattern (_not_ a `%' -- pattern). -- *Note The Function `wildcard': Wildcard Function. -- --`$(realpath NAMES...)' -- For each file name in NAMES, expand to an absolute name that does -- not contain any `.', `..', nor symlinks. -- *Note Functions for File Names: File Name Functions. -- --`$(abspath NAMES...)' -- For each file name in NAMES, expand to an absolute name that does -- not contain any `.' or `..' components, but preserves symlinks. -- *Note Functions for File Names: File Name Functions. -- --`$(error TEXT...)' -- When this function is evaluated, `make' generates a fatal error -- with the message TEXT. -- *Note Functions That Control Make: Make Control Functions. -- --`$(warning TEXT...)' -- When this function is evaluated, `make' generates a warning with -- the message TEXT. -- *Note Functions That Control Make: Make Control Functions. -- --`$(shell COMMAND)' -- Execute a shell command and return its output. -- *Note The `shell' Function: Shell Function. -- --`$(origin VARIABLE)' -- Return a string describing how the `make' variable VARIABLE was -- defined. -- *Note The `origin' Function: Origin Function. -- --`$(flavor VARIABLE)' -- Return a string describing the flavor of the `make' variable -- VARIABLE. -- *Note The `flavor' Function: Flavor Function. -- --`$(foreach VAR,WORDS,TEXT)' -- Evaluate TEXT with VAR bound to each word in WORDS, and -- concatenate the results. -- *Note The `foreach' Function: Foreach Function. -- --`$(call VAR,PARAM,...)' -- Evaluate the variable VAR replacing any references to `$(1)', -- `$(2)' with the first, second, etc. PARAM values. -- *Note The `call' Function: Call Function. -- --`$(eval TEXT)' -- Evaluate TEXT then read the results as makefile commands. Expands -- to the empty string. -- *Note The `eval' Function: Eval Function. -- --`$(value VAR)' -- Evaluates to the contents of the variable VAR, with no expansion -- performed on it. -- *Note The `value' Function: Value Function. -- -- Here is a summary of the automatic variables. *Note Automatic --Variables::, for full information. -- --`$@' -- The file name of the target. -- --`$%' -- The target member name, when the target is an archive member. -- --`$<' -- The name of the first prerequisite. -- --`$?' -- The names of all the prerequisites that are newer than the target, -- with spaces between them. For prerequisites which are archive -- members, only the member named is used (*note Archives::). -- --`$^' --`$+' -- The names of all the prerequisites, with spaces between them. For -- prerequisites which are archive members, only the member named is -- used (*note Archives::). The value of `$^' omits duplicate -- prerequisites, while `$+' retains them and preserves their order. -- --`$*' -- The stem with which an implicit rule matches (*note How Patterns -- Match: Pattern Match.). -- --`$(@D)' --`$(@F)' -- The directory part and the file-within-directory part of `$@'. -- --`$(*D)' --`$(*F)' -- The directory part and the file-within-directory part of `$*'. -- --`$(%D)' --`$(%F)' -- The directory part and the file-within-directory part of `$%'. -- --`$( tar-`sed -e '/version_string/!d' \ -- -e 's/[^0-9.]*\([0-9.]*\).*/\1/' \ -- -e q -- version.c`.shar.Z -- -- .PHONY: dist -- dist: $(SRCS) $(AUX) -- echo tar-`sed \ -- -e '/version_string/!d' \ -- -e 's/[^0-9.]*\([0-9.]*\).*/\1/' \ -- -e q -- version.c` > .fname -- -rm -rf `cat .fname` -- mkdir `cat .fname` -- ln $(SRCS) $(AUX) `cat .fname` -- tar chZf `cat .fname`.tar.Z `cat .fname` -- -rm -rf `cat .fname` .fname -- -- tar.zoo: $(SRCS) $(AUX) -- -rm -rf tmp.dir -- -mkdir tmp.dir -- -rm tar.zoo -- for X in $(SRCS) $(AUX) ; do \ -- echo $$X ; \ -- sed 's/$$/^M/' $$X \ -- > tmp.dir/$$X ; done -- cd tmp.dir ; zoo aM ../tar.zoo * -- -rm -rf tmp.dir -- -- --File: make.info, Node: GNU Free Documentation License, Next: Concept Index, Prev: Complex Makefile, Up: Top -- --Appendix D GNU Free Documentation License --***************************************** -- -- Version 1.2, November 2002 -- -- Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. -- 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA -- -- Everyone is permitted to copy and distribute verbatim copies -- of this license document, but changing it is not allowed. -- -- 0. PREAMBLE -- -- The purpose of this License is to make a manual, textbook, or other -- functional and useful document "free" in the sense of freedom: to -- assure everyone the effective freedom to copy and redistribute it, -- with or without modifying it, either commercially or -- noncommercially. Secondarily, this License preserves for the -- author and publisher a way to get credit for their work, while not -- being considered responsible for modifications made by others. -- -- This License is a kind of "copyleft", which means that derivative -- works of the document must themselves be free in the same sense. -- It complements the GNU General Public License, which is a copyleft -- license designed for free software. -- -- We have designed this License in order to use it for manuals for -- free software, because free software needs free documentation: a -- free program should come with manuals providing the same freedoms -- that the software does. But this License is not limited to -- software manuals; it can be used for any textual work, regardless -- of subject matter or whether it is published as a printed book. -- We recommend this License principally for works whose purpose is -- instruction or reference. -- -- 1. APPLICABILITY AND DEFINITIONS -- -- This License applies to any manual or other work, in any medium, -- that contains a notice placed by the copyright holder saying it -- can be distributed under the terms of this License. Such a notice -- grants a world-wide, royalty-free license, unlimited in duration, -- to use that work under the conditions stated herein. The -- "Document", below, refers to any such manual or work. Any member -- of the public is a licensee, and is addressed as "you". You -- accept the license if you copy, modify or distribute the work in a -- way requiring permission under copyright law. -- -- A "Modified Version" of the Document means any work containing the -- Document or a portion of it, either copied verbatim, or with -- modifications and/or translated into another language. -- -- A "Secondary Section" is a named appendix or a front-matter section -- of the Document that deals exclusively with the relationship of the -- publishers or authors of the Document to the Document's overall -- subject (or to related matters) and contains nothing that could -- fall directly within that overall subject. (Thus, if the Document -- is in part a textbook of mathematics, a Secondary Section may not -- explain any mathematics.) The relationship could be a matter of -- historical connection with the subject or with related matters, or -- of legal, commercial, philosophical, ethical or political position -- regarding them. -- -- The "Invariant Sections" are certain Secondary Sections whose -- titles are designated, as being those of Invariant Sections, in -- the notice that says that the Document is released under this -- License. If a section does not fit the above definition of -- Secondary then it is not allowed to be designated as Invariant. -- The Document may contain zero Invariant Sections. If the Document -- does not identify any Invariant Sections then there are none. -- -- The "Cover Texts" are certain short passages of text that are -- listed, as Front-Cover Texts or Back-Cover Texts, in the notice -- that says that the Document is released under this License. A -- Front-Cover Text may be at most 5 words, and a Back-Cover Text may -- be at most 25 words. -- -- A "Transparent" copy of the Document means a machine-readable copy, -- represented in a format whose specification is available to the -- general public, that is suitable for revising the document -- straightforwardly with generic text editors or (for images -- composed of pixels) generic paint programs or (for drawings) some -- widely available drawing editor, and that is suitable for input to -- text formatters or for automatic translation to a variety of -- formats suitable for input to text formatters. A copy made in an -- otherwise Transparent file format whose markup, or absence of -- markup, has been arranged to thwart or discourage subsequent -- modification by readers is not Transparent. An image format is -- not Transparent if used for any substantial amount of text. A -- copy that is not "Transparent" is called "Opaque". -- -- Examples of suitable formats for Transparent copies include plain -- ASCII without markup, Texinfo input format, LaTeX input format, -- SGML or XML using a publicly available DTD, and -- standard-conforming simple HTML, PostScript or PDF designed for -- human modification. Examples of transparent image formats include -- PNG, XCF and JPG. Opaque formats include proprietary formats that -- can be read and edited only by proprietary word processors, SGML or -- XML for which the DTD and/or processing tools are not generally -- available, and the machine-generated HTML, PostScript or PDF -- produced by some word processors for output purposes only. -- -- The "Title Page" means, for a printed book, the title page itself, -- plus such following pages as are needed to hold, legibly, the -- material this License requires to appear in the title page. For -- works in formats which do not have any title page as such, "Title -- Page" means the text near the most prominent appearance of the -- work's title, preceding the beginning of the body of the text. -- -- A section "Entitled XYZ" means a named subunit of the Document -- whose title either is precisely XYZ or contains XYZ in parentheses -- following text that translates XYZ in another language. (Here XYZ -- stands for a specific section name mentioned below, such as -- "Acknowledgements", "Dedications", "Endorsements", or "History".) -- To "Preserve the Title" of such a section when you modify the -- Document means that it remains a section "Entitled XYZ" according -- to this definition. -- -- The Document may include Warranty Disclaimers next to the notice -- which states that this License applies to the Document. These -- Warranty Disclaimers are considered to be included by reference in -- this License, but only as regards disclaiming warranties: any other -- implication that these Warranty Disclaimers may have is void and -- has no effect on the meaning of this License. -- -- 2. VERBATIM COPYING -- -- You may copy and distribute the Document in any medium, either -- commercially or noncommercially, provided that this License, the -- copyright notices, and the license notice saying this License -- applies to the Document are reproduced in all copies, and that you -- add no other conditions whatsoever to those of this License. You -- may not use technical measures to obstruct or control the reading -- or further copying of the copies you make or distribute. However, -- you may accept compensation in exchange for copies. If you -- distribute a large enough number of copies you must also follow -- the conditions in section 3. -- -- You may also lend copies, under the same conditions stated above, -- and you may publicly display copies. -- -- 3. COPYING IN QUANTITY -- -- If you publish printed copies (or copies in media that commonly -- have printed covers) of the Document, numbering more than 100, and -- the Document's license notice requires Cover Texts, you must -- enclose the copies in covers that carry, clearly and legibly, all -- these Cover Texts: Front-Cover Texts on the front cover, and -- Back-Cover Texts on the back cover. Both covers must also clearly -- and legibly identify you as the publisher of these copies. The -- front cover must present the full title with all words of the -- title equally prominent and visible. You may add other material -- on the covers in addition. Copying with changes limited to the -- covers, as long as they preserve the title of the Document and -- satisfy these conditions, can be treated as verbatim copying in -- other respects. -- -- If the required texts for either cover are too voluminous to fit -- legibly, you should put the first ones listed (as many as fit -- reasonably) on the actual cover, and continue the rest onto -- adjacent pages. -- -- If you publish or distribute Opaque copies of the Document -- numbering more than 100, you must either include a -- machine-readable Transparent copy along with each Opaque copy, or -- state in or with each Opaque copy a computer-network location from -- which the general network-using public has access to download -- using public-standard network protocols a complete Transparent -- copy of the Document, free of added material. If you use the -- latter option, you must take reasonably prudent steps, when you -- begin distribution of Opaque copies in quantity, to ensure that -- this Transparent copy will remain thus accessible at the stated -- location until at least one year after the last time you -- distribute an Opaque copy (directly or through your agents or -- retailers) of that edition to the public. -- -- It is requested, but not required, that you contact the authors of -- the Document well before redistributing any large number of -- copies, to give them a chance to provide you with an updated -- version of the Document. -- -- 4. MODIFICATIONS -- -- You may copy and distribute a Modified Version of the Document -- under the conditions of sections 2 and 3 above, provided that you -- release the Modified Version under precisely this License, with -- the Modified Version filling the role of the Document, thus -- licensing distribution and modification of the Modified Version to -- whoever possesses a copy of it. In addition, you must do these -- things in the Modified Version: -- -- A. Use in the Title Page (and on the covers, if any) a title -- distinct from that of the Document, and from those of -- previous versions (which should, if there were any, be listed -- in the History section of the Document). You may use the -- same title as a previous version if the original publisher of -- that version gives permission. -- -- B. List on the Title Page, as authors, one or more persons or -- entities responsible for authorship of the modifications in -- the Modified Version, together with at least five of the -- principal authors of the Document (all of its principal -- authors, if it has fewer than five), unless they release you -- from this requirement. -- -- C. State on the Title page the name of the publisher of the -- Modified Version, as the publisher. -- -- D. Preserve all the copyright notices of the Document. -- -- E. Add an appropriate copyright notice for your modifications -- adjacent to the other copyright notices. -- -- F. Include, immediately after the copyright notices, a license -- notice giving the public permission to use the Modified -- Version under the terms of this License, in the form shown in -- the Addendum below. -- -- G. Preserve in that license notice the full lists of Invariant -- Sections and required Cover Texts given in the Document's -- license notice. -- -- H. Include an unaltered copy of this License. -- -- I. Preserve the section Entitled "History", Preserve its Title, -- and add to it an item stating at least the title, year, new -- authors, and publisher of the Modified Version as given on -- the Title Page. If there is no section Entitled "History" in -- the Document, create one stating the title, year, authors, -- and publisher of the Document as given on its Title Page, -- then add an item describing the Modified Version as stated in -- the previous sentence. -- -- J. Preserve the network location, if any, given in the Document -- for public access to a Transparent copy of the Document, and -- likewise the network locations given in the Document for -- previous versions it was based on. These may be placed in -- the "History" section. You may omit a network location for a -- work that was published at least four years before the -- Document itself, or if the original publisher of the version -- it refers to gives permission. -- -- K. For any section Entitled "Acknowledgements" or "Dedications", -- Preserve the Title of the section, and preserve in the -- section all the substance and tone of each of the contributor -- acknowledgements and/or dedications given therein. -- -- L. Preserve all the Invariant Sections of the Document, -- unaltered in their text and in their titles. Section numbers -- or the equivalent are not considered part of the section -- titles. -- -- M. Delete any section Entitled "Endorsements". Such a section -- may not be included in the Modified Version. -- -- N. Do not retitle any existing section to be Entitled -- "Endorsements" or to conflict in title with any Invariant -- Section. -- -- O. Preserve any Warranty Disclaimers. -- -- If the Modified Version includes new front-matter sections or -- appendices that qualify as Secondary Sections and contain no -- material copied from the Document, you may at your option -- designate some or all of these sections as invariant. To do this, -- add their titles to the list of Invariant Sections in the Modified -- Version's license notice. These titles must be distinct from any -- other section titles. -- -- You may add a section Entitled "Endorsements", provided it contains -- nothing but endorsements of your Modified Version by various -- parties--for example, statements of peer review or that the text -- has been approved by an organization as the authoritative -- definition of a standard. -- -- You may add a passage of up to five words as a Front-Cover Text, -- and a passage of up to 25 words as a Back-Cover Text, to the end -- of the list of Cover Texts in the Modified Version. Only one -- passage of Front-Cover Text and one of Back-Cover Text may be -- added by (or through arrangements made by) any one entity. If the -- Document already includes a cover text for the same cover, -- previously added by you or by arrangement made by the same entity -- you are acting on behalf of, you may not add another; but you may -- replace the old one, on explicit permission from the previous -- publisher that added the old one. -- -- The author(s) and publisher(s) of the Document do not by this -- License give permission to use their names for publicity for or to -- assert or imply endorsement of any Modified Version. -- -- 5. COMBINING DOCUMENTS -- -- You may combine the Document with other documents released under -- this License, under the terms defined in section 4 above for -- modified versions, provided that you include in the combination -- all of the Invariant Sections of all of the original documents, -- unmodified, and list them all as Invariant Sections of your -- combined work in its license notice, and that you preserve all -- their Warranty Disclaimers. -- -- The combined work need only contain one copy of this License, and -- multiple identical Invariant Sections may be replaced with a single -- copy. If there are multiple Invariant Sections with the same name -- but different contents, make the title of each such section unique -- by adding at the end of it, in parentheses, the name of the -- original author or publisher of that section if known, or else a -- unique number. Make the same adjustment to the section titles in -- the list of Invariant Sections in the license notice of the -- combined work. -- -- In the combination, you must combine any sections Entitled -- "History" in the various original documents, forming one section -- Entitled "History"; likewise combine any sections Entitled -- "Acknowledgements", and any sections Entitled "Dedications". You -- must delete all sections Entitled "Endorsements." -- -- 6. COLLECTIONS OF DOCUMENTS -- -- You may make a collection consisting of the Document and other -- documents released under this License, and replace the individual -- copies of this License in the various documents with a single copy -- that is included in the collection, provided that you follow the -- rules of this License for verbatim copying of each of the -- documents in all other respects. -- -- You may extract a single document from such a collection, and -- distribute it individually under this License, provided you insert -- a copy of this License into the extracted document, and follow -- this License in all other respects regarding verbatim copying of -- that document. -- -- 7. AGGREGATION WITH INDEPENDENT WORKS -- -- A compilation of the Document or its derivatives with other -- separate and independent documents or works, in or on a volume of -- a storage or distribution medium, is called an "aggregate" if the -- copyright resulting from the compilation is not used to limit the -- legal rights of the compilation's users beyond what the individual -- works permit. When the Document is included in an aggregate, this -- License does not apply to the other works in the aggregate which -- are not themselves derivative works of the Document. -- -- If the Cover Text requirement of section 3 is applicable to these -- copies of the Document, then if the Document is less than one half -- of the entire aggregate, the Document's Cover Texts may be placed -- on covers that bracket the Document within the aggregate, or the -- electronic equivalent of covers if the Document is in electronic -- form. Otherwise they must appear on printed covers that bracket -- the whole aggregate. -- -- 8. TRANSLATION -- -- Translation is considered a kind of modification, so you may -- distribute translations of the Document under the terms of section -- 4. Replacing Invariant Sections with translations requires special -- permission from their copyright holders, but you may include -- translations of some or all Invariant Sections in addition to the -- original versions of these Invariant Sections. You may include a -- translation of this License, and all the license notices in the -- Document, and any Warranty Disclaimers, provided that you also -- include the original English version of this License and the -- original versions of those notices and disclaimers. In case of a -- disagreement between the translation and the original version of -- this License or a notice or disclaimer, the original version will -- prevail. -- -- If a section in the Document is Entitled "Acknowledgements", -- "Dedications", or "History", the requirement (section 4) to -- Preserve its Title (section 1) will typically require changing the -- actual title. -- -- 9. TERMINATION -- -- You may not copy, modify, sublicense, or distribute the Document -- except as expressly provided for under this License. Any other -- attempt to copy, modify, sublicense or distribute the Document is -- void, and will automatically terminate your rights under this -- License. However, parties who have received copies, or rights, -- from you under this License will not have their licenses -- terminated so long as such parties remain in full compliance. -- -- 10. FUTURE REVISIONS OF THIS LICENSE -- -- The Free Software Foundation may publish new, revised versions of -- the GNU Free Documentation License from time to time. Such new -- versions will be similar in spirit to the present version, but may -- differ in detail to address new problems or concerns. See -- `http://www.gnu.org/copyleft/'. -- -- Each version of the License is given a distinguishing version -- number. If the Document specifies that a particular numbered -- version of this License "or any later version" applies to it, you -- have the option of following the terms and conditions either of -- that specified version or of any later version that has been -- published (not as a draft) by the Free Software Foundation. If -- the Document does not specify a version number of this License, -- you may choose any version ever published (not as a draft) by the -- Free Software Foundation. -- --D.1 ADDENDUM: How to use this License for your documents --======================================================== -- --To use this License in a document you have written, include a copy of --the License in the document and put the following copyright and license --notices just after the title page: -- -- Copyright (C) YEAR YOUR NAME. -- Permission is granted to copy, distribute and/or modify this document -- under the terms of the GNU Free Documentation License, Version 1.2 -- or any later version published by the Free Software Foundation; -- with no Invariant Sections, no Front-Cover Texts, and no Back-Cover -- Texts. A copy of the license is included in the section entitled ``GNU -- Free Documentation License''. -- -- If you have Invariant Sections, Front-Cover Texts and Back-Cover --Texts, replace the "with...Texts." line with this: -- -- with the Invariant Sections being LIST THEIR TITLES, with -- the Front-Cover Texts being LIST, and with the Back-Cover Texts -- being LIST. -- -- If you have Invariant Sections without Cover Texts, or some other --combination of the three, merge those two alternatives to suit the --situation. -- -- If your document contains nontrivial examples of program code, we --recommend releasing these examples in parallel under your choice of --free software license, such as the GNU General Public License, to --permit their use in free software. -- -- --File: make.info, Node: Concept Index, Next: Name Index, Prev: GNU Free Documentation License, Up: Top -- --Index of Concepts --***************** -- --[index] --* Menu: -- --* # (comments), in commands: Command Syntax. (line 27) --* # (comments), in makefile: Makefile Contents. (line 41) --* #include: Automatic Prerequisites. -- (line 16) --* $, in function call: Syntax of Functions. (line 6) --* $, in rules: Rule Syntax. (line 32) --* $, in variable name: Computed Names. (line 6) --* $, in variable reference: Reference. (line 6) --* %, in pattern rules: Pattern Intro. (line 9) --* %, quoting in patsubst: Text Functions. (line 26) --* %, quoting in static pattern: Static Usage. (line 37) --* %, quoting in vpath: Selective Search. (line 38) --* %, quoting with \ (backslash) <1>: Text Functions. (line 26) --* %, quoting with \ (backslash) <2>: Static Usage. (line 37) --* %, quoting with \ (backslash): Selective Search. (line 38) --* * (wildcard character): Wildcards. (line 6) --* +, and command execution: Instead of Execution. -- (line 58) --* +, and commands: MAKE Variable. (line 18) --* +, and define: Sequences. (line 50) --* +=: Appending. (line 6) --* +=, expansion: Reading Makefiles. (line 33) --* ,v (RCS file extension): Catalogue of Rules. (line 164) --* - (in commands): Errors. (line 19) --* -, and define: Sequences. (line 50) --* --always-make: Options Summary. (line 15) --* --assume-new <1>: Options Summary. (line 242) --* --assume-new: Instead of Execution. -- (line 33) --* --assume-new, and recursion: Options/Recursion. (line 22) --* --assume-old <1>: Options Summary. (line 147) --* --assume-old: Avoiding Compilation. -- (line 6) --* --assume-old, and recursion: Options/Recursion. (line 22) --* --check-symlink-times: Options Summary. (line 130) --* --debug: Options Summary. (line 42) --* --directory <1>: Options Summary. (line 26) --* --directory: Recursion. (line 20) --* --directory, and --print-directory: -w Option. (line 20) --* --directory, and recursion: Options/Recursion. (line 22) --* --dry-run <1>: Options Summary. (line 140) --* --dry-run <2>: Instead of Execution. -- (line 14) --* --dry-run: Echoing. (line 18) --* --environment-overrides: Options Summary. (line 78) --* --file <1>: Options Summary. (line 84) --* --file <2>: Makefile Arguments. (line 6) --* --file: Makefile Names. (line 23) --* --file, and recursion: Options/Recursion. (line 22) --* --help: Options Summary. (line 90) --* --ignore-errors <1>: Options Summary. (line 94) --* --ignore-errors: Errors. (line 30) --* --include-dir <1>: Options Summary. (line 99) --* --include-dir: Include. (line 52) --* --jobs <1>: Options Summary. (line 106) --* --jobs: Parallel. (line 6) --* --jobs, and recursion: Options/Recursion. (line 25) --* --just-print <1>: Options Summary. (line 139) --* --just-print <2>: Instead of Execution. -- (line 14) --* --just-print: Echoing. (line 18) --* --keep-going <1>: Options Summary. (line 115) --* --keep-going <2>: Testing. (line 16) --* --keep-going: Errors. (line 47) --* --load-average <1>: Options Summary. (line 122) --* --load-average: Parallel. (line 57) --* --makefile <1>: Options Summary. (line 85) --* --makefile <2>: Makefile Arguments. (line 6) --* --makefile: Makefile Names. (line 23) --* --max-load <1>: Options Summary. (line 123) --* --max-load: Parallel. (line 57) --* --new-file <1>: Options Summary. (line 241) --* --new-file: Instead of Execution. -- (line 33) --* --new-file, and recursion: Options/Recursion. (line 22) --* --no-builtin-rules: Options Summary. (line 175) --* --no-builtin-variables: Options Summary. (line 188) --* --no-keep-going: Options Summary. (line 203) --* --no-print-directory <1>: Options Summary. (line 233) --* --no-print-directory: -w Option. (line 20) --* --old-file <1>: Options Summary. (line 146) --* --old-file: Avoiding Compilation. -- (line 6) --* --old-file, and recursion: Options/Recursion. (line 22) --* --print-data-base: Options Summary. (line 155) --* --print-directory: Options Summary. (line 225) --* --print-directory, and --directory: -w Option. (line 20) --* --print-directory, and recursion: -w Option. (line 20) --* --print-directory, disabling: -w Option. (line 20) --* --question <1>: Options Summary. (line 167) --* --question: Instead of Execution. -- (line 25) --* --quiet <1>: Options Summary. (line 198) --* --quiet: Echoing. (line 24) --* --recon <1>: Options Summary. (line 141) --* --recon <2>: Instead of Execution. -- (line 14) --* --recon: Echoing. (line 18) --* --silent <1>: Options Summary. (line 197) --* --silent: Echoing. (line 24) --* --stop: Options Summary. (line 204) --* --touch <1>: Options Summary. (line 212) --* --touch: Instead of Execution. -- (line 19) --* --touch, and recursion: MAKE Variable. (line 34) --* --version: Options Summary. (line 220) --* --warn-undefined-variables: Options Summary. (line 251) --* --what-if <1>: Options Summary. (line 240) --* --what-if: Instead of Execution. -- (line 33) --* -B: Options Summary. (line 14) --* -b: Options Summary. (line 9) --* -C <1>: Options Summary. (line 25) --* -C: Recursion. (line 20) --* -C, and -w: -w Option. (line 20) --* -C, and recursion: Options/Recursion. (line 22) --* -d: Options Summary. (line 33) --* -e: Options Summary. (line 77) --* -e (shell flag): Automatic Prerequisites. -- (line 66) --* -f <1>: Options Summary. (line 83) --* -f <2>: Makefile Arguments. (line 6) --* -f: Makefile Names. (line 23) --* -f, and recursion: Options/Recursion. (line 22) --* -h: Options Summary. (line 89) --* -I: Options Summary. (line 98) --* -i <1>: Options Summary. (line 93) --* -i: Errors. (line 30) --* -I: Include. (line 52) --* -j <1>: Options Summary. (line 105) --* -j: Parallel. (line 6) --* -j, and archive update: Archive Pitfalls. (line 6) --* -j, and recursion: Options/Recursion. (line 25) --* -k <1>: Options Summary. (line 114) --* -k <2>: Testing. (line 16) --* -k: Errors. (line 47) --* -L: Options Summary. (line 129) --* -l: Options Summary. (line 121) --* -l (library search): Libraries/Search. (line 6) --* -l (load average): Parallel. (line 57) --* -m: Options Summary. (line 10) --* -M (to compiler): Automatic Prerequisites. -- (line 18) --* -MM (to GNU compiler): Automatic Prerequisites. -- (line 68) --* -n <1>: Options Summary. (line 138) --* -n <2>: Instead of Execution. -- (line 14) --* -n: Echoing. (line 18) --* -o <1>: Options Summary. (line 145) --* -o: Avoiding Compilation. -- (line 6) --* -o, and recursion: Options/Recursion. (line 22) --* -p: Options Summary. (line 154) --* -q <1>: Options Summary. (line 166) --* -q: Instead of Execution. -- (line 25) --* -R: Options Summary. (line 187) --* -r: Options Summary. (line 174) --* -S: Options Summary. (line 202) --* -s <1>: Options Summary. (line 196) --* -s: Echoing. (line 24) --* -t <1>: Options Summary. (line 211) --* -t: Instead of Execution. -- (line 19) --* -t, and recursion: MAKE Variable. (line 34) --* -v: Options Summary. (line 219) --* -W: Options Summary. (line 239) --* -w: Options Summary. (line 224) --* -W: Instead of Execution. -- (line 33) --* -w, and -C: -w Option. (line 20) --* -w, and recursion: -w Option. (line 20) --* -W, and recursion: Options/Recursion. (line 22) --* -w, disabling: -w Option. (line 20) --* .a (archives): Archive Suffix Rules. -- (line 6) --* .C: Catalogue of Rules. (line 39) --* .c: Catalogue of Rules. (line 35) --* .cc: Catalogue of Rules. (line 39) --* .ch: Catalogue of Rules. (line 151) --* .cpp: Catalogue of Rules. (line 39) --* .d: Automatic Prerequisites. -- (line 81) --* .def: Catalogue of Rules. (line 74) --* .dvi: Catalogue of Rules. (line 151) --* .F: Catalogue of Rules. (line 49) --* .f: Catalogue of Rules. (line 49) --* .info: Catalogue of Rules. (line 158) --* .l: Catalogue of Rules. (line 124) --* .LIBPATTERNS, and link libraries: Libraries/Search. (line 6) --* .ln: Catalogue of Rules. (line 146) --* .mod: Catalogue of Rules. (line 74) --* .o: Catalogue of Rules. (line 35) --* .p: Catalogue of Rules. (line 45) --* .PRECIOUS intermediate files: Chained Rules. (line 56) --* .r: Catalogue of Rules. (line 49) --* .S: Catalogue of Rules. (line 82) --* .s: Catalogue of Rules. (line 79) --* .sh: Catalogue of Rules. (line 180) --* .sym: Catalogue of Rules. (line 74) --* .tex: Catalogue of Rules. (line 151) --* .texi: Catalogue of Rules. (line 158) --* .texinfo: Catalogue of Rules. (line 158) --* .txinfo: Catalogue of Rules. (line 158) --* .w: Catalogue of Rules. (line 151) --* .web: Catalogue of Rules. (line 151) --* .y: Catalogue of Rules. (line 120) --* :: rules (double-colon): Double-Colon. (line 6) --* := <1>: Setting. (line 6) --* :=: Flavors. (line 56) --* = <1>: Setting. (line 6) --* =: Flavors. (line 10) --* =, expansion: Reading Makefiles. (line 33) --* ? (wildcard character): Wildcards. (line 6) --* ?= <1>: Setting. (line 6) --* ?=: Flavors. (line 129) --* ?=, expansion: Reading Makefiles. (line 33) --* @ (in commands): Echoing. (line 6) --* @, and define: Sequences. (line 50) --* [...] (wildcard characters): Wildcards. (line 6) --* \ (backslash), for continuation lines: Simple Makefile. (line 40) --* \ (backslash), in commands: Splitting Lines. (line 6) --* \ (backslash), to quote % <1>: Text Functions. (line 26) --* \ (backslash), to quote % <2>: Static Usage. (line 37) --* \ (backslash), to quote %: Selective Search. (line 38) --* __.SYMDEF: Archive Symbols. (line 6) --* abspath: File Name Functions. (line 121) --* algorithm for directory search: Search Algorithm. (line 6) --* all (standard target): Goals. (line 72) --* appending to variables: Appending. (line 6) --* ar: Implicit Variables. (line 41) --* archive: Archives. (line 6) --* archive member targets: Archive Members. (line 6) --* archive symbol directory updating: Archive Symbols. (line 6) --* archive, and -j: Archive Pitfalls. (line 6) --* archive, and parallel execution: Archive Pitfalls. (line 6) --* archive, suffix rule for: Archive Suffix Rules. -- (line 6) --* Arg list too long: Options/Recursion. (line 57) --* arguments of functions: Syntax of Functions. (line 6) --* as <1>: Implicit Variables. (line 44) --* as: Catalogue of Rules. (line 79) --* assembly, rule to compile: Catalogue of Rules. (line 79) --* automatic generation of prerequisites <1>: Automatic Prerequisites. -- (line 6) --* automatic generation of prerequisites: Include. (line 50) --* automatic variables: Automatic Variables. (line 6) --* automatic variables in prerequisites: Automatic Variables. (line 17) --* backquotes: Shell Function. (line 6) --* backslash (\), for continuation lines: Simple Makefile. (line 40) --* backslash (\), in commands: Splitting Lines. (line 6) --* backslash (\), to quote % <1>: Text Functions. (line 26) --* backslash (\), to quote % <2>: Static Usage. (line 37) --* backslash (\), to quote %: Selective Search. (line 38) --* backslashes in pathnames and wildcard expansion: Wildcard Pitfall. -- (line 31) --* basename: File Name Functions. (line 57) --* binary packages: Install Command Categories. -- (line 80) --* broken pipe: Parallel. (line 30) --* bugs, reporting: Bugs. (line 6) --* built-in special targets: Special Targets. (line 6) --* C++, rule to compile: Catalogue of Rules. (line 39) --* C, rule to compile: Catalogue of Rules. (line 35) --* cc <1>: Implicit Variables. (line 47) --* cc: Catalogue of Rules. (line 35) --* cd (shell command) <1>: MAKE Variable. (line 16) --* cd (shell command): Execution. (line 10) --* chains of rules: Chained Rules. (line 6) --* check (standard target): Goals. (line 114) --* clean (standard target): Goals. (line 75) --* clean target <1>: Cleanup. (line 11) --* clean target: Simple Makefile. (line 83) --* cleaning up: Cleanup. (line 6) --* clobber (standard target): Goals. (line 86) --* co <1>: Implicit Variables. (line 56) --* co: Catalogue of Rules. (line 164) --* combining rules by prerequisite: Combine By Prerequisite. -- (line 6) --* command line variable definitions, and recursion: Options/Recursion. -- (line 17) --* command line variables: Overriding. (line 6) --* command syntax: Command Syntax. (line 6) --* commands: Rule Syntax. (line 26) --* commands setting shell variables: Execution. (line 10) --* commands, backslash (\) in: Splitting Lines. (line 6) --* commands, comments in: Command Syntax. (line 27) --* commands, echoing: Echoing. (line 6) --* commands, empty: Empty Commands. (line 6) --* commands, errors in: Errors. (line 6) --* commands, execution: Execution. (line 6) --* commands, execution in parallel: Parallel. (line 6) --* commands, expansion: Shell Function. (line 6) --* commands, how to write: Commands. (line 6) --* commands, instead of executing: Instead of Execution. -- (line 6) --* commands, introduction to: Rule Introduction. (line 8) --* commands, quoting newlines in: Splitting Lines. (line 6) --* commands, sequences of: Sequences. (line 6) --* commands, splitting: Splitting Lines. (line 6) --* commands, using variables in: Variables in Commands. -- (line 6) --* comments, in commands: Command Syntax. (line 27) --* comments, in makefile: Makefile Contents. (line 41) --* compatibility: Features. (line 6) --* compatibility in exporting: Variables/Recursion. (line 105) --* compilation, testing: Testing. (line 6) --* computed variable name: Computed Names. (line 6) --* conditional expansion: Conditional Functions. -- (line 6) --* conditional variable assignment: Flavors. (line 129) --* conditionals: Conditionals. (line 6) --* continuation lines: Simple Makefile. (line 40) --* controlling make: Make Control Functions. -- (line 6) --* conventions for makefiles: Makefile Conventions. -- (line 6) --* ctangle <1>: Implicit Variables. (line 107) --* ctangle: Catalogue of Rules. (line 151) --* cweave <1>: Implicit Variables. (line 101) --* cweave: Catalogue of Rules. (line 151) --* data base of make rules: Options Summary. (line 155) --* deducing commands (implicit rules): make Deduces. (line 6) --* default directories for included makefiles: Include. (line 52) --* default goal <1>: Rules. (line 11) --* default goal: How Make Works. (line 11) --* default makefile name: Makefile Names. (line 6) --* default rules, last-resort: Last Resort. (line 6) --* define, expansion: Reading Makefiles. (line 33) --* defining variables verbatim: Defining. (line 6) --* deletion of target files <1>: Interrupts. (line 6) --* deletion of target files: Errors. (line 64) --* directive: Makefile Contents. (line 28) --* directories, printing them: -w Option. (line 6) --* directories, updating archive symbol: Archive Symbols. (line 6) --* directory part: File Name Functions. (line 17) --* directory search (VPATH): Directory Search. (line 6) --* directory search (VPATH), and implicit rules: Implicit/Search. -- (line 6) --* directory search (VPATH), and link libraries: Libraries/Search. -- (line 6) --* directory search (VPATH), and shell commands: Commands/Search. -- (line 6) --* directory search algorithm: Search Algorithm. (line 6) --* directory search, traditional (GPATH): Search Algorithm. (line 42) --* dist (standard target): Goals. (line 106) --* distclean (standard target): Goals. (line 84) --* dollar sign ($), in function call: Syntax of Functions. (line 6) --* dollar sign ($), in rules: Rule Syntax. (line 32) --* dollar sign ($), in variable name: Computed Names. (line 6) --* dollar sign ($), in variable reference: Reference. (line 6) --* DOS, choosing a shell in: Choosing the Shell. (line 36) --* double-colon rules: Double-Colon. (line 6) --* duplicate words, removing: Text Functions. (line 155) --* E2BIG: Options/Recursion. (line 57) --* echoing of commands: Echoing. (line 6) --* editor: Introduction. (line 22) --* Emacs (M-x compile): Errors. (line 62) --* empty commands: Empty Commands. (line 6) --* empty targets: Empty Targets. (line 6) --* environment: Environment. (line 6) --* environment, and recursion: Variables/Recursion. (line 6) --* environment, SHELL in: Choosing the Shell. (line 10) --* error, stopping on: Make Control Functions. -- (line 11) --* errors (in commands): Errors. (line 6) --* errors with wildcards: Wildcard Pitfall. (line 6) --* evaluating makefile syntax: Eval Function. (line 6) --* execution, in parallel: Parallel. (line 6) --* execution, instead of: Instead of Execution. -- (line 6) --* execution, of commands: Execution. (line 6) --* exit status (errors): Errors. (line 6) --* exit status of make: Running. (line 18) --* expansion, secondary: Secondary Expansion. (line 6) --* explicit rule, definition of: Makefile Contents. (line 10) --* explicit rule, expansion: Reading Makefiles. (line 62) --* explicit rules, secondary expansion of: Secondary Expansion. -- (line 106) --* exporting variables: Variables/Recursion. (line 6) --* f77 <1>: Implicit Variables. (line 64) --* f77: Catalogue of Rules. (line 49) --* FDL, GNU Free Documentation License: GNU Free Documentation License. -- (line 6) --* features of GNU make: Features. (line 6) --* features, missing: Missing. (line 6) --* file name functions: File Name Functions. (line 6) --* file name of makefile: Makefile Names. (line 6) --* file name of makefile, how to specify: Makefile Names. (line 30) --* file name prefix, adding: File Name Functions. (line 79) --* file name suffix: File Name Functions. (line 43) --* file name suffix, adding: File Name Functions. (line 68) --* file name with wildcards: Wildcards. (line 6) --* file name, abspath of: File Name Functions. (line 121) --* file name, basename of: File Name Functions. (line 57) --* file name, directory part: File Name Functions. (line 17) --* file name, nondirectory part: File Name Functions. (line 27) --* file name, realpath of: File Name Functions. (line 114) --* files, assuming new: Instead of Execution. -- (line 33) --* files, assuming old: Avoiding Compilation. -- (line 6) --* files, avoiding recompilation of: Avoiding Compilation. -- (line 6) --* files, intermediate: Chained Rules. (line 16) --* filtering out words: Text Functions. (line 132) --* filtering words: Text Functions. (line 114) --* finding strings: Text Functions. (line 103) --* flags: Options Summary. (line 6) --* flags for compilers: Implicit Variables. (line 6) --* flavor of variable: Flavor Function. (line 6) --* flavors of variables: Flavors. (line 6) --* FORCE: Force Targets. (line 6) --* force targets: Force Targets. (line 6) --* Fortran, rule to compile: Catalogue of Rules. (line 49) --* functions: Functions. (line 6) --* functions, for controlling make: Make Control Functions. -- (line 6) --* functions, for file names: File Name Functions. (line 6) --* functions, for text: Text Functions. (line 6) --* functions, syntax of: Syntax of Functions. (line 6) --* functions, user defined: Call Function. (line 6) --* g++ <1>: Implicit Variables. (line 53) --* g++: Catalogue of Rules. (line 39) --* gcc: Catalogue of Rules. (line 35) --* generating prerequisites automatically <1>: Automatic Prerequisites. -- (line 6) --* generating prerequisites automatically: Include. (line 50) --* get <1>: Implicit Variables. (line 67) --* get: Catalogue of Rules. (line 173) --* globbing (wildcards): Wildcards. (line 6) --* goal: How Make Works. (line 11) --* goal, default <1>: Rules. (line 11) --* goal, default: How Make Works. (line 11) --* goal, how to specify: Goals. (line 6) --* home directory: Wildcards. (line 11) --* IEEE Standard 1003.2: Overview. (line 13) --* ifdef, expansion: Reading Makefiles. (line 51) --* ifeq, expansion: Reading Makefiles. (line 51) --* ifndef, expansion: Reading Makefiles. (line 51) --* ifneq, expansion: Reading Makefiles. (line 51) --* implicit rule: Implicit Rules. (line 6) --* implicit rule, and directory search: Implicit/Search. (line 6) --* implicit rule, and VPATH: Implicit/Search. (line 6) --* implicit rule, definition of: Makefile Contents. (line 16) --* implicit rule, expansion: Reading Makefiles. (line 62) --* implicit rule, how to use: Using Implicit. (line 6) --* implicit rule, introduction to: make Deduces. (line 6) --* implicit rule, predefined: Catalogue of Rules. (line 6) --* implicit rule, search algorithm: Implicit Rule Search. -- (line 6) --* implicit rules, secondary expansion of: Secondary Expansion. -- (line 146) --* included makefiles, default directories: Include. (line 52) --* including (MAKEFILE_LIST variable): MAKEFILE_LIST Variable. -- (line 6) --* including (MAKEFILES variable): MAKEFILES Variable. (line 6) --* including other makefiles: Include. (line 6) --* incompatibilities: Missing. (line 6) --* Info, rule to format: Catalogue of Rules. (line 158) --* install (standard target): Goals. (line 92) --* intermediate files: Chained Rules. (line 16) --* intermediate files, preserving: Chained Rules. (line 46) --* intermediate targets, explicit: Special Targets. (line 44) --* interrupt: Interrupts. (line 6) --* job slots: Parallel. (line 6) --* job slots, and recursion: Options/Recursion. (line 25) --* jobs, limiting based on load: Parallel. (line 57) --* joining lists of words: File Name Functions. (line 90) --* killing (interruption): Interrupts. (line 6) --* last-resort default rules: Last Resort. (line 6) --* ld: Catalogue of Rules. (line 86) --* lex <1>: Implicit Variables. (line 71) --* lex: Catalogue of Rules. (line 124) --* Lex, rule to run: Catalogue of Rules. (line 124) --* libraries for linking, directory search: Libraries/Search. (line 6) --* library archive, suffix rule for: Archive Suffix Rules. -- (line 6) --* limiting jobs based on load: Parallel. (line 57) --* link libraries, and directory search: Libraries/Search. (line 6) --* link libraries, patterns matching: Libraries/Search. (line 6) --* linking, predefined rule for: Catalogue of Rules. (line 86) --* lint <1>: Implicit Variables. (line 78) --* lint: Catalogue of Rules. (line 146) --* lint, rule to run: Catalogue of Rules. (line 146) --* list of all prerequisites: Automatic Variables. (line 61) --* list of changed prerequisites: Automatic Variables. (line 51) --* load average: Parallel. (line 57) --* loops in variable expansion: Flavors. (line 44) --* lpr (shell command) <1>: Empty Targets. (line 25) --* lpr (shell command): Wildcard Examples. (line 21) --* m2c <1>: Implicit Variables. (line 81) --* m2c: Catalogue of Rules. (line 74) --* macro: Using Variables. (line 10) --* make depend: Automatic Prerequisites. -- (line 37) --* makefile: Introduction. (line 7) --* makefile name: Makefile Names. (line 6) --* makefile name, how to specify: Makefile Names. (line 30) --* makefile rule parts: Rule Introduction. (line 6) --* makefile syntax, evaluating: Eval Function. (line 6) --* makefile, and MAKEFILES variable: MAKEFILES Variable. (line 6) --* makefile, conventions for: Makefile Conventions. -- (line 6) --* makefile, how make processes: How Make Works. (line 6) --* makefile, how to write: Makefiles. (line 6) --* makefile, including: Include. (line 6) --* makefile, overriding: Overriding Makefiles. -- (line 6) --* makefile, parsing: Reading Makefiles. (line 6) --* makefile, remaking of: Remaking Makefiles. (line 6) --* makefile, simple: Simple Makefile. (line 6) --* makefiles, and MAKEFILE_LIST variable: MAKEFILE_LIST Variable. -- (line 6) --* makefiles, and special variables: Special Variables. (line 6) --* makeinfo <1>: Implicit Variables. (line 88) --* makeinfo: Catalogue of Rules. (line 158) --* match-anything rule: Match-Anything Rules. -- (line 6) --* match-anything rule, used to override: Overriding Makefiles. -- (line 12) --* missing features: Missing. (line 6) --* mistakes with wildcards: Wildcard Pitfall. (line 6) --* modified variable reference: Substitution Refs. (line 6) --* Modula-2, rule to compile: Catalogue of Rules. (line 74) --* mostlyclean (standard target): Goals. (line 78) --* multiple rules for one target: Multiple Rules. (line 6) --* multiple rules for one target (::): Double-Colon. (line 6) --* multiple targets: Multiple Targets. (line 6) --* multiple targets, in pattern rule: Pattern Intro. (line 49) --* name of makefile: Makefile Names. (line 6) --* name of makefile, how to specify: Makefile Names. (line 30) --* nested variable reference: Computed Names. (line 6) --* newline, quoting, in commands: Splitting Lines. (line 6) --* newline, quoting, in makefile: Simple Makefile. (line 40) --* nondirectory part: File Name Functions. (line 27) --* normal prerequisites: Prerequisite Types. (line 6) --* OBJ: Variables Simplify. (line 20) --* obj: Variables Simplify. (line 20) --* OBJECTS: Variables Simplify. (line 20) --* objects: Variables Simplify. (line 14) --* OBJS: Variables Simplify. (line 20) --* objs: Variables Simplify. (line 20) --* old-fashioned suffix rules: Suffix Rules. (line 6) --* options: Options Summary. (line 6) --* options, and recursion: Options/Recursion. (line 6) --* options, setting from environment: Options/Recursion. (line 81) --* options, setting in makefiles: Options/Recursion. (line 81) --* order of pattern rules: Pattern Intro. (line 57) --* order-only prerequisites: Prerequisite Types. (line 6) --* origin of variable: Origin Function. (line 6) --* overriding makefiles: Overriding Makefiles. -- (line 6) --* overriding variables with arguments: Overriding. (line 6) --* overriding with override: Override Directive. (line 6) --* parallel execution: Parallel. (line 6) --* parallel execution, and archive update: Archive Pitfalls. (line 6) --* parallel execution, overriding: Special Targets. (line 135) --* parts of makefile rule: Rule Introduction. (line 6) --* Pascal, rule to compile: Catalogue of Rules. (line 45) --* pattern rule: Pattern Intro. (line 6) --* pattern rule, expansion: Reading Makefiles. (line 62) --* pattern rules, order of: Pattern Intro. (line 57) --* pattern rules, static (not implicit): Static Pattern. (line 6) --* pattern rules, static, syntax of: Static Usage. (line 6) --* pattern-specific variables: Pattern-specific. (line 6) --* pc <1>: Implicit Variables. (line 84) --* pc: Catalogue of Rules. (line 45) --* phony targets: Phony Targets. (line 6) --* pitfalls of wildcards: Wildcard Pitfall. (line 6) --* portability: Features. (line 6) --* POSIX: Overview. (line 13) --* POSIX.2: Options/Recursion. (line 60) --* post-installation commands: Install Command Categories. -- (line 6) --* pre-installation commands: Install Command Categories. -- (line 6) --* precious targets: Special Targets. (line 29) --* predefined rules and variables, printing: Options Summary. (line 155) --* prefix, adding: File Name Functions. (line 79) --* prerequisite: Rules. (line 6) --* prerequisite pattern, implicit: Pattern Intro. (line 22) --* prerequisite pattern, static (not implicit): Static Usage. (line 30) --* prerequisite types: Prerequisite Types. (line 6) --* prerequisite, expansion: Reading Makefiles. (line 62) --* prerequisites: Rule Syntax. (line 46) --* prerequisites, and automatic variables: Automatic Variables. -- (line 17) --* prerequisites, automatic generation <1>: Automatic Prerequisites. -- (line 6) --* prerequisites, automatic generation: Include. (line 50) --* prerequisites, introduction to: Rule Introduction. (line 8) --* prerequisites, list of all: Automatic Variables. (line 61) --* prerequisites, list of changed: Automatic Variables. (line 51) --* prerequisites, normal: Prerequisite Types. (line 6) --* prerequisites, order-only: Prerequisite Types. (line 6) --* prerequisites, varying (static pattern): Static Pattern. (line 6) --* preserving intermediate files: Chained Rules. (line 46) --* preserving with .PRECIOUS <1>: Chained Rules. (line 56) --* preserving with .PRECIOUS: Special Targets. (line 29) --* preserving with .SECONDARY: Special Targets. (line 49) --* print (standard target): Goals. (line 97) --* print target <1>: Empty Targets. (line 25) --* print target: Wildcard Examples. (line 21) --* printing directories: -w Option. (line 6) --* printing messages: Make Control Functions. -- (line 43) --* printing of commands: Echoing. (line 6) --* printing user warnings: Make Control Functions. -- (line 35) --* problems and bugs, reporting: Bugs. (line 6) --* problems with wildcards: Wildcard Pitfall. (line 6) --* processing a makefile: How Make Works. (line 6) --* question mode: Instead of Execution. -- (line 25) --* quoting %, in patsubst: Text Functions. (line 26) --* quoting %, in static pattern: Static Usage. (line 37) --* quoting %, in vpath: Selective Search. (line 38) --* quoting newline, in commands: Splitting Lines. (line 6) --* quoting newline, in makefile: Simple Makefile. (line 40) --* Ratfor, rule to compile: Catalogue of Rules. (line 49) --* RCS, rule to extract from: Catalogue of Rules. (line 164) --* reading makefiles: Reading Makefiles. (line 6) --* README: Makefile Names. (line 9) --* realclean (standard target): Goals. (line 85) --* realpath: File Name Functions. (line 114) --* recompilation: Introduction. (line 22) --* recompilation, avoiding: Avoiding Compilation. -- (line 6) --* recording events with empty targets: Empty Targets. (line 6) --* recursion: Recursion. (line 6) --* recursion, and -C: Options/Recursion. (line 22) --* recursion, and -f: Options/Recursion. (line 22) --* recursion, and -j: Options/Recursion. (line 25) --* recursion, and -o: Options/Recursion. (line 22) --* recursion, and -t: MAKE Variable. (line 34) --* recursion, and -w: -w Option. (line 20) --* recursion, and -W: Options/Recursion. (line 22) --* recursion, and command line variable definitions: Options/Recursion. -- (line 17) --* recursion, and environment: Variables/Recursion. (line 6) --* recursion, and MAKE variable: MAKE Variable. (line 6) --* recursion, and MAKEFILES variable: MAKEFILES Variable. (line 14) --* recursion, and options: Options/Recursion. (line 6) --* recursion, and printing directories: -w Option. (line 6) --* recursion, and variables: Variables/Recursion. (line 6) --* recursion, level of: Variables/Recursion. (line 115) --* recursive variable expansion <1>: Flavors. (line 6) --* recursive variable expansion: Using Variables. (line 6) --* recursively expanded variables: Flavors. (line 6) --* reference to variables <1>: Advanced. (line 6) --* reference to variables: Reference. (line 6) --* relinking: How Make Works. (line 46) --* remaking makefiles: Remaking Makefiles. (line 6) --* removal of target files <1>: Interrupts. (line 6) --* removal of target files: Errors. (line 64) --* removing duplicate words: Text Functions. (line 155) --* removing targets on failure: Special Targets. (line 68) --* removing, to clean up: Cleanup. (line 6) --* reporting bugs: Bugs. (line 6) --* rm: Implicit Variables. (line 110) --* rm (shell command) <1>: Errors. (line 27) --* rm (shell command) <2>: Phony Targets. (line 20) --* rm (shell command) <3>: Wildcard Examples. (line 12) --* rm (shell command): Simple Makefile. (line 83) --* rule commands: Commands. (line 6) --* rule prerequisites: Rule Syntax. (line 46) --* rule syntax: Rule Syntax. (line 6) --* rule targets: Rule Syntax. (line 18) --* rule, double-colon (::): Double-Colon. (line 6) --* rule, explicit, definition of: Makefile Contents. (line 10) --* rule, how to write: Rules. (line 6) --* rule, implicit: Implicit Rules. (line 6) --* rule, implicit, and directory search: Implicit/Search. (line 6) --* rule, implicit, and VPATH: Implicit/Search. (line 6) --* rule, implicit, chains of: Chained Rules. (line 6) --* rule, implicit, definition of: Makefile Contents. (line 16) --* rule, implicit, how to use: Using Implicit. (line 6) --* rule, implicit, introduction to: make Deduces. (line 6) --* rule, implicit, predefined: Catalogue of Rules. (line 6) --* rule, introduction to: Rule Introduction. (line 6) --* rule, multiple for one target: Multiple Rules. (line 6) --* rule, no commands or prerequisites: Force Targets. (line 6) --* rule, pattern: Pattern Intro. (line 6) --* rule, static pattern: Static Pattern. (line 6) --* rule, static pattern versus implicit: Static versus Implicit. -- (line 6) --* rule, with multiple targets: Multiple Targets. (line 6) --* rules, and $: Rule Syntax. (line 32) --* s. (SCCS file prefix): Catalogue of Rules. (line 173) --* SCCS, rule to extract from: Catalogue of Rules. (line 173) --* search algorithm, implicit rule: Implicit Rule Search. -- (line 6) --* search path for prerequisites (VPATH): Directory Search. (line 6) --* search path for prerequisites (VPATH), and implicit rules: Implicit/Search. -- (line 6) --* search path for prerequisites (VPATH), and link libraries: Libraries/Search. -- (line 6) --* searching for strings: Text Functions. (line 103) --* secondary expansion: Secondary Expansion. (line 6) --* secondary expansion and explicit rules: Secondary Expansion. -- (line 106) --* secondary expansion and implicit rules: Secondary Expansion. -- (line 146) --* secondary expansion and static pattern rules: Secondary Expansion. -- (line 138) --* secondary files: Chained Rules. (line 46) --* secondary targets: Special Targets. (line 49) --* sed (shell command): Automatic Prerequisites. -- (line 73) --* selecting a word: Text Functions. (line 159) --* selecting word lists: Text Functions. (line 168) --* sequences of commands: Sequences. (line 6) --* setting options from environment: Options/Recursion. (line 81) --* setting options in makefiles: Options/Recursion. (line 81) --* setting variables: Setting. (line 6) --* several rules for one target: Multiple Rules. (line 6) --* several targets in a rule: Multiple Targets. (line 6) --* shar (standard target): Goals. (line 103) --* shell command: Simple Makefile. (line 72) --* shell command, and directory search: Commands/Search. (line 6) --* shell command, execution: Execution. (line 6) --* shell command, function for: Shell Function. (line 6) --* shell file name pattern (in include): Include. (line 13) --* shell variables, setting in commands: Execution. (line 10) --* shell wildcards (in include): Include. (line 13) --* shell, choosing the: Choosing the Shell. (line 6) --* SHELL, exported value: Variables/Recursion. (line 23) --* SHELL, import from environment: Environment. (line 37) --* shell, in DOS and Windows: Choosing the Shell. (line 36) --* SHELL, MS-DOS specifics: Choosing the Shell. (line 42) --* SHELL, value of: Choosing the Shell. (line 6) --* signal: Interrupts. (line 6) --* silent operation: Echoing. (line 6) --* simple makefile: Simple Makefile. (line 6) --* simple variable expansion: Using Variables. (line 6) --* simplifying with variables: Variables Simplify. (line 6) --* simply expanded variables: Flavors. (line 56) --* sorting words: Text Functions. (line 146) --* spaces, in variable values: Flavors. (line 103) --* spaces, stripping: Text Functions. (line 80) --* special targets: Special Targets. (line 6) --* special variables: Special Variables. (line 6) --* specifying makefile name: Makefile Names. (line 30) --* splitting commands: Splitting Lines. (line 6) --* standard input: Parallel. (line 30) --* standards conformance: Overview. (line 13) --* standards for makefiles: Makefile Conventions. -- (line 6) --* static pattern rule: Static Pattern. (line 6) --* static pattern rule, syntax of: Static Usage. (line 6) --* static pattern rule, versus implicit: Static versus Implicit. -- (line 6) --* static pattern rules, secondary expansion of: Secondary Expansion. -- (line 138) --* stem <1>: Pattern Match. (line 6) --* stem: Static Usage. (line 17) --* stem, variable for: Automatic Variables. (line 77) --* stopping make: Make Control Functions. -- (line 11) --* strings, searching for: Text Functions. (line 103) --* stripping whitespace: Text Functions. (line 80) --* sub-make: Variables/Recursion. (line 6) --* subdirectories, recursion for: Recursion. (line 6) --* substitution variable reference: Substitution Refs. (line 6) --* suffix rule: Suffix Rules. (line 6) --* suffix rule, for archive: Archive Suffix Rules. -- (line 6) --* suffix, adding: File Name Functions. (line 68) --* suffix, function to find: File Name Functions. (line 43) --* suffix, substituting in variables: Substitution Refs. (line 6) --* switches: Options Summary. (line 6) --* symbol directories, updating archive: Archive Symbols. (line 6) --* syntax of commands: Command Syntax. (line 6) --* syntax of rules: Rule Syntax. (line 6) --* tab character (in commands): Rule Syntax. (line 26) --* tabs in rules: Rule Introduction. (line 21) --* TAGS (standard target): Goals. (line 111) --* tangle <1>: Implicit Variables. (line 104) --* tangle: Catalogue of Rules. (line 151) --* tar (standard target): Goals. (line 100) --* target: Rules. (line 6) --* target pattern, implicit: Pattern Intro. (line 9) --* target pattern, static (not implicit): Static Usage. (line 17) --* target, deleting on error: Errors. (line 64) --* target, deleting on interrupt: Interrupts. (line 6) --* target, expansion: Reading Makefiles. (line 62) --* target, multiple in pattern rule: Pattern Intro. (line 49) --* target, multiple rules for one: Multiple Rules. (line 6) --* target, touching: Instead of Execution. -- (line 19) --* target-specific variables: Target-specific. (line 6) --* targets: Rule Syntax. (line 18) --* targets without a file: Phony Targets. (line 6) --* targets, built-in special: Special Targets. (line 6) --* targets, empty: Empty Targets. (line 6) --* targets, force: Force Targets. (line 6) --* targets, introduction to: Rule Introduction. (line 8) --* targets, multiple: Multiple Targets. (line 6) --* targets, phony: Phony Targets. (line 6) --* terminal rule: Match-Anything Rules. -- (line 6) --* test (standard target): Goals. (line 115) --* testing compilation: Testing. (line 6) --* tex <1>: Implicit Variables. (line 91) --* tex: Catalogue of Rules. (line 151) --* TeX, rule to run: Catalogue of Rules. (line 151) --* texi2dvi <1>: Implicit Variables. (line 95) --* texi2dvi: Catalogue of Rules. (line 158) --* Texinfo, rule to format: Catalogue of Rules. (line 158) --* tilde (~): Wildcards. (line 11) --* touch (shell command) <1>: Empty Targets. (line 25) --* touch (shell command): Wildcard Examples. (line 21) --* touching files: Instead of Execution. -- (line 19) --* traditional directory search (GPATH): Search Algorithm. (line 42) --* types of prerequisites: Prerequisite Types. (line 6) --* undefined variables, warning message: Options Summary. (line 251) --* updating archive symbol directories: Archive Symbols. (line 6) --* updating makefiles: Remaking Makefiles. (line 6) --* user defined functions: Call Function. (line 6) --* value: Using Variables. (line 6) --* value, how a variable gets it: Values. (line 6) --* variable: Using Variables. (line 6) --* variable definition: Makefile Contents. (line 22) --* variable references in commands: Variables in Commands. -- (line 6) --* variables: Variables Simplify. (line 6) --* variables, $ in name: Computed Names. (line 6) --* variables, and implicit rule: Automatic Variables. (line 6) --* variables, appending to: Appending. (line 6) --* variables, automatic: Automatic Variables. (line 6) --* variables, command line: Overriding. (line 6) --* variables, command line, and recursion: Options/Recursion. (line 17) --* variables, computed names: Computed Names. (line 6) --* variables, conditional assignment: Flavors. (line 129) --* variables, defining verbatim: Defining. (line 6) --* variables, environment <1>: Environment. (line 6) --* variables, environment: Variables/Recursion. (line 6) --* variables, exporting: Variables/Recursion. (line 6) --* variables, flavor of: Flavor Function. (line 6) --* variables, flavors: Flavors. (line 6) --* variables, how they get their values: Values. (line 6) --* variables, how to reference: Reference. (line 6) --* variables, loops in expansion: Flavors. (line 44) --* variables, modified reference: Substitution Refs. (line 6) --* variables, nested references: Computed Names. (line 6) --* variables, origin of: Origin Function. (line 6) --* variables, overriding: Override Directive. (line 6) --* variables, overriding with arguments: Overriding. (line 6) --* variables, pattern-specific: Pattern-specific. (line 6) --* variables, recursively expanded: Flavors. (line 6) --* variables, setting: Setting. (line 6) --* variables, simply expanded: Flavors. (line 56) --* variables, spaces in values: Flavors. (line 103) --* variables, substituting suffix in: Substitution Refs. (line 6) --* variables, substitution reference: Substitution Refs. (line 6) --* variables, target-specific: Target-specific. (line 6) --* variables, unexpanded value: Value Function. (line 6) --* variables, warning for undefined: Options Summary. (line 251) --* varying prerequisites: Static Pattern. (line 6) --* verbatim variable definition: Defining. (line 6) --* vpath: Directory Search. (line 6) --* VPATH, and implicit rules: Implicit/Search. (line 6) --* VPATH, and link libraries: Libraries/Search. (line 6) --* warnings, printing: Make Control Functions. -- (line 35) --* weave <1>: Implicit Variables. (line 98) --* weave: Catalogue of Rules. (line 151) --* Web, rule to run: Catalogue of Rules. (line 151) --* what if: Instead of Execution. -- (line 33) --* whitespace, in variable values: Flavors. (line 103) --* whitespace, stripping: Text Functions. (line 80) --* wildcard: Wildcards. (line 6) --* wildcard pitfalls: Wildcard Pitfall. (line 6) --* wildcard, function: File Name Functions. (line 107) --* wildcard, in archive member: Archive Members. (line 36) --* wildcard, in include: Include. (line 13) --* wildcards and MS-DOS/MS-Windows backslashes: Wildcard Pitfall. -- (line 31) --* Windows, choosing a shell in: Choosing the Shell. (line 36) --* word, selecting a: Text Functions. (line 159) --* words, extracting first: Text Functions. (line 184) --* words, extracting last: Text Functions. (line 197) --* words, filtering: Text Functions. (line 114) --* words, filtering out: Text Functions. (line 132) --* words, finding number: Text Functions. (line 180) --* words, iterating over: Foreach Function. (line 6) --* words, joining lists: File Name Functions. (line 90) --* words, removing duplicates: Text Functions. (line 155) --* words, selecting lists of: Text Functions. (line 168) --* writing rule commands: Commands. (line 6) --* writing rules: Rules. (line 6) --* yacc <1>: Implicit Variables. (line 75) --* yacc <2>: Catalogue of Rules. (line 120) --* yacc: Sequences. (line 18) --* Yacc, rule to run: Catalogue of Rules. (line 120) --* ~ (tilde): Wildcards. (line 11) -- -- --File: make.info, Node: Name Index, Prev: Concept Index, Up: Top -- --Index of Functions, Variables, & Directives --******************************************* -- --[index] --* Menu: -- --* $%: Automatic Variables. (line 37) --* $(%D): Automatic Variables. (line 129) --* $(%F): Automatic Variables. (line 130) --* $(*D): Automatic Variables. (line 124) --* $(*F): Automatic Variables. (line 125) --* $(+D): Automatic Variables. (line 147) --* $(+F): Automatic Variables. (line 148) --* $(: Last Resort. (line 23) --* .DEFAULT: Special Targets. (line 20) --* .DEFAULT, and empty commands: Empty Commands. (line 16) --* .DEFAULT_GOAL (define default goal): Special Variables. (line 10) --* .DELETE_ON_ERROR <1>: Errors. (line 64) --* .DELETE_ON_ERROR: Special Targets. (line 67) --* .EXPORT_ALL_VARIABLES <1>: Variables/Recursion. (line 99) --* .EXPORT_ALL_VARIABLES: Special Targets. (line 129) --* .FEATURES (list of supported features): Special Variables. (line 65) --* .IGNORE <1>: Errors. (line 30) --* .IGNORE: Special Targets. (line 74) --* .INCLUDE_DIRS (list of include directories): Special Variables. -- (line 98) --* .INTERMEDIATE: Special Targets. (line 43) --* .LIBPATTERNS: Libraries/Search. (line 6) --* .LOW_RESOLUTION_TIME: Special Targets. (line 86) --* .NOTPARALLEL: Special Targets. (line 134) --* .PHONY <1>: Special Targets. (line 8) --* .PHONY: Phony Targets. (line 22) --* .POSIX: Options/Recursion. (line 60) --* .PRECIOUS <1>: Interrupts. (line 22) --* .PRECIOUS: Special Targets. (line 28) --* .SECONDARY: Special Targets. (line 48) --* .SECONDEXPANSION <1>: Special Targets. (line 57) --* .SECONDEXPANSION: Secondary Expansion. (line 6) --* .SILENT <1>: Echoing. (line 24) --* .SILENT: Special Targets. (line 116) --* .SUFFIXES <1>: Suffix Rules. (line 61) --* .SUFFIXES: Special Targets. (line 15) --* .VARIABLES (list of variables): Special Variables. (line 56) --* /usr/gnu/include: Include. (line 52) --* /usr/include: Include. (line 52) --* /usr/local/include: Include. (line 52) --* < (automatic variable): Automatic Variables. (line 43) --* : Flavors. (line 84) --* MAKE: MAKE Variable. (line 6) --* MAKE_RESTARTS (number of times make has restarted): Special Variables. -- (line 49) --* MAKE_VERSION: Features. (line 197) --* MAKECMDGOALS: Goals. (line 30) --* makefile: Makefile Names. (line 7) --* Makefile: Makefile Names. (line 7) --* MAKEFILE_LIST: MAKEFILE_LIST Variable. -- (line 6) --* MAKEFILES <1>: Variables/Recursion. (line 127) --* MAKEFILES: MAKEFILES Variable. (line 6) --* MAKEFLAGS: Options/Recursion. (line 6) --* MAKEINFO: Implicit Variables. (line 87) --* MAKELEVEL <1>: Flavors. (line 84) --* MAKELEVEL: Variables/Recursion. (line 115) --* MAKEOVERRIDES: Options/Recursion. (line 49) --* MAKESHELL (MS-DOS alternative to SHELL): Choosing the Shell. -- (line 25) --* MFLAGS: Options/Recursion. (line 65) --* notdir: File Name Functions. (line 27) --* or: Conditional Functions. -- (line 37) --* origin: Origin Function. (line 6) --* OUTPUT_OPTION: Catalogue of Rules. (line 202) --* override: Override Directive. (line 6) --* patsubst <1>: Text Functions. (line 18) --* patsubst: Substitution Refs. (line 28) --* PC: Implicit Variables. (line 84) --* PFLAGS: Implicit Variables. (line 153) --* prefix: Directory Variables. (line 25) --* realpath: File Name Functions. (line 114) --* RFLAGS: Implicit Variables. (line 156) --* RM: Implicit Variables. (line 110) --* sbindir: Directory Variables. (line 59) --* shell: Shell Function. (line 6) --* SHELL: Choosing the Shell. (line 6) --* SHELL (command execution): Execution. (line 6) --* sort: Text Functions. (line 146) --* strip: Text Functions. (line 80) --* subst <1>: Text Functions. (line 9) --* subst: Multiple Targets. (line 28) --* suffix: File Name Functions. (line 43) --* SUFFIXES: Suffix Rules. (line 81) --* TANGLE: Implicit Variables. (line 104) --* TEX: Implicit Variables. (line 91) --* TEXI2DVI: Implicit Variables. (line 94) --* unexport: Variables/Recursion. (line 45) --* value: Value Function. (line 6) --* vpath: Selective Search. (line 6) --* VPATH: General Search. (line 6) --* vpath: Directory Search. (line 6) --* VPATH: Directory Search. (line 6) --* warning: Make Control Functions. -- (line 35) --* WEAVE: Implicit Variables. (line 98) --* wildcard <1>: File Name Functions. (line 107) --* wildcard: Wildcard Function. (line 6) --* word: Text Functions. (line 159) --* wordlist: Text Functions. (line 168) --* words: Text Functions. (line 180) --* YACC: Implicit Variables. (line 74) --* YFLAGS: Implicit Variables. (line 150) --* | (automatic variable): Automatic Variables. (line 69) -- -- -diff -rNU3 dist.orig/doc/make.texi dist/doc/make.texi ---- dist.orig/doc/make.texi 2006-04-01 08:36:40.000000000 +0200 -+++ dist/doc/make.texi 2014-08-18 08:47:47.000000000 +0200 -@@ -4,7 +4,7 @@ - - @include version.texi - @set EDITION 0.70 --@set RCSID $Id: make.texi,v 1.45 2006/04/01 06:36:40 psmith Exp $ -+@set RCSID $Id: make.texi,v 1.1.1.1 2014/08/18 06:47:47 christos Exp $ - - @settitle GNU @code{make} - @setchapternewpage odd -diff -rNU3 dist.orig/po/Makefile.in.in dist/po/Makefile.in.in ---- dist.orig/po/Makefile.in.in 2006-04-01 08:39:51.000000000 +0200 -+++ dist/po/Makefile.in.in 2014-08-18 08:57:25.000000000 +0200 -@@ -13,7 +13,7 @@ - PACKAGE = @PACKAGE@ - VERSION = @VERSION@ - --SHELL = /bin/sh -+SHELL = @SHELL@ - @SET_MAKE@ - - srcdir = @srcdir@ -diff -rNU3 dist.orig/tests/scripts/functions/foreach dist/tests/scripts/functions/foreach ---- dist.orig/tests/scripts/functions/foreach 2006-03-10 03:20:46.000000000 +0100 -+++ dist/tests/scripts/functions/foreach 2014-08-18 08:47:57.000000000 +0200 -@@ -1,5 +1,5 @@ - # -*-perl-*- --# $Id: foreach,v 1.5 2006/03/10 02:20:46 psmith Exp $ -+# $Id: foreach,v 1.1.1.1 2014/08/18 06:47:57 christos Exp $ - - $description = "Test the foreach function."; - -diff -rNU3 dist.orig/tests/test_driver.pl dist/tests/test_driver.pl ---- dist.orig/tests/test_driver.pl 2006-03-10 03:20:45.000000000 +0100 -+++ dist/tests/test_driver.pl 2014-08-18 08:47:57.000000000 +0200 -@@ -28,7 +28,7 @@ - # this routine controls the whole mess; each test suite sets up a few - # variables and then calls &toplevel, which does all the real work. - --# $Id: test_driver.pl,v 1.19 2006/03/10 02:20:45 psmith Exp $ -+# $Id: test_driver.pl,v 1.1.1.1 2014/08/18 06:47:57 christos Exp $ - - - # The number of test categories we've run -diff -rNU3 dist.orig/w32/include/sub_proc.h dist/w32/include/sub_proc.h ---- dist.orig/w32/include/sub_proc.h 2006-02-11 23:16:05.000000000 +0100 -+++ dist/w32/include/sub_proc.h 2014-08-18 08:47:56.000000000 +0200 -@@ -21,11 +21,11 @@ - /* - * Component Name: - * -- * $Date: 2006/02/11 22:16:05 $ -+ * $Date: 2014/08/18 06:47:56 $ - * -- * $Source: /sources/make/make/w32/include/sub_proc.h,v $ -+ * $Source: /cvsroot/src/external/gpl2/gmake/dist/w32/include/sub_proc.h,v $ - * -- * $Id: sub_proc.h,v 1.8 2006/02/11 22:16:05 psmith Exp $ -+ * $Id: sub_proc.h,v 1.1.1.1 2014/08/18 06:47:56 christos Exp $ - */ - - #define EXTERN_DECL(entry, args) extern entry args diff --git a/external/gpl3/binutils/patches/0000-binutils_nbsd.patch b/external/gpl3/binutils/patches/0000-binutils_nbsd.patch deleted file mode 100644 index 7ad82421f..000000000 --- a/external/gpl3/binutils/patches/0000-binutils_nbsd.patch +++ /dev/null @@ -1,37997 +0,0 @@ -diff -rNU3 dist.orig/bfd/ChangeLog dist/bfd/ChangeLog ---- dist.orig/bfd/ChangeLog 2013-03-25 10:08:08.000000000 +0100 -+++ dist/bfd/ChangeLog 2015-10-18 13:11:12.000000000 +0200 -@@ -1,3 +1,8 @@ -+2013-12-14 Alan Modra -+ -+ * elflink.c (_bfd_elf_merge_symbol): If merging a new weak -+ symbol that will be skipped, we don't have a new definition. -+ - 2013-03-25 Tristan Gingold - - * configure.in: Bump version to 2.23.2 -diff -rNU3 dist.orig/bfd/Makefile.am dist/bfd/Makefile.am ---- dist.orig/bfd/Makefile.am 2013-03-25 10:08:05.000000000 +0100 -+++ dist/bfd/Makefile.am 2015-10-18 13:11:13.000000000 +0200 -@@ -897,6 +897,18 @@ - sed -e s/NN/64/g < $(srcdir)/elfnn-ia64.c > elf64-ia64.new - mv -f elf64-ia64.new elf64-ia64.c - -+elf32-riscv.c : elfnn-riscv.c -+ rm -f elf32-riscv.c -+ echo "#line 1 \"$(srcdir)/elfnn-riscv.c\"" > elf32-riscv.new -+ sed -e s/NN/32/g < $(srcdir)/elfnn-riscv.c >> elf32-riscv.new -+ mv -f elf32-riscv.new elf32-riscv.c -+ -+elf64-riscv.c : elfnn-riscv.c -+ rm -f elf64-riscv.c -+ echo "#line 1 \"$(srcdir)/elfnn-riscv.c\"" > elf64-riscv.new -+ sed -e s/NN/64/g < $(srcdir)/elfnn-riscv.c >> elf64-riscv.new -+ mv -f elf64-riscv.new elf64-riscv.c -+ - peigen.c : peXXigen.c - rm -f peigen.c - sed -e s/XX/pe/g < $(srcdir)/peXXigen.c > peigen.new -diff -rNU3 dist.orig/bfd/Makefile.in dist/bfd/Makefile.in ---- dist.orig/bfd/Makefile.in 2013-03-25 10:08:08.000000000 +0100 -+++ dist/bfd/Makefile.in 2015-10-18 13:11:13.000000000 +0200 -@@ -419,7 +419,7 @@ - cpu-mt.lo \ - cpu-ns32k.lo \ - cpu-openrisc.lo \ -- cpu-or32.lo \ -+ cpu-or1k.lo \ - cpu-pdp11.lo \ - cpu-pj.lo \ - cpu-plugin.lo \ -@@ -500,7 +500,7 @@ - cpu-mt.c \ - cpu-ns32k.c \ - cpu-openrisc.c \ -- cpu-or32.c \ -+ cpu-or1k.c \ - cpu-pdp11.c \ - cpu-pj.c \ - cpu-plugin.c \ -@@ -559,7 +559,7 @@ - coff-m68k.lo \ - coff-m88k.lo \ - coff-mips.lo \ -- coff-or32.lo \ -+ coff-or1k.lo \ - coff-rs6000.lo \ - coff-sh.lo \ - coff-sparc.lo \ -@@ -627,7 +627,7 @@ - elf32-msp430.lo \ - elf32-mt.lo \ - elf32-openrisc.lo \ -- elf32-or32.lo \ -+ elf32-or1k.lo \ - elf32-pj.lo \ - elf32-ppc.lo \ - elf32-rl78.lo \ -@@ -747,7 +747,7 @@ - coff-m68k.c \ - coff-m88k.c \ - coff-mips.c \ -- coff-or32.c \ -+ coff-or1k.c \ - coff-rs6000.c \ - coff-sh.c \ - coff-sparc.c \ -@@ -815,7 +815,7 @@ - elf32-msp430.c \ - elf32-mt.c \ - elf32-openrisc.c \ -- elf32-or32.c \ -+ elf32-or1k.c \ - elf32-pj.c \ - elf32-ppc.c \ - elf32-rl78.c \ -@@ -1253,7 +1253,7 @@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/coff-m68k.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/coff-m88k.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/coff-mips.Plo@am__quote@ --@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/coff-or32.Plo@am__quote@ -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/coff-or1k.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/coff-rs6000.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/coff-sh.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/coff-sparc.Plo@am__quote@ -@@ -1323,7 +1323,7 @@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-mt.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-ns32k.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-openrisc.Plo@am__quote@ --@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-or32.Plo@am__quote@ -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-or1k.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-pdp11.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-pj.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cpu-plugin.Plo@am__quote@ -@@ -1408,7 +1408,7 @@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-msp430.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-mt.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-openrisc.Plo@am__quote@ --@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-or32.Plo@am__quote@ -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-or1k.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-pj.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-ppc.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/elf32-rl78.Plo@am__quote@ -@@ -1967,6 +1967,18 @@ - sed -e s/NN/64/g < $(srcdir)/elfnn-ia64.c > elf64-ia64.new - mv -f elf64-ia64.new elf64-ia64.c - -+elf32-riscv.c : elfnn-riscv.c -+ rm -f elf32-riscv.c -+ echo "#line 1 \"$(srcdir)/elfnn-riscv.c\"" > elf32-riscv.new -+ sed -e s/NN/32/g < $(srcdir)/elfnn-riscv.c >> elf32-riscv.new -+ mv -f elf32-riscv.new elf32-riscv.c -+ -+elf64-riscv.c : elfnn-riscv.c -+ rm -f elf64-riscv.c -+ echo "#line 1 \"$(srcdir)/elfnn-riscv.c\"" > elf64-riscv.new -+ sed -e s/NN/64/g < $(srcdir)/elfnn-riscv.c >> elf64-riscv.new -+ mv -f elf64-riscv.new elf64-riscv.c -+ - peigen.c : peXXigen.c - rm -f peigen.c - sed -e s/XX/pe/g < $(srcdir)/peXXigen.c > peigen.new -diff -rNU3 dist.orig/bfd/aoutx.h dist/bfd/aoutx.h ---- dist.orig/bfd/aoutx.h 2012-05-01 18:07:33.000000000 +0200 -+++ dist/bfd/aoutx.h 2015-10-18 13:11:12.000000000 +0200 -@@ -762,7 +762,7 @@ - break; - - case bfd_arch_arm: -- if (machine == 0) -+ if (machine == 0 || machine == 5) - arch_flags = M_ARM; - break; - -diff -rNU3 dist.orig/bfd/archive.c dist/bfd/archive.c ---- dist.orig/bfd/archive.c 2013-03-25 09:06:19.000000000 +0100 -+++ dist/bfd/archive.c 2015-10-18 13:11:12.000000000 +0200 -@@ -157,6 +157,9 @@ - #define ar_maxnamelen(abfd) ((abfd)->xvec->ar_max_namelen) - - #define arch_eltdata(bfd) ((struct areltdata *) ((bfd)->arelt_data)) -+ -+static const char * normalize (bfd *, const char *); -+ - #define arch_hdr(bfd) ((struct ar_hdr *) arch_eltdata (bfd)->arch_header) - - /* True iff NAME designated a BSD 4.4 extended name. */ -@@ -760,7 +763,9 @@ - /* Pad to an even boundary... - Note that last_file->origin can be odd in the case of - BSD-4.4-style element with a long odd size. */ -- filestart += filestart % 2; -+ if (!strncmp(arch_hdr (last_file)->ar_name, "#1/", 3)) -+ size += strlen(normalize(last_file, last_file->filename)); -+ filestart += size % 2; - } - - return _bfd_get_elt_at_filepos (archive, filestart); -@@ -2180,11 +2185,22 @@ - current = current->archive_next) - { - char buffer[DEFAULT_BUFFERSIZE]; -- bfd_size_type remaining = arelt_size (current); -+ bfd_size_type saved_size = arelt_size (current); -+ bfd_size_type remaining = saved_size; -+ struct ar_hdr *hdr = arch_hdr (current); - - /* Write ar header. */ - if (!_bfd_write_ar_hdr (arch, current)) -- return FALSE; -+ return FALSE; -+ /* Write filename if it is a 4.4BSD extended file, and add to size. */ -+ if (!strncmp (hdr->ar_name, "#1/", 3)) -+ { -+ const char *normal = normalize (current, current->filename); -+ unsigned int thislen = strlen (normal); -+ if (bfd_write (normal, 1, thislen, arch) != thislen) -+ return FALSE; -+ saved_size += thislen; -+ } - if (bfd_is_thin_archive (arch)) - continue; - if (bfd_seek (current, (file_ptr) 0, SEEK_SET) != 0) -@@ -2457,11 +2473,19 @@ - { - do - { -+#if 1 -+ bfd_size_type size = arelt_size (current); -+ if (!strncmp(arch_hdr (current)->ar_name, "#1/", 3)) -+ size += strlen(normalize(current, current->filename)); -+ firstreal += size + sizeof (struct ar_hdr); -+ firstreal += size % 2; -+#else - struct areltdata *ared = arch_eltdata (current); - - firstreal += (ared->parsed_size + ared->extra_size - + sizeof (struct ar_hdr)); - firstreal += firstreal % 2; -+#endif - current = current->archive_next; - } - while (current != map[count].u.abfd); -diff -rNU3 dist.orig/bfd/archures.c dist/bfd/archures.c ---- dist.orig/bfd/archures.c 2012-09-04 14:53:41.000000000 +0200 -+++ dist/bfd/archures.c 2015-10-18 13:11:12.000000000 +0200 -@@ -123,7 +123,7 @@ - .#define bfd_mach_i960_jx 7 - .#define bfd_mach_i960_hx 8 - . --. bfd_arch_or32, {* OpenRISC 32 *} -+. bfd_arch_or1k, {* OpenRISC 32 *} - . - . bfd_arch_sparc, {* SPARC *} - .#define bfd_mach_sparc 1 -@@ -245,6 +245,9 @@ - .#define bfd_mach_ppc_e6500 5007 - .#define bfd_mach_ppc_titan 83 - .#define bfd_mach_ppc_vle 84 -+. bfd_arch_riscv, {* RISC-V *} -+.#define bfd_mach_riscv32 132 -+.#define bfd_mach_riscv64 164 - . bfd_arch_rs6000, {* IBM RS/6000 *} - .#define bfd_mach_rs6k 6000 - .#define bfd_mach_rs6k_rs1 6001 -@@ -556,12 +559,13 @@ - extern const bfd_arch_info_type bfd_mt_arch; - extern const bfd_arch_info_type bfd_ns32k_arch; - extern const bfd_arch_info_type bfd_openrisc_arch; --extern const bfd_arch_info_type bfd_or32_arch; -+extern const bfd_arch_info_type bfd_or1k_arch; - extern const bfd_arch_info_type bfd_pdp11_arch; - extern const bfd_arch_info_type bfd_pj_arch; - extern const bfd_arch_info_type bfd_plugin_arch; - extern const bfd_arch_info_type bfd_powerpc_archs[]; - #define bfd_powerpc_arch bfd_powerpc_archs[0] -+extern const bfd_arch_info_type bfd_riscv_arch; - extern const bfd_arch_info_type bfd_rs6000_arch; - extern const bfd_arch_info_type bfd_rl78_arch; - extern const bfd_arch_info_type bfd_rx_arch; -@@ -642,9 +646,10 @@ - &bfd_mt_arch, - &bfd_ns32k_arch, - &bfd_openrisc_arch, -- &bfd_or32_arch, -+ &bfd_or1k_arch, - &bfd_pdp11_arch, - &bfd_powerpc_arch, -+ &bfd_riscv_arch, - &bfd_rs6000_arch, - &bfd_rl78_arch, - &bfd_rx_arch, -diff -rNU3 dist.orig/bfd/bfd-in2.h dist/bfd/bfd-in2.h ---- dist.orig/bfd/bfd-in2.h 2012-09-04 14:53:41.000000000 +0200 -+++ dist/bfd/bfd-in2.h 2015-10-18 13:11:12.000000000 +0200 -@@ -1852,7 +1852,9 @@ - #define bfd_mach_i960_jx 7 - #define bfd_mach_i960_hx 8 - -- bfd_arch_or32, /* OpenRISC 32 */ -+ bfd_arch_or1k, /* OpenRISC 1000 */ -+#define bfd_mach_or1k 1 -+#define bfd_mach_or1knd 2 - - bfd_arch_sparc, /* SPARC */ - #define bfd_mach_sparc 1 -@@ -1974,6 +1976,9 @@ - #define bfd_mach_ppc_e6500 5007 - #define bfd_mach_ppc_titan 83 - #define bfd_mach_ppc_vle 84 -+ bfd_arch_riscv, /* RISC-V */ -+#define bfd_mach_riscv32 132 -+#define bfd_mach_riscv64 164 - bfd_arch_rs6000, /* IBM RS/6000 */ - #define bfd_mach_rs6k 6000 - #define bfd_mach_rs6k_rs1 6001 -@@ -4803,9 +4808,66 @@ - BFD_RELOC_860_HIGOT, - BFD_RELOC_860_HIGOTOFF, - --/* OpenRISC Relocations. */ -- BFD_RELOC_OPENRISC_ABS_26, -- BFD_RELOC_OPENRISC_REL_26, -+/* OpenRISC 1000 Relocations. */ -+ BFD_RELOC_OR1K_REL_26, -+ BFD_RELOC_OR1K_GOTPC_HI16, -+ BFD_RELOC_OR1K_GOTPC_LO16, -+ BFD_RELOC_OR1K_GOT16, -+ BFD_RELOC_OR1K_PLT26, -+ BFD_RELOC_OR1K_GOTOFF_HI16, -+ BFD_RELOC_OR1K_GOTOFF_LO16, -+ BFD_RELOC_OR1K_COPY, -+ BFD_RELOC_OR1K_GLOB_DAT, -+ BFD_RELOC_OR1K_JMP_SLOT, -+ BFD_RELOC_OR1K_RELATIVE, -+ BFD_RELOC_OR1K_TLS_GD_HI16, -+ BFD_RELOC_OR1K_TLS_GD_LO16, -+ BFD_RELOC_OR1K_TLS_LDM_HI16, -+ BFD_RELOC_OR1K_TLS_LDM_LO16, -+ BFD_RELOC_OR1K_TLS_LDO_HI16, -+ BFD_RELOC_OR1K_TLS_LDO_LO16, -+ BFD_RELOC_OR1K_TLS_IE_HI16, -+ BFD_RELOC_OR1K_TLS_IE_LO16, -+ BFD_RELOC_OR1K_TLS_LE_HI16, -+ BFD_RELOC_OR1K_TLS_LE_LO16, -+ BFD_RELOC_OR1K_TLS_TPOFF, -+ BFD_RELOC_OR1K_TLS_DTPOFF, -+ BFD_RELOC_OR1K_TLS_DTPMOD, -+ -+/* RISC-V relocations. */ -+ BFD_RELOC_RISCV_HI20, -+ BFD_RELOC_RISCV_PCREL_HI20, -+ BFD_RELOC_RISCV_PCREL_LO12_I, -+ BFD_RELOC_RISCV_PCREL_LO12_S, -+ BFD_RELOC_RISCV_LO12_I, -+ BFD_RELOC_RISCV_LO12_S, -+ BFD_RELOC_RISCV_GPREL12_I, -+ BFD_RELOC_RISCV_GPREL12_S, -+ BFD_RELOC_RISCV_TPREL_HI20, -+ BFD_RELOC_RISCV_TPREL_LO12_I, -+ BFD_RELOC_RISCV_TPREL_LO12_S, -+ BFD_RELOC_RISCV_TPREL_ADD, -+ BFD_RELOC_RISCV_CALL, -+ BFD_RELOC_RISCV_CALL_PLT, -+ BFD_RELOC_RISCV_ADD8, -+ BFD_RELOC_RISCV_ADD16, -+ BFD_RELOC_RISCV_ADD32, -+ BFD_RELOC_RISCV_ADD64, -+ BFD_RELOC_RISCV_SUB8, -+ BFD_RELOC_RISCV_SUB16, -+ BFD_RELOC_RISCV_SUB32, -+ BFD_RELOC_RISCV_SUB64, -+ BFD_RELOC_RISCV_GOT_HI20, -+ BFD_RELOC_RISCV_TLS_GOT_HI20, -+ BFD_RELOC_RISCV_TLS_GD_HI20, -+ BFD_RELOC_RISCV_JMP, -+ BFD_RELOC_RISCV_TLS_DTPMOD32, -+ BFD_RELOC_RISCV_TLS_DTPREL32, -+ BFD_RELOC_RISCV_TLS_DTPMOD64, -+ BFD_RELOC_RISCV_TLS_DTPREL64, -+ BFD_RELOC_RISCV_TLS_TPREL32, -+ BFD_RELOC_RISCV_TLS_TPREL64, -+ BFD_RELOC_RISCV_ALIGN, - - /* H8 elf Relocations. */ - BFD_RELOC_H8_DIR16A8, -@@ -5788,6 +5850,11 @@ - /* This BFD has been created by the linker and doesn't correspond - to any input file. */ - #define BFD_LINKER_CREATED 0x2000 -+ /* This may be set before writing out a BFD to request that it -+ be written using values for UIDs, GIDs, timestamps, etc. that -+ will be consistent from run to run. */ -+#define BFD_DETERMINISTIC_OUTPUT 0x4000 -+ - - /* This may be set before writing out a BFD to request that it - be written using values for UIDs, GIDs, timestamps, etc. that -diff -rNU3 dist.orig/bfd/coff-alpha.c dist/bfd/coff-alpha.c ---- dist.orig/bfd/coff-alpha.c 2012-07-13 16:22:42.000000000 +0200 -+++ dist/bfd/coff-alpha.c 2015-10-18 13:11:12.000000000 +0200 -@@ -642,7 +642,9 @@ - case ALPHA_R_OP_STORE: - /* The STORE reloc needs the size and offset fields. We store - them in the addend. */ -+#if 0 - BFD_ASSERT (intern->r_offset <= 256); -+#endif - rptr->addend = (intern->r_offset << 8) + intern->r_size; - break; - -diff -rNU3 dist.orig/bfd/coff-or32.c dist/bfd/coff-or32.c ---- dist.orig/bfd/coff-or32.c 2012-07-13 16:22:43.000000000 +0200 -+++ dist/bfd/coff-or32.c 1970-01-01 01:00:00.000000000 +0100 -@@ -1,629 +0,0 @@ --/* BFD back-end for OpenRISC 1000 COFF binaries. -- Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2011, 2012 -- Free Software Foundation, Inc. -- Contributed by Ivan Guzvinec -- -- This file is part of BFD, the Binary File Descriptor library. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, -- MA 02110-1301, USA. */ -- --#define OR32 1 -- --#include "sysdep.h" --#include "bfd.h" --#include "libbfd.h" --#include "coff/or32.h" --#include "coff/internal.h" --#include "libcoff.h" -- --static bfd_reloc_status_type or32_reloc -- (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); -- --#define COFF_DEFAULT_SECTION_ALIGNMENT_POWER (2) -- --#define INSERT_HWORD(WORD,HWORD) \ -- (((WORD) & 0xffff0000) | ((HWORD)& 0x0000ffff)) --#define EXTRACT_HWORD(WORD) \ -- ((WORD) & 0x0000ffff) --#define SIGN_EXTEND_HWORD(HWORD) \ -- ((HWORD) & 0x8000 ? (HWORD)|(~0xffffL) : (HWORD)) -- --#define INSERT_JUMPTARG(WORD,JT) \ -- (((WORD) & 0xfc000000) | ((JT)& 0x03ffffff)) --#define EXTRACT_JUMPTARG(WORD) \ -- ((WORD) & 0x03ffffff) --#define SIGN_EXTEND_JUMPTARG(JT) \ -- ((JT) & 0x04000000 ? (JT)|(~0x03ffffffL) : (JT)) -- --/* Provided the symbol, returns the value reffed. */ -- --static long --get_symbol_value (asymbol *symbol) --{ -- long relocation = 0; -- -- if (bfd_is_com_section (symbol->section)) -- relocation = 0; -- else -- relocation = symbol->value + -- symbol->section->output_section->vma + -- symbol->section->output_offset; -- -- return relocation; --} -- --/* This function is in charge of performing all the or32 relocations. */ -- --static bfd_reloc_status_type --or32_reloc (bfd *abfd, -- arelent *reloc_entry, -- asymbol *symbol_in, -- void * data, -- asection *input_section, -- bfd *output_bfd, -- char **error_message) --{ -- /* The consth relocation comes in two parts, we have to remember -- the state between calls, in these variables. */ -- static bfd_boolean part1_consth_active = FALSE; -- static unsigned long part1_consth_value; -- -- unsigned long insn; -- unsigned long sym_value; -- unsigned long unsigned_value; -- unsigned short r_type; -- long signed_value; -- -- unsigned long addr = reloc_entry->address ; /*+ input_section->vma*/ -- bfd_byte *hit_data =addr + (bfd_byte *)(data); -- -- r_type = reloc_entry->howto->type; -- -- if (output_bfd) -- { -- /* Partial linking - do nothing. */ -- reloc_entry->address += input_section->output_offset; -- return bfd_reloc_ok; -- } -- -- if (symbol_in != NULL -- && bfd_is_und_section (symbol_in->section)) -- { -- /* Keep the state machine happy in case we're called again. */ -- if (r_type == R_IHIHALF) -- { -- part1_consth_active = TRUE; -- part1_consth_value = 0; -- } -- -- return bfd_reloc_undefined; -- } -- -- if ((part1_consth_active) && (r_type != R_IHCONST)) -- { -- part1_consth_active = FALSE; -- *error_message = (char *) "Missing IHCONST"; -- -- return bfd_reloc_dangerous; -- } -- -- sym_value = get_symbol_value (symbol_in); -- -- switch (r_type) -- { -- case R_IREL: -- insn = bfd_get_32(abfd, hit_data); -- -- /* Take the value in the field and sign extend it. */ -- signed_value = EXTRACT_JUMPTARG (insn); -- signed_value = SIGN_EXTEND_JUMPTARG (signed_value); -- signed_value <<= 2; -- -- /* See the note on the R_IREL reloc in coff_or32_relocate_section. */ -- if (signed_value == - (long) reloc_entry->address) -- signed_value = 0; -- -- signed_value += sym_value + reloc_entry->addend; -- /* Relative jmp/call, so subtract from the value the -- address of the place we're coming from. */ -- signed_value -= (reloc_entry->address -- + input_section->output_section->vma -- + input_section->output_offset); -- if (signed_value > 0x7ffffff || signed_value < -0x8000000) -- return bfd_reloc_overflow; -- -- signed_value >>= 2; -- insn = INSERT_JUMPTARG (insn, signed_value); -- bfd_put_32 (abfd, insn, hit_data); -- break; -- -- case R_ILOHALF: -- insn = bfd_get_32 (abfd, hit_data); -- unsigned_value = EXTRACT_HWORD (insn); -- unsigned_value += sym_value + reloc_entry->addend; -- insn = INSERT_HWORD (insn, unsigned_value); -- bfd_put_32 (abfd, insn, hit_data); -- break; -- -- case R_IHIHALF: -- insn = bfd_get_32 (abfd, hit_data); -- -- /* consth, part 1 -- Just get the symbol value that is referenced. */ -- part1_consth_active = TRUE; -- part1_consth_value = sym_value + reloc_entry->addend; -- -- /* Don't modify insn until R_IHCONST. */ -- break; -- -- case R_IHCONST: -- insn = bfd_get_32 (abfd, hit_data); -- -- /* consth, part 2 -- Now relocate the reference. */ -- if (! part1_consth_active) -- { -- *error_message = (char *) "Missing IHIHALF"; -- return bfd_reloc_dangerous; -- } -- -- /* sym_ptr_ptr = r_symndx, in coff_slurp_reloc_table() */ -- unsigned_value = 0; /*EXTRACT_HWORD(insn) << 16;*/ -- unsigned_value += reloc_entry->addend; /* r_symndx */ -- unsigned_value += part1_consth_value; -- unsigned_value = unsigned_value >> 16; -- insn = INSERT_HWORD (insn, unsigned_value); -- part1_consth_active = FALSE; -- bfd_put_32 (abfd, insn, hit_data); -- break; -- -- case R_BYTE: -- insn = bfd_get_8 (abfd, hit_data); -- unsigned_value = insn + sym_value + reloc_entry->addend; -- if (unsigned_value & 0xffffff00) -- return bfd_reloc_overflow; -- bfd_put_8 (abfd, unsigned_value, hit_data); -- break; -- -- case R_HWORD: -- insn = bfd_get_16 (abfd, hit_data); -- unsigned_value = insn + sym_value + reloc_entry->addend; -- if (unsigned_value & 0xffff0000) -- return bfd_reloc_overflow; -- bfd_put_16 (abfd, insn, hit_data); -- break; -- -- case R_WORD: -- insn = bfd_get_32 (abfd, hit_data); -- insn += sym_value + reloc_entry->addend; -- bfd_put_32 (abfd, insn, hit_data); -- break; -- -- default: -- *error_message = _("Unrecognized reloc"); -- return bfd_reloc_dangerous; -- } -- -- return bfd_reloc_ok; --} -- --/* type rightshift -- size -- bitsize -- pc-relative -- bitpos -- absolute -- complain_on_overflow -- special_function -- relocation name -- partial_inplace -- src_mask --*/ -- --/* FIXME: I'm not real sure about this table. */ --static reloc_howto_type howto_table[] = --{ -- { R_ABS, 0, 3, 32, FALSE, 0, complain_overflow_bitfield, or32_reloc, "ABS", TRUE, 0xffffffff,0xffffffff, FALSE }, -- EMPTY_HOWTO (1), -- EMPTY_HOWTO (2), -- EMPTY_HOWTO (3), -- EMPTY_HOWTO (4), -- EMPTY_HOWTO (5), -- EMPTY_HOWTO (6), -- EMPTY_HOWTO (7), -- EMPTY_HOWTO (8), -- EMPTY_HOWTO (9), -- EMPTY_HOWTO (10), -- EMPTY_HOWTO (11), -- EMPTY_HOWTO (12), -- EMPTY_HOWTO (13), -- EMPTY_HOWTO (14), -- EMPTY_HOWTO (15), -- EMPTY_HOWTO (16), -- EMPTY_HOWTO (17), -- EMPTY_HOWTO (18), -- EMPTY_HOWTO (19), -- EMPTY_HOWTO (20), -- EMPTY_HOWTO (21), -- EMPTY_HOWTO (22), -- EMPTY_HOWTO (23), -- { R_IREL, 0, 3, 32, TRUE, 0, complain_overflow_signed, or32_reloc, "IREL", TRUE, 0xffffffff,0xffffffff, FALSE }, -- { R_IABS, 0, 3, 32, FALSE, 0, complain_overflow_bitfield, or32_reloc, "IABS", TRUE, 0xffffffff,0xffffffff, FALSE }, -- { R_ILOHALF, 0, 3, 16, TRUE, 0, complain_overflow_signed, or32_reloc, "ILOHALF", TRUE, 0x0000ffff,0x0000ffff, FALSE }, -- { R_IHIHALF, 0, 3, 16, TRUE, 16,complain_overflow_signed, or32_reloc, "IHIHALF", TRUE, 0xffff0000,0xffff0000, FALSE }, -- { R_IHCONST, 0, 3, 16, TRUE, 0, complain_overflow_signed, or32_reloc, "IHCONST", TRUE, 0xffff0000,0xffff0000, FALSE }, -- { R_BYTE, 0, 0, 8, FALSE, 0, complain_overflow_bitfield, or32_reloc, "BYTE", TRUE, 0x000000ff,0x000000ff, FALSE }, -- { R_HWORD, 0, 1, 16, FALSE, 0, complain_overflow_bitfield, or32_reloc, "HWORD", TRUE, 0x0000ffff,0x0000ffff, FALSE }, -- { R_WORD, 0, 2, 32, FALSE, 0, complain_overflow_bitfield, or32_reloc, "WORD", TRUE, 0xffffffff,0xffffffff, FALSE }, --}; -- --#define BADMAG(x) OR32BADMAG (x) -- --#define RELOC_PROCESSING(relent, reloc, symbols, abfd, section) \ -- reloc_processing (relent, reloc, symbols, abfd, section) -- --static void --reloc_processing (arelent *relent, -- struct internal_reloc *reloc, -- asymbol **symbols, -- bfd *abfd, -- asection *section) --{ -- static bfd_vma ihihalf_vaddr = (bfd_vma) -1; -- -- relent->address = reloc->r_vaddr; -- relent->howto = howto_table + reloc->r_type; -- -- if (reloc->r_type == R_IHCONST) -- { -- /* The address of an R_IHCONST should always be the address of -- the immediately preceding R_IHIHALF. relocs generated by gas -- are correct, but relocs generated by High C are different (I -- can't figure out what the address means for High C). We can -- handle both gas and High C by ignoring the address here, and -- simply reusing the address saved for R_IHIHALF. */ -- if (ihihalf_vaddr == (bfd_vma) -1) -- abort (); -- -- relent->address = ihihalf_vaddr; -- ihihalf_vaddr = (bfd_vma) -1; -- relent->addend = reloc->r_symndx; -- relent->sym_ptr_ptr= bfd_abs_section_ptr->symbol_ptr_ptr; -- } -- else -- { -- relent->sym_ptr_ptr = symbols + obj_convert (abfd)[reloc->r_symndx]; -- relent->addend = 0; -- relent->address-= section->vma; -- -- if (reloc->r_type == R_IHIHALF) -- ihihalf_vaddr = relent->address; -- else if (ihihalf_vaddr != (bfd_vma) -1) -- abort (); -- } --} -- --/* The reloc processing routine for the optimized COFF linker. */ -- --static bfd_boolean --coff_or32_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info, -- bfd *input_bfd, -- asection *input_section, -- bfd_byte *contents, -- struct internal_reloc *relocs, -- struct internal_syment *syms, -- asection **sections) --{ -- struct internal_reloc *rel; -- struct internal_reloc *relend; -- bfd_boolean hihalf; -- bfd_vma hihalf_val; -- -- /* If we are performing a relocatable link, we don't need to do a -- thing. The caller will take care of adjusting the reloc -- addresses and symbol indices. */ -- if (info->relocatable) -- return TRUE; -- -- hihalf = FALSE; -- hihalf_val = 0; -- -- rel = relocs; -- relend = rel + input_section->reloc_count; -- -- for (; rel < relend; rel++) -- { -- long symndx; -- bfd_byte *loc; -- struct coff_link_hash_entry *h; -- struct internal_syment *sym; -- asection *sec; -- bfd_vma val; -- bfd_boolean overflow; -- unsigned long insn; -- long signed_value; -- unsigned long unsigned_value; -- bfd_reloc_status_type rstat; -- -- symndx = rel->r_symndx; -- loc = contents + rel->r_vaddr - input_section->vma; -- -- if (symndx == -1 || rel->r_type == R_IHCONST) -- h = NULL; -- else -- h = obj_coff_sym_hashes (input_bfd)[symndx]; -- -- sym = NULL; -- sec = NULL; -- val = 0; -- -- /* An R_IHCONST reloc does not have a symbol. Instead, the -- symbol index is an addend. R_IHCONST is always used in -- conjunction with R_IHHALF. */ -- if (rel->r_type != R_IHCONST) -- { -- if (h == NULL) -- { -- if (symndx == -1) -- sec = bfd_abs_section_ptr; -- else -- { -- sym = syms + symndx; -- sec = sections[symndx]; -- val = (sec->output_section->vma -- + sec->output_offset -- + sym->n_value -- - sec->vma); -- } -- } -- else -- { -- if (h->root.type == bfd_link_hash_defined -- || h->root.type == bfd_link_hash_defweak) -- { -- sec = h->root.u.def.section; -- val = (h->root.u.def.value -- + sec->output_section->vma -- + sec->output_offset); -- } -- else -- { -- if (! ((*info->callbacks->undefined_symbol) -- (info, h->root.root.string, input_bfd, input_section, -- rel->r_vaddr - input_section->vma, TRUE))) -- return FALSE; -- } -- } -- -- if (hihalf) -- { -- if (! ((*info->callbacks->reloc_dangerous) -- (info, "missing IHCONST reloc", input_bfd, -- input_section, rel->r_vaddr - input_section->vma))) -- return FALSE; -- hihalf = FALSE; -- } -- } -- -- overflow = FALSE; -- -- switch (rel->r_type) -- { -- default: -- bfd_set_error (bfd_error_bad_value); -- return FALSE; -- -- case R_IREL: -- insn = bfd_get_32 (input_bfd, loc); -- -- /* Extract the addend. */ -- signed_value = EXTRACT_JUMPTARG (insn); -- signed_value = SIGN_EXTEND_JUMPTARG (signed_value); -- signed_value <<= 2; -- -- /* Determine the destination of the jump. */ -- signed_value += val; -- -- /* Make the destination PC relative. */ -- signed_value -= (input_section->output_section->vma -- + input_section->output_offset -- + (rel->r_vaddr - input_section->vma)); -- if (signed_value > 0x7ffffff || signed_value < - 0x8000000) -- { -- overflow = TRUE; -- signed_value = 0; -- } -- -- /* Put the adjusted value back into the instruction. */ -- signed_value >>= 2; -- insn = INSERT_JUMPTARG(insn, signed_value); -- -- bfd_put_32 (input_bfd, (bfd_vma) insn, loc); -- break; -- -- case R_ILOHALF: -- insn = bfd_get_32 (input_bfd, loc); -- unsigned_value = EXTRACT_HWORD (insn); -- unsigned_value += val; -- insn = INSERT_HWORD (insn, unsigned_value); -- bfd_put_32 (input_bfd, insn, loc); -- break; -- -- case R_IHIHALF: -- /* Save the value for the R_IHCONST reloc. */ -- hihalf = TRUE; -- hihalf_val = val; -- break; -- -- case R_IHCONST: -- if (! hihalf) -- { -- if (! ((*info->callbacks->reloc_dangerous) -- (info, "missing IHIHALF reloc", input_bfd, -- input_section, rel->r_vaddr - input_section->vma))) -- return FALSE; -- hihalf_val = 0; -- } -- -- insn = bfd_get_32 (input_bfd, loc); -- unsigned_value = rel->r_symndx + hihalf_val; -- unsigned_value >>= 16; -- insn = INSERT_HWORD (insn, unsigned_value); -- bfd_put_32 (input_bfd, (bfd_vma) insn, loc); -- -- hihalf = FALSE; -- break; -- -- case R_BYTE: -- case R_HWORD: -- case R_WORD: -- rstat = _bfd_relocate_contents (howto_table + rel->r_type, -- input_bfd, val, loc); -- if (rstat == bfd_reloc_overflow) -- overflow = TRUE; -- else if (rstat != bfd_reloc_ok) -- abort (); -- break; -- } -- -- if (overflow) -- { -- const char *name; -- char buf[SYMNMLEN + 1]; -- -- if (symndx == -1) -- name = "*ABS*"; -- else if (h != NULL) -- name = NULL; -- else if (sym == NULL) -- name = "*unknown*"; -- else if (sym->_n._n_n._n_zeroes == 0 -- && sym->_n._n_n._n_offset != 0) -- name = obj_coff_strings (input_bfd) + sym->_n._n_n._n_offset; -- else -- { -- strncpy (buf, sym->_n._n_name, SYMNMLEN); -- buf[SYMNMLEN] = '\0'; -- name = buf; -- } -- -- if (! ((*info->callbacks->reloc_overflow) -- (info, (h ? &h->root : NULL), name, -- howto_table[rel->r_type].name, (bfd_vma) 0, input_bfd, -- input_section, rel->r_vaddr - input_section->vma))) -- return FALSE; -- } -- } -- -- return TRUE; --} -- --#define coff_relocate_section coff_or32_relocate_section -- --/* We don't want to change the symndx of a R_IHCONST reloc, since it -- is actually an addend, not a symbol index at all. */ -- --static bfd_boolean --coff_or32_adjust_symndx (bfd *obfd ATTRIBUTE_UNUSED, -- struct bfd_link_info *info ATTRIBUTE_UNUSED, -- bfd *ibfd ATTRIBUTE_UNUSED, -- asection *sec ATTRIBUTE_UNUSED, -- struct internal_reloc *irel, -- bfd_boolean *adjustedp) --{ -- if (irel->r_type == R_IHCONST) -- *adjustedp = TRUE; -- else -- *adjustedp = FALSE; -- return TRUE; --} -- --#define coff_adjust_symndx coff_or32_adjust_symndx -- --#ifndef bfd_pe_print_pdata --#define bfd_pe_print_pdata NULL --#endif -- --#include "coffcode.h" -- --const bfd_target or32coff_big_vec = --{ -- "coff-or32-big", /* Name. */ -- bfd_target_coff_flavour, -- BFD_ENDIAN_BIG, /* Data byte order is big. */ -- BFD_ENDIAN_BIG, /* Header byte order is big. */ -- -- (HAS_RELOC | EXEC_P | /* Object flags. */ -- HAS_LINENO | HAS_DEBUG | -- HAS_SYMS | HAS_LOCALS | WP_TEXT), -- -- (SEC_HAS_CONTENTS | SEC_ALLOC | /* Section flags. */ -- SEC_LOAD | SEC_RELOC | -- SEC_READONLY ), -- '_', /* Leading underscore. */ -- '/', /* ar_pad_char. */ -- 15, /* ar_max_namelen. */ -- 0, /* match priority. */ -- -- /* Data. */ -- bfd_getb64, bfd_getb_signed_64, bfd_putb64, -- bfd_getb32, bfd_getb_signed_32, bfd_putb32, -- bfd_getb16, bfd_getb_signed_16, bfd_putb16, -- -- /* Headers. */ -- bfd_getb64, bfd_getb_signed_64, bfd_putb64, -- bfd_getb32, bfd_getb_signed_32, bfd_putb32, -- bfd_getb16, bfd_getb_signed_16, bfd_putb16, -- -- { -- _bfd_dummy_target, -- coff_object_p, -- bfd_generic_archive_p, -- _bfd_dummy_target -- }, -- { -- bfd_false, -- coff_mkobject, -- _bfd_generic_mkarchive, -- bfd_false -- }, -- { -- bfd_false, -- coff_write_object_contents, -- _bfd_write_archive_contents, -- bfd_false -- }, -- -- BFD_JUMP_TABLE_GENERIC (coff), -- BFD_JUMP_TABLE_COPY (coff), -- BFD_JUMP_TABLE_CORE (_bfd_nocore), -- BFD_JUMP_TABLE_ARCHIVE (_bfd_archive_coff), -- BFD_JUMP_TABLE_SYMBOLS (coff), -- BFD_JUMP_TABLE_RELOCS (coff), -- BFD_JUMP_TABLE_WRITE (coff), -- BFD_JUMP_TABLE_LINK (coff), -- BFD_JUMP_TABLE_DYNAMIC (_bfd_nodynamic), -- -- /* Alternative_target. */ --#ifdef TARGET_LITTLE_SYM -- & TARGET_LITTLE_SYM, --#else -- NULL, --#endif -- -- COFF_SWAP_TABLE --}; -diff -rNU3 dist.orig/bfd/coffcode.h dist/bfd/coffcode.h ---- dist.orig/bfd/coffcode.h 2011-09-27 18:03:49.000000000 +0200 -+++ dist/bfd/coffcode.h 2015-10-18 13:11:12.000000000 +0200 -@@ -2083,12 +2083,6 @@ - machine = 0; - switch (internal_f->f_magic) - { --#ifdef OR32_MAGIC_BIG -- case OR32_MAGIC_BIG: -- case OR32_MAGIC_LITTLE: -- arch = bfd_arch_or32; -- break; --#endif - #ifdef PPCMAGIC - case PPCMAGIC: - arch = bfd_arch_powerpc; -@@ -3055,15 +3049,6 @@ - return TRUE; - #endif - --#ifdef OR32_MAGIC_BIG -- case bfd_arch_or32: -- if (bfd_big_endian (abfd)) -- * magicp = OR32_MAGIC_BIG; -- else -- * magicp = OR32_MAGIC_LITTLE; -- return TRUE; --#endif -- - default: /* Unknown architecture. */ - /* Fall through to "return FALSE" below, to avoid - "statement never reached" errors on the one below. */ -diff -rNU3 dist.orig/bfd/config.bfd dist/bfd/config.bfd ---- dist.orig/bfd/config.bfd 2012-09-04 16:14:59.000000000 +0200 -+++ dist/bfd/config.bfd 2015-10-18 13:11:12.000000000 +0200 -@@ -86,16 +86,18 @@ - i[3-7]86) targ_archs=bfd_i386_arch ;; - i370) targ_archs=bfd_i370_arch ;; - lm32) targ_archs=bfd_lm32_arch ;; -+m5200|m5407) targ_archs=bfd_m68k_arch ;; - m6811*|m68hc11*) targ_archs="bfd_m68hc11_arch bfd_m68hc12_arch bfd_m9s12x_arch bfd_m9s12xg_arch" ;; - m6812*|m68hc12*) targ_archs="bfd_m68hc12_arch bfd_m68hc11_arch bfd_m9s12x_arch bfd_m9s12xg_arch" ;; - m68*) targ_archs=bfd_m68k_arch ;; - m88*) targ_archs=bfd_m88k_arch ;; - microblaze*) targ_archs=bfd_microblaze_arch ;; - mips*) targ_archs=bfd_mips_arch ;; --or32*) targ_archs=bfd_or32_arch ;; -+or1k*) targ_archs=bfd_or1k_arch ;; - pdp11*) targ_archs=bfd_pdp11_arch ;; - pj*) targ_archs="bfd_pj_arch bfd_i386_arch";; - powerpc*) targ_archs="bfd_rs6000_arch bfd_powerpc_arch" ;; -+riscv*) targ_archs=bfd_riscv_arch ;; - rs6000) targ_archs="bfd_rs6000_arch bfd_powerpc_arch" ;; - s390*) targ_archs=bfd_s390_arch ;; - sh*) targ_archs=bfd_sh_arch ;; -@@ -164,6 +166,16 @@ - targ_selvecs="bfd_elf64_littleaarch64_vec bfd_elf32_bigarm_vec bfd_elf32_littlearm_vec" - want64=true - ;; -+ aarch64-*-netbsd*) -+ targ_defvec=bfd_elf64_littleaarch64_vec -+ targ_selvecs="bfd_elf64_bigaarch64_vec bfd_elf32_littlearm_vec bfd_elf32_bigarm_vec" -+ want64=true -+ ;; -+ aarch64_be-*-netbsd*) -+ targ_defvec=bfd_elf64_bigaarch64_vec -+ targ_selvecs="bfd_elf64_littleaarch64_vec bfd_elf32_bigarm_vec bfd_elf32_littlearm_vec" -+ want64=true -+ ;; - alpha*-*-freebsd* | alpha*-*-kfreebsd*-gnu) - targ_defvec=bfd_elf64_alpha_freebsd_vec - targ_selvecs="bfd_elf64_alpha_vec ecoffalpha_little_vec" -@@ -250,17 +262,17 @@ - targ64_selvecs="bfd_elf32_x86_64_nacl_vec bfd_elf64_x86_64_nacl_vec" - targ_archs="$targ_archs bfd_i386_arch" - ;; -- armeb-*-netbsdelf*) -+ arm*eb-*-netbsdelf*) - targ_defvec=bfd_elf32_bigarm_vec -- targ_selvecs="bfd_elf32_littlearm_vec armnetbsd_vec" -+ targ_selvecs="bfd_elf32_littlearm_vec armnetbsd_vec armcoff_little_vec armcoff_big_vec" - ;; -- arm-*-netbsdelf*) -+ arm*-*-netbsdelf*) - targ_defvec=bfd_elf32_littlearm_vec -- targ_selvecs="bfd_elf32_bigarm_vec armnetbsd_vec" -+ targ_selvecs="bfd_elf32_bigarm_vec armnetbsd_vec armcoff_little_vec armcoff_big_vec" - ;; - arm-*-netbsd* | arm-*-openbsd*) - targ_defvec=armnetbsd_vec -- targ_selvecs="bfd_elf32_littlearm_vec bfd_elf32_bigarm_vec" -+ targ_selvecs="bfd_elf32_littlearm_vec bfd_elf32_bigarm_vec armcoff_little_vec armcoff_big_vec" - targ_underscore=yes - targ_cflags=-D__QNXTARGET__ - ;; -@@ -574,8 +586,8 @@ - ;; - i[3-7]86-*-netbsdelf* | i[3-7]86-*-netbsd*-gnu* | i[3-7]86-*-knetbsd*-gnu) - targ_defvec=bfd_elf32_i386_vec -- targ_selvecs=i386netbsd_vec -- targ64_selvecs="bfd_elf64_x86_64_vec bfd_elf64_l1om_vec bfd_elf64_k1om_vec" -+ targ_selvecs="i386netbsd_vec i386coff_vec i386pei_vec" -+ targ64_selvecs="bfd_elf64_x86_64_vec x86_64pei_vec bfd_elf64_l1om_vec bfd_elf64_k1om_vec" - ;; - i[3-7]86-*-netbsdpe*) - targ_defvec=i386pe_vec -@@ -845,12 +857,12 @@ - # targ_selvecs=m68kmach3_vec - # targ_cflags=-DSTAT_FOR_EXEC - ;; -- m68*-hp*-netbsd*) -+ m68k4k*-*-netbsd*) - targ_defvec=m68k4knetbsd_vec -- targ_selvecs="m68knetbsd_vec hp300bsd_vec sunos_big_vec" -+ targ_selvecs="m68knetbsd_vec hp300bsd_vec sunos_big_vec bfd_elf32_m68k_vec" - targ_underscore=yes - ;; -- m68*-*-netbsdelf*) -+ m68*-*-netbsdelf* | m5407-*-netbsdelf*) - targ_defvec=bfd_elf32_m68k_vec - targ_selvecs="m68knetbsd_vec m68k4knetbsd_vec hp300bsd_vec sunos_big_vec" - ;; -@@ -923,6 +935,16 @@ - targ_defvec=ecoff_big_vec - targ_selvecs=ecoff_little_vec - ;; -+#ifdef BFD64 -+ mips64*el-*-netbsd*) -+ targ_defvec=bfd_elf32_ntradlittlemips_vec -+ targ_selvecs="bfd_elf64_tradbigmips_vec bfd_elf64_tradlittlemips_vec bfd_elf32_ntradbigmips_vec bfd_elf32_tradlittlemips_vec bfd_elf32_tradbigmips_vec" -+ ;; -+ mips64*-*-netbsd*) -+ targ_defvec=bfd_elf32_ntradbigmips_vec -+ targ_selvecs="bfd_elf64_tradbigmips_vec bfd_elf64_tradlittlemips_vec bfd_elf32_ntradlittlemips_vec bfd_elf32_tradlittlemips_vec bfd_elf32_tradbigmips_vec" -+ ;; -+#endif - mips*el-*-netbsd*) - targ_defvec=bfd_elf32_tradlittlemips_vec - targ_selvecs="bfd_elf32_tradbigmips_vec bfd_elf64_tradbigmips_vec bfd_elf64_tradlittlemips_vec ecoff_little_vec ecoff_big_vec" -@@ -1102,17 +1124,16 @@ - targ_underscore=yes - ;; - -- openrisc-*-elf) -- targ_defvec=bfd_elf32_openrisc_vec -+ or1k*-*-elf) -+ targ_defvec=bfd_elf32_or1k_big_vec - ;; - -- or32-*-coff) -- targ_defvec=or32coff_big_vec -- targ_underscore=yes -+ or1k*-*-linux*) -+ targ_defvec=bfd_elf32_or1k_big_vec - ;; - -- or32-*-elf) -- targ_defvec=bfd_elf32_or32_big_vec -+ or1k*-*-netbsd*) -+ targ_defvec=bfd_elf32_or1k_big_vec - ;; - - pdp11-*-*) -@@ -1252,6 +1273,14 @@ - targ_defvec=bfd_elf32_rl78_vec - ;; - -+#ifdef BFD64 -+ riscv*-*-*) -+ targ_defvec=bfd_elf64_riscv_vec -+ targ_selvecs="bfd_elf32_riscv_vec bfd_elf64_riscv_vec" -+ want64=true -+ ;; -+#endif -+ - rx-*-elf) - targ_defvec=bfd_elf32_rx_le_vec - targ_selvecs="bfd_elf32_rx_be_vec bfd_elf32_rx_le_vec bfd_elf32_rx_be_ns_vec" -@@ -1347,6 +1376,8 @@ - want64=true - ;; - -+#endif -+ - sh*l*-*-netbsdelf*) - targ_defvec=bfd_elf32_shlnbsd_vec - targ_selvecs="bfd_elf32_shnbsd_vec shcoff_vec shlcoff_vec bfd_elf32_sh64lnbsd_vec bfd_elf32_sh64nbsd_vec bfd_elf64_sh64lnbsd_vec bfd_elf64_sh64nbsd_vec" -@@ -1357,8 +1388,6 @@ - targ_selvecs="bfd_elf32_shlnbsd_vec shcoff_vec shlcoff_vec bfd_elf32_sh64lnbsd_vec bfd_elf32_sh64nbsd_vec bfd_elf64_sh64lnbsd_vec bfd_elf64_sh64nbsd_vec" - want64=true - ;; --#endif -- - sh*-*-netbsdelf*) - targ_defvec=bfd_elf32_shnbsd_vec - targ_selvecs="bfd_elf32_shlnbsd_vec shcoff_vec shlcoff_vec" -@@ -1448,11 +1477,12 @@ - ;; - sparc-*-netbsdelf*) - targ_defvec=bfd_elf32_sparc_vec -- targ_selvecs=sparcnetbsd_vec -+ targ_selvecs="sparcnetbsd_vec sunos_big_vec" -+ want64=true - ;; -- sparc-*-netbsdaout* | sparc-*-netbsd*) -+ sparc-*-netbsd*) - targ_defvec=sparcnetbsd_vec -- targ_selvecs=bfd_elf32_sparc_vec -+ targ_selvecs="bfd_elf32_sparc_vec sunos_big_vec" - targ_underscore=yes - ;; - sparc-*-openbsd[0-2].* | sparc-*-openbsd3.[0-1]) -@@ -1500,6 +1530,10 @@ - targ_selvecs="bfd_elf32_sparc_vec sparclinux_vec sunos_big_vec" - want64=true - ;; -+ sparc64-*-netbsd*) -+ targ_defvec=bfd_elf64_sparc_vec -+ targ_selvecs="bfd_elf32_sparc_vec sparcnetbsd_vec sunos_big_vec" -+ ;; - sparc64-*-elf* | sparc64-*-rtems* ) - targ_defvec=bfd_elf64_sparc_vec - targ_selvecs=bfd_elf32_sparc_vec -diff -rNU3 dist.orig/bfd/configure dist/bfd/configure ---- dist.orig/bfd/configure 2013-03-25 10:08:07.000000000 +0100 -+++ dist/bfd/configure 2015-10-18 13:11:12.000000000 +0200 -@@ -12101,10 +12101,10 @@ - withval=$with_pkgversion; case "$withval" in - yes) as_fn_error "package version not specified" "$LINENO" 5 ;; - no) PKGVERSION= ;; -- *) PKGVERSION="($withval) " ;; -+ *) PKGVERSION="($withval)\ " ;; - esac - else -- PKGVERSION="(GNU Binutils) " -+ PKGVERSION="(GNU Binutils)\ " - - fi - -@@ -13861,6 +13861,7 @@ - COREFILE=netbsd-core.lo - ;; - arm-*-riscix) COREFILE=trad-core.lo ;; -+ arm*-*-netbsd*) COREFILE=netbsd-core.lo ;; - hppa*-*-hpux*) COREFILE=hpux-core.lo ;; - hppa*-*-hiux*) COREFILE=hpux-core.lo ;; - hppa*-*-mpeix*) COREFILE=hpux-core.lo ;; -@@ -13923,7 +13924,7 @@ - COREFILE=trad-core.lo - TRAD_HEADER='"hosts/i860mach3.h"' - ;; -- mips-*-netbsd* | mips*-*-openbsd*) -+ mips*-*-netbsd* | mips*-*-openbsd*) - COREFILE=netbsd-core.lo - ;; - mips-dec-*) -@@ -15278,14 +15279,14 @@ - tb="$tb elfn32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; - bfd_elf32_ntradlittlemips_vec | bfd_elf32_ntradlittlemips_freebsd_vec) - tb="$tb elfn32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; -- bfd_elf32_openrisc_vec) tb="$tb elf32-openrisc.lo elf32.lo $elf" ;; -- bfd_elf32_or32_big_vec) tb="$tb elf32-or32.lo elf32.lo $elf" ;; -+ bfd_elf32_or1k_big_vec) tb="$tb elf32-or1k.lo elf32.lo $elf" ;; - bfd_elf32_pj_vec) tb="$tb elf32-pj.lo elf32.lo $elf";; - bfd_elf32_pjl_vec) tb="$tb elf32-pj.lo elf32.lo $elf";; - bfd_elf32_powerpc_vec) tb="$tb elf32-ppc.lo elf-vxworks.lo elf32.lo $elf" ;; - bfd_elf32_powerpcle_vec) tb="$tb elf32-ppc.lo elf-vxworks.lo elf32.lo $elf" ;; - bfd_elf32_powerpc_freebsd_vec) tb="$tb elf32-ppc.lo elf-vxworks.lo elf32.lo $elf" ;; - bfd_elf32_powerpc_vxworks_vec) tb="$tb elf32-ppc.lo elf-vxworks.lo elf32.lo $elf" ;; -+ bfd_elf32_riscv_vec) tb="$tb elf32-riscv.lo elfxx-riscv.lo elf32.lo $elf" ;; - bfd_elf32_rl78_vec) tb="$tb elf32-rl78.lo $elf" ;; - bfd_elf32_rx_le_vec) tb="$tb elf32-rx.lo elf32.lo $elf" ;; - bfd_elf32_rx_be_vec) tb="$tb elf32-rx.lo elf32.lo $elf" ;; -@@ -15356,6 +15357,7 @@ - bfd_elf64_powerpc_vec) tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf"; target_size=64 ;; - bfd_elf64_powerpcle_vec) tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf" target_size=64 ;; - bfd_elf64_powerpc_freebsd_vec) tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf" target_size=64 ;; -+ bfd_elf64_riscv_vec) tb="$tb elf64-riscv.lo elf64.lo elfxx-riscv.lo elf32.lo $elf"; target_size=64 ;; - bfd_elf64_s390_vec) tb="$tb elf64-s390.lo elf64.lo $elf"; target_size=64 ;; - bfd_elf64_sh64_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;; - bfd_elf64_sh64l_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;; -@@ -15447,7 +15449,6 @@ - nlm32_i386_vec) tb="$tb nlm32-i386.lo nlm32.lo nlm.lo" ;; - nlm32_powerpc_vec) tb="$tb nlm32-ppc.lo nlm32.lo nlm.lo" ;; - nlm32_sparc_vec) tb="$tb nlm32-sparc.lo nlm32.lo nlm.lo" ;; -- or32coff_big_vec) tb="$tb coff-or32.lo cofflink.lo" ;; - pc532machaout_vec) tb="$tb pc532-mach.lo aout-ns32k.lo" ;; - pc532netbsd_vec) tb="$tb ns32knetbsd.lo aout-ns32k.lo" ;; - pef_vec) tb="$tb pef.lo" ;; -diff -rNU3 dist.orig/bfd/configure.host dist/bfd/configure.host ---- dist.orig/bfd/configure.host 2010-12-31 12:00:52.000000000 +0100 -+++ dist/bfd/configure.host 2015-10-18 13:11:12.000000000 +0200 -@@ -57,6 +57,18 @@ - - m68*-hp-hpux*) HDEFINES=-DHOST_HP300HPUX ;; - -+sparc64*-*-netbsd*) host64=true; HOST_64BIT_TYPE=long ;; -+ -+x86_64*-*-netbsd*) host64=true; HOST_64BIT_TYPE=long ;; -+ -+*-*-aix*) HOST_64BIT_TYPE="long long" -+ HOST_U_64BIT_TYPE="unsigned long long" -+ ;; -+ -+*-*-solaris*) HOST_64BIT_TYPE="long long" -+ HOST_U_64BIT_TYPE="unsigned long long" -+ ;; -+ - # Some Solaris systems (osol0906 at least) have a libc that doesn't recognise - # the "MS-ANSI" code page name, so we define an override for CP_ACP (sets the - # default code page used by windres/windmc when not specified by a commandline -diff -rNU3 dist.orig/bfd/configure.in dist/bfd/configure.in ---- dist.orig/bfd/configure.in 2013-03-25 10:08:05.000000000 +0100 -+++ dist/bfd/configure.in 2015-10-18 13:11:12.000000000 +0200 -@@ -254,6 +254,7 @@ - COREFILE=netbsd-core.lo - ;; - arm-*-riscix) COREFILE=trad-core.lo ;; -+ arm*-*-netbsd*) COREFILE=netbsd-core.lo ;; - hppa*-*-hpux*) COREFILE=hpux-core.lo ;; - hppa*-*-hiux*) COREFILE=hpux-core.lo ;; - hppa*-*-mpeix*) COREFILE=hpux-core.lo ;; -@@ -340,7 +341,7 @@ - COREFILE=trad-core.lo - TRAD_HEADER='"hosts/i860mach3.h"' - ;; -- mips-*-netbsd* | mips*-*-openbsd*) -+ mips*-*-netbsd* | mips*-*-openbsd*) - COREFILE=netbsd-core.lo - ;; - mips-dec-*) -@@ -771,7 +772,8 @@ - bfd_elf32_ntradlittlemips_vec | bfd_elf32_ntradlittlemips_freebsd_vec) - tb="$tb elfn32-mips.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; - bfd_elf32_openrisc_vec) tb="$tb elf32-openrisc.lo elf32.lo $elf" ;; -- bfd_elf32_or32_big_vec) tb="$tb elf32-or32.lo elf32.lo $elf" ;; -+ bfd_elf32_or1k_big_vec) tb="$tb elf32-or1k.lo elf32.lo $elf" ;; -+ bfd_elf32_riscv_vec) tb="$tb elf32-riscv.lo elfxx-riscv.lo elf32.lo $elf"; target_size=64 ;; - bfd_elf32_pj_vec) tb="$tb elf32-pj.lo elf32.lo $elf";; - bfd_elf32_pjl_vec) tb="$tb elf32-pj.lo elf32.lo $elf";; - bfd_elf32_powerpc_vec) tb="$tb elf32-ppc.lo elf-vxworks.lo elf32.lo $elf" ;; -@@ -835,6 +837,7 @@ - bfd_elf64_bigaarch64_vec) tb="$tb elf64-aarch64.lo elf64.lo $elf"; target_size=64 ;; - bfd_elf64_big_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;; - bfd_elf64_bigmips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; -+ bfd_elf32_m32c_vec) tb="$tb elf32-m32c.lo elf32.lo $elf" ;; - bfd_elf64_hppa_linux_vec) tb="$tb elf64-hppa.lo elf64.lo $elf"; target_size=64 ;; - bfd_elf64_hppa_vec) tb="$tb elf64-hppa.lo elf64.lo $elf"; target_size=64 ;; - bfd_elf64_ia64_big_vec) tb="$tb elf64-ia64.lo elfxx-ia64.lo elf64.lo $elf"; target_size=64 ;; -@@ -844,10 +847,12 @@ - bfd_elf64_littleaarch64_vec)tb="$tb elf64-aarch64.lo elf64.lo $elf"; target_size=64 ;; - bfd_elf64_little_generic_vec) tb="$tb elf64-gen.lo elf64.lo $elf"; target_size=64 ;; - bfd_elf64_littlemips_vec) tb="$tb elf64-mips.lo elf64.lo elfxx-mips.lo elf-vxworks.lo elf32.lo $elf ecofflink.lo"; target_size=64 ;; -+ bfd_elf32_m32c_vec) tb="$tb elf32-m32c.lo elf32.lo $elf" ;; - bfd_elf64_mmix_vec) tb="$tb elf64-mmix.lo elf64.lo $elf" target_size=64 ;; - bfd_elf64_powerpc_vec) tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf"; target_size=64 ;; - bfd_elf64_powerpcle_vec) tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf" target_size=64 ;; - bfd_elf64_powerpc_freebsd_vec) tb="$tb elf64-ppc.lo elf64-gen.lo elf64.lo $elf" target_size=64 ;; -+ bfd_elf64_riscv_vec) tb="$tb elf64-riscv.lo elf64.lo elfxx-riscv.lo elf32.lo $elf"; target_size=64 ;; - bfd_elf64_s390_vec) tb="$tb elf64-s390.lo elf64.lo $elf"; target_size=64 ;; - bfd_elf64_sh64_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;; - bfd_elf64_sh64l_vec) tb="$tb elf64-sh64.lo elf64.lo $elf" target_size=64 ;; -@@ -939,7 +944,6 @@ - nlm32_i386_vec) tb="$tb nlm32-i386.lo nlm32.lo nlm.lo" ;; - nlm32_powerpc_vec) tb="$tb nlm32-ppc.lo nlm32.lo nlm.lo" ;; - nlm32_sparc_vec) tb="$tb nlm32-sparc.lo nlm32.lo nlm.lo" ;; -- or32coff_big_vec) tb="$tb coff-or32.lo cofflink.lo" ;; - pc532machaout_vec) tb="$tb pc532-mach.lo aout-ns32k.lo" ;; - pc532netbsd_vec) tb="$tb ns32knetbsd.lo aout-ns32k.lo" ;; - pef_vec) tb="$tb pef.lo" ;; -diff -rNU3 dist.orig/bfd/cpu-or1k.c dist/bfd/cpu-or1k.c ---- dist.orig/bfd/cpu-or1k.c 1970-01-01 01:00:00.000000000 +0100 -+++ dist/bfd/cpu-or1k.c 2015-10-18 13:11:12.000000000 +0200 -@@ -0,0 +1,61 @@ -+/* BFD support for the OpenRISC 1000 architecture. -+ Copyright 2002, 2005, 2007 Free Software Foundation, Inc. -+ Contributed by Ivan Guzvinec -+ -+ This file is part of BFD, the Binary File Descriptor library. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, write to the Free Software -+ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, -+ MA 02110-1301, USA. */ -+ -+#include "sysdep.h" -+#include "bfd.h" -+#include "libbfd.h" -+ -+extern const bfd_arch_info_type bfd_or1knd_arch; -+ -+const bfd_arch_info_type bfd_or1k_arch = -+ { -+ 32, /* 32 bits in a word. */ -+ 32, /* 32 bits in an address. */ -+ 8, /* 8 bits in a byte. */ -+ bfd_arch_or1k, -+ bfd_mach_or1k, -+ "or1k", -+ "or1k", -+ 4, -+ TRUE, /* The one and only. */ -+ bfd_default_compatible, -+ bfd_default_scan, -+ bfd_arch_default_fill, -+ &bfd_or1knd_arch, -+ }; -+ -+ -+const bfd_arch_info_type bfd_or1knd_arch = -+ { -+ 32, /* 32 bits in a word. */ -+ 32, /* 32 bits in an address. */ -+ 8, /* 8 bits in a byte. */ -+ bfd_arch_or1k, -+ bfd_mach_or1knd, -+ "or1knd", -+ "or1knd", -+ 4, -+ TRUE, /* The one and only. */ -+ bfd_default_compatible, -+ bfd_default_scan, -+ bfd_arch_default_fill, -+ 0, -+ }; -diff -rNU3 dist.orig/bfd/cpu-or32.c dist/bfd/cpu-or32.c ---- dist.orig/bfd/cpu-or32.c 2012-01-31 18:54:35.000000000 +0100 -+++ dist/bfd/cpu-or32.c 1970-01-01 01:00:00.000000000 +0100 -@@ -1,42 +0,0 @@ --/* BFD support for the OpenRISC 1000 architecture. -- Copyright 2002, 2005, 2007 Free Software Foundation, Inc. -- Contributed by Ivan Guzvinec -- -- This file is part of BFD, the Binary File Descriptor library. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, -- MA 02110-1301, USA. */ -- --#include "sysdep.h" --#include "bfd.h" --#include "libbfd.h" -- --const bfd_arch_info_type bfd_or32_arch = -- { -- 32, /* 32 bits in a word. */ -- 32, /* 32 bits in an address. */ -- 8, /* 8 bits in a byte. */ -- bfd_arch_or32, -- 0, /* Only 1 machine. */ -- "or32", -- "or32", -- 4, -- TRUE, /* The one and only. */ -- bfd_default_compatible, -- bfd_default_scan, -- bfd_arch_default_fill, -- 0, -- }; -- -diff -rNU3 dist.orig/bfd/cpu-riscv.c dist/bfd/cpu-riscv.c ---- dist.orig/bfd/cpu-riscv.c 1970-01-01 01:00:00.000000000 +0100 -+++ dist/bfd/cpu-riscv.c 2015-10-18 13:11:12.000000000 +0200 -@@ -0,0 +1,80 @@ -+/* BFD backend for RISC-V -+ Copyright 2011-2014 Free Software Foundation, Inc. -+ -+ Contributed by Andrew Waterman (waterman@cs.berkeley.edu) at UC Berkeley. -+ Based on MIPS target. -+ -+ This file is part of BFD, the Binary File Descriptor library. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, write to the Free Software -+ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, -+ MA 02110-1301, USA. */ -+ -+#include "sysdep.h" -+#include "bfd.h" -+#include "libbfd.h" -+ -+static const bfd_arch_info_type *riscv_compatible -+ (const bfd_arch_info_type *, const bfd_arch_info_type *); -+ -+/* The default routine tests bits_per_word, which is wrong on RISC-V, as -+ RISC-V word size doesn't correlate with reloc size. */ -+ -+static const bfd_arch_info_type * -+riscv_compatible (const bfd_arch_info_type *a, const bfd_arch_info_type *b) -+{ -+ if (a->arch != b->arch) -+ return NULL; -+ -+ /* Machine compatibility is checked in -+ _bfd_riscv_elf_merge_private_bfd_data. */ -+ -+ return a; -+} -+ -+#define N(BITS_WORD, BITS_ADDR, NUMBER, PRINT, DEFAULT, NEXT) \ -+ { \ -+ BITS_WORD, /* bits in a word */ \ -+ BITS_ADDR, /* bits in an address */ \ -+ 8, /* 8 bits in a byte */ \ -+ bfd_arch_riscv, \ -+ NUMBER, \ -+ "riscv", \ -+ PRINT, \ -+ 3, \ -+ DEFAULT, \ -+ riscv_compatible, \ -+ bfd_default_scan, \ -+ bfd_arch_default_fill, \ -+ NEXT, \ -+ } -+ -+enum -+{ -+ I_riscv64, -+ I_riscv32 -+}; -+ -+#define NN(index) (&arch_info_struct[(index) + 1]) -+ -+static const bfd_arch_info_type arch_info_struct[] = -+{ -+ N (64, 64, bfd_mach_riscv64, "riscv:rv64", FALSE, NN(I_riscv64)), -+ N (32, 32, bfd_mach_riscv32, "riscv:rv32", FALSE, 0) -+}; -+ -+/* The default architecture is riscv:rv64. */ -+ -+const bfd_arch_info_type bfd_riscv_arch = -+N (64, 64, 0, "riscv", TRUE, &arch_info_struct[0]); -diff -rNU3 dist.orig/bfd/doc/Makefile.in dist/bfd/doc/Makefile.in ---- dist.orig/bfd/doc/Makefile.in 2013-03-25 10:08:08.000000000 +0100 -+++ dist/bfd/doc/Makefile.in 2015-10-18 13:11:12.000000000 +0200 -@@ -417,7 +417,9 @@ - clean-libtool: - -rm -rf .libs _libs - --bfd.info: bfd.texinfo $(bfd_TEXINFOS) -+bfd.info: -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_bfd.info: bfd.texinfo $(bfd_TEXINFOS) - restore=: && backupdir="$(am__leading_dot)am$$$$" && \ - rm -rf $$backupdir && mkdir $$backupdir && \ - if ($(MAKEINFO) --version) >/dev/null 2>&1; then \ -diff -rNU3 dist.orig/bfd/doc/reloc.texi dist/bfd/doc/reloc.texi ---- dist.orig/bfd/doc/reloc.texi 2012-11-13 15:19:29.000000000 +0100 -+++ dist/bfd/doc/reloc.texi 2015-10-18 13:11:12.000000000 +0200 -@@ -570,6 +570,12 @@ - @deffnx {} BFD_RELOC_68K_TLS_LE8 - Relocations used by 68K ELF. - @end deffn -+@deffn {} BFD_RELOC_VAX_GLOB_DAT -+@deffnx {} BFD_RELOC_VAX_GLOB_REF -+@deffnx {} BFD_RELOC_VAX_JMP_SLOT -+@deffnx {} BFD_RELOC_VAX_RELATIVE -+Relocations used by VAX ELF. -+@end deffn - @deffn {} BFD_RELOC_32_BASEREL - @deffnx {} BFD_RELOC_16_BASEREL - @deffnx {} BFD_RELOC_LO16_BASEREL -diff -rNU3 dist.orig/bfd/elf-bfd.h dist/bfd/elf-bfd.h ---- dist.orig/bfd/elf-bfd.h 2013-03-25 09:06:19.000000000 +0100 -+++ dist/bfd/elf-bfd.h 2015-10-18 13:11:12.000000000 +0200 -@@ -420,6 +420,7 @@ - MICROBLAZE_ELF_DATA, - MIPS_ELF_DATA, - MN10300_ELF_DATA, -+ OR1K_ELF_DATA, - PPC32_ELF_DATA, - PPC64_ELF_DATA, - S390_ELF_DATA, -@@ -432,6 +433,7 @@ - XGATE_ELF_DATA, - TILEGX_ELF_DATA, - TILEPRO_ELF_DATA, -+ RISCV_ELF_DATA, - GENERIC_ELF_DATA - }; - -diff -rNU3 dist.orig/bfd/elf.c dist/bfd/elf.c ---- dist.orig/bfd/elf.c 2013-03-25 09:06:19.000000000 +0100 -+++ dist/bfd/elf.c 2015-10-18 13:11:12.000000000 +0200 -@@ -8756,6 +8756,23 @@ - return TRUE; - } - -+ /* On SuperH, PT_GETREGS == mach+3 and PT_GETFPREGS == mach+5. -+ There's also old PT___GETREGS40 == mach + 1 for old reg -+ structure which lacks GBR. */ -+ -+ case bfd_arch_sh: -+ switch (note->type) -+ { -+ case NT_NETBSDCORE_FIRSTMACH+3: -+ return elfcore_make_note_pseudosection (abfd, ".reg", note); -+ -+ case NT_NETBSDCORE_FIRSTMACH+5: -+ return elfcore_make_note_pseudosection (abfd, ".reg2", note); -+ -+ default: -+ return TRUE; -+ } -+ - /* On all other arch's, PT_GETREGS == mach+1 and - PT_GETFPREGS == mach+3. */ - -diff -rNU3 dist.orig/bfd/elf32-arm.c dist/bfd/elf32-arm.c ---- dist.orig/bfd/elf32-arm.c 2013-03-25 09:06:19.000000000 +0100 -+++ dist/bfd/elf32-arm.c 2015-10-18 13:11:12.000000000 +0200 -@@ -13475,6 +13475,10 @@ - { - struct bfd_link_info *info = (struct bfd_link_info *) inf; - -+ if (info->warn_shared_textrel) -+ (*_bfd_error_handler) -+ (_("warning: dynamic relocation to `%s' in readonly section `%s'"), -+ h->root.root.string, s->name); - info->flags |= DF_TEXTREL; - - /* Not an error, just cut short the traversal. */ -@@ -15640,7 +15644,7 @@ - #ifdef __QNXTARGET__ - #define ELF_MAXPAGESIZE 0x1000 - #else --#define ELF_MAXPAGESIZE 0x8000 -+#define ELF_MAXPAGESIZE 0x10000 - #endif - #define ELF_MINPAGESIZE 0x1000 - #define ELF_COMMONPAGESIZE 0x1000 -@@ -15769,9 +15773,6 @@ - #undef elf_backend_modify_program_headers - #define elf_backend_modify_program_headers nacl_modify_program_headers - --#undef ELF_MAXPAGESIZE --#define ELF_MAXPAGESIZE 0x10000 -- - #include "elf32-target.h" - - /* Reset to defaults. */ -diff -rNU3 dist.orig/bfd/elf32-hppa.c dist/bfd/elf32-hppa.c ---- dist.orig/bfd/elf32-hppa.c 2012-06-29 16:45:58.000000000 +0200 -+++ dist/bfd/elf32-hppa.c 2015-10-18 13:11:12.000000000 +0200 -@@ -2191,6 +2191,10 @@ - { - struct bfd_link_info *info = inf; - -+ if (info->warn_shared_textrel) -+ (*_bfd_error_handler) -+ (_("warning: dynamic relocation in readonly section `%s'"), -+ eh->root.root.string); - info->flags |= DF_TEXTREL; - - /* Not an error, just cut short the traversal. */ -diff -rNU3 dist.orig/bfd/elf32-i386.c dist/bfd/elf32-i386.c ---- dist.orig/bfd/elf32-i386.c 2013-03-25 09:06:19.000000000 +0100 -+++ dist/bfd/elf32-i386.c 2015-10-18 13:11:12.000000000 +0200 -@@ -518,7 +518,7 @@ - /* The name of the dynamic interpreter. This is put in the .interp - section. */ - --#define ELF_DYNAMIC_INTERPRETER "/usr/lib/libc.so.1" -+#define ELF_DYNAMIC_INTERPRETER "/libexec/ld.elf_so" - - /* If ELIMINATE_COPY_RELOCS is non-zero, the linker will try to avoid - copying dynamic variables from a shared lib into an app's dynbss -@@ -2552,7 +2552,10 @@ - if (s != NULL && (s->flags & SEC_READONLY) != 0) - { - struct bfd_link_info *info = (struct bfd_link_info *) inf; -- -+ if (info->warn_shared_textrel) -+ (*_bfd_error_handler) -+ (_("warning: dynamic relocation in readonly section `%s'"), -+ h->root.root.string); - info->flags |= DF_TEXTREL; - - if (info->warn_shared_textrel && info->shared) -diff -rNU3 dist.orig/bfd/elf32-m68k.c dist/bfd/elf32-m68k.c ---- dist.orig/bfd/elf32-m68k.c 2012-07-13 16:22:47.000000000 +0200 -+++ dist/bfd/elf32-m68k.c 2015-10-18 13:11:12.000000000 +0200 -@@ -2532,7 +2532,7 @@ - if (ind->got_entry_key != 0) - { - BFD_ASSERT (dir->got_entry_key == 0); -- /* Assert that GOTs aren't partioned yet. */ -+ /* Assert that GOTs aren't partitioned yet. */ - BFD_ASSERT (ind->glist == NULL); - - dir->got_entry_key = ind->got_entry_key; -@@ -3104,6 +3104,7 @@ - /* Make sure we know what is going on here. */ - BFD_ASSERT (dynobj != NULL - && (h->needs_plt -+ || h->type == STT_GNU_IFUNC - || h->u.weakdef != NULL - || (h->def_dynamic - && h->ref_regular -@@ -3112,7 +3113,7 @@ - /* If this is a function, put it in the procedure linkage table. We - will fill in the contents of the procedure linkage table later, - when we know the address of the .got section. */ -- if (h->type == STT_FUNC -+ if ((h->type == STT_FUNC || h->type == STT_GNU_IFUNC) - || h->needs_plt) - { - if ((h->plt.refcount <= 0 -diff -rNU3 dist.orig/bfd/elf32-openrisc.c dist/bfd/elf32-openrisc.c ---- dist.orig/bfd/elf32-openrisc.c 2012-05-07 05:27:50.000000000 +0200 -+++ dist/bfd/elf32-openrisc.c 1970-01-01 01:00:00.000000000 +0100 -@@ -1,566 +0,0 @@ --/* OpenRISC-specific support for 32-bit ELF. -- Copyright 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2010, 2012 -- Free Software Foundation, Inc. -- Contributed by Johan Rydberg, jrydberg@opencores.org -- -- This file is part of BFD, the Binary File Descriptor library. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, -- MA 02110-1301, USA. */ -- --#include "sysdep.h" --#include "bfd.h" --#include "libbfd.h" --#include "elf-bfd.h" --#include "elf/openrisc.h" --#include "libiberty.h" -- --static reloc_howto_type openrisc_elf_howto_table[] = --{ -- /* This reloc does nothing. */ -- HOWTO (R_OPENRISC_NONE, /* type */ -- 0, /* rightshift */ -- 2, /* size (0 = byte, 1 = short, 2 = long) */ -- 32, /* bitsize */ -- FALSE, /* pc_relative */ -- 0, /* bitpos */ -- complain_overflow_bitfield, /* complain_on_overflow */ -- bfd_elf_generic_reloc, /* special_function */ -- "R_OPENRISC_NONE", /* name */ -- FALSE, /* partial_inplace */ -- 0, /* src_mask */ -- 0, /* dst_mask */ -- FALSE), /* pcrel_offset */ -- -- /* A PC relative 26 bit relocation, right shifted by 2. */ -- HOWTO (R_OPENRISC_INSN_REL_26, /* type */ -- 2, /* rightshift */ -- 2, /* size (0 = byte, 1 = short, 2 = long) */ -- 26, /* bitsize */ -- TRUE, /* pc_relative */ -- 0, /* bitpos */ -- complain_overflow_signed, /* complain_on_overflow */ -- bfd_elf_generic_reloc, /* special_function */ -- "R_OPENRISC_INSN_REL_26", /* name */ -- FALSE, /* partial_inplace */ -- 0x00000000, /* src_mask */ -- 0x03ffffff, /* dst_mask */ -- FALSE), /* pcrel_offset */ -- -- /* A absolute 26 bit relocation, right shifted by 2. */ -- HOWTO (R_OPENRISC_INSN_ABS_26, /* type */ -- 2, /* rightshift */ -- 2, /* size (0 = byte, 1 = short, 2 = long) */ -- 26, /* bitsize */ -- FALSE, /* pc_relative */ -- 0, /* bitpos */ -- complain_overflow_signed, /* complain_on_overflow */ -- bfd_elf_generic_reloc, /* special_function */ -- "R_OPENRISC_INSN_ABS_26", /* name */ -- FALSE, /* partial_inplace */ -- 0x00000000, /* src_mask */ -- 0x03ffffff, /* dst_mask */ -- FALSE), /* pcrel_offset */ -- -- HOWTO (R_OPENRISC_LO_16_IN_INSN, /* type */ -- 0, /* rightshift */ -- 1, /* size (0 = byte, 1 = short, 2 = long) */ -- 16, /* bitsize */ -- FALSE, /* pc_relative */ -- 0, /* bitpos */ -- complain_overflow_dont, /* complain_on_overflow */ -- bfd_elf_generic_reloc, /* special_function */ -- "R_OPENRISC_LO_16_IN_INSN", /* name */ -- FALSE, /* partial_inplace */ -- 0, /* src_mask */ -- 0x0000ffff, /* dst_mask */ -- FALSE), /* pcrel_offset */ -- -- HOWTO (R_OPENRISC_HI_16_IN_INSN, /* type */ -- 16, /* rightshift */ -- 1, /* size (0 = byte, 1 = short, 2 = long) */ -- 16, /* bitsize */ -- FALSE, /* pc_relative */ -- 0, /* bitpos */ -- complain_overflow_dont, /* complain_on_overflow */ -- bfd_elf_generic_reloc, /* special_function */ -- "R_OPENRISC_HI_16_IN_INSN", /* name */ -- FALSE, /* partial_inplace */ -- 0, /* src_mask */ -- 0x0000ffff, /* dst_mask */ -- FALSE), /* pcrel_offset */ -- -- /* An 8 bit absolute relocation. */ -- HOWTO (R_OPENRISC_8, /* type */ -- 0, /* rightshift */ -- 0, /* size (0 = byte, 1 = short, 2 = long) */ -- 8, /* bitsize */ -- FALSE, /* pc_relative */ -- 0, /* bitpos */ -- complain_overflow_bitfield, /* complain_on_overflow */ -- bfd_elf_generic_reloc, /* special_function */ -- "R_OPENRISC_8", /* name */ -- TRUE, /* partial_inplace */ -- 0x0000, /* src_mask */ -- 0x00ff, /* dst_mask */ -- FALSE), /* pcrel_offset */ -- -- /* A 16 bit absolute relocation. */ -- HOWTO (R_OPENRISC_16, /* type */ -- 0, /* rightshift */ -- 1, /* size (0 = byte, 1 = short, 2 = long) */ -- 16, /* bitsize */ -- FALSE, /* pc_relative */ -- 0, /* bitpos */ -- complain_overflow_bitfield, /* complain_on_overflow */ -- bfd_elf_generic_reloc, /* special_function */ -- "R_OPENRISC_16", /* name */ -- TRUE, /* partial_inplace */ -- 0x00000000, /* src_mask */ -- 0x0000ffff, /* dst_mask */ -- FALSE), /* pcrel_offset */ -- -- /* A 32 bit absolute relocation. */ -- HOWTO (R_OPENRISC_32, /* type */ -- 0, /* rightshift */ -- 2, /* size (0 = byte, 1 = short, 2 = long) */ -- 32, /* bitsize */ -- FALSE, /* pc_relative */ -- 0, /* bitpos */ -- complain_overflow_bitfield, /* complain_on_overflow */ -- bfd_elf_generic_reloc, /* special_function */ -- "R_OPENRISC_32", /* name */ -- TRUE, /* partial_inplace */ -- 0x00000000, /* src_mask */ -- 0xffffffff, /* dst_mask */ -- FALSE), /* pcrel_offset */ -- -- /* GNU extension to record C++ vtable hierarchy. */ -- HOWTO (R_OPENRISC_GNU_VTINHERIT, /* type */ -- 0, /* rightshift */ -- 2, /* size (0 = byte, 1 = short, 2 = long) */ -- 0, /* bitsize */ -- FALSE, /* pc_relative */ -- 0, /* bitpos */ -- complain_overflow_dont, /* complain_on_overflow */ -- NULL, /* special_function */ -- "R_OPENRISC_GNU_VTINHERIT", /* name */ -- FALSE, /* partial_inplace */ -- 0, /* src_mask */ -- 0, /* dst_mask */ -- FALSE), /* pcrel_offset */ -- -- /* GNU extension to record C++ vtable member usage. */ -- HOWTO (R_OPENRISC_GNU_VTENTRY, /* type */ -- 0, /* rightshift */ -- 2, /* size (0 = byte, 1 = short, 2 = long) */ -- 0, /* bitsize */ -- FALSE, /* pc_relative */ -- 0, /* bitpos */ -- complain_overflow_dont, /* complain_on_overflow */ -- _bfd_elf_rel_vtable_reloc_fn, /* special_function */ -- "R_OPENRISC_GNU_VTENTRY", /* name */ -- FALSE, /* partial_inplace */ -- 0, /* src_mask */ -- 0, /* dst_mask */ -- FALSE), /* pcrel_offset */ --}; -- --/* Map BFD reloc types to OpenRISC ELF reloc types. */ -- --struct openrisc_reloc_map --{ -- bfd_reloc_code_real_type bfd_reloc_val; -- unsigned int openrisc_reloc_val; --}; -- --static const struct openrisc_reloc_map openrisc_reloc_map[] = --{ -- { BFD_RELOC_NONE, R_OPENRISC_NONE }, -- { BFD_RELOC_32, R_OPENRISC_32 }, -- { BFD_RELOC_16, R_OPENRISC_16 }, -- { BFD_RELOC_8, R_OPENRISC_8 }, -- { BFD_RELOC_OPENRISC_REL_26, R_OPENRISC_INSN_REL_26 }, -- { BFD_RELOC_OPENRISC_ABS_26, R_OPENRISC_INSN_ABS_26 }, -- { BFD_RELOC_HI16, R_OPENRISC_HI_16_IN_INSN }, -- { BFD_RELOC_LO16, R_OPENRISC_LO_16_IN_INSN }, -- { BFD_RELOC_VTABLE_INHERIT, R_OPENRISC_GNU_VTINHERIT }, -- { BFD_RELOC_VTABLE_ENTRY, R_OPENRISC_GNU_VTENTRY } --}; -- --static reloc_howto_type * --openrisc_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED, -- bfd_reloc_code_real_type code) --{ -- unsigned int i; -- -- for (i = ARRAY_SIZE (openrisc_reloc_map); --i;) -- if (openrisc_reloc_map[i].bfd_reloc_val == code) -- return & openrisc_elf_howto_table[openrisc_reloc_map[i]. -- openrisc_reloc_val]; -- -- return NULL; --} -- --static reloc_howto_type * --openrisc_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, -- const char *r_name) --{ -- unsigned int i; -- -- for (i = 0; -- i < (sizeof (openrisc_elf_howto_table) -- / sizeof (openrisc_elf_howto_table[0])); -- i++) -- if (openrisc_elf_howto_table[i].name != NULL -- && strcasecmp (openrisc_elf_howto_table[i].name, r_name) == 0) -- return &openrisc_elf_howto_table[i]; -- -- return NULL; --} -- --/* Set the howto pointer for an OpenRISC ELF reloc. */ -- --static void --openrisc_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED, -- arelent * cache_ptr, -- Elf_Internal_Rela * dst) --{ -- unsigned int r_type; -- -- r_type = ELF32_R_TYPE (dst->r_info); -- BFD_ASSERT (r_type < (unsigned int) R_OPENRISC_max); -- cache_ptr->howto = & openrisc_elf_howto_table[r_type]; --} -- --/* Perform a single relocation. By default we use the standard BFD -- routines, but a few relocs, we have to do them ourselves. */ -- --static bfd_reloc_status_type --openrisc_final_link_relocate (reloc_howto_type *howto, -- bfd *input_bfd, -- asection *input_section, -- bfd_byte *contents, -- Elf_Internal_Rela *rel, -- bfd_vma relocation) --{ -- bfd_reloc_status_type r = bfd_reloc_ok; -- -- switch (howto->type) -- { -- case R_OPENRISC_LO_16_IN_INSN: -- relocation &= 0xffff; -- r = _bfd_final_link_relocate (howto, input_bfd, input_section, -- contents, rel->r_offset, -- relocation, rel->r_addend); -- break; -- -- default: -- r = _bfd_final_link_relocate (howto, input_bfd, input_section, -- contents, rel->r_offset, -- relocation, rel->r_addend); -- } -- -- return r; --} -- --/* Relocate an OpenRISC ELF section. -- -- The RELOCATE_SECTION function is called by the new ELF backend linker -- to handle the relocations for a section. -- -- The relocs are always passed as Rela structures; if the section -- actually uses Rel structures, the r_addend field will always be -- zero. -- -- This function is responsible for adjusting the section contents as -- necessary, and (if using Rela relocs and generating a relocatable -- output file) adjusting the reloc addend as necessary. -- -- This function does not have to worry about setting the reloc -- address or the reloc symbol index. -- -- LOCAL_SYMS is a pointer to the swapped in local symbols. -- -- LOCAL_SECTIONS is an array giving the section in the input file -- corresponding to the st_shndx field of each local symbol. -- -- The global hash table entry for the global symbols can be found -- via elf_sym_hashes (input_bfd). -- -- When generating relocatable output, this function must handle -- STB_LOCAL/STT_SECTION symbols specially. The output symbol is -- going to be the section symbol corresponding to the output -- section, which means that the addend must be adjusted -- accordingly. */ -- --static bfd_boolean --openrisc_elf_relocate_section (bfd *output_bfd, -- struct bfd_link_info *info, -- bfd *input_bfd, -- asection *input_section, -- bfd_byte *contents, -- Elf_Internal_Rela *relocs, -- Elf_Internal_Sym *local_syms, -- asection **local_sections) --{ -- Elf_Internal_Shdr *symtab_hdr; -- struct elf_link_hash_entry **sym_hashes; -- Elf_Internal_Rela *rel; -- Elf_Internal_Rela *relend; -- -- symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; -- sym_hashes = elf_sym_hashes (input_bfd); -- relend = relocs + input_section->reloc_count; -- -- for (rel = relocs; rel < relend; rel++) -- { -- reloc_howto_type *howto; -- unsigned long r_symndx; -- Elf_Internal_Sym *sym; -- asection *sec; -- struct elf_link_hash_entry *h; -- bfd_vma relocation; -- bfd_reloc_status_type r; -- const char *name = NULL; -- int r_type; -- -- r_type = ELF32_R_TYPE (rel->r_info); -- r_symndx = ELF32_R_SYM (rel->r_info); -- -- if (r_type == R_OPENRISC_GNU_VTINHERIT -- || r_type == R_OPENRISC_GNU_VTENTRY) -- continue; -- -- if ((unsigned int) r_type > -- (sizeof openrisc_elf_howto_table / sizeof (reloc_howto_type))) -- abort (); -- -- howto = openrisc_elf_howto_table + ELF32_R_TYPE (rel->r_info); -- h = NULL; -- sym = NULL; -- sec = NULL; -- -- if (r_symndx < symtab_hdr->sh_info) -- { -- sym = local_syms + r_symndx; -- sec = local_sections[r_symndx]; -- relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel); -- -- name = bfd_elf_string_from_elf_section -- (input_bfd, symtab_hdr->sh_link, sym->st_name); -- name = (name == NULL) ? bfd_section_name (input_bfd, sec) : name; -- } -- else -- { -- bfd_boolean unresolved_reloc, warned; -- -- RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, -- r_symndx, symtab_hdr, sym_hashes, -- h, sec, relocation, -- unresolved_reloc, warned); -- } -- -- if (sec != NULL && discarded_section (sec)) -- RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section, -- rel, 1, relend, howto, 0, contents); -- -- if (info->relocatable) -- continue; -- -- r = openrisc_final_link_relocate (howto, input_bfd, input_section, -- contents, rel, relocation); -- -- if (r != bfd_reloc_ok) -- { -- const char *msg = NULL; -- -- switch (r) -- { -- case bfd_reloc_overflow: -- r = info->callbacks->reloc_overflow -- (info, (h ? &h->root : NULL), name, howto->name, -- (bfd_vma) 0, input_bfd, input_section, rel->r_offset); -- break; -- -- case bfd_reloc_undefined: -- r = info->callbacks->undefined_symbol -- (info, name, input_bfd, input_section, rel->r_offset, TRUE); -- break; -- -- case bfd_reloc_outofrange: -- msg = _("internal error: out of range error"); -- break; -- -- case bfd_reloc_notsupported: -- msg = _("internal error: unsupported relocation error"); -- break; -- -- case bfd_reloc_dangerous: -- msg = _("internal error: dangerous relocation"); -- break; -- -- default: -- msg = _("internal error: unknown error"); -- break; -- } -- -- if (msg) -- r = info->callbacks->warning -- (info, msg, name, input_bfd, input_section, rel->r_offset); -- -- if (!r) -- return FALSE; -- } -- } -- -- return TRUE; --} -- --/* Return the section that should be marked against GC for a given -- relocation. */ -- --static asection * --openrisc_elf_gc_mark_hook (asection *sec, -- struct bfd_link_info *info, -- Elf_Internal_Rela *rel, -- struct elf_link_hash_entry *h, -- Elf_Internal_Sym *sym) --{ -- if (h != NULL) -- switch (ELF32_R_TYPE (rel->r_info)) -- { -- case R_OPENRISC_GNU_VTINHERIT: -- case R_OPENRISC_GNU_VTENTRY: -- return NULL; -- } -- -- return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym); --} -- --/* Look through the relocs for a section during the first phase. -- Since we don't do .gots or .plts, we just need to consider the -- virtual table relocs for gc. */ -- --static bfd_boolean --openrisc_elf_check_relocs (bfd *abfd, -- struct bfd_link_info *info, -- asection *sec, -- const Elf_Internal_Rela *relocs) --{ -- Elf_Internal_Shdr *symtab_hdr; -- struct elf_link_hash_entry **sym_hashes; -- const Elf_Internal_Rela *rel; -- const Elf_Internal_Rela *rel_end; -- -- if (info->relocatable) -- return TRUE; -- -- symtab_hdr = &elf_tdata (abfd)->symtab_hdr; -- sym_hashes = elf_sym_hashes (abfd); -- -- rel_end = relocs + sec->reloc_count; -- for (rel = relocs; rel < rel_end; rel++) -- { -- struct elf_link_hash_entry *h; -- unsigned long r_symndx; -- -- r_symndx = ELF32_R_SYM (rel->r_info); -- if (r_symndx < symtab_hdr->sh_info) -- h = NULL; -- else -- { -- h = sym_hashes[r_symndx - symtab_hdr->sh_info]; -- while (h->root.type == bfd_link_hash_indirect -- || h->root.type == bfd_link_hash_warning) -- h = (struct elf_link_hash_entry *) h->root.u.i.link; -- } -- -- switch (ELF32_R_TYPE (rel->r_info)) -- { -- /* This relocation describes the C++ object vtable hierarchy. -- Reconstruct it for later use during GC. */ -- case R_OPENRISC_GNU_VTINHERIT: -- if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset)) -- return FALSE; -- break; -- -- /* This relocation describes which C++ vtable entries are actually -- used. Record for later use during GC. */ -- case R_OPENRISC_GNU_VTENTRY: -- BFD_ASSERT (h != NULL); -- if (h != NULL -- && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend)) -- return FALSE; -- break; -- } -- } -- -- return TRUE; --} -- --/* Set the right machine number. */ -- --static bfd_boolean --openrisc_elf_object_p (bfd *abfd) --{ -- bfd_default_set_arch_mach (abfd, bfd_arch_openrisc, 0); -- return TRUE; --} -- --/* Store the machine number in the flags field. */ -- --static void --openrisc_elf_final_write_processing (bfd *abfd, -- bfd_boolean linker ATTRIBUTE_UNUSED) --{ -- unsigned long val; -- -- switch (bfd_get_mach (abfd)) -- { -- default: -- val = 0; -- break; -- } -- -- elf_elfheader (abfd)->e_flags &= ~0xf; -- elf_elfheader (abfd)->e_flags |= val; --} -- -- --#define ELF_ARCH bfd_arch_openrisc --#define ELF_MACHINE_CODE EM_OPENRISC --#define ELF_MACHINE_ALT1 EM_OPENRISC_OLD --#define ELF_MAXPAGESIZE 0x1000 -- --#define TARGET_BIG_SYM bfd_elf32_openrisc_vec --#define TARGET_BIG_NAME "elf32-openrisc" -- --#define elf_info_to_howto_rel NULL --#define elf_info_to_howto openrisc_info_to_howto_rela --#define elf_backend_relocate_section openrisc_elf_relocate_section --#define elf_backend_gc_mark_hook openrisc_elf_gc_mark_hook --#define elf_backend_check_relocs openrisc_elf_check_relocs -- --#define elf_backend_can_gc_sections 1 --#define elf_backend_rela_normal 1 -- --#define bfd_elf32_bfd_reloc_type_lookup openrisc_reloc_type_lookup --#define bfd_elf32_bfd_reloc_name_lookup openrisc_reloc_name_lookup -- --#define elf_backend_object_p openrisc_elf_object_p --#define elf_backend_final_write_processing openrisc_elf_final_write_processing -- --#include "elf32-target.h" -diff -rNU3 dist.orig/bfd/elf32-or1k.c dist/bfd/elf32-or1k.c ---- dist.orig/bfd/elf32-or1k.c 1970-01-01 01:00:00.000000000 +0100 -+++ dist/bfd/elf32-or1k.c 2015-10-18 13:11:12.000000000 +0200 -@@ -0,0 +1,2852 @@ -+/* Or1k-specific support for 32-bit ELF. -+ Copyright 2001-2014 Free Software Foundation, Inc. -+ Contributed for OR32 by Johan Rydberg, jrydberg@opencores.org -+ -+ PIC parts added by Stefan Kristiansson, stefan.kristiansson@saunalahti.fi, -+ largely based on elf32-m32r.c and elf32-microblaze.c. -+ -+ This file is part of BFD, the Binary File Descriptor library. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, see . */ -+ -+#include "sysdep.h" -+#include "bfd.h" -+#include "libbfd.h" -+#include "elf-bfd.h" -+#include "elf/or1k.h" -+#include "libiberty.h" -+ -+#define PLT_ENTRY_SIZE 20 -+ -+#define PLT0_ENTRY_WORD0 0x19800000 /* l.movhi r12, 0 <- hi(.got+4) */ -+#define PLT0_ENTRY_WORD1 0xa98c0000 /* l.ori r12, r12, 0 <- lo(.got+4) */ -+#define PLT0_ENTRY_WORD2 0x85ec0004 /* l.lwz r15, 4(r12) <- *(.got+8)*/ -+#define PLT0_ENTRY_WORD3 0x44007800 /* l.jr r15 */ -+#define PLT0_ENTRY_WORD4 0x858c0000 /* l.lwz r12, 0(r12) */ -+ -+#define PLT0_PIC_ENTRY_WORD0 0x85900004 /* l.lwz r12, 4(r16) */ -+#define PLT0_PIC_ENTRY_WORD1 0x85f00008 /* l.lwz r15, 8(r16) */ -+#define PLT0_PIC_ENTRY_WORD2 0x44007800 /* l.jr r15 */ -+#define PLT0_PIC_ENTRY_WORD3 0x15000000 /* l.nop */ -+#define PLT0_PIC_ENTRY_WORD4 0x15000000 /* l.nop */ -+ -+#define PLT_ENTRY_WORD0 0x19800000 /* l.movhi r12, 0 <- hi(got idx addr) */ -+#define PLT_ENTRY_WORD1 0xa98c0000 /* l.ori r12, r12, 0 <- lo(got idx addr) */ -+#define PLT_ENTRY_WORD2 0x858c0000 /* l.lwz r12, 0(r12) */ -+#define PLT_ENTRY_WORD3 0x44006000 /* l.jr r12 */ -+#define PLT_ENTRY_WORD4 0xa9600000 /* l.ori r11, r0, 0 <- reloc offset */ -+ -+#define PLT_PIC_ENTRY_WORD0 0x85900000 /* l.lwz r12, 0(r16) <- index in got */ -+#define PLT_PIC_ENTRY_WORD1 0xa9600000 /* l.ori r11, r0, 0 <- reloc offset */ -+#define PLT_PIC_ENTRY_WORD2 0x44006000 /* l.jr r12 */ -+#define PLT_PIC_ENTRY_WORD3 0x15000000 /* l.nop */ -+#define PLT_PIC_ENTRY_WORD4 0x15000000 /* l.nop */ -+ -+#define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1" -+ -+static reloc_howto_type or1k_elf_howto_table[] = -+{ -+ /* This reloc does nothing. */ -+ HOWTO (R_OR1K_NONE, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 32, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_OR1K_NONE", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ 0, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ HOWTO (R_OR1K_32, -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 32, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_unsigned, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_OR1K_32", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ 0xffffffff, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ HOWTO (R_OR1K_16, -+ 0, /* rightshift */ -+ 1, /* size (0 = byte, 1 = short, 2 = long) */ -+ 16, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_unsigned, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_OR1K_16", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ 0xffff, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ HOWTO (R_OR1K_8, -+ 0, /* rightshift */ -+ 0, /* size (0 = byte, 1 = short, 2 = long) */ -+ 8, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_unsigned, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_OR1K_8", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ 0xff, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ HOWTO (R_OR1K_LO_16_IN_INSN, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 16, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_OR1K_LO_16_IN_INSN", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ 0x0000ffff, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ HOWTO (R_OR1K_HI_16_IN_INSN, /* type */ -+ 16, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 16, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_OR1K_HI_16_IN_INSN", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ 0x0000ffff, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ /* A PC relative 26 bit relocation, right shifted by 2. */ -+ HOWTO (R_OR1K_INSN_REL_26, /* type */ -+ 2, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 26, /* bitsize */ -+ TRUE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_signed, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_OR1K_INSN_REL_26", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ 0x03ffffff, /* dst_mask */ -+ TRUE), /* pcrel_offset */ -+ -+ /* GNU extension to record C++ vtable hierarchy. */ -+ HOWTO (R_OR1K_GNU_VTINHERIT, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 0, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ NULL, /* special_function */ -+ "R_OR1K_GNU_VTINHERIT", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ 0, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ /* GNU extension to record C++ vtable member usage. */ -+ HOWTO (R_OR1K_GNU_VTENTRY, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 0, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ _bfd_elf_rel_vtable_reloc_fn, /* special_function */ -+ "R_OR1K_GNU_VTENTRY", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ 0, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ HOWTO (R_OR1K_32_PCREL, -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 32, /* bitsize */ -+ TRUE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_signed, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_OR1K_32_PCREL", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ 0xffffffff, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ HOWTO (R_OR1K_16_PCREL, -+ 0, /* rightshift */ -+ 1, /* size (0 = byte, 1 = short, 2 = long) */ -+ 16, /* bitsize */ -+ TRUE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_signed, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_OR1K_16_PCREL", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ 0xffff, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ HOWTO (R_OR1K_8_PCREL, -+ 0, /* rightshift */ -+ 0, /* size (0 = byte, 1 = short, 2 = long) */ -+ 8, /* bitsize */ -+ TRUE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_signed, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_OR1K_8_PCREL", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ 0xff, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ HOWTO (R_OR1K_GOTPC_HI16, /* Type. */ -+ 16, /* Rightshift. */ -+ 2, /* Size (0 = byte, 1 = short, 2 = long). */ -+ 16, /* Bitsize. */ -+ TRUE, /* PC_relative. */ -+ 0, /* Bitpos. */ -+ complain_overflow_dont, /* Complain on overflow. */ -+ bfd_elf_generic_reloc, /* Special Function. */ -+ "R_OR1K_GOTPC_HI16", /* Name. */ -+ FALSE, /* Partial Inplace. */ -+ 0, /* Source Mask. */ -+ 0xffff, /* Dest Mask. */ -+ TRUE), /* PC relative offset? */ -+ -+ HOWTO (R_OR1K_GOTPC_LO16, /* Type. */ -+ 0, /* Rightshift. */ -+ 2, /* Size (0 = byte, 1 = short, 2 = long). */ -+ 16, /* Bitsize. */ -+ TRUE, /* PC_relative. */ -+ 0, /* Bitpos. */ -+ complain_overflow_dont, /* Complain on overflow. */ -+ bfd_elf_generic_reloc, /* Special Function. */ -+ "R_OR1K_GOTPC_LO16", /* Name. */ -+ FALSE, /* Partial Inplace. */ -+ 0, /* Source Mask. */ -+ 0xffff, /* Dest Mask. */ -+ TRUE), /* PC relative offset? */ -+ -+ HOWTO (R_OR1K_GOT16, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 16, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_signed, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_OR1K_GOT16", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ 0xffff, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ /* A 26 bit PLT relocation. Shifted by 2. */ -+ HOWTO (R_OR1K_PLT26, /* Type. */ -+ 2, /* Rightshift. */ -+ 2, /* Size (0 = byte, 1 = short, 2 = long). */ -+ 26, /* Bitsize. */ -+ TRUE, /* PC_relative. */ -+ 0, /* Bitpos. */ -+ complain_overflow_dont, /* Complain on overflow. */ -+ bfd_elf_generic_reloc,/* Special Function. */ -+ "R_OR1K_PLT26", /* Name. */ -+ FALSE, /* Partial Inplace. */ -+ 0, /* Source Mask. */ -+ 0x03ffffff, /* Dest Mask. */ -+ TRUE), /* PC relative offset? */ -+ -+ HOWTO (R_OR1K_GOTOFF_HI16, /* type */ -+ 16, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 16, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_OR1K_GOTOFF_HI16", /* name */ -+ FALSE, /* partial_inplace */ -+ 0x0, /* src_mask */ -+ 0xffff, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ HOWTO (R_OR1K_GOTOFF_LO16, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 16, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_OR1K_GOTOFF_LO16", /* name */ -+ FALSE, /* partial_inplace */ -+ 0x0, /* src_mask */ -+ 0xffff, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ HOWTO (R_OR1K_COPY, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 32, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_bitfield, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_OR1K_COPY", /* name */ -+ FALSE, /* partial_inplace */ -+ 0xffffffff, /* src_mask */ -+ 0xffffffff, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ HOWTO (R_OR1K_GLOB_DAT, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 32, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_bitfield, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_OR1K_GLOB_DAT", /* name */ -+ FALSE, /* partial_inplace */ -+ 0xffffffff, /* src_mask */ -+ 0xffffffff, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ HOWTO (R_OR1K_JMP_SLOT, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 32, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_bitfield, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_OR1K_JMP_SLOT", /* name */ -+ FALSE, /* partial_inplace */ -+ 0xffffffff, /* src_mask */ -+ 0xffffffff, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ HOWTO (R_OR1K_RELATIVE, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 32, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_bitfield, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_OR1K_RELATIVE", /* name */ -+ FALSE, /* partial_inplace */ -+ 0xffffffff, /* src_mask */ -+ 0xffffffff, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ HOWTO (R_OR1K_TLS_GD_HI16, /* type */ -+ 16, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 16, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_OR1K_TLS_GD_HI16", /* name */ -+ FALSE, /* partial_inplace */ -+ 0x0, /* src_mask */ -+ 0xffff, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ HOWTO (R_OR1K_TLS_GD_LO16, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 16, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_OR1K_TLS_GD_LO16", /* name */ -+ FALSE, /* partial_inplace */ -+ 0x0, /* src_mask */ -+ 0xffff, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ HOWTO (R_OR1K_TLS_LDM_HI16, /* type */ -+ 16, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 16, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_OR1K_TLS_LDM_HI16", /* name */ -+ FALSE, /* partial_inplace */ -+ 0x0, /* src_mask */ -+ 0xffff, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ HOWTO (R_OR1K_TLS_LDM_LO16, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 16, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_OR1K_TLS_LDM_LO16", /* name */ -+ FALSE, /* partial_inplace */ -+ 0x0, /* src_mask */ -+ 0xffff, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ HOWTO (R_OR1K_TLS_LDO_HI16, /* type */ -+ 16, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 16, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_OR1K_TLS_LDO_HI16", /* name */ -+ FALSE, /* partial_inplace */ -+ 0x0, /* src_mask */ -+ 0xffff, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ HOWTO (R_OR1K_TLS_LDO_LO16, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 16, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_OR1K_TLS_LDO_LO16", /* name */ -+ FALSE, /* partial_inplace */ -+ 0x0, /* src_mask */ -+ 0xffff, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ HOWTO (R_OR1K_TLS_IE_HI16, /* type */ -+ 16, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 16, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_OR1K_TLS_IE_HI16", /* name */ -+ FALSE, /* partial_inplace */ -+ 0x0, /* src_mask */ -+ 0xffff, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ HOWTO (R_OR1K_TLS_IE_LO16, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 16, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_OR1K_TLS_IE_LO16", /* name */ -+ FALSE, /* partial_inplace */ -+ 0x0, /* src_mask */ -+ 0xffff, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ HOWTO (R_OR1K_TLS_LE_HI16, /* type */ -+ 16, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 16, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_OR1K_TLS_LE_HI16", /* name */ -+ FALSE, /* partial_inplace */ -+ 0x0, /* src_mask */ -+ 0xffff, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ HOWTO (R_OR1K_TLS_LE_LO16, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 16, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_OR1K_TLS_LE_LO16", /* name */ -+ FALSE, /* partial_inplace */ -+ 0x0, /* src_mask */ -+ 0xffff, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+}; -+ -+/* Map BFD reloc types to Or1k ELF reloc types. */ -+ -+struct or1k_reloc_map -+{ -+ bfd_reloc_code_real_type bfd_reloc_val; -+ unsigned int or1k_reloc_val; -+}; -+ -+static const struct or1k_reloc_map or1k_reloc_map[] = -+{ -+ { BFD_RELOC_NONE, R_OR1K_NONE }, -+ { BFD_RELOC_32, R_OR1K_32 }, -+ { BFD_RELOC_16, R_OR1K_16 }, -+ { BFD_RELOC_8, R_OR1K_8 }, -+ { BFD_RELOC_LO16, R_OR1K_LO_16_IN_INSN }, -+ { BFD_RELOC_HI16, R_OR1K_HI_16_IN_INSN }, -+ { BFD_RELOC_OR1K_REL_26, R_OR1K_INSN_REL_26 }, -+ { BFD_RELOC_VTABLE_ENTRY, R_OR1K_GNU_VTENTRY }, -+ { BFD_RELOC_VTABLE_INHERIT, R_OR1K_GNU_VTINHERIT }, -+ { BFD_RELOC_32_PCREL, R_OR1K_32_PCREL }, -+ { BFD_RELOC_16_PCREL, R_OR1K_16_PCREL }, -+ { BFD_RELOC_8_PCREL, R_OR1K_8_PCREL }, -+ { BFD_RELOC_OR1K_GOTPC_HI16, R_OR1K_GOTPC_HI16 }, -+ { BFD_RELOC_OR1K_GOTPC_LO16, R_OR1K_GOTPC_LO16 }, -+ { BFD_RELOC_OR1K_GOT16, R_OR1K_GOT16 }, -+ { BFD_RELOC_OR1K_PLT26, R_OR1K_PLT26 }, -+ { BFD_RELOC_OR1K_GOTOFF_HI16, R_OR1K_GOTOFF_HI16 }, -+ { BFD_RELOC_OR1K_GOTOFF_LO16, R_OR1K_GOTOFF_LO16 }, -+ { BFD_RELOC_OR1K_GLOB_DAT, R_OR1K_GLOB_DAT }, -+ { BFD_RELOC_OR1K_COPY, R_OR1K_COPY }, -+ { BFD_RELOC_OR1K_JMP_SLOT, R_OR1K_JMP_SLOT }, -+ { BFD_RELOC_OR1K_RELATIVE, R_OR1K_RELATIVE }, -+ { BFD_RELOC_OR1K_TLS_GD_HI16, R_OR1K_TLS_GD_HI16 }, -+ { BFD_RELOC_OR1K_TLS_GD_LO16, R_OR1K_TLS_GD_LO16 }, -+ { BFD_RELOC_OR1K_TLS_LDM_HI16, R_OR1K_TLS_LDM_HI16 }, -+ { BFD_RELOC_OR1K_TLS_LDM_LO16, R_OR1K_TLS_LDM_LO16 }, -+ { BFD_RELOC_OR1K_TLS_LDO_HI16, R_OR1K_TLS_LDO_HI16 }, -+ { BFD_RELOC_OR1K_TLS_LDO_LO16, R_OR1K_TLS_LDO_LO16 }, -+ { BFD_RELOC_OR1K_TLS_IE_HI16, R_OR1K_TLS_IE_HI16 }, -+ { BFD_RELOC_OR1K_TLS_IE_LO16, R_OR1K_TLS_IE_LO16 }, -+ { BFD_RELOC_OR1K_TLS_LE_HI16, R_OR1K_TLS_LE_HI16 }, -+ { BFD_RELOC_OR1K_TLS_LE_LO16, R_OR1K_TLS_LE_LO16 }, -+}; -+ -+/* The linker needs to keep track of the number of relocs that it -+ decides to copy as dynamic relocs in check_relocs for each symbol. -+ This is so that it can later discard them if they are found to be -+ unnecessary. We store the information in a field extending the -+ regular ELF linker hash table. */ -+ -+struct elf_or1k_dyn_relocs -+{ -+ struct elf_or1k_dyn_relocs *next; -+ -+ /* The input section of the reloc. */ -+ asection *sec; -+ -+ /* Total number of relocs copied for the input section. */ -+ bfd_size_type count; -+ -+ /* Number of pc-relative relocs copied for the input section. */ -+ bfd_size_type pc_count; -+}; -+ -+#define TLS_UNKNOWN 0 -+#define TLS_NONE 1 -+#define TLS_GD 2 -+#define TLS_LD 3 -+#define TLS_IE 4 -+#define TLS_LE 5 -+ -+/* ELF linker hash entry. */ -+struct elf_or1k_link_hash_entry -+{ -+ struct elf_link_hash_entry root; -+ -+ /* Track dynamic relocs copied for this symbol. */ -+ struct elf_or1k_dyn_relocs *dyn_relocs; -+ -+ /* Track type of TLS access. */ -+ unsigned char tls_type; -+}; -+ -+/* ELF object data. */ -+struct elf_or1k_obj_tdata -+{ -+ struct elf_obj_tdata root; -+ -+ /* tls_type for each local got entry. */ -+ unsigned char *local_tls_type; -+}; -+ -+#define elf_or1k_tdata(abfd) \ -+ ((struct elf_or1k_obj_tdata *) (abfd)->tdata.any) -+ -+#define elf_or1k_local_tls_type(abfd) \ -+ (elf_or1k_tdata (abfd)->local_tls_type) -+ -+/* ELF linker hash table. */ -+struct elf_or1k_link_hash_table -+{ -+ struct elf_link_hash_table root; -+ -+ /* Short-cuts to get to dynamic linker sections. */ -+ asection *sgot; -+ asection *sgotplt; -+ asection *srelgot; -+ asection *splt; -+ asection *srelplt; -+ asection *sdynbss; -+ asection *srelbss; -+ -+ /* Small local sym to section mapping cache. */ -+ struct sym_cache sym_sec; -+}; -+ -+/* Get the ELF linker hash table from a link_info structure. */ -+#define or1k_elf_hash_table(p) \ -+ (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \ -+ == OR1K_ELF_DATA ? ((struct elf_or1k_link_hash_table *) ((p)->hash)) : NULL) -+ -+static bfd_boolean -+elf_or1k_mkobject (bfd *abfd) -+{ -+ return bfd_elf_allocate_object (abfd, sizeof (struct elf_or1k_obj_tdata), -+ OR1K_ELF_DATA); -+} -+ -+/* Create an entry in an or1k ELF linker hash table. */ -+ -+static struct bfd_hash_entry * -+or1k_elf_link_hash_newfunc (struct bfd_hash_entry *entry, -+ struct bfd_hash_table *table, -+ const char *string) -+{ -+ struct elf_or1k_link_hash_entry *ret = -+ (struct elf_or1k_link_hash_entry *) entry; -+ -+ /* Allocate the structure if it has not already been allocated by a -+ subclass. */ -+ if (ret == NULL) -+ ret = bfd_hash_allocate (table, -+ sizeof (struct elf_or1k_link_hash_entry)); -+ if (ret == NULL) -+ return NULL; -+ -+ /* Call the allocation method of the superclass. */ -+ ret = ((struct elf_or1k_link_hash_entry *) -+ _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret, -+ table, string)); -+ if (ret != NULL) -+ { -+ struct elf_or1k_link_hash_entry *eh; -+ -+ eh = (struct elf_or1k_link_hash_entry *) ret; -+ eh->dyn_relocs = NULL; -+ eh->tls_type = TLS_UNKNOWN; -+ } -+ -+ return (struct bfd_hash_entry *) ret; -+} -+ -+/* Create an or1k ELF linker hash table. */ -+ -+static struct bfd_link_hash_table * -+or1k_elf_link_hash_table_create (bfd *abfd) -+{ -+ struct elf_or1k_link_hash_table *ret; -+ bfd_size_type amt = sizeof (struct elf_or1k_link_hash_table); -+ -+ ret = bfd_zmalloc (amt); -+ if (ret == NULL) -+ return NULL; -+ -+ if (!_bfd_elf_link_hash_table_init (&ret->root, abfd, -+ or1k_elf_link_hash_newfunc, -+ sizeof (struct elf_or1k_link_hash_entry), -+ OR1K_ELF_DATA)) -+ { -+ free (ret); -+ return NULL; -+ } -+ -+ return &ret->root.root; -+} -+ -+static reloc_howto_type * -+or1k_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED, -+ bfd_reloc_code_real_type code) -+{ -+ unsigned int i; -+ -+ for (i = ARRAY_SIZE (or1k_reloc_map); --i;) -+ if (or1k_reloc_map[i].bfd_reloc_val == code) -+ return & or1k_elf_howto_table[or1k_reloc_map[i].or1k_reloc_val]; -+ -+ return NULL; -+} -+ -+static reloc_howto_type * -+or1k_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, -+ const char *r_name) -+{ -+ unsigned int i; -+ -+ for (i = 0; -+ i < (sizeof (or1k_elf_howto_table) -+ / sizeof (or1k_elf_howto_table[0])); -+ i++) -+ if (or1k_elf_howto_table[i].name != NULL -+ && strcasecmp (or1k_elf_howto_table[i].name, r_name) == 0) -+ return &or1k_elf_howto_table[i]; -+ -+ return NULL; -+} -+ -+/* Set the howto pointer for an Or1k ELF reloc. */ -+ -+static void -+or1k_info_to_howto_rela (bfd * abfd ATTRIBUTE_UNUSED, -+ arelent * cache_ptr, -+ Elf_Internal_Rela * dst) -+{ -+ unsigned int r_type; -+ -+ r_type = ELF32_R_TYPE (dst->r_info); -+ BFD_ASSERT (r_type < (unsigned int) R_OR1K_max); -+ cache_ptr->howto = & or1k_elf_howto_table[r_type]; -+} -+ -+ -+/* Return the relocation value for @tpoff relocations.. */ -+static bfd_vma -+tpoff (struct bfd_link_info *info, bfd_vma address) -+{ -+ /* If tls_sec is NULL, we should have signalled an error already. */ -+ if (elf_hash_table (info)->tls_sec == NULL) -+ return 0; -+ -+ /* The thread pointer on or1k stores the address after the TCB where -+ the data is, just compute the difference. No need to compensate -+ for the size of TCB. */ -+ return (address - elf_hash_table (info)->tls_sec->vma); -+} -+ -+/* Relocate an Or1k ELF section. -+ -+ The RELOCATE_SECTION function is called by the new ELF backend linker -+ to handle the relocations for a section. -+ -+ The relocs are always passed as Rela structures; if the section -+ actually uses Rel structures, the r_addend field will always be -+ zero. -+ -+ This function is responsible for adjusting the section contents as -+ necessary, and (if using Rela relocs and generating a relocatable -+ output file) adjusting the reloc addend as necessary. -+ -+ This function does not have to worry about setting the reloc -+ address or the reloc symbol index. -+ -+ LOCAL_SYMS is a pointer to the swapped in local symbols. -+ -+ LOCAL_SECTIONS is an array giving the section in the input file -+ corresponding to the st_shndx field of each local symbol. -+ -+ The global hash table entry for the global symbols can be found -+ via elf_sym_hashes (input_bfd). -+ -+ When generating relocatable output, this function must handle -+ STB_LOCAL/STT_SECTION symbols specially. The output symbol is -+ going to be the section symbol corresponding to the output -+ section, which means that the addend must be adjusted -+ accordingly. */ -+ -+static bfd_boolean -+or1k_elf_relocate_section (bfd *output_bfd, -+ struct bfd_link_info *info, -+ bfd *input_bfd, -+ asection *input_section, -+ bfd_byte *contents, -+ Elf_Internal_Rela *relocs, -+ Elf_Internal_Sym *local_syms, -+ asection **local_sections) -+{ -+ Elf_Internal_Shdr *symtab_hdr; -+ struct elf_link_hash_entry **sym_hashes; -+ Elf_Internal_Rela *rel; -+ Elf_Internal_Rela *relend; -+ struct elf_or1k_link_hash_table *htab = or1k_elf_hash_table (info); -+ bfd *dynobj; -+ asection *sreloc; -+ bfd_vma *local_got_offsets; -+ asection *sgot; -+ -+ if (htab == NULL) -+ return FALSE; -+ -+ dynobj = htab->root.dynobj; -+ local_got_offsets = elf_local_got_offsets (input_bfd); -+ -+ sreloc = elf_section_data (input_section)->sreloc; -+ -+ sgot = htab->sgot; -+ -+ symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; -+ sym_hashes = elf_sym_hashes (input_bfd); -+ relend = relocs + input_section->reloc_count; -+ -+ for (rel = relocs; rel < relend; rel++) -+ { -+ reloc_howto_type *howto; -+ unsigned long r_symndx; -+ Elf_Internal_Sym *sym; -+ asection *sec; -+ struct elf_link_hash_entry *h; -+ bfd_vma relocation; -+ bfd_reloc_status_type r; -+ const char *name = NULL; -+ int r_type; -+ -+ r_type = ELF32_R_TYPE (rel->r_info); -+ r_symndx = ELF32_R_SYM (rel->r_info); -+ -+ if (r_type == R_OR1K_GNU_VTINHERIT -+ || r_type == R_OR1K_GNU_VTENTRY) -+ continue; -+ -+ if (r_type < 0 || r_type >= (int) R_OR1K_max) -+ { -+ bfd_set_error (bfd_error_bad_value); -+ return FALSE; -+ } -+ -+ howto = or1k_elf_howto_table + ELF32_R_TYPE (rel->r_info); -+ h = NULL; -+ sym = NULL; -+ sec = NULL; -+ -+ if (r_symndx < symtab_hdr->sh_info) -+ { -+ sym = local_syms + r_symndx; -+ sec = local_sections[r_symndx]; -+ relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel); -+ -+ name = bfd_elf_string_from_elf_section -+ (input_bfd, symtab_hdr->sh_link, sym->st_name); -+ name = (name == NULL) ? bfd_section_name (input_bfd, sec) : name; -+ } -+ else -+ { -+ bfd_boolean unresolved_reloc, warned; -+ -+ RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, -+ r_symndx, symtab_hdr, sym_hashes, -+ h, sec, relocation, -+ unresolved_reloc, warned); -+ } -+ -+ if (sec != NULL && discarded_section (sec)) -+ RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section, -+ rel, 1, relend, howto, 0, contents); -+ -+ if (info->relocatable) -+ continue; -+ -+ switch (howto->type) -+ { -+ case R_OR1K_PLT26: -+ { -+ if (htab->splt != NULL && h != NULL -+ && h->plt.offset != (bfd_vma) -1) -+ { -+ relocation = (htab->splt->output_section->vma -+ + htab->splt->output_offset -+ + h->plt.offset); -+ } -+ break; -+ } -+ -+ case R_OR1K_GOT16: -+ /* Relocation is to the entry for this symbol in the global -+ offset table. */ -+ BFD_ASSERT (sgot != NULL); -+ if (h != NULL) -+ { -+ bfd_boolean dyn; -+ bfd_vma off; -+ -+ off = h->got.offset; -+ BFD_ASSERT (off != (bfd_vma) -1); -+ -+ dyn = htab->root.dynamic_sections_created; -+ if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h) -+ || (info->shared -+ && SYMBOL_REFERENCES_LOCAL (info, h))) -+ { -+ /* This is actually a static link, or it is a -+ -Bsymbolic link and the symbol is defined -+ locally, or the symbol was forced to be local -+ because of a version file. We must initialize -+ this entry in the global offset table. Since the -+ offset must always be a multiple of 4, we use the -+ least significant bit to record whether we have -+ initialized it already. -+ -+ When doing a dynamic link, we create a .rela.got -+ relocation entry to initialize the value. This -+ is done in the finish_dynamic_symbol routine. */ -+ if ((off & 1) != 0) -+ off &= ~1; -+ else -+ { -+ /* Write entry in GOT. */ -+ bfd_put_32 (output_bfd, relocation, -+ sgot->contents + off); -+ /* Mark GOT entry as having been written. */ -+ h->got.offset |= 1; -+ } -+ } -+ -+ relocation = sgot->output_offset + off; -+ } -+ else -+ { -+ bfd_vma off; -+ bfd_byte *loc; -+ -+ BFD_ASSERT (local_got_offsets != NULL -+ && local_got_offsets[r_symndx] != (bfd_vma) -1); -+ -+ /* Get offset into GOT table. */ -+ off = local_got_offsets[r_symndx]; -+ -+ /* The offset must always be a multiple of 4. We use -+ the least significant bit to record whether we have -+ already processed this entry. */ -+ if ((off & 1) != 0) -+ off &= ~1; -+ else -+ { -+ /* Write entry in GOT. */ -+ bfd_put_32 (output_bfd, relocation, sgot->contents + off); -+ if (info->shared) -+ { -+ asection *srelgot; -+ Elf_Internal_Rela outrel; -+ -+ /* We need to generate a R_OR1K_RELATIVE reloc -+ for the dynamic linker. */ -+ srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); -+ BFD_ASSERT (srelgot != NULL); -+ -+ outrel.r_offset = (sgot->output_section->vma -+ + sgot->output_offset -+ + off); -+ outrel.r_info = ELF32_R_INFO (0, R_OR1K_RELATIVE); -+ outrel.r_addend = relocation; -+ loc = srelgot->contents; -+ loc += srelgot->reloc_count * sizeof (Elf32_External_Rela); -+ bfd_elf32_swap_reloca_out (output_bfd, &outrel,loc); -+ ++srelgot->reloc_count; -+ } -+ -+ local_got_offsets[r_symndx] |= 1; -+ } -+ relocation = sgot->output_offset + off; -+ } -+ -+ /* Addend should be zero. */ -+ if (rel->r_addend != 0) -+ (*_bfd_error_handler) -+ (_("internal error: addend should be zero for R_OR1K_GOT16")); -+ -+ break; -+ -+ case R_OR1K_GOTOFF_LO16: -+ case R_OR1K_GOTOFF_HI16: -+ /* Relocation is offset from GOT. */ -+ BFD_ASSERT (sgot != NULL); -+ relocation -= sgot->output_section->vma; -+ break; -+ -+ case R_OR1K_INSN_REL_26: -+ case R_OR1K_HI_16_IN_INSN: -+ case R_OR1K_LO_16_IN_INSN: -+ case R_OR1K_32: -+ /* R_OR1K_16? */ -+ { -+ /* r_symndx will be STN_UNDEF (zero) only for relocs against symbols -+ from removed linkonce sections, or sections discarded by -+ a linker script. */ -+ if (r_symndx == STN_UNDEF -+ || (input_section->flags & SEC_ALLOC) == 0) -+ break; -+ -+ if ((info->shared -+ && (h == NULL -+ || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT -+ || h->root.type != bfd_link_hash_undefweak) -+ && (howto->type != R_OR1K_INSN_REL_26 -+ || !SYMBOL_CALLS_LOCAL (info, h))) -+ || (!info->shared -+ && h != NULL -+ && h->dynindx != -1 -+ && !h->non_got_ref -+ && ((h->def_dynamic -+ && !h->def_regular) -+ || h->root.type == bfd_link_hash_undefweak -+ || h->root.type == bfd_link_hash_undefined))) -+ { -+ Elf_Internal_Rela outrel; -+ bfd_byte *loc; -+ bfd_boolean skip; -+ -+ /* When generating a shared object, these relocations -+ are copied into the output file to be resolved at run -+ time. */ -+ -+ BFD_ASSERT (sreloc != NULL); -+ -+ skip = FALSE; -+ -+ outrel.r_offset = -+ _bfd_elf_section_offset (output_bfd, info, input_section, -+ rel->r_offset); -+ if (outrel.r_offset == (bfd_vma) -1) -+ skip = TRUE; -+ else if (outrel.r_offset == (bfd_vma) -2) -+ skip = TRUE; -+ outrel.r_offset += (input_section->output_section->vma -+ + input_section->output_offset); -+ -+ if (skip) -+ memset (&outrel, 0, sizeof outrel); -+ /* h->dynindx may be -1 if the symbol was marked to -+ become local. */ -+ else if (h != NULL -+ && ((! info->symbolic && h->dynindx != -1) -+ || !h->def_regular)) -+ { -+ BFD_ASSERT (h->dynindx != -1); -+ outrel.r_info = ELF32_R_INFO (h->dynindx, r_type); -+ outrel.r_addend = rel->r_addend; -+ } -+ else -+ { -+ if (r_type == R_OR1K_32) -+ { -+ outrel.r_info = ELF32_R_INFO (0, R_OR1K_RELATIVE); -+ outrel.r_addend = relocation + rel->r_addend; -+ } -+ else -+ { -+ BFD_FAIL (); -+ (*_bfd_error_handler) -+ (_("%B: probably compiled without -fPIC?"), -+ input_bfd); -+ bfd_set_error (bfd_error_bad_value); -+ return FALSE; -+ } -+ } -+ -+ loc = sreloc->contents; -+ loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rela); -+ bfd_elf32_swap_reloca_out (output_bfd, &outrel, loc); -+ break; -+ } -+ break; -+ } -+ -+ case R_OR1K_TLS_LDM_HI16: -+ case R_OR1K_TLS_LDM_LO16: -+ case R_OR1K_TLS_LDO_HI16: -+ case R_OR1K_TLS_LDO_LO16: -+ /* TODO: implement support for local dynamic. */ -+ BFD_FAIL (); -+ (*_bfd_error_handler) -+ (_("%B: support for local dynamic not implemented"), -+ input_bfd); -+ bfd_set_error (bfd_error_bad_value); -+ return FALSE; -+ -+ -+ case R_OR1K_TLS_GD_HI16: -+ case R_OR1K_TLS_GD_LO16: -+ case R_OR1K_TLS_IE_HI16: -+ case R_OR1K_TLS_IE_LO16: -+ { -+ bfd_vma gotoff; -+ Elf_Internal_Rela rela; -+ bfd_byte *loc; -+ int dynamic; -+ -+ sreloc = bfd_get_section_by_name (dynobj, ".rela.got"); -+ -+ /* Mark as TLS related GOT entry by setting -+ bit 2 as well as bit 1. */ -+ if (h != NULL) -+ { -+ gotoff = h->got.offset; -+ h->got.offset |= 3; -+ } -+ else -+ { -+ gotoff = local_got_offsets[r_symndx]; -+ local_got_offsets[r_symndx] |= 3; -+ } -+ -+ /* Only process the relocation once. */ -+ if (gotoff & 1) -+ { -+ relocation = sgot->output_offset + (gotoff & ~3); -+ break; -+ } -+ -+ BFD_ASSERT (elf_hash_table (info)->hgot == NULL -+ || elf_hash_table (info)->hgot->root.u.def.value == 0); -+ -+ /* Dynamic entries will require relocations. if we do not need -+ them we will just use the default R_OR1K_NONE and -+ not set anything. */ -+ dynamic = info->shared -+ || (sec && (sec->flags & SEC_ALLOC) != 0 -+ && h != NULL -+ && (h->root.type == bfd_link_hash_defweak || !h->def_regular)); -+ -+ /* Shared GD. */ -+ if (dynamic && (howto->type == R_OR1K_TLS_GD_HI16 -+ || howto->type == R_OR1K_TLS_GD_LO16)) -+ { -+ int i; -+ -+ /* Add DTPMOD and DTPOFF GOT and rela entries. */ -+ for (i = 0; i < 2; ++i) -+ { -+ rela.r_offset = sgot->output_section->vma + -+ sgot->output_offset + gotoff + i*4; -+ if (h != NULL && h->dynindx != -1) -+ { -+ rela.r_info = ELF32_R_INFO (h->dynindx, -+ (i == 0 ? R_OR1K_TLS_DTPMOD : R_OR1K_TLS_DTPOFF)); -+ rela.r_addend = 0; -+ } -+ else -+ { -+ rela.r_info = ELF32_R_INFO (0, -+ (i == 0 ? R_OR1K_TLS_DTPMOD : R_OR1K_TLS_DTPOFF)); -+ rela.r_addend = tpoff (info, relocation); -+ } -+ -+ loc = sreloc->contents; -+ loc += sreloc->reloc_count++ * -+ sizeof (Elf32_External_Rela); -+ -+ bfd_elf32_swap_reloca_out (output_bfd, &rela, loc); -+ bfd_put_32 (output_bfd, 0, sgot->contents + gotoff + i*4); -+ } -+ } -+ /* Static GD. */ -+ else if (howto->type == R_OR1K_TLS_GD_HI16 -+ || howto->type == R_OR1K_TLS_GD_LO16) -+ { -+ bfd_put_32 (output_bfd, 1, sgot->contents + gotoff); -+ bfd_put_32 (output_bfd, tpoff (info, relocation), -+ sgot->contents + gotoff + 4); -+ } -+ /* Shared IE. */ -+ else if (dynamic) -+ { -+ /* Add TPOFF GOT and rela entries. */ -+ rela.r_offset = sgot->output_section->vma + -+ sgot->output_offset + gotoff; -+ if (h != NULL && h->dynindx != -1) -+ { -+ rela.r_info = ELF32_R_INFO (h->dynindx, R_OR1K_TLS_TPOFF); -+ rela.r_addend = 0; -+ } -+ else -+ { -+ rela.r_info = ELF32_R_INFO (0, R_OR1K_TLS_TPOFF); -+ rela.r_addend = tpoff (info, relocation); -+ } -+ -+ loc = sreloc->contents; -+ loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rela); -+ -+ bfd_elf32_swap_reloca_out (output_bfd, &rela, loc); -+ bfd_put_32 (output_bfd, 0, sgot->contents + gotoff); -+ } -+ /* Static IE. */ -+ else -+ { -+ bfd_put_32 (output_bfd, tpoff (info, relocation), -+ sgot->contents + gotoff); -+ } -+ relocation = sgot->output_offset + gotoff; -+ break; -+ } -+ case R_OR1K_TLS_LE_HI16: -+ case R_OR1K_TLS_LE_LO16: -+ -+ /* Relocation is offset from TP. */ -+ relocation = tpoff (info, relocation); -+ break; -+ -+ case R_OR1K_TLS_DTPMOD: -+ case R_OR1K_TLS_DTPOFF: -+ case R_OR1K_TLS_TPOFF: -+ /* These are resolved dynamically on load and shouldn't -+ be used as linker input. */ -+ BFD_FAIL (); -+ (*_bfd_error_handler) -+ (_("%B: will not resolve runtime TLS relocation"), -+ input_bfd); -+ bfd_set_error (bfd_error_bad_value); -+ return FALSE; -+ -+ default: -+ break; -+ } -+ r = _bfd_final_link_relocate (howto, input_bfd, input_section, contents, -+ rel->r_offset, relocation, rel->r_addend); -+ -+ if (r != bfd_reloc_ok) -+ { -+ const char *msg = NULL; -+ -+ switch (r) -+ { -+ case bfd_reloc_overflow: -+ r = info->callbacks->reloc_overflow -+ (info, (h ? &h->root : NULL), name, howto->name, -+ (bfd_vma) 0, input_bfd, input_section, rel->r_offset); -+ break; -+ -+ case bfd_reloc_undefined: -+ r = info->callbacks->undefined_symbol -+ (info, name, input_bfd, input_section, rel->r_offset, TRUE); -+ break; -+ -+ case bfd_reloc_outofrange: -+ msg = _("internal error: out of range error"); -+ break; -+ -+ case bfd_reloc_notsupported: -+ msg = _("internal error: unsupported relocation error"); -+ break; -+ -+ case bfd_reloc_dangerous: -+ msg = _("internal error: dangerous relocation"); -+ break; -+ -+ default: -+ msg = _("internal error: unknown error"); -+ break; -+ } -+ -+ if (msg) -+ r = info->callbacks->warning -+ (info, msg, name, input_bfd, input_section, rel->r_offset); -+ -+ if (!r) -+ return FALSE; -+ } -+ } -+ -+ return TRUE; -+} -+ -+/* Return the section that should be marked against GC for a given -+ relocation. */ -+ -+static asection * -+or1k_elf_gc_mark_hook (asection *sec, -+ struct bfd_link_info *info, -+ Elf_Internal_Rela *rel, -+ struct elf_link_hash_entry *h, -+ Elf_Internal_Sym *sym) -+{ -+ if (h != NULL) -+ switch (ELF32_R_TYPE (rel->r_info)) -+ { -+ case R_OR1K_GNU_VTINHERIT: -+ case R_OR1K_GNU_VTENTRY: -+ return NULL; -+ } -+ -+ return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym); -+} -+ -+static bfd_boolean -+or1k_elf_gc_sweep_hook (bfd *abfd, -+ struct bfd_link_info *info ATTRIBUTE_UNUSED, -+ asection *sec, -+ const Elf_Internal_Rela *relocs ATTRIBUTE_UNUSED) -+{ -+ /* Update the got entry reference counts for the section being removed. */ -+ Elf_Internal_Shdr *symtab_hdr; -+ struct elf_link_hash_entry **sym_hashes; -+ bfd_signed_vma *local_got_refcounts; -+ const Elf_Internal_Rela *rel, *relend; -+ -+ elf_section_data (sec)->local_dynrel = NULL; -+ -+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr; -+ sym_hashes = elf_sym_hashes (abfd); -+ local_got_refcounts = elf_local_got_refcounts (abfd); -+ -+ relend = relocs + sec->reloc_count; -+ for (rel = relocs; rel < relend; rel++) -+ { -+ unsigned long r_symndx; -+ struct elf_link_hash_entry *h = NULL; -+ -+ r_symndx = ELF32_R_SYM (rel->r_info); -+ if (r_symndx >= symtab_hdr->sh_info) -+ { -+ h = sym_hashes[r_symndx - symtab_hdr->sh_info]; -+ while (h->root.type == bfd_link_hash_indirect -+ || h->root.type == bfd_link_hash_warning) -+ h = (struct elf_link_hash_entry *) h->root.u.i.link; -+ } -+ -+ switch (ELF32_R_TYPE (rel->r_info)) -+ { -+ case R_OR1K_GOT16: -+ if (h != NULL) -+ { -+ if (h->got.refcount > 0) -+ h->got.refcount--; -+ } -+ else -+ { -+ if (local_got_refcounts && local_got_refcounts[r_symndx] > 0) -+ local_got_refcounts[r_symndx]--; -+ } -+ break; -+ -+ default: -+ break; -+ } -+ } -+ return TRUE; -+} -+ -+/* Create .got, .gotplt, and .rela.got sections in DYNOBJ, and set up -+ shortcuts to them in our hash table. */ -+ -+static bfd_boolean -+create_got_section (bfd *dynobj, struct bfd_link_info *info) -+{ -+ struct elf_or1k_link_hash_table *htab; -+ asection *s; -+ -+ /* This function may be called more than once. */ -+ s = bfd_get_section_by_name (dynobj, ".got"); -+ if (s != NULL && (s->flags & SEC_LINKER_CREATED) != 0) -+ return TRUE; -+ -+ htab = or1k_elf_hash_table (info); -+ if (htab == NULL) -+ return FALSE; -+ -+ if (! _bfd_elf_create_got_section (dynobj, info)) -+ return FALSE; -+ -+ htab->sgot = bfd_get_section_by_name (dynobj, ".got"); -+ htab->sgotplt = bfd_get_section_by_name (dynobj, ".got.plt"); -+ htab->srelgot = bfd_get_section_by_name (dynobj, ".rela.got"); -+ -+ if (! htab->sgot || ! htab->sgotplt || ! htab->srelgot) -+ abort (); -+ -+ if (! bfd_set_section_flags (dynobj, htab->srelgot, SEC_ALLOC -+ | SEC_LOAD -+ | SEC_HAS_CONTENTS -+ | SEC_IN_MEMORY -+ | SEC_LINKER_CREATED -+ | SEC_READONLY) -+ || ! bfd_set_section_alignment (dynobj, htab->srelgot, 2)) -+ return FALSE; -+ -+ return TRUE; -+} -+ -+/* Look through the relocs for a section during the first phase. */ -+ -+static bfd_boolean -+or1k_elf_check_relocs (bfd *abfd, -+ struct bfd_link_info *info, -+ asection *sec, -+ const Elf_Internal_Rela *relocs) -+{ -+ Elf_Internal_Shdr *symtab_hdr; -+ struct elf_link_hash_entry **sym_hashes; -+ const Elf_Internal_Rela *rel; -+ -+ const Elf_Internal_Rela *rel_end; -+ struct elf_or1k_link_hash_table *htab; -+ bfd *dynobj; -+ asection *sreloc = NULL; -+ -+ if (info->relocatable) -+ return TRUE; -+ -+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr; -+ sym_hashes = elf_sym_hashes (abfd); -+ -+ htab = or1k_elf_hash_table (info); -+ if (htab == NULL) -+ return FALSE; -+ -+ dynobj = htab->root.dynobj; -+ -+ rel_end = relocs + sec->reloc_count; -+ for (rel = relocs; rel < rel_end; rel++) -+ { -+ struct elf_link_hash_entry *h; -+ unsigned long r_symndx; -+ unsigned char tls_type; -+ -+ r_symndx = ELF32_R_SYM (rel->r_info); -+ if (r_symndx < symtab_hdr->sh_info) -+ h = NULL; -+ else -+ { -+ h = sym_hashes[r_symndx - symtab_hdr->sh_info]; -+ while (h->root.type == bfd_link_hash_indirect -+ || h->root.type == bfd_link_hash_warning) -+ h = (struct elf_link_hash_entry *) h->root.u.i.link; -+ -+ /* PR15323, ref flags aren't set for references in the same -+ object. */ -+ h->root.non_ir_ref = 1; -+ } -+ -+ switch (ELF32_R_TYPE (rel->r_info)) -+ { -+ case R_OR1K_TLS_GD_HI16: -+ case R_OR1K_TLS_GD_LO16: -+ tls_type = TLS_GD; -+ break; -+ case R_OR1K_TLS_LDM_HI16: -+ case R_OR1K_TLS_LDM_LO16: -+ case R_OR1K_TLS_LDO_HI16: -+ case R_OR1K_TLS_LDO_LO16: -+ tls_type = TLS_LD; -+ break; -+ case R_OR1K_TLS_IE_HI16: -+ case R_OR1K_TLS_IE_LO16: -+ tls_type = TLS_IE; -+ break; -+ case R_OR1K_TLS_LE_HI16: -+ case R_OR1K_TLS_LE_LO16: -+ tls_type = TLS_LE; -+ break; -+ default: -+ tls_type = TLS_NONE; -+ } -+ -+ /* Record TLS type. */ -+ if (h != NULL) -+ ((struct elf_or1k_link_hash_entry *) h)->tls_type = tls_type; -+ else -+ { -+ unsigned char *local_tls_type; -+ -+ /* This is a TLS type record for a local symbol. */ -+ local_tls_type = (unsigned char *) elf_or1k_local_tls_type (abfd); -+ if (local_tls_type == NULL) -+ { -+ bfd_size_type size; -+ -+ size = symtab_hdr->sh_info; -+ local_tls_type = bfd_zalloc (abfd, size); -+ if (local_tls_type == NULL) -+ return FALSE; -+ elf_or1k_local_tls_type (abfd) = local_tls_type; -+ } -+ local_tls_type[r_symndx] = tls_type; -+ } -+ -+ switch (ELF32_R_TYPE (rel->r_info)) -+ { -+ /* This relocation describes the C++ object vtable hierarchy. -+ Reconstruct it for later use during GC. */ -+ case R_OR1K_GNU_VTINHERIT: -+ if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset)) -+ return FALSE; -+ break; -+ -+ /* This relocation describes which C++ vtable entries are actually -+ used. Record for later use during GC. */ -+ case R_OR1K_GNU_VTENTRY: -+ BFD_ASSERT (h != NULL); -+ if (h != NULL -+ && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend)) -+ return FALSE; -+ break; -+ -+ /* This relocation requires .plt entry. */ -+ case R_OR1K_PLT26: -+ if (h != NULL) -+ { -+ h->needs_plt = 1; -+ h->plt.refcount += 1; -+ } -+ break; -+ -+ case R_OR1K_GOT16: -+ case R_OR1K_GOTOFF_HI16: -+ case R_OR1K_GOTOFF_LO16: -+ case R_OR1K_TLS_GD_HI16: -+ case R_OR1K_TLS_GD_LO16: -+ case R_OR1K_TLS_IE_HI16: -+ case R_OR1K_TLS_IE_LO16: -+ if (htab->sgot == NULL) -+ { -+ if (dynobj == NULL) -+ htab->root.dynobj = dynobj = abfd; -+ if (! create_got_section (dynobj, info)) -+ return FALSE; -+ } -+ -+ if (ELF32_R_TYPE (rel->r_info) != R_OR1K_GOTOFF_HI16 && -+ ELF32_R_TYPE (rel->r_info) != R_OR1K_GOTOFF_LO16) -+ { -+ if (h != NULL) -+ h->got.refcount += 1; -+ else -+ { -+ bfd_signed_vma *local_got_refcounts; -+ -+ /* This is a global offset table entry for a local symbol. */ -+ local_got_refcounts = elf_local_got_refcounts (abfd); -+ if (local_got_refcounts == NULL) -+ { -+ bfd_size_type size; -+ -+ size = symtab_hdr->sh_info; -+ size *= sizeof (bfd_signed_vma); -+ local_got_refcounts = bfd_zalloc (abfd, size); -+ if (local_got_refcounts == NULL) -+ return FALSE; -+ elf_local_got_refcounts (abfd) = local_got_refcounts; -+ } -+ local_got_refcounts[r_symndx] += 1; -+ } -+ } -+ break; -+ -+ case R_OR1K_INSN_REL_26: -+ case R_OR1K_HI_16_IN_INSN: -+ case R_OR1K_LO_16_IN_INSN: -+ case R_OR1K_32: -+ /* R_OR1K_16? */ -+ { -+ if (h != NULL && !info->shared) -+ { -+ /* We may need a copy reloc. */ -+ h->non_got_ref = 1; -+ -+ /* We may also need a .plt entry. */ -+ h->plt.refcount += 1; -+ if (ELF32_R_TYPE (rel->r_info) != R_OR1K_INSN_REL_26) -+ h->pointer_equality_needed = 1; -+ } -+ -+ /* If we are creating a shared library, and this is a reloc -+ against a global symbol, or a non PC relative reloc -+ against a local symbol, then we need to copy the reloc -+ into the shared library. However, if we are linking with -+ -Bsymbolic, we do not need to copy a reloc against a -+ global symbol which is defined in an object we are -+ including in the link (i.e., DEF_REGULAR is set). At -+ this point we have not seen all the input files, so it is -+ possible that DEF_REGULAR is not set now but will be set -+ later (it is never cleared). In case of a weak definition, -+ DEF_REGULAR may be cleared later by a strong definition in -+ a shared library. We account for that possibility below by -+ storing information in the relocs_copied field of the hash -+ table entry. A similar situation occurs when creating -+ shared libraries and symbol visibility changes render the -+ symbol local. -+ -+ If on the other hand, we are creating an executable, we -+ may need to keep relocations for symbols satisfied by a -+ dynamic library if we manage to avoid copy relocs for the -+ symbol. */ -+ -+ if ((info->shared -+ && (sec->flags & SEC_ALLOC) != 0 -+ && (ELF32_R_TYPE (rel->r_info) != R_OR1K_INSN_REL_26 -+ || (h != NULL -+ && (!SYMBOLIC_BIND (info, h) -+ || h->root.type == bfd_link_hash_defweak -+ || !h->def_regular)))) -+ || (!info->shared -+ && (sec->flags & SEC_ALLOC) != 0 -+ && h != NULL -+ && (h->root.type == bfd_link_hash_defweak -+ || !h->def_regular))) -+ { -+ struct elf_or1k_dyn_relocs *p; -+ struct elf_or1k_dyn_relocs **head; -+ -+ /* When creating a shared object, we must copy these -+ relocs into the output file. We create a reloc -+ section in dynobj and make room for the reloc. */ -+ if (sreloc == NULL) -+ { -+ const char *name; -+ unsigned int strndx = elf_elfheader (abfd)->e_shstrndx; -+ unsigned int shnam = _bfd_elf_single_rel_hdr (sec)->sh_name; -+ -+ name = bfd_elf_string_from_elf_section (abfd, strndx, shnam); -+ if (name == NULL) -+ return FALSE; -+ -+ if (strncmp (name, ".rela", 5) != 0 -+ || strcmp (bfd_get_section_name (abfd, sec), -+ name + 5) != 0) -+ { -+ (*_bfd_error_handler) -+ (_("%B: bad relocation section name `%s\'"), -+ abfd, name); -+ } -+ -+ if (htab->root.dynobj == NULL) -+ htab->root.dynobj = abfd; -+ dynobj = htab->root.dynobj; -+ -+ sreloc = bfd_get_section_by_name (dynobj, name); -+ if (sreloc == NULL) -+ { -+ sreloc = _bfd_elf_make_dynamic_reloc_section -+ (sec, dynobj, 2, abfd, /*rela?*/ TRUE); -+ -+ if (sreloc == NULL) -+ return FALSE; -+ } -+ elf_section_data (sec)->sreloc = sreloc; -+ } -+ -+ /* If this is a global symbol, we count the number of -+ relocations we need for this symbol. */ -+ if (h != NULL) -+ head = &((struct elf_or1k_link_hash_entry *) h)->dyn_relocs; -+ else -+ { -+ /* Track dynamic relocs needed for local syms too. -+ We really need local syms available to do this -+ easily. Oh well. */ -+ -+ asection *s; -+ Elf_Internal_Sym *isym; -+ void *vpp; -+ -+ isym = bfd_sym_from_r_symndx (&htab->sym_sec, -+ abfd, r_symndx); -+ if (isym == NULL) -+ return FALSE; -+ -+ s = bfd_section_from_elf_index (abfd, isym->st_shndx); -+ if (s == NULL) -+ return FALSE; -+ -+ vpp = &elf_section_data (s)->local_dynrel; -+ head = (struct elf_or1k_dyn_relocs **) vpp; -+ } -+ -+ p = *head; -+ if (p == NULL || p->sec != sec) -+ { -+ bfd_size_type amt = sizeof *p; -+ p = ((struct elf_or1k_dyn_relocs *) -+ bfd_alloc (htab->root.dynobj, amt)); -+ if (p == NULL) -+ return FALSE; -+ p->next = *head; -+ *head = p; -+ p->sec = sec; -+ p->count = 0; -+ p->pc_count = 0; -+ } -+ -+ p->count += 1; -+ if (ELF32_R_TYPE (rel->r_info) == R_OR1K_INSN_REL_26) -+ p->pc_count += 1; -+ } -+ } -+ break; -+ } -+ } -+ -+ return TRUE; -+} -+ -+/* Finish up the dynamic sections. */ -+ -+static bfd_boolean -+or1k_elf_finish_dynamic_sections (bfd *output_bfd, -+ struct bfd_link_info *info) -+{ -+ bfd *dynobj; -+ asection *sdyn, *sgot; -+ struct elf_or1k_link_hash_table *htab; -+ -+ htab = or1k_elf_hash_table (info); -+ if (htab == NULL) -+ return FALSE; -+ -+ dynobj = htab->root.dynobj; -+ -+ sgot = htab->sgotplt; -+ sdyn = bfd_get_section_by_name (dynobj, ".dynamic"); -+ -+ if (htab->root.dynamic_sections_created) -+ { -+ asection *splt; -+ Elf32_External_Dyn *dyncon, *dynconend; -+ -+ BFD_ASSERT (sgot != NULL && sdyn != NULL); -+ -+ dyncon = (Elf32_External_Dyn *) sdyn->contents; -+ dynconend = (Elf32_External_Dyn *) (sdyn->contents + sdyn->size); -+ -+ for (; dyncon < dynconend; dyncon++) -+ { -+ Elf_Internal_Dyn dyn; -+ asection *s; -+ -+ bfd_elf32_swap_dyn_in (dynobj, dyncon, &dyn); -+ -+ switch (dyn.d_tag) -+ { -+ default: -+ continue; -+ -+ case DT_PLTGOT: -+ s = htab->sgot->output_section; -+ BFD_ASSERT (s != NULL); -+ dyn.d_un.d_ptr = s->vma; -+ break; -+ -+ case DT_JMPREL: -+ s = htab->srelplt->output_section; -+ BFD_ASSERT (s != NULL); -+ dyn.d_un.d_ptr = s->vma; -+ break; -+ -+ case DT_PLTRELSZ: -+ s = htab->srelplt->output_section; -+ BFD_ASSERT (s != NULL); -+ dyn.d_un.d_val = s->size; -+ break; -+ -+ case DT_RELASZ: -+ /* My reading of the SVR4 ABI indicates that the -+ procedure linkage table relocs (DT_JMPREL) should be -+ included in the overall relocs (DT_RELA). This is -+ what Solaris does. However, UnixWare can not handle -+ that case. Therefore, we override the DT_RELASZ entry -+ here to make it not include the JMPREL relocs. Since -+ the linker script arranges for .rela.plt to follow all -+ other relocation sections, we don't have to worry -+ about changing the DT_RELA entry. */ -+ if (htab->srelplt != NULL) -+ { -+ /* FIXME: this calculation sometimes produces -+ wrong result, the problem is that the dyn.d_un.d_val -+ is not always correct, needs investigation why -+ that happens. In the meantime, reading the -+ ".rela.dyn" section by name seems to yield -+ correct result. -+ -+ s = htab->srelplt->output_section; -+ dyn.d_un.d_val -= s->size; -+ */ -+ -+ s = bfd_get_section_by_name (output_bfd, ".rela.dyn"); -+ dyn.d_un.d_val = s ? s->size : 0; -+ } -+ break; -+ } -+ bfd_elf32_swap_dyn_out (output_bfd, &dyn, dyncon); -+ } -+ -+ -+ /* Fill in the first entry in the procedure linkage table. */ -+ splt = htab->splt; -+ if (splt && splt->size > 0) -+ { -+ if (info->shared) -+ { -+ bfd_put_32 (output_bfd, PLT0_PIC_ENTRY_WORD0, -+ splt->contents); -+ bfd_put_32 (output_bfd, PLT0_PIC_ENTRY_WORD1, -+ splt->contents + 4); -+ bfd_put_32 (output_bfd, PLT0_PIC_ENTRY_WORD2, -+ splt->contents + 8); -+ bfd_put_32 (output_bfd, PLT0_PIC_ENTRY_WORD3, -+ splt->contents + 12); -+ bfd_put_32 (output_bfd, PLT0_PIC_ENTRY_WORD4, -+ splt->contents + 16); -+ } -+ else -+ { -+ unsigned long addr; -+ /* addr = .got + 4 */ -+ addr = sgot->output_section->vma + sgot->output_offset + 4; -+ bfd_put_32 (output_bfd, -+ PLT0_ENTRY_WORD0 | ((addr >> 16) & 0xffff), -+ splt->contents); -+ bfd_put_32 (output_bfd, -+ PLT0_ENTRY_WORD1 | (addr & 0xffff), -+ splt->contents + 4); -+ bfd_put_32 (output_bfd, PLT0_ENTRY_WORD2, splt->contents + 8); -+ bfd_put_32 (output_bfd, PLT0_ENTRY_WORD3, splt->contents + 12); -+ bfd_put_32 (output_bfd, PLT0_ENTRY_WORD4, splt->contents + 16); -+ } -+ -+ elf_section_data (splt->output_section)->this_hdr.sh_entsize = 4; -+ } -+ } -+ -+ /* Set the first entry in the global offset table to the address of -+ the dynamic section. */ -+ if (sgot && sgot->size > 0) -+ { -+ if (sdyn == NULL) -+ bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents); -+ else -+ bfd_put_32 (output_bfd, -+ sdyn->output_section->vma + sdyn->output_offset, -+ sgot->contents); -+ elf_section_data (sgot->output_section)->this_hdr.sh_entsize = 4; -+ } -+ -+ if (htab->sgot && htab->sgot->size > 0) -+ elf_section_data (htab->sgot->output_section)->this_hdr.sh_entsize = 4; -+ -+ return TRUE; -+} -+ -+/* Finish up dynamic symbol handling. We set the contents of various -+ dynamic sections here. */ -+ -+static bfd_boolean -+or1k_elf_finish_dynamic_symbol (bfd *output_bfd, -+ struct bfd_link_info *info, -+ struct elf_link_hash_entry *h, -+ Elf_Internal_Sym *sym) -+{ -+ struct elf_or1k_link_hash_table *htab; -+ bfd_byte *loc; -+ -+ htab = or1k_elf_hash_table (info); -+ if (htab == NULL) -+ return FALSE; -+ -+ if (h->plt.offset != (bfd_vma) -1) -+ { -+ asection *splt; -+ asection *sgot; -+ asection *srela; -+ -+ bfd_vma plt_index; -+ bfd_vma got_offset; -+ bfd_vma got_addr; -+ Elf_Internal_Rela rela; -+ -+ /* This symbol has an entry in the procedure linkage table. Set -+ it up. */ -+ BFD_ASSERT (h->dynindx != -1); -+ -+ splt = htab->splt; -+ sgot = htab->sgotplt; -+ srela = htab->srelplt; -+ BFD_ASSERT (splt != NULL && sgot != NULL && srela != NULL); -+ -+ /* Get the index in the procedure linkage table which -+ corresponds to this symbol. This is the index of this symbol -+ in all the symbols for which we are making plt entries. The -+ first entry in the procedure linkage table is reserved. */ -+ plt_index = h->plt.offset / PLT_ENTRY_SIZE - 1; -+ -+ /* Get the offset into the .got table of the entry that -+ corresponds to this function. Each .got entry is 4 bytes. -+ The first three are reserved. */ -+ got_offset = (plt_index + 3) * 4; -+ got_addr = got_offset; -+ -+ /* Fill in the entry in the procedure linkage table. */ -+ if (! info->shared) -+ { -+ got_addr += htab->sgotplt->output_section->vma -+ + htab->sgotplt->output_offset; -+ bfd_put_32 (output_bfd, PLT_ENTRY_WORD0 | ((got_addr >> 16) & 0xffff), -+ splt->contents + h->plt.offset); -+ bfd_put_32 (output_bfd, PLT_ENTRY_WORD1 | (got_addr & 0xffff), -+ splt->contents + h->plt.offset + 4); -+ bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD2, -+ splt->contents + h->plt.offset + 8); -+ bfd_put_32 (output_bfd, (bfd_vma) PLT_ENTRY_WORD3, -+ splt->contents + h->plt.offset + 12); -+ bfd_put_32 (output_bfd, PLT_ENTRY_WORD4 -+ | plt_index * sizeof (Elf32_External_Rela), -+ splt->contents + h->plt.offset + 16); -+ } -+ else -+ { -+ bfd_put_32 (output_bfd, PLT_PIC_ENTRY_WORD0 | (got_addr & 0xffff), -+ splt->contents + h->plt.offset); -+ bfd_put_32 (output_bfd, PLT_PIC_ENTRY_WORD1 -+ | plt_index * sizeof (Elf32_External_Rela), -+ splt->contents + h->plt.offset + 4); -+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_ENTRY_WORD2, -+ splt->contents + h->plt.offset + 8); -+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_ENTRY_WORD3, -+ splt->contents + h->plt.offset + 12); -+ bfd_put_32 (output_bfd, (bfd_vma) PLT_PIC_ENTRY_WORD4, -+ splt->contents + h->plt.offset + 16); -+ } -+ -+ /* Fill in the entry in the global offset table. */ -+ bfd_put_32 (output_bfd, -+ (splt->output_section->vma -+ + splt->output_offset), /* Same offset. */ -+ sgot->contents + got_offset); -+ -+ /* Fill in the entry in the .rela.plt section. */ -+ rela.r_offset = (sgot->output_section->vma -+ + sgot->output_offset -+ + got_offset); -+ rela.r_info = ELF32_R_INFO (h->dynindx, R_OR1K_JMP_SLOT); -+ rela.r_addend = 0; -+ loc = srela->contents; -+ loc += plt_index * sizeof (Elf32_External_Rela); -+ bfd_elf32_swap_reloca_out (output_bfd, &rela, loc); -+ -+ if (!h->def_regular) -+ { -+ /* Mark the symbol as undefined, rather than as defined in -+ the .plt section. Leave the value alone. */ -+ sym->st_shndx = SHN_UNDEF; -+ } -+ -+ } -+ -+ if (h->got.offset != (bfd_vma) -1 -+ && (h->got.offset & 2) == 0) /* Homemade TLS check. */ -+ { -+ asection *sgot; -+ asection *srela; -+ Elf_Internal_Rela rela; -+ -+ /* This symbol has an entry in the global offset table. Set it -+ up. */ -+ sgot = htab->sgot; -+ srela = htab->srelgot; -+ BFD_ASSERT (sgot != NULL && srela != NULL); -+ -+ rela.r_offset = (sgot->output_section->vma -+ + sgot->output_offset -+ + (h->got.offset &~ 1)); -+ -+ /* If this is a -Bsymbolic link, and the symbol is defined -+ locally, we just want to emit a RELATIVE reloc. Likewise if -+ the symbol was forced to be local because of a version file. -+ The entry in the global offset table will already have been -+ initialized in the relocate_section function. */ -+ if (info->shared && SYMBOL_REFERENCES_LOCAL (info, h)) -+ { -+ rela.r_info = ELF32_R_INFO (0, R_OR1K_RELATIVE); -+ rela.r_addend = (h->root.u.def.value -+ + h->root.u.def.section->output_section->vma -+ + h->root.u.def.section->output_offset); -+ } -+ else -+ { -+ BFD_ASSERT ((h->got.offset & 1) == 0); -+ bfd_put_32 (output_bfd, (bfd_vma) 0, sgot->contents + h->got.offset); -+ rela.r_info = ELF32_R_INFO (h->dynindx, R_OR1K_GLOB_DAT); -+ rela.r_addend = 0; -+ } -+ -+ loc = srela->contents; -+ loc += srela->reloc_count * sizeof (Elf32_External_Rela); -+ bfd_elf32_swap_reloca_out (output_bfd, &rela, loc); -+ ++srela->reloc_count; -+ } -+ -+ if (h->needs_copy) -+ { -+ asection *s; -+ Elf_Internal_Rela rela; -+ -+ /* This symbols needs a copy reloc. Set it up. */ -+ BFD_ASSERT (h->dynindx != -1 -+ && (h->root.type == bfd_link_hash_defined -+ || h->root.type == bfd_link_hash_defweak)); -+ -+ s = bfd_get_section_by_name (h->root.u.def.section->owner, -+ ".rela.bss"); -+ BFD_ASSERT (s != NULL); -+ -+ rela.r_offset = (h->root.u.def.value -+ + h->root.u.def.section->output_section->vma -+ + h->root.u.def.section->output_offset); -+ rela.r_info = ELF32_R_INFO (h->dynindx, R_OR1K_COPY); -+ rela.r_addend = 0; -+ loc = s->contents; -+ loc += s->reloc_count * sizeof (Elf32_External_Rela); -+ bfd_elf32_swap_reloca_out (output_bfd, &rela, loc); -+ ++s->reloc_count; -+ } -+ -+ /* Mark some specially defined symbols as absolute. */ -+ if (strcmp (h->root.root.string, "_DYNAMIC") == 0 -+ || h == htab->root.hgot) -+ sym->st_shndx = SHN_ABS; -+ -+ return TRUE; -+} -+ -+static enum elf_reloc_type_class -+or1k_elf_reloc_type_class (const Elf_Internal_Rela *rela) -+{ -+ switch ((int) ELF32_R_TYPE (rela->r_info)) -+ { -+ case R_OR1K_RELATIVE: return reloc_class_relative; -+ case R_OR1K_JMP_SLOT: return reloc_class_plt; -+ case R_OR1K_COPY: return reloc_class_copy; -+ default: return reloc_class_normal; -+ } -+} -+ -+/* Adjust a symbol defined by a dynamic object and referenced by a -+ regular object. The current definition is in some section of the -+ dynamic object, but we're not including those sections. We have to -+ change the definition to something the rest of the link can -+ understand. */ -+ -+static bfd_boolean -+or1k_elf_adjust_dynamic_symbol (struct bfd_link_info *info, -+ struct elf_link_hash_entry *h) -+{ -+ struct elf_or1k_link_hash_table *htab; -+ struct elf_or1k_link_hash_entry *eh; -+ struct elf_or1k_dyn_relocs *p; -+ bfd *dynobj; -+ asection *s; -+ -+ dynobj = elf_hash_table (info)->dynobj; -+ -+ /* Make sure we know what is going on here. */ -+ BFD_ASSERT (dynobj != NULL -+ && (h->needs_plt -+ || h->type == STT_GNU_IFUNC -+ || h->u.weakdef != NULL -+ || (h->def_dynamic -+ && h->ref_regular -+ && !h->def_regular))); -+ -+ /* If this is a function, put it in the procedure linkage table. We -+ will fill in the contents of the procedure linkage table later, -+ when we know the address of the .got section. */ -+ if ((h->type == STT_FUNC || h->type == STT_GNU_IFUNC) -+ || h->needs_plt) -+ { -+ if (! info->shared -+ && !h->def_dynamic -+ && !h->ref_dynamic -+ && h->root.type != bfd_link_hash_undefweak -+ && h->root.type != bfd_link_hash_undefined) -+ { -+ /* This case can occur if we saw a PLT reloc in an input -+ file, but the symbol was never referred to by a dynamic -+ object. In such a case, we don't actually need to build -+ a procedure linkage table, and we can just do a PCREL -+ reloc instead. */ -+ h->plt.offset = (bfd_vma) -1; -+ h->needs_plt = 0; -+ } -+ -+ return TRUE; -+ } -+ else -+ h->plt.offset = (bfd_vma) -1; -+ -+ /* If this is a weak symbol, and there is a real definition, the -+ processor independent code will have arranged for us to see the -+ real definition first, and we can just use the same value. */ -+ if (h->u.weakdef != NULL) -+ { -+ BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined -+ || h->u.weakdef->root.type == bfd_link_hash_defweak); -+ h->root.u.def.section = h->u.weakdef->root.u.def.section; -+ h->root.u.def.value = h->u.weakdef->root.u.def.value; -+ return TRUE; -+ } -+ -+ /* This is a reference to a symbol defined by a dynamic object which -+ is not a function. */ -+ -+ /* If we are creating a shared library, we must presume that the -+ only references to the symbol are via the global offset table. -+ For such cases we need not do anything here; the relocations will -+ be handled correctly by relocate_section. */ -+ if (info->shared) -+ return TRUE; -+ -+ /* If there are no references to this symbol that do not use the -+ GOT, we don't need to generate a copy reloc. */ -+ if (!h->non_got_ref) -+ return TRUE; -+ -+ /* If -z nocopyreloc was given, we won't generate them either. */ -+ if (info->nocopyreloc) -+ { -+ h->non_got_ref = 0; -+ return TRUE; -+ } -+ -+ eh = (struct elf_or1k_link_hash_entry *) h; -+ for (p = eh->dyn_relocs; p != NULL; p = p->next) -+ { -+ s = p->sec->output_section; -+ if (s != NULL && (s->flags & (SEC_READONLY | SEC_HAS_CONTENTS)) != 0) -+ break; -+ } -+ -+ /* If we didn't find any dynamic relocs in sections which needs the -+ copy reloc, then we'll be keeping the dynamic relocs and avoiding -+ the copy reloc. */ -+ if (p == NULL) -+ { -+ h->non_got_ref = 0; -+ return TRUE; -+ } -+ -+ /* We must allocate the symbol in our .dynbss section, which will -+ become part of the .bss section of the executable. There will be -+ an entry for this symbol in the .dynsym section. The dynamic -+ object will contain position independent code, so all references -+ from the dynamic object to this symbol will go through the global -+ offset table. The dynamic linker will use the .dynsym entry to -+ determine the address it must put in the global offset table, so -+ both the dynamic object and the regular object will refer to the -+ same memory location for the variable. */ -+ -+ htab = or1k_elf_hash_table (info); -+ if (htab == NULL) -+ return FALSE; -+ -+ s = htab->sdynbss; -+ BFD_ASSERT (s != NULL); -+ -+ /* We must generate a R_OR1K_COPY reloc to tell the dynamic linker -+ to copy the initial value out of the dynamic object and into the -+ runtime process image. We need to remember the offset into the -+ .rela.bss section we are going to use. */ -+ if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0) -+ { -+ asection *srel; -+ -+ srel = htab->srelbss; -+ BFD_ASSERT (srel != NULL); -+ srel->size += sizeof (Elf32_External_Rela); -+ h->needs_copy = 1; -+ } -+ -+ return _bfd_elf_adjust_dynamic_copy (h, s); -+} -+ -+/* Allocate space in .plt, .got and associated reloc sections for -+ dynamic relocs. */ -+ -+static bfd_boolean -+allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf) -+{ -+ struct bfd_link_info *info; -+ struct elf_or1k_link_hash_table *htab; -+ struct elf_or1k_link_hash_entry *eh; -+ struct elf_or1k_dyn_relocs *p; -+ -+ if (h->root.type == bfd_link_hash_indirect) -+ return TRUE; -+ -+ info = (struct bfd_link_info *) inf; -+ htab = or1k_elf_hash_table (info); -+ if (htab == NULL) -+ return FALSE; -+ -+ eh = (struct elf_or1k_link_hash_entry *) h; -+ -+ if (htab->root.dynamic_sections_created -+ && h->plt.refcount > 0) -+ { -+ /* Make sure this symbol is output as a dynamic symbol. -+ Undefined weak syms won't yet be marked as dynamic. */ -+ if (h->dynindx == -1 -+ && !h->forced_local) -+ { -+ if (! bfd_elf_link_record_dynamic_symbol (info, h)) -+ return FALSE; -+ } -+ -+ if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info->shared, h)) -+ { -+ asection *s = htab->splt; -+ -+ /* If this is the first .plt entry, make room for the special -+ first entry. */ -+ if (s->size == 0) -+ s->size = PLT_ENTRY_SIZE; -+ -+ h->plt.offset = s->size; -+ -+ /* If this symbol is not defined in a regular file, and we are -+ not generating a shared library, then set the symbol to this -+ location in the .plt. This is required to make function -+ pointers compare as equal between the normal executable and -+ the shared library. */ -+ if (! info->shared -+ && !h->def_regular) -+ { -+ h->root.u.def.section = s; -+ h->root.u.def.value = h->plt.offset; -+ } -+ -+ /* Make room for this entry. */ -+ s->size += PLT_ENTRY_SIZE; -+ -+ /* We also need to make an entry in the .got.plt section, which -+ will be placed in the .got section by the linker script. */ -+ htab->sgotplt->size += 4; -+ -+ /* We also need to make an entry in the .rel.plt section. */ -+ htab->srelplt->size += sizeof (Elf32_External_Rela); -+ } -+ else -+ { -+ h->plt.offset = (bfd_vma) -1; -+ h->needs_plt = 0; -+ } -+ } -+ else -+ { -+ h->plt.offset = (bfd_vma) -1; -+ h->needs_plt = 0; -+ } -+ -+ if (h->got.refcount > 0) -+ { -+ asection *s; -+ bfd_boolean dyn; -+ unsigned char tls_type; -+ -+ /* Make sure this symbol is output as a dynamic symbol. -+ Undefined weak syms won't yet be marked as dynamic. */ -+ if (h->dynindx == -1 -+ && !h->forced_local) -+ { -+ if (! bfd_elf_link_record_dynamic_symbol (info, h)) -+ return FALSE; -+ } -+ -+ s = htab->sgot; -+ -+ h->got.offset = s->size; -+ -+ tls_type = ((struct elf_or1k_link_hash_entry *) h)->tls_type; -+ -+ /* TLS GD requires two GOT and two relocs. */ -+ if (tls_type == TLS_GD) -+ s->size += 8; -+ else -+ s->size += 4; -+ dyn = htab->root.dynamic_sections_created; -+ if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)) -+ { -+ if (tls_type == TLS_GD) -+ htab->srelgot->size += 2 * sizeof (Elf32_External_Rela); -+ else -+ htab->srelgot->size += sizeof (Elf32_External_Rela); -+ } -+ } -+ else -+ h->got.offset = (bfd_vma) -1; -+ -+ if (eh->dyn_relocs == NULL) -+ return TRUE; -+ -+ /* In the shared -Bsymbolic case, discard space allocated for -+ dynamic pc-relative relocs against symbols which turn out to be -+ defined in regular objects. For the normal shared case, discard -+ space for pc-relative relocs that have become local due to symbol -+ visibility changes. */ -+ -+ if (info->shared) -+ { -+ if (SYMBOL_CALLS_LOCAL (info, h)) -+ { -+ struct elf_or1k_dyn_relocs **pp; -+ -+ for (pp = &eh->dyn_relocs; (p = *pp) != NULL;) -+ { -+ p->count -= p->pc_count; -+ p->pc_count = 0; -+ if (p->count == 0) -+ *pp = p->next; -+ else -+ pp = &p->next; -+ } -+ } -+ -+ /* Also discard relocs on undefined weak syms with non-default -+ visibility. */ -+ if (eh->dyn_relocs != NULL -+ && h->root.type == bfd_link_hash_undefweak) -+ { -+ if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT) -+ eh->dyn_relocs = NULL; -+ -+ /* Make sure undefined weak symbols are output as a dynamic -+ symbol in PIEs. */ -+ else if (h->dynindx == -1 -+ && !h->forced_local) -+ { -+ if (! bfd_elf_link_record_dynamic_symbol (info, h)) -+ return FALSE; -+ } -+ } -+ } -+ else -+ { -+ /* For the non-shared case, discard space for relocs against -+ symbols which turn out to need copy relocs or are not -+ dynamic. */ -+ -+ if (!h->non_got_ref -+ && ((h->def_dynamic -+ && !h->def_regular) -+ || (htab->root.dynamic_sections_created -+ && (h->root.type == bfd_link_hash_undefweak -+ || h->root.type == bfd_link_hash_undefined)))) -+ { -+ /* Make sure this symbol is output as a dynamic symbol. -+ Undefined weak syms won't yet be marked as dynamic. */ -+ if (h->dynindx == -1 -+ && !h->forced_local) -+ { -+ if (! bfd_elf_link_record_dynamic_symbol (info, h)) -+ return FALSE; -+ } -+ -+ /* If that succeeded, we know we'll be keeping all the -+ relocs. */ -+ if (h->dynindx != -1) -+ goto keep; -+ } -+ -+ eh->dyn_relocs = NULL; -+ -+ keep: ; -+ } -+ -+ /* Finally, allocate space. */ -+ for (p = eh->dyn_relocs; p != NULL; p = p->next) -+ { -+ asection *sreloc = elf_section_data (p->sec)->sreloc; -+ sreloc->size += p->count * sizeof (Elf32_External_Rela); -+ } -+ -+ return TRUE; -+} -+ -+/* Find any dynamic relocs that apply to read-only sections. */ -+ -+static bfd_boolean -+readonly_dynrelocs (struct elf_link_hash_entry *h, void * inf) -+{ -+ struct elf_or1k_link_hash_entry *eh; -+ struct elf_or1k_dyn_relocs *p; -+ -+ eh = (struct elf_or1k_link_hash_entry *) h; -+ for (p = eh->dyn_relocs; p != NULL; p = p->next) -+ { -+ asection *s = p->sec->output_section; -+ -+ if (s != NULL && (s->flags & SEC_READONLY) != 0) -+ { -+ struct bfd_link_info *info = (struct bfd_link_info *) inf; -+ -+ info->flags |= DF_TEXTREL; -+ -+ /* Not an error, just cut short the traversal. */ -+ return FALSE; -+ } -+ } -+ return TRUE; -+} -+ -+/* Set the sizes of the dynamic sections. */ -+ -+static bfd_boolean -+or1k_elf_size_dynamic_sections (bfd *output_bfd ATTRIBUTE_UNUSED, -+ struct bfd_link_info *info) -+{ -+ struct elf_or1k_link_hash_table *htab; -+ bfd *dynobj; -+ asection *s; -+ bfd_boolean relocs; -+ bfd *ibfd; -+ -+ htab = or1k_elf_hash_table (info); -+ if (htab == NULL) -+ return FALSE; -+ -+ dynobj = htab->root.dynobj; -+ BFD_ASSERT (dynobj != NULL); -+ -+ if (htab->root.dynamic_sections_created) -+ { -+ /* Set the contents of the .interp section to the interpreter. */ -+ if (info->executable) -+ { -+ s = bfd_get_section_by_name (dynobj, ".interp"); -+ BFD_ASSERT (s != NULL); -+ s->size = sizeof ELF_DYNAMIC_INTERPRETER; -+ s->contents = (unsigned char *) ELF_DYNAMIC_INTERPRETER; -+ } -+ } -+ -+ /* Set up .got offsets for local syms, and space for local dynamic -+ relocs. */ -+ for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next) -+ { -+ bfd_signed_vma *local_got; -+ bfd_signed_vma *end_local_got; -+ bfd_size_type locsymcount; -+ Elf_Internal_Shdr *symtab_hdr; -+ unsigned char *local_tls_type; -+ asection *srel; -+ -+ if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour) -+ continue; -+ -+ for (s = ibfd->sections; s != NULL; s = s->next) -+ { -+ struct elf_or1k_dyn_relocs *p; -+ -+ for (p = ((struct elf_or1k_dyn_relocs *) -+ elf_section_data (s)->local_dynrel); -+ p != NULL; -+ p = p->next) -+ { -+ if (! bfd_is_abs_section (p->sec) -+ && bfd_is_abs_section (p->sec->output_section)) -+ { -+ /* Input section has been discarded, either because -+ it is a copy of a linkonce section or due to -+ linker script /DISCARD/, so we'll be discarding -+ the relocs too. */ -+ } -+ else if (p->count != 0) -+ { -+ srel = elf_section_data (p->sec)->sreloc; -+ srel->size += p->count * sizeof (Elf32_External_Rela); -+ if ((p->sec->output_section->flags & SEC_READONLY) != 0) -+ info->flags |= DF_TEXTREL; -+ } -+ } -+ } -+ -+ local_got = elf_local_got_refcounts (ibfd); -+ if (!local_got) -+ continue; -+ -+ symtab_hdr = &elf_tdata (ibfd)->symtab_hdr; -+ locsymcount = symtab_hdr->sh_info; -+ end_local_got = local_got + locsymcount; -+ s = htab->sgot; -+ srel = htab->srelgot; -+ local_tls_type = (unsigned char *) elf_or1k_local_tls_type (ibfd); -+ for (; local_got < end_local_got; ++local_got) -+ { -+ if (*local_got > 0) -+ { -+ *local_got = s->size; -+ -+ /* TLS GD requires two GOT and two relocs. */ -+ if (local_tls_type != NULL && *local_tls_type == TLS_GD) -+ s->size += 8; -+ else -+ s->size += 4; -+ if (info->shared) -+ { -+ if (local_tls_type != NULL && *local_tls_type == TLS_GD) -+ srel->size += 2 * sizeof (Elf32_External_Rela); -+ else -+ srel->size += sizeof (Elf32_External_Rela); -+ } -+ } -+ else -+ -+ *local_got = (bfd_vma) -1; -+ -+ if (local_tls_type) -+ ++local_tls_type; -+ } -+ } -+ -+ /* Allocate global sym .plt and .got entries, and space for global -+ sym dynamic relocs. */ -+ elf_link_hash_traverse (&htab->root, allocate_dynrelocs, info); -+ -+ /* We now have determined the sizes of the various dynamic sections. -+ Allocate memory for them. */ -+ relocs = FALSE; -+ for (s = dynobj->sections; s != NULL; s = s->next) -+ { -+ if ((s->flags & SEC_LINKER_CREATED) == 0) -+ continue; -+ -+ if (s == htab->splt -+ || s == htab->sgot -+ || s == htab->sgotplt -+ || s == htab->sdynbss) -+ { -+ /* Strip this section if we don't need it; see the -+ comment below. */ -+ } -+ else if (CONST_STRNEQ (bfd_get_section_name (dynobj, s), ".rela")) -+ { -+ if (s->size != 0 && s != htab->srelplt) -+ relocs = TRUE; -+ -+ /* We use the reloc_count field as a counter if we need -+ to copy relocs into the output file. */ -+ s->reloc_count = 0; -+ } -+ else -+ /* It's not one of our sections, so don't allocate space. */ -+ continue; -+ -+ if (s->size == 0) -+ { -+ /* If we don't need this section, strip it from the -+ output file. This is mostly to handle .rela.bss and -+ .rela.plt. We must create both sections in -+ create_dynamic_sections, because they must be created -+ before the linker maps input sections to output -+ sections. The linker does that before -+ adjust_dynamic_symbol is called, and it is that -+ function which decides whether anything needs to go -+ into these sections. */ -+ s->flags |= SEC_EXCLUDE; -+ continue; -+ } -+ -+ if ((s->flags & SEC_HAS_CONTENTS) == 0) -+ continue; -+ -+ /* Allocate memory for the section contents. We use bfd_zalloc -+ here in case unused entries are not reclaimed before the -+ section's contents are written out. This should not happen, -+ but this way if it does, we get a R_OR1K_NONE reloc instead -+ of garbage. */ -+ s->contents = bfd_zalloc (dynobj, s->size); -+ -+ if (s->contents == NULL) -+ return FALSE; -+ } -+ -+ if (htab->root.dynamic_sections_created) -+ { -+ /* Add some entries to the .dynamic section. We fill in the -+ values later, in or1k_elf_finish_dynamic_sections, but we -+ must add the entries now so that we get the correct size for -+ the .dynamic section. The DT_DEBUG entry is filled in by the -+ dynamic linker and used by the debugger. */ -+#define add_dynamic_entry(TAG, VAL) \ -+ _bfd_elf_add_dynamic_entry (info, TAG, VAL) -+ -+ if (info->executable) -+ { -+ if (! add_dynamic_entry (DT_DEBUG, 0)) -+ return FALSE; -+ } -+ -+ if (htab->splt->size != 0) -+ { -+ if (! add_dynamic_entry (DT_PLTGOT, 0) -+ || ! add_dynamic_entry (DT_PLTRELSZ, 0) -+ || ! add_dynamic_entry (DT_PLTREL, DT_RELA) -+ || ! add_dynamic_entry (DT_JMPREL, 0)) -+ return FALSE; -+ } -+ -+ if (relocs) -+ { -+ if (! add_dynamic_entry (DT_RELA, 0) -+ || ! add_dynamic_entry (DT_RELASZ, 0) -+ || ! add_dynamic_entry (DT_RELAENT, -+ sizeof (Elf32_External_Rela))) -+ return FALSE; -+ -+ /* If any dynamic relocs apply to a read-only section, -+ then we need a DT_TEXTREL entry. */ -+ if ((info->flags & DF_TEXTREL) == 0) -+ elf_link_hash_traverse (&htab->root, readonly_dynrelocs, -+ info); -+ -+ if ((info->flags & DF_TEXTREL) != 0) -+ { -+ if (! add_dynamic_entry (DT_TEXTREL, 0)) -+ return FALSE; -+ } -+ } -+ } -+ -+#undef add_dynamic_entry -+ return TRUE; -+} -+ -+/* Create dynamic sections when linking against a dynamic object. */ -+ -+static bfd_boolean -+or1k_elf_create_dynamic_sections (bfd *dynobj, struct bfd_link_info *info) -+{ -+ struct elf_or1k_link_hash_table *htab; -+ -+ htab = or1k_elf_hash_table (info); -+ if (htab == NULL) -+ return FALSE; -+ -+ if (!htab->sgot && !create_got_section (dynobj, info)) -+ return FALSE; -+ -+ if (!_bfd_elf_create_dynamic_sections (dynobj, info)) -+ return FALSE; -+ -+ htab->splt = bfd_get_section_by_name (dynobj, ".plt"); -+ htab->srelplt = bfd_get_section_by_name (dynobj, ".rela.plt"); -+ htab->sdynbss = bfd_get_section_by_name (dynobj, ".dynbss"); -+ if (!info->shared) -+ htab->srelbss = bfd_get_section_by_name (dynobj, ".rela.bss"); -+ -+ if (!htab->splt || !htab->srelplt || !htab->sdynbss -+ || (!info->shared && !htab->srelbss)) -+ abort (); -+ -+ return TRUE; -+} -+ -+/* Copy the extra info we tack onto an elf_link_hash_entry. */ -+ -+static void -+or1k_elf_copy_indirect_symbol (struct bfd_link_info *info, -+ struct elf_link_hash_entry *dir, -+ struct elf_link_hash_entry *ind) -+{ -+ struct elf_or1k_link_hash_entry * edir; -+ struct elf_or1k_link_hash_entry * eind; -+ -+ edir = (struct elf_or1k_link_hash_entry *) dir; -+ eind = (struct elf_or1k_link_hash_entry *) ind; -+ -+ if (eind->dyn_relocs != NULL) -+ { -+ if (edir->dyn_relocs != NULL) -+ { -+ struct elf_or1k_dyn_relocs **pp; -+ struct elf_or1k_dyn_relocs *p; -+ -+ /* Add reloc counts against the indirect sym to the direct sym -+ list. Merge any entries against the same section. */ -+ for (pp = &eind->dyn_relocs; (p = *pp) != NULL;) -+ { -+ struct elf_or1k_dyn_relocs *q; -+ -+ for (q = edir->dyn_relocs; q != NULL; q = q->next) -+ if (q->sec == p->sec) -+ { -+ q->pc_count += p->pc_count; -+ q->count += p->count; -+ *pp = p->next; -+ break; -+ } -+ if (q == NULL) -+ pp = &p->next; -+ } -+ *pp = edir->dyn_relocs; -+ } -+ -+ edir->dyn_relocs = eind->dyn_relocs; -+ eind->dyn_relocs = NULL; -+ } -+ -+ if (ind->root.type == bfd_link_hash_indirect) -+ { -+ if (dir->got.refcount <= 0) -+ { -+ edir->tls_type = eind->tls_type; -+ eind->tls_type = TLS_UNKNOWN; -+ } -+ } -+ -+ _bfd_elf_link_hash_copy_indirect (info, dir, ind); -+} -+ -+/* Set the right machine number. */ -+ -+static bfd_boolean -+or1k_elf_object_p (bfd *abfd) -+{ -+ unsigned long mach = bfd_mach_or1k; -+ -+ if (elf_elfheader (abfd)->e_flags & EF_OR1K_NODELAY) -+ mach = bfd_mach_or1knd; -+ -+ return bfd_default_set_arch_mach (abfd, bfd_arch_or1k, mach); -+} -+ -+/* Store the machine number in the flags field. */ -+ -+static void -+or1k_elf_final_write_processing (bfd *abfd, -+ bfd_boolean linker ATTRIBUTE_UNUSED) -+{ -+ switch (bfd_get_mach (abfd)) -+ { -+ default: -+ case bfd_mach_or1k: -+ break; -+ case bfd_mach_or1knd: -+ elf_elfheader (abfd)->e_flags |= EF_OR1K_NODELAY; -+ break; -+ } -+} -+ -+static bfd_boolean -+or1k_elf_set_private_flags (bfd *abfd, flagword flags) -+{ -+ BFD_ASSERT (!elf_flags_init (abfd) -+ || elf_elfheader (abfd)->e_flags == flags); -+ -+ elf_elfheader (abfd)->e_flags = flags; -+ elf_flags_init (abfd) = TRUE; -+ return TRUE; -+} -+ -+/* Make sure all input files are consistent with respect to -+ EF_OR1K_NODELAY flag setting. */ -+ -+static bfd_boolean -+elf32_or1k_merge_private_bfd_data (bfd *ibfd, bfd *obfd) -+{ -+ flagword out_flags; -+ flagword in_flags; -+ -+ in_flags = elf_elfheader (ibfd)->e_flags; -+ out_flags = elf_elfheader (obfd)->e_flags; -+ -+ if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour -+ || bfd_get_flavour (obfd) != bfd_target_elf_flavour) -+ return TRUE; -+ -+ if (!elf_flags_init (obfd)) -+ { -+ elf_flags_init (obfd) = TRUE; -+ elf_elfheader (obfd)->e_flags = in_flags; -+ -+ return TRUE; -+ } -+ -+ if (in_flags == out_flags) -+ return TRUE; -+ -+ if ((in_flags & EF_OR1K_NODELAY) != (out_flags & EF_OR1K_NODELAY)) -+ { -+ (*_bfd_error_handler) -+ (_("%B: EF_OR1K_NODELAY flag mismatch with previous modules"), ibfd); -+ -+ bfd_set_error (bfd_error_bad_value); -+ return FALSE; -+ } -+ -+ return TRUE; -+ -+} -+ -+#define ELF_ARCH bfd_arch_or1k -+#define ELF_MACHINE_CODE EM_OR1K -+#define ELF_TARGET_ID OR1K_ELF_DATA -+#define ELF_MAXPAGESIZE 0x2000 -+ -+#define TARGET_BIG_SYM bfd_elf32_or1k_big_vec -+#define TARGET_BIG_NAME "elf32-or1k" -+ -+#define elf_info_to_howto_rel NULL -+#define elf_info_to_howto or1k_info_to_howto_rela -+#define elf_backend_relocate_section or1k_elf_relocate_section -+#define elf_backend_gc_mark_hook or1k_elf_gc_mark_hook -+#define elf_backend_gc_sweep_hook or1k_elf_gc_sweep_hook -+#define elf_backend_check_relocs or1k_elf_check_relocs -+#define elf_backend_reloc_type_class or1k_elf_reloc_type_class -+#define elf_backend_can_gc_sections 1 -+#define elf_backend_rela_normal 1 -+ -+#define bfd_elf32_mkobject elf_or1k_mkobject -+ -+#define bfd_elf32_bfd_merge_private_bfd_data elf32_or1k_merge_private_bfd_data -+#define bfd_elf32_bfd_set_private_flags or1k_elf_set_private_flags -+#define bfd_elf32_bfd_reloc_type_lookup or1k_reloc_type_lookup -+#define bfd_elf32_bfd_reloc_name_lookup or1k_reloc_name_lookup -+ -+#define elf_backend_object_p or1k_elf_object_p -+#define elf_backend_final_write_processing or1k_elf_final_write_processing -+#define elf_backend_can_refcount 1 -+ -+#define elf_backend_plt_readonly 1 -+#define elf_backend_want_got_plt 1 -+#define elf_backend_want_plt_sym 0 -+#define elf_backend_got_header_size 12 -+#define bfd_elf32_bfd_link_hash_table_create or1k_elf_link_hash_table_create -+#define elf_backend_copy_indirect_symbol or1k_elf_copy_indirect_symbol -+#define elf_backend_create_dynamic_sections or1k_elf_create_dynamic_sections -+#define elf_backend_finish_dynamic_sections or1k_elf_finish_dynamic_sections -+#define elf_backend_size_dynamic_sections or1k_elf_size_dynamic_sections -+#define elf_backend_adjust_dynamic_symbol or1k_elf_adjust_dynamic_symbol -+#define elf_backend_finish_dynamic_symbol or1k_elf_finish_dynamic_symbol -+ -+#include "elf32-target.h" -diff -rNU3 dist.orig/bfd/elf32-or32.c dist/bfd/elf32-or32.c ---- dist.orig/bfd/elf32-or32.c 2007-07-03 16:26:41.000000000 +0200 -+++ dist/bfd/elf32-or32.c 1970-01-01 01:00:00.000000000 +0100 -@@ -1,514 +0,0 @@ --/* OR32-specific support for 32-bit ELF -- Copyright 2002, 2004, 2005, 2007 Free Software Foundation, Inc. -- Contributed by Ivan Guzvinec -- -- This file is part of BFD, the Binary File Descriptor library. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, -- MA 02110-1301, USA. */ -- --#include "sysdep.h" --#include "bfd.h" --#include "libbfd.h" --#include "elf-bfd.h" --#include "elf/or32.h" --#include "libiberty.h" -- --/* Try to minimize the amount of space occupied by relocation tables -- on the ROM (not that the ROM won't be swamped by other ELF overhead). */ --#define USE_REL 1 -- --/* Set the right machine number for an OR32 ELF file. */ -- --static bfd_boolean --or32_elf_object_p (bfd *abfd) --{ -- (void) bfd_default_set_arch_mach (abfd, bfd_arch_or32, 0); -- return TRUE; --} -- --/* The final processing done just before writing out an OR32 ELF object file. -- This gets the OR32 architecture right based on the machine number. */ -- --static void --or32_elf_final_write_processing (bfd *abfd, -- bfd_boolean linker ATTRIBUTE_UNUSED) --{ -- elf_elfheader (abfd)->e_flags &=~ EF_OR32_MACH; --} -- --static bfd_reloc_status_type --or32_elf_32_reloc (bfd *abfd, -- arelent *reloc_entry, -- asymbol *symbol, -- void * data, -- asection *input_section, -- bfd *output_bfd, -- char **error_message ATTRIBUTE_UNUSED) --{ -- if (output_bfd != NULL) -- { -- unsigned long insn; -- bfd_size_type addr = reloc_entry->address; -- -- reloc_entry->address += input_section->output_offset; -- -- insn = bfd_get_32 (abfd, (bfd_byte *) data + addr); -- insn += symbol->section->output_section->vma; -- insn += symbol->section->output_offset; -- insn += symbol->value; -- bfd_put_32 (abfd, insn, (bfd_byte *) data + addr); -- -- return bfd_reloc_ok; -- } -- -- return bfd_reloc_continue; --} -- --static bfd_reloc_status_type --or32_elf_16_reloc (bfd *abfd, -- arelent *reloc_entry, -- asymbol *symbol, -- void * data, -- asection *input_section, -- bfd *output_bfd, -- char **error_message ATTRIBUTE_UNUSED) --{ -- if (output_bfd != NULL) -- { -- unsigned short insn; -- bfd_size_type addr = reloc_entry->address; -- -- reloc_entry->address += input_section->output_offset; -- -- insn = bfd_get_16 (abfd, (bfd_byte *) data + addr); -- insn += symbol->section->output_section->vma; -- insn += symbol->section->output_offset; -- insn += symbol->value; -- bfd_put_16 (abfd, insn, (bfd_byte *) data + addr); -- -- return bfd_reloc_ok; -- } -- -- return bfd_reloc_continue; --} -- --static bfd_reloc_status_type --or32_elf_8_reloc (bfd *abfd ATTRIBUTE_UNUSED, -- arelent *reloc_entry, -- asymbol *symbol, -- void * data, -- asection *input_section, -- bfd *output_bfd, -- char **error_message ATTRIBUTE_UNUSED) --{ -- if (output_bfd != NULL) -- { -- unsigned char insn; -- bfd_size_type addr = reloc_entry->address; -- -- reloc_entry->address += input_section->output_offset; -- -- insn = bfd_get_8 (abfd, (bfd_byte *) data + addr); -- insn += symbol->section->output_section->vma; -- insn += symbol->section->output_offset; -- insn += symbol->value; -- bfd_put_8 (abfd, insn, (bfd_byte *) data + addr); -- -- return bfd_reloc_ok; -- } -- -- return bfd_reloc_continue; --} -- --/* Do a R_OR32_CONSTH relocation. This has to be done in combination -- with a R_OR32_CONST reloc, because there is a carry from the LO16 to -- the HI16. Here we just save the information we need; we do the -- actual relocation when we see the LO16. OR32 ELF requires that the -- LO16 immediately follow the HI16. As a GNU extension, we permit an -- arbitrary number of HI16 relocs to be associated with a single LO16 -- reloc. This extension permits gcc to output the HI and LO relocs -- itself. This code is copied from the elf32-mips.c. */ -- --struct or32_consth --{ -- struct or32_consth *next; -- bfd_byte *addr; -- bfd_vma addend; --}; -- --/* FIXME: This should not be a static variable. */ -- --static struct or32_consth *or32_consth_list; -- --static bfd_reloc_status_type --or32_elf_consth_reloc (bfd *abfd ATTRIBUTE_UNUSED, -- arelent *reloc_entry, -- asymbol *symbol, -- void * data, -- asection *input_section, -- bfd *output_bfd, -- char **error_message ATTRIBUTE_UNUSED) --{ -- bfd_reloc_status_type ret; -- bfd_vma relocation; -- struct or32_consth *n; -- -- ret = bfd_reloc_ok; -- -- if (bfd_is_und_section (symbol->section) -- && output_bfd == NULL) -- ret = bfd_reloc_undefined; -- -- if (bfd_is_com_section (symbol->section)) -- relocation = 0; -- else -- relocation = symbol->value; -- -- relocation += symbol->section->output_section->vma; -- relocation += symbol->section->output_offset; -- relocation += reloc_entry->addend; -- -- if (reloc_entry->address > bfd_get_section_limit (abfd, input_section)) -- return bfd_reloc_outofrange; -- -- /* Save the information, and let LO16 do the actual relocation. */ -- n = bfd_malloc (sizeof *n); -- if (n == NULL) -- return bfd_reloc_outofrange; -- n->addr = (bfd_byte *) data + reloc_entry->address; -- n->addend = relocation; -- n->next = or32_consth_list; -- or32_consth_list = n; -- -- if (output_bfd != NULL) -- reloc_entry->address += input_section->output_offset; -- -- return ret; --} -- --/* Do a R_OR32_CONST relocation. This is a straightforward 16 bit -- inplace relocation; this function exists in order to do the -- R_OR32_CONSTH relocation described above. */ -- --static bfd_reloc_status_type --or32_elf_const_reloc (bfd *abfd, -- arelent *reloc_entry, -- asymbol *symbol, -- void * data, -- asection *input_section, -- bfd *output_bfd, -- char **error_message) --{ -- if (or32_consth_list != NULL) -- { -- struct or32_consth *l; -- -- l = or32_consth_list; -- while (l != NULL) -- { -- unsigned long insn; -- unsigned long val; -- unsigned long vallo; -- struct or32_consth *next; -- -- /* Do the HI16 relocation. Note that we actually don't need -- to know anything about the LO16 itself, except where to -- find the low 16 bits of the addend needed by the LO16. */ -- insn = bfd_get_32 (abfd, l->addr); -- vallo = (bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address) -- & 0xffff); -- val = ((insn & 0xffff) << 16) + vallo; -- val += l->addend; -- -- insn = (insn &~ 0xffff) | ((val >> 16) & 0xffff); -- bfd_put_32 (abfd, insn, l->addr); -- -- next = l->next; -- free (l); -- l = next; -- } -- -- or32_consth_list = NULL; -- } -- -- if (output_bfd != NULL) -- { -- unsigned long insn, tmp; -- bfd_size_type addr = reloc_entry->address; -- -- reloc_entry->address += input_section->output_offset; -- -- insn = bfd_get_32 (abfd, (bfd_byte *) data + addr); -- tmp = insn & 0x0000ffff; -- tmp += symbol->section->output_section->vma; -- tmp += symbol->section->output_offset; -- tmp += symbol->value; -- insn = (insn & 0xffff0000) | (tmp & 0x0000ffff); -- bfd_put_32 (abfd, insn, (bfd_byte *) data + addr); -- -- return bfd_reloc_ok; -- } -- -- /* Now do the LO16 reloc in the usual way. */ -- return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data, -- input_section, output_bfd, error_message); --} -- --static bfd_reloc_status_type --or32_elf_jumptarg_reloc (bfd *abfd, -- arelent *reloc_entry, -- asymbol *symbol ATTRIBUTE_UNUSED, -- void * data, -- asection *input_section, -- bfd *output_bfd, -- char **error_message ATTRIBUTE_UNUSED) --{ -- if (output_bfd != NULL) -- { -- unsigned long insn, tmp; -- bfd_size_type addr = reloc_entry->address; -- -- reloc_entry->address += input_section->output_offset; -- -- insn = bfd_get_32 (abfd, (bfd_byte *) data + addr); -- tmp = insn | 0xfc000000; -- tmp -= (input_section->output_offset >> 2); -- insn = (insn & 0xfc000000) | (tmp & 0x03ffffff); -- bfd_put_32 (abfd, insn, (bfd_byte *) data + addr); -- -- return bfd_reloc_ok; -- } -- -- return bfd_reloc_continue; --} -- --static reloc_howto_type elf_or32_howto_table[] = --{ -- /* This reloc does nothing. */ -- HOWTO (R_OR32_NONE, /* type */ -- 0, /* rightshift */ -- 2, /* size (0 = byte, 1 = short, 2 = long) */ -- 32, /* bitsize */ -- FALSE, /* pc_relative */ -- 0, /* bitpos */ -- complain_overflow_bitfield, /* complain_on_overflow */ -- bfd_elf_generic_reloc, /* special_function */ -- "R_OR32_NONE", /* name */ -- FALSE, /* partial_inplace */ -- 0, /* src_mask */ -- 0, /* dst_mask */ -- FALSE), /* pcrel_offset */ -- -- /* A standard 32 bit relocation. */ -- HOWTO (R_OR32_32, /* type */ -- 0, /* rightshift */ -- 2, /* size (0 = byte, 1 = short, 2 = long) */ -- 32, /* bitsize */ -- FALSE, /* pc_relative */ -- 0, /* bitpos */ -- complain_overflow_bitfield, /* complain_on_overflow */ -- or32_elf_32_reloc, /* special_function */ -- "R_OR32_32", /* name */ -- FALSE, /* partial_inplace */ -- 0xffffffff, /* src_mask */ -- 0xffffffff, /* dst_mask */ -- FALSE), /* pcrel_offset */ -- -- /* A standard 16 bit relocation. */ -- HOWTO (R_OR32_16, /* type */ -- 0, /* rightshift */ -- 1, /* size (0 = byte, 1 = short, 2 = long) */ -- 16, /* bitsize */ -- FALSE, /* pc_relative */ -- 0, /* bitpos */ -- complain_overflow_bitfield, /* complain_on_overflow */ -- or32_elf_16_reloc, /* special_function */ -- "R_OR32_16", /* name */ -- FALSE, /* partial_inplace */ -- 0x0000ffff, /* src_mask */ -- 0x0000ffff, /* dst_mask */ -- FALSE), /* pcrel_offset */ -- -- /* A standard 8 bit relocation. */ -- HOWTO (R_OR32_8, /* type */ -- 0, /* rightshift */ -- 0, /* size (0 = byte, 1 = short, 2 = long) */ -- 8, /* bitsize */ -- FALSE, /* pc_relative */ -- 0, /* bitpos */ -- complain_overflow_bitfield, /* complain_on_overflow */ -- or32_elf_8_reloc, /* special_function */ -- "R_OR32_8", /* name */ -- FALSE, /* partial_inplace */ -- 0x000000ff, /* src_mask */ -- 0x000000ff, /* dst_mask */ -- FALSE), /* pcrel_offset */ -- -- /* A standard low 16 bit relocation. */ -- HOWTO (R_OR32_CONST, /* type */ -- 0, /* rightshift */ -- 2, /* size (0 = byte, 1 = short, 2 = long) */ -- 16, /* bitsize */ -- FALSE, /* pc_relative */ -- 0, /* bitpos */ -- complain_overflow_dont, /* complain_on_overflow */ -- or32_elf_const_reloc, /* special_function */ -- "R_OR32_CONST", /* name */ -- FALSE, /* partial_inplace */ -- 0x0000ffff, /* src_mask */ -- 0x0000ffff, /* dst_mask */ -- FALSE), /* pcrel_offset */ -- -- /* A standard high 16 bit relocation. */ -- HOWTO (R_OR32_CONSTH, /* type */ -- 16, /* rightshift */ -- 2, /* size (0 = byte, 1 = short, 2 = long) */ -- 16, /* bitsize */ -- TRUE, /* pc_relative */ -- 0, /* bitpos */ -- complain_overflow_dont, /* complain_on_overflow */ -- or32_elf_consth_reloc, /* special_function */ -- "R_OR32_CONSTH", /* name */ -- FALSE, /* partial_inplace */ -- 0xffff0000, /* src_mask */ -- 0x0000ffff, /* dst_mask */ -- FALSE), /* pcrel_offset */ -- -- /* A standard branch relocation. */ -- HOWTO (R_OR32_JUMPTARG, /* type */ -- 2, /* rightshift */ -- 2, /* size (0 = byte, 1 = short, 2 = long) */ -- 28, /* bitsize */ -- TRUE, /* pc_relative */ -- 0, /* bitpos */ -- complain_overflow_signed, /* complain_on_overflow */ -- or32_elf_jumptarg_reloc,/* special_function */ -- "R_OR32_JUMPTARG", /* name */ -- FALSE, /* partial_inplace */ -- 0, /* src_mask */ -- 0x03ffffff, /* dst_mask */ -- TRUE), /* pcrel_offset */ -- -- /* GNU extension to record C++ vtable hierarchy. */ -- HOWTO (R_OR32_GNU_VTINHERIT, /* type */ -- 0, /* rightshift */ -- 2, /* size (0 = byte, 1 = short, 2 = long) */ -- 0, /* bitsize */ -- FALSE, /* pc_relative */ -- 0, /* bitpos */ -- complain_overflow_dont, /* complain_on_overflow */ -- NULL, /* special_function */ -- "R_OR32_GNU_VTINHERIT", /* name */ -- FALSE, /* partial_inplace */ -- 0, /* src_mask */ -- 0, /* dst_mask */ -- FALSE), /* pcrel_offset */ -- -- /* GNU extension to record C++ vtable member usage. */ -- HOWTO (R_OR32_GNU_VTENTRY, /* type */ -- 0, /* rightshift */ -- 2, /* size (0 = byte, 1 = short, 2 = long) */ -- 0, /* bitsize */ -- FALSE, /* pc_relative */ -- 0, /* bitpos */ -- complain_overflow_dont, /* complain_on_overflow */ -- _bfd_elf_rel_vtable_reloc_fn, /* special_function */ -- "R_OR32_GNU_VTENTRY", /* name */ -- FALSE, /* partial_inplace */ -- 0, /* src_mask */ -- 0, /* dst_mask */ -- FALSE), /* pcrel_offset */ --}; -- --/* Map BFD reloc types to OR32 ELF reloc types. */ -- --struct or32_reloc_map --{ -- bfd_reloc_code_real_type bfd_reloc_val; -- unsigned char elf_reloc_val; --}; -- --static const struct or32_reloc_map or32_reloc_map[] = --{ -- { BFD_RELOC_NONE, R_OR32_NONE }, -- { BFD_RELOC_32, R_OR32_32 }, -- { BFD_RELOC_16, R_OR32_16 }, -- { BFD_RELOC_8, R_OR32_8 }, -- { BFD_RELOC_LO16, R_OR32_CONST }, -- { BFD_RELOC_HI16, R_OR32_CONSTH }, -- { BFD_RELOC_32_GOT_PCREL, R_OR32_JUMPTARG }, -- { BFD_RELOC_VTABLE_INHERIT, R_OR32_GNU_VTINHERIT }, -- { BFD_RELOC_VTABLE_ENTRY, R_OR32_GNU_VTENTRY }, --}; -- --static reloc_howto_type * --bfd_elf32_bfd_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, -- bfd_reloc_code_real_type code) --{ -- unsigned int i; -- -- for (i = ARRAY_SIZE (or32_reloc_map); i--;) -- if (or32_reloc_map[i].bfd_reloc_val == code) -- return &elf_or32_howto_table[or32_reloc_map[i].elf_reloc_val]; -- -- return NULL; --} -- --static reloc_howto_type * --bfd_elf32_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, -- const char *r_name) --{ -- unsigned int i; -- -- for (i = 0; -- i < sizeof (elf_or32_howto_table) / sizeof (elf_or32_howto_table[0]); -- i++) -- if (elf_or32_howto_table[i].name != NULL -- && strcasecmp (elf_or32_howto_table[i].name, r_name) == 0) -- return &elf_or32_howto_table[i]; -- -- return NULL; --} -- --/* Set the howto pointer for an OR32 ELF reloc. */ -- --static void --or32_info_to_howto_rel (bfd *abfd ATTRIBUTE_UNUSED, -- arelent *cache_ptr, -- Elf_Internal_Rela *dst) --{ -- unsigned int r_type; -- -- r_type = ELF32_R_TYPE (dst->r_info); -- BFD_ASSERT (r_type < (unsigned int) R_OR32_max); -- cache_ptr->howto = &elf_or32_howto_table[r_type]; --} -- --#define TARGET_LITTLE_SYM bfd_elf32_or32_little_vec --#define TARGET_LITTLE_NAME "elf32-littleor32" --#define TARGET_BIG_SYM bfd_elf32_or32_big_vec --#define TARGET_BIG_NAME "elf32-or32" --#define ELF_ARCH bfd_arch_or32 --#define ELF_MACHINE_CODE EM_OR32 --#define ELF_MAXPAGESIZE 0x1000 -- --#define elf_info_to_howto 0 --#define elf_info_to_howto_rel or32_info_to_howto_rel --#define elf_backend_object_p or32_elf_object_p --#define elf_backend_final_write_processing \ -- or32_elf_final_write_processing -- --#include "elf32-target.h" -diff -rNU3 dist.orig/bfd/elf32-ppc.c dist/bfd/elf32-ppc.c ---- dist.orig/bfd/elf32-ppc.c 2013-03-25 09:06:19.000000000 +0100 -+++ dist/bfd/elf32-ppc.c 2015-10-18 13:11:12.000000000 +0200 -@@ -3898,7 +3898,7 @@ - sec->has_tls_get_addr_call = 1; - } - -- switch (r_type) -+ switch ((int)r_type) - { - case R_PPC_TLSGD: - case R_PPC_TLSLD: -@@ -7766,7 +7766,7 @@ - howto = NULL; - if (r_type < R_PPC_max) - howto = ppc_elf_howto_table[r_type]; -- switch (r_type) -+ switch ((int)r_type) - { - default: - info->callbacks->einfo -diff -rNU3 dist.orig/bfd/elf32-sh.c dist/bfd/elf32-sh.c ---- dist.orig/bfd/elf32-sh.c 2013-03-25 09:06:20.000000000 +0100 -+++ dist/bfd/elf32-sh.c 2015-10-18 13:11:12.000000000 +0200 -@@ -2808,6 +2808,7 @@ - /* Make sure we know what is going on here. */ - BFD_ASSERT (htab->root.dynobj != NULL - && (h->needs_plt -+ || h->type == STT_GNU_IFUNC - || h->u.weakdef != NULL - || (h->def_dynamic - && h->ref_regular -@@ -2816,7 +2817,7 @@ - /* If this is a function, put it in the procedure linkage table. We - will fill in the contents of the procedure linkage table later, - when we know the address of the .got section. */ -- if (h->type == STT_FUNC -+ if ((h->type == STT_FUNC || h->type == STT_GNU_IFUNC) - || h->needs_plt) - { - if (h->plt.refcount <= 0 -@@ -3285,6 +3286,10 @@ - { - struct bfd_link_info *info = (struct bfd_link_info *) inf; - -+ if (info->warn_shared_textrel) -+ (*_bfd_error_handler) -+ (_("warning: dynamic relocation in readonly section `%s'"), -+ h->root.root.string); - info->flags |= DF_TEXTREL; - - /* Not an error, just cut short the traversal. */ -diff -rNU3 dist.orig/bfd/elf32-vax.c dist/bfd/elf32-vax.c ---- dist.orig/bfd/elf32-vax.c 2012-09-04 15:32:53.000000000 +0200 -+++ dist/bfd/elf32-vax.c 2015-10-18 13:11:13.000000000 +0200 -@@ -490,6 +490,24 @@ - return TRUE; - } - -+/* Copy vax-specific data from one module to another */ -+static bfd_boolean -+elf32_vax_copy_private_bfd_data (bfd *ibfd, bfd *obfd) -+{ -+ flagword in_flags; -+ -+ if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour -+ || bfd_get_flavour (obfd) != bfd_target_elf_flavour) -+ return TRUE; -+ -+ in_flags = elf_elfheader (ibfd)->e_flags; -+ -+ elf_elfheader (obfd)->e_flags = in_flags; -+ elf_flags_init (obfd) = TRUE; -+ -+ return TRUE; -+} -+ - /* Merge backend specific data from an object file to the output - object file when linking. */ - static bfd_boolean -@@ -752,7 +770,13 @@ - return FALSE; - - if (sec->flags & SEC_READONLY) -- info->flags |= DF_TEXTREL; -+ { -+ if (info->warn_shared_textrel) -+ (*_bfd_error_handler) -+ (_("warning: dynamic relocation in readonly section `%s'"), -+ sec->name); -+ info->flags |= DF_TEXTREL; -+ } - } - - sreloc->size += sizeof (Elf32_External_Rela); -@@ -922,6 +946,7 @@ - /* Make sure we know what is going on here. */ - BFD_ASSERT (dynobj != NULL - && (h->needs_plt -+ || h->type == STT_GNU_IFUNC - || h->u.weakdef != NULL - || (h->def_dynamic - && h->ref_regular -@@ -930,7 +955,7 @@ - /* If this is a function, put it in the procedure linkage table. We - will fill in the contents of the procedure linkage table later, - when we know the address of the .got section. */ -- if (h->type == STT_FUNC -+ if ((h->type == STT_FUNC || h->type == STT_GNU_IFUNC) - || h->needs_plt) - { - if (h->plt.refcount <= 0 -@@ -1186,7 +1211,12 @@ - continue; - - /* Allocate memory for the section contents. */ -- s->contents = (bfd_byte *) bfd_alloc (dynobj, s->size); -+ /* FIXME: This should be a call to bfd_alloc not bfd_zalloc. -+ Unused entries should be reclaimed before the section's contents -+ are written out, but at the moment this does not happen. Thus in -+ order to prevent writing out garbage, we initialise the section's -+ contents to zero. */ -+ s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size); - if (s->contents == NULL) - return FALSE; - } -@@ -1285,6 +1315,7 @@ - - if (!elf_hash_table (info)->dynamic_sections_created - || (info->shared && info->symbolic) -+ || ELF_ST_VISIBILITY (h->other) != STV_DEFAULT - || h->forced_local) - { - h->got.refcount = 0; -@@ -1305,9 +1336,7 @@ - - dyn = elf_hash_table (info)->dynamic_sections_created; - /* Allocate space in the .got and .rela.got sections. */ -- if (ELF_ST_VISIBILITY (h->other) == STV_DEFAULT -- && (info->shared -- || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h))) -+ if (info->shared || WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, 0, h)) - { - sgot->size += 4; - srelgot->size += sizeof (Elf32_External_Rela); -@@ -1631,9 +1660,9 @@ - { - relocate = TRUE; - outrel.r_info = ELF32_R_INFO (0, R_VAX_RELATIVE); -- BFD_ASSERT (bfd_get_signed_32 (input_bfd, -- &contents[rel->r_offset]) == 0); -- outrel.r_addend = relocation + rel->r_addend; -+ outrel.r_addend = bfd_get_signed_32(input_bfd, -+ &contents[rel->r_offset]) -+ + relocation + rel->r_addend; - } - else - { -@@ -1672,6 +1701,9 @@ - } - } - -+ if (input_section->flags & SEC_CODE) -+ info->flags |= DF_TEXTREL; -+ - if ((input_section->flags & SEC_CODE) != 0 - || (ELF32_R_TYPE (outrel.r_info) != R_VAX_32 - && ELF32_R_TYPE (outrel.r_info) != R_VAX_RELATIVE -@@ -2051,12 +2083,15 @@ - #define TARGET_LITTLE_SYM bfd_elf32_vax_vec - #define TARGET_LITTLE_NAME "elf32-vax" - #define ELF_MACHINE_CODE EM_VAX --#define ELF_MAXPAGESIZE 0x1000 -+#define ELF_MAXPAGESIZE 0x10000 - - #define elf_backend_create_dynamic_sections \ - _bfd_elf_create_dynamic_sections - #define bfd_elf32_bfd_link_hash_table_create \ - elf_vax_link_hash_table_create -+#define bfd_elf32_bfd_copy_private_bfd_data \ -+ elf32_vax_copy_private_bfd_data -+ - #define bfd_elf32_bfd_final_link bfd_elf_gc_common_final_link - - #define elf_backend_check_relocs elf_vax_check_relocs -diff -rNU3 dist.orig/bfd/elf64-alpha.c dist/bfd/elf64-alpha.c ---- dist.orig/bfd/elf64-alpha.c 2012-07-24 23:06:58.000000000 +0200 -+++ dist/bfd/elf64-alpha.c 2015-10-18 13:11:13.000000000 +0200 -@@ -100,6 +100,11 @@ - #define PLT_ENTRY_SIZE \ - (elf64_alpha_use_secureplt ? NEW_PLT_ENTRY_SIZE : OLD_PLT_ENTRY_SIZE) - -+/* ld --traditional-format uses this older format instead. */ -+#define OLD_PLT_ENTRY_WORD1 0x279f0000 /* ldah $28, 0($31) */ -+#define OLD_PLT_ENTRY_WORD2 0x239c0000 /* lda $28, 0($28) */ -+#define OLD_PLT_ENTRY_WORD3 0xc3e00000 /* br $31, plt0 */ -+ - #define MAX_GOT_SIZE (64*1024) - - #define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so" -@@ -4821,6 +4826,32 @@ - plt_index = ((gotent->plt_offset - NEW_PLT_HEADER_SIZE) - / NEW_PLT_ENTRY_SIZE); - } -+ else if ((output_bfd->flags & BFD_TRADITIONAL_FORMAT) != 0) -+ { -+ long hi, lo; -+ -+ /* decompose the reloc offset for the plt for ldah+lda */ -+ hi = plt_index * sizeof(Elf64_External_Rela); -+ lo = ((hi & 0xffff) ^ 0x8000) - 0x8000; -+ hi = (hi - lo) >> 16; -+ -+ insn = INSN_ABO (INSN_LDAH, 28, 31, hi); -+ bfd_put_32 (output_bfd, insn, -+ splt->contents + gotent->plt_offset); -+ -+ insn = INSN_ABO (INSN_LDA, 28, 28, lo); -+ bfd_put_32 (output_bfd, insn, -+ splt->contents + gotent->plt_offset + 4); -+ -+ disp = -(gotent->plt_offset + 12); -+ insn = INSN_AD (INSN_BR, 31, disp); -+ -+ bfd_put_32 (output_bfd, insn, -+ splt->contents + gotent->plt_offset + 8); -+ -+ plt_index = ((gotent->plt_offset - OLD_PLT_HEADER_SIZE) -+ / OLD_PLT_ENTRY_SIZE); -+ } - else - { - disp = -(gotent->plt_offset + 4); -diff -rNU3 dist.orig/bfd/elf64-mips.c dist/bfd/elf64-mips.c ---- dist.orig/bfd/elf64-mips.c 2012-09-04 16:13:07.000000000 +0200 -+++ dist/bfd/elf64-mips.c 2015-10-18 13:11:13.000000000 +0200 -@@ -123,6 +123,8 @@ - (bfd *, asymbol *, bfd_boolean, char **, bfd_vma *); - static bfd_boolean mips_elf64_object_p - (bfd *); -+static bfd_boolean mips_elf64_is_local_label_name -+ (bfd *, const char *); - static irix_compat_t elf64_mips_irix_compat - (bfd *); - static bfd_boolean elf64_mips_grok_prstatus -@@ -3917,7 +3919,18 @@ - bfd_default_set_arch_mach (abfd, bfd_arch_mips, mach); - return TRUE; - } -+ -+/* MIPS ELF local labels start with "$L". */ -+static bfd_boolean -+mips_elf64_is_local_label_name (bfd *abfd, const char *name) -+{ -+ if (name[0] == '$' && name[1] == 'L') -+ return TRUE; - -+ /* We accept the generic ELF local label syntax as well. */ -+ return _bfd_elf_is_local_label_name (abfd, name); -+} -+ - /* Depending on the target vector we generate some version of Irix - executables or "normal" MIPS ELF ABI executables. */ - static irix_compat_t -@@ -4141,9 +4154,8 @@ - - #define elf_backend_write_section _bfd_mips_elf_write_section - --/* We don't set bfd_elf64_bfd_is_local_label_name because the 32-bit -- MIPS-specific function only applies to IRIX5, which had no 64-bit -- ABI. */ -+#define bfd_elf64_bfd_is_local_label_name \ -+ mips_elf64_is_local_label_name - #define bfd_elf64_bfd_is_target_special_symbol \ - _bfd_mips_elf_is_target_special_symbol - #define bfd_elf64_find_nearest_line _bfd_mips_elf_find_nearest_line -diff -rNU3 dist.orig/bfd/elf64-ppc.c dist/bfd/elf64-ppc.c ---- dist.orig/bfd/elf64-ppc.c 2013-03-25 09:06:20.000000000 +0100 -+++ dist/bfd/elf64-ppc.c 2015-10-18 13:11:13.000000000 +0200 -@@ -3618,9 +3618,6 @@ - struct ppc_link_hash_entry *h; - struct plt_entry *plt_ent; - -- /* And the reloc addend that this was derived from. */ -- bfd_vma addend; -- - /* Where this stub is being called from, or, in the case of combined - stub sections, the first input section in the group. */ - asection *id_sec; -@@ -9112,6 +9109,10 @@ - { - struct bfd_link_info *info = inf; - -+ if (info->warn_shared_textrel) -+ (*_bfd_error_handler) -+ (_("warning: dynamic relocation in readonly section `%s'"), -+ h->root.root.string); - info->flags |= DF_TEXTREL; - - /* Not an error, just cut short the traversal. */ -@@ -9192,7 +9193,13 @@ - srel = htab->reliplt; - srel->size += p->count * sizeof (Elf64_External_Rela); - if ((p->sec->output_section->flags & SEC_READONLY) != 0) -- info->flags |= DF_TEXTREL; -+ { -+ if (info->warn_shared_textrel) -+ (*_bfd_error_handler) -+ (_("warning: dynamic relocation in readonly section `%s'"), -+ p->sec->output_section->name); -+ info->flags |= DF_TEXTREL; -+ } - } - } - } -@@ -11659,7 +11666,6 @@ - } - stub_entry->h = hash; - stub_entry->plt_ent = plt_ent; -- stub_entry->addend = irela->r_addend; - - if (stub_entry->h != NULL) - htab->stub_globals += 1; -@@ -12900,60 +12906,96 @@ - { - bfd_boolean can_plt_call = FALSE; - -+ /* All of these stubs will modify r2, so there must be a -+ branch and link followed by a nop. The nop is -+ replaced by an insn to restore r2. */ - if (rel->r_offset + 8 <= input_section->size) - { -- unsigned long nop; -- nop = bfd_get_32 (input_bfd, contents + rel->r_offset + 4); -- if (nop == NOP -- || nop == CROR_151515 || nop == CROR_313131) -- { -- if (h != NULL -- && (h == htab->tls_get_addr_fd -- || h == htab->tls_get_addr) -- && !htab->no_tls_get_addr_opt) -+ unsigned long br; -+ -+ br = bfd_get_32 (input_bfd, -+ contents + rel->r_offset); -+ if ((br & 1) != 0) -+ { -+ unsigned long nop; -+ -+ nop = bfd_get_32 (input_bfd, -+ contents + rel->r_offset + 4); -+ if (nop == NOP -+ || nop == CROR_151515 || nop == CROR_313131) - { -- /* Special stub used, leave nop alone. */ -+ if (h != NULL -+ && (h == htab->tls_get_addr_fd -+ || h == htab->tls_get_addr) -+ && !htab->no_tls_get_addr_opt) -+ { -+ /* Special stub used, leave nop alone. */ -+ } -+ else -+ bfd_put_32 (input_bfd, LD_R2_40R1, -+ contents + rel->r_offset + 4); -+ can_plt_call = TRUE; - } -- else -- bfd_put_32 (input_bfd, LD_R2_40R1, -- contents + rel->r_offset + 4); -- can_plt_call = TRUE; - } - } - -- if (!can_plt_call) -+ if (!can_plt_call && h != NULL) - { -- if (stub_entry->stub_type == ppc_stub_plt_call -- || stub_entry->stub_type == ppc_stub_plt_call_r2save) -- { -- /* If this is a plain branch rather than a branch -- and link, don't require a nop. However, don't -- allow tail calls in a shared library as they -- will result in r2 being corrupted. */ -- unsigned long br; -- br = bfd_get_32 (input_bfd, contents + rel->r_offset); -- if (info->executable && (br & 1) == 0) -- can_plt_call = TRUE; -- else -- stub_entry = NULL; -- } -- else if (h != NULL -- && strcmp (h->elf.root.root.string, -- ".__libc_start_main") == 0) -+ const char *name = h->elf.root.root.string; -+ -+ if (*name == '.') -+ ++name; -+ -+ if (strncmp (name, "__libc_start_main", 17) == 0 -+ && (name[17] == 0 || name[17] == '@')) - { -- /* Allow crt1 branch to go via a toc adjusting stub. */ -+ /* Allow crt1 branch to go via a toc adjusting -+ stub. Other calls that never return could do -+ the same, if we could detect such. */ - can_plt_call = TRUE; - } -- else -+ } -+ -+ if (!can_plt_call) -+ { -+ /* g++ as of 20130507 emits self-calls without a -+ following nop. This is arguably wrong since we -+ have conflicting information. On the one hand a -+ global symbol and on the other a local call -+ sequence, but don't error for this special case. -+ It isn't possible to cheaply verify we have -+ exactly such a call. Allow all calls to the same -+ section. */ -+ asection *code_sec = sec; -+ -+ if (get_opd_info (sec) != NULL) - { -- info->callbacks->einfo -- (_("%P: %H: call to `%T' lacks nop, can't restore toc; " -- "recompile with -fPIC"), -- input_bfd, input_section, rel->r_offset, sym_name); -+ bfd_vma off = (relocation + addend -+ - sec->output_section->vma -+ - sec->output_offset); - -- bfd_set_error (bfd_error_bad_value); -- ret = FALSE; -+ opd_entry_value (sec, off, &code_sec, NULL, FALSE); - } -+ if (code_sec == input_section) -+ can_plt_call = TRUE; -+ } -+ -+ if (!can_plt_call) -+ { -+ -+ if (stub_entry->stub_type == ppc_stub_plt_call -+ || stub_entry->stub_type == ppc_stub_plt_call_r2save) -+ info->callbacks->einfo -+ (_("%P: %H: call to `%T' lacks nop, can't restore toc; " -+ "recompile with -fPIC"), -+ input_bfd, input_section, rel->r_offset, sym_name); -+ else -+ info->callbacks->einfo -+ (_("%P: %H: call to `%T' lacks nop, can't restore toc; " -+ "(-mcmodel=small toc adjust stub)"), -+ input_bfd, input_section, rel->r_offset, sym_name); -+ bfd_set_error (bfd_error_bad_value); -+ ret = FALSE; - } - - if (can_plt_call -diff -rNU3 dist.orig/bfd/elf64-x86-64.c dist/bfd/elf64-x86-64.c ---- dist.orig/bfd/elf64-x86-64.c 2013-03-25 09:06:20.000000000 +0100 -+++ dist/bfd/elf64-x86-64.c 2015-10-18 13:11:13.000000000 +0200 -@@ -2589,6 +2589,10 @@ - { - struct bfd_link_info *info = (struct bfd_link_info *) inf; - -+ if (info->warn_shared_textrel) -+ (*_bfd_error_handler) -+ (_("warning: dynamic relocation in readonly section `%s'"), -+ h->root.root.string); - info->flags |= DF_TEXTREL; - - if (info->warn_shared_textrel && info->shared) -diff -rNU3 dist.orig/bfd/elflink.c dist/bfd/elflink.c ---- dist.orig/bfd/elflink.c 2013-03-25 09:06:20.000000000 +0100 -+++ dist/bfd/elflink.c 2015-10-18 13:11:13.000000000 +0200 -@@ -1442,7 +1442,10 @@ - if (!(oldbfd != NULL - && (oldbfd->flags & BFD_PLUGIN) != 0 - && (abfd->flags & BFD_PLUGIN) == 0)) -- *skip = TRUE; -+ { -+ newdef = FALSE; -+ *skip = TRUE; -+ } - - /* Merge st_other. If the symbol already has a dynamic index, - but visibility says it should not be visible, turn it into a -@@ -10183,7 +10186,14 @@ - if (bed->s->arch_size == 32) - irel[0].r_info = ELF32_R_INFO (indx, howto->type); - else -- irel[0].r_info = ELF64_R_INFO (indx, howto->type); -+#ifdef BFD64 -+ { -+ bfd_uint64_t indx64 = indx; -+ irel[0].r_info = ELF64_R_INFO (indx64, howto->type); -+ } -+#else -+ BFD_FAIL(); -+#endif - - rel_hdr = reldata->hdr; - erel = rel_hdr->contents; -diff -rNU3 dist.orig/bfd/elfn32-mips.c dist/bfd/elfn32-mips.c ---- dist.orig/bfd/elfn32-mips.c 2012-09-04 16:13:08.000000000 +0200 -+++ dist/bfd/elfn32-mips.c 2015-10-18 13:11:13.000000000 +0200 -@@ -81,6 +81,8 @@ - (bfd *, Elf_Internal_Note *); - static bfd_boolean elf32_mips_grok_psinfo - (bfd *, Elf_Internal_Note *); -+static bfd_boolean mips_elf_n32_is_local_label_name -+ (bfd *, const char *); - static irix_compat_t elf_n32_mips_irix_compat - (bfd *); - -@@ -3241,6 +3243,17 @@ - return TRUE; - } - -+/* MIPS ELF local labels start with "$L". */ -+static bfd_boolean -+mips_elf_n32_is_local_label_name (bfd *abfd, const char *name) -+{ -+ if (name[0] == '$' && name[1] == 'L') -+ return TRUE; -+ -+ /* We accept the generic ELF local label syntax as well. */ -+ return _bfd_elf_is_local_label_name (abfd, name); -+} -+ - /* Depending on the target vector we generate some version of Irix - executables or "normal" MIPS ELF ABI executables. */ - static irix_compat_t -@@ -3364,6 +3377,9 @@ - #define elf_backend_write_section _bfd_mips_elf_write_section - #define elf_backend_mips_irix_compat elf_n32_mips_irix_compat - #define elf_backend_mips_rtype_to_howto mips_elf_n32_rtype_to_howto -+ -+#define bfd_elf32_bfd_is_local_label_name \ -+ mips_elf_n32_is_local_label_name - #define bfd_elf32_bfd_is_target_special_symbol \ - _bfd_mips_elf_is_target_special_symbol - #define bfd_elf32_find_nearest_line _bfd_mips_elf_find_nearest_line -diff -rNU3 dist.orig/bfd/elfnn-riscv.c dist/bfd/elfnn-riscv.c ---- dist.orig/bfd/elfnn-riscv.c 1970-01-01 01:00:00.000000000 +0100 -+++ dist/bfd/elfnn-riscv.c 2015-10-18 13:11:13.000000000 +0200 -@@ -0,0 +1,2957 @@ -+/* RISC-V-specific support for NN-bit ELF. -+ Copyright 2011-2014 Free Software Foundation, Inc. -+ -+ Contributed by Andrew Waterman (waterman@cs.berkeley.edu) at UC Berkeley. -+ Based on TILE-Gx and MIPS targets. -+ -+ This file is part of BFD, the Binary File Descriptor library. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, write to the Free Software -+ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, -+ MA 02110-1301, USA. */ -+ -+ -+/* This file handles RISC-V ELF targets. */ -+ -+#include "sysdep.h" -+#include "bfd.h" -+#include "libbfd.h" -+#include "bfdlink.h" -+#include "genlink.h" -+#include "elf-bfd.h" -+#include "elfxx-riscv.h" -+#include "elf/riscv.h" -+#include "opcode/riscv.h" -+ -+#define ARCH_SIZE NN -+ -+#define MINUS_ONE ((bfd_vma)0 - 1) -+ -+#define RISCV_ELF_LOG_WORD_BYTES (ARCH_SIZE == 32 ? 2 : 3) -+ -+#define RISCV_ELF_WORD_BYTES (1 << RISCV_ELF_LOG_WORD_BYTES) -+ -+/* The name of the dynamic interpreter. This is put in the .interp -+ section. */ -+ -+#define ELF64_DYNAMIC_INTERPRETER "/lib/ld.so.1" -+#define ELF32_DYNAMIC_INTERPRETER "/lib32/ld.so.1" -+ -+/* The RISC-V linker needs to keep track of the number of relocs that it -+ decides to copy as dynamic relocs in check_relocs for each symbol. -+ This is so that it can later discard them if they are found to be -+ unnecessary. We store the information in a field extending the -+ regular ELF linker hash table. */ -+ -+struct riscv_elf_dyn_relocs -+{ -+ struct riscv_elf_dyn_relocs *next; -+ -+ /* The input section of the reloc. */ -+ asection *sec; -+ -+ /* Total number of relocs copied for the input section. */ -+ bfd_size_type count; -+ -+ /* Number of pc-relative relocs copied for the input section. */ -+ bfd_size_type pc_count; -+}; -+ -+/* RISC-V ELF linker hash entry. */ -+ -+struct riscv_elf_link_hash_entry -+{ -+ struct elf_link_hash_entry elf; -+ -+ /* Track dynamic relocs copied for this symbol. */ -+ struct riscv_elf_dyn_relocs *dyn_relocs; -+ -+#define GOT_UNKNOWN 0 -+#define GOT_NORMAL 1 -+#define GOT_TLS_GD 2 -+#define GOT_TLS_IE 4 -+#define GOT_TLS_LE 8 -+ char tls_type; -+}; -+ -+#define riscv_elf_hash_entry(ent) \ -+ ((struct riscv_elf_link_hash_entry *)(ent)) -+ -+struct _bfd_riscv_elf_obj_tdata -+{ -+ struct elf_obj_tdata root; -+ -+ /* tls_type for each local got entry. */ -+ char *local_got_tls_type; -+}; -+ -+#define _bfd_riscv_elf_tdata(abfd) \ -+ ((struct _bfd_riscv_elf_obj_tdata *) (abfd)->tdata.any) -+ -+#define _bfd_riscv_elf_local_got_tls_type(abfd) \ -+ (_bfd_riscv_elf_tdata (abfd)->local_got_tls_type) -+ -+#define _bfd_riscv_elf_tls_type(abfd, h, symndx) \ -+ (*((h) != NULL ? &riscv_elf_hash_entry(h)->tls_type \ -+ : &_bfd_riscv_elf_local_got_tls_type (abfd) [symndx])) -+ -+#define is_riscv_elf(bfd) \ -+ (bfd_get_flavour (bfd) == bfd_target_elf_flavour \ -+ && elf_tdata (bfd) != NULL \ -+ && elf_object_id (bfd) == RISCV_ELF_DATA) -+ -+#include "elf/common.h" -+#include "elf/internal.h" -+ -+struct riscv_elf_link_hash_table -+{ -+ struct elf_link_hash_table elf; -+ -+ /* Short-cuts to get to dynamic linker sections. */ -+ asection *sdynbss; -+ asection *srelbss; -+ asection *sdyntdata; -+ -+ /* Small local sym to section mapping cache. */ -+ struct sym_cache sym_cache; -+}; -+ -+ -+/* Get the RISC-V ELF linker hash table from a link_info structure. */ -+#define riscv_elf_hash_table(p) \ -+ (elf_hash_table_id ((struct elf_link_hash_table *) ((p)->hash)) \ -+ == RISCV_ELF_DATA ? ((struct riscv_elf_link_hash_table *) ((p)->hash)) : NULL) -+ -+static void -+riscv_info_to_howto_rela (bfd *abfd ATTRIBUTE_UNUSED, -+ arelent *cache_ptr, -+ Elf_Internal_Rela *dst) -+{ -+ cache_ptr->howto = riscv_elf_rtype_to_howto (ELFNN_R_TYPE (dst->r_info)); -+} -+ -+static void -+riscv_elf_append_rela (bfd *abfd, asection *s, Elf_Internal_Rela *rel) -+{ -+ const struct elf_backend_data *bed; -+ bfd_byte *loc; -+ -+ bed = get_elf_backend_data (abfd); -+ loc = s->contents + (s->reloc_count++ * bed->s->sizeof_rela); -+ bed->s->swap_reloca_out (abfd, rel, loc); -+} -+ -+/* PLT/GOT stuff */ -+ -+#define PLT_HEADER_INSNS 8 -+#define PLT_ENTRY_INSNS 4 -+#define PLT_HEADER_SIZE (PLT_HEADER_INSNS * 4) -+#define PLT_ENTRY_SIZE (PLT_ENTRY_INSNS * 4) -+ -+#define GOT_ENTRY_SIZE RISCV_ELF_WORD_BYTES -+ -+#define GOTPLT_HEADER_SIZE (2 * GOT_ENTRY_SIZE) -+ -+#define sec_addr(sec) ((sec)->output_section->vma + (sec)->output_offset) -+ -+static bfd_vma -+riscv_elf_got_plt_val (bfd_vma plt_index, struct bfd_link_info *info) -+{ -+ return sec_addr (riscv_elf_hash_table (info)->elf.sgotplt) -+ + GOTPLT_HEADER_SIZE + (plt_index * GOT_ENTRY_SIZE); -+} -+ -+#if ARCH_SIZE == 32 -+# define MATCH_LREG MATCH_LW -+#else -+# define MATCH_LREG MATCH_LD -+#endif -+ -+/* The format of the first PLT entry. */ -+ -+static void -+riscv_make_plt0_entry(bfd_vma gotplt_addr, bfd_vma addr, uint32_t *entry) -+{ -+ /* auipc t2, %hi(.got.plt) -+ sub t1, t1, t0 # shifted .got.plt offset + hdr size + 12 -+ l[w|d] t3, %lo(.got.plt)(t2) # _dl_runtime_resolve -+ addi t1, t1, -(hdr size + 12) # shifted .got.plt offset -+ addi t0, t2, %lo(.got.plt) # &.got.plt -+ srli t1, t1, log2(16/PTRSIZE) # .got.plt offset -+ l[w|d] t0, PTRSIZE(t0) # link map -+ jr t3 */ -+ -+ entry[0] = RISCV_UTYPE (AUIPC, X_T2, RISCV_PCREL_HIGH_PART (gotplt_addr, addr)); -+ entry[1] = RISCV_RTYPE (SUB, X_T1, X_T1, X_T0); -+ entry[2] = RISCV_ITYPE (LREG, X_T3, X_T2, RISCV_PCREL_LOW_PART (gotplt_addr, addr)); -+ entry[3] = RISCV_ITYPE (ADDI, X_T1, X_T1, -(PLT_HEADER_SIZE + 12)); -+ entry[4] = RISCV_ITYPE (ADDI, X_T0, X_T2, RISCV_PCREL_LOW_PART (gotplt_addr, addr)); -+ entry[5] = RISCV_ITYPE (SRLI, X_T1, X_T1, 4 - RISCV_ELF_LOG_WORD_BYTES); -+ entry[6] = RISCV_ITYPE (LREG, X_T0, X_T0, RISCV_ELF_WORD_BYTES); -+ entry[7] = RISCV_ITYPE (JALR, 0, X_T3, 0); -+} -+ -+/* The format of subsequent PLT entries. */ -+ -+static void -+riscv_make_plt_entry(bfd_vma got_address, bfd_vma addr, uint32_t *entry) -+{ -+ /* auipc t1, %hi(.got.plt entry) -+ l[w|d] t0, %lo(.got.plt entry)(t1) -+ jalr t1, t0 -+ nop */ -+ -+ entry[0] = RISCV_UTYPE (AUIPC, X_T1, RISCV_PCREL_HIGH_PART (got_address, addr)); -+ entry[1] = RISCV_ITYPE (LREG, X_T0, X_T1, RISCV_PCREL_LOW_PART(got_address, addr)); -+ entry[2] = RISCV_ITYPE (JALR, X_T1, X_T0, 0); -+ entry[3] = RISCV_NOP; -+} -+ -+/* Create an entry in an RISC-V ELF linker hash table. */ -+ -+static struct bfd_hash_entry * -+link_hash_newfunc (struct bfd_hash_entry *entry, -+ struct bfd_hash_table *table, const char *string) -+{ -+ /* Allocate the structure if it has not already been allocated by a -+ subclass. */ -+ if (entry == NULL) -+ { -+ entry = -+ bfd_hash_allocate (table, -+ sizeof (struct riscv_elf_link_hash_entry)); -+ if (entry == NULL) -+ return entry; -+ } -+ -+ /* Call the allocation method of the superclass. */ -+ entry = _bfd_elf_link_hash_newfunc (entry, table, string); -+ if (entry != NULL) -+ { -+ struct riscv_elf_link_hash_entry *eh; -+ -+ eh = (struct riscv_elf_link_hash_entry *) entry; -+ eh->dyn_relocs = NULL; -+ eh->tls_type = GOT_UNKNOWN; -+ } -+ -+ return entry; -+} -+ -+/* Create a RISC-V ELF linker hash table. */ -+ -+static struct bfd_link_hash_table * -+riscv_elf_link_hash_table_create (bfd *abfd) -+{ -+ struct riscv_elf_link_hash_table *ret; -+ bfd_size_type amt = sizeof (struct riscv_elf_link_hash_table); -+ -+ ret = (struct riscv_elf_link_hash_table *) bfd_zmalloc (amt); -+ if (ret == NULL) -+ return NULL; -+ -+ if (!_bfd_elf_link_hash_table_init (&ret->elf, abfd, link_hash_newfunc, -+ sizeof (struct riscv_elf_link_hash_entry), -+ RISCV_ELF_DATA)) -+ { -+ free (ret); -+ return NULL; -+ } -+ -+ return &ret->elf.root; -+} -+ -+/* Create the .got section. */ -+ -+static bfd_boolean -+riscv_elf_create_got_section (bfd *abfd, struct bfd_link_info *info) -+{ -+ flagword flags; -+ asection *s, *s_got; -+ struct elf_link_hash_entry *h; -+ const struct elf_backend_data *bed = get_elf_backend_data (abfd); -+ struct elf_link_hash_table *htab = elf_hash_table (info); -+ -+ /* This function may be called more than once. */ -+ s = bfd_get_linker_section (abfd, ".got"); -+ if (s != NULL) -+ return TRUE; -+ -+ flags = bed->dynamic_sec_flags; -+ -+ s = bfd_make_section_anyway_with_flags (abfd, -+ (bed->rela_plts_and_copies_p -+ ? ".rela.got" : ".rel.got"), -+ (bed->dynamic_sec_flags -+ | SEC_READONLY)); -+ if (s == NULL -+ || ! bfd_set_section_alignment (abfd, s, bed->s->log_file_align)) -+ return FALSE; -+ htab->srelgot = s; -+ -+ s = s_got = bfd_make_section_anyway_with_flags (abfd, ".got", flags); -+ if (s == NULL -+ || !bfd_set_section_alignment (abfd, s, bed->s->log_file_align)) -+ return FALSE; -+ htab->sgot = s; -+ -+ /* The first bit of the global offset table is the header. */ -+ s->size += bed->got_header_size; -+ -+ if (bed->want_got_plt) -+ { -+ s = bfd_make_section_anyway_with_flags (abfd, ".got.plt", flags); -+ if (s == NULL -+ || !bfd_set_section_alignment (abfd, s, -+ bed->s->log_file_align)) -+ return FALSE; -+ htab->sgotplt = s; -+ -+ /* Reserve room for the header. */ -+ s->size += GOTPLT_HEADER_SIZE; -+ } -+ -+ if (bed->want_got_sym) -+ { -+ /* Define the symbol _GLOBAL_OFFSET_TABLE_ at the start of the .got -+ section. We don't do this in the linker script because we don't want -+ to define the symbol if we are not creating a global offset -+ table. */ -+ h = _bfd_elf_define_linkage_sym (abfd, info, s_got, -+ "_GLOBAL_OFFSET_TABLE_"); -+ elf_hash_table (info)->hgot = h; -+ if (h == NULL) -+ return FALSE; -+ } -+ -+ return TRUE; -+} -+ -+/* Create .plt, .rela.plt, .got, .got.plt, .rela.got, .dynbss, and -+ .rela.bss sections in DYNOBJ, and set up shortcuts to them in our -+ hash table. */ -+ -+static bfd_boolean -+riscv_elf_create_dynamic_sections (bfd *dynobj, -+ struct bfd_link_info *info) -+{ -+ struct riscv_elf_link_hash_table *htab; -+ -+ htab = riscv_elf_hash_table (info); -+ BFD_ASSERT (htab != NULL); -+ -+ if (!riscv_elf_create_got_section (dynobj, info)) -+ return FALSE; -+ -+ if (!_bfd_elf_create_dynamic_sections (dynobj, info)) -+ return FALSE; -+ -+ htab->sdynbss = bfd_get_linker_section (dynobj, ".dynbss"); -+ if (!info->shared) -+ { -+ htab->srelbss = bfd_get_linker_section (dynobj, ".rela.bss"); -+ htab->sdyntdata = -+ bfd_make_section_anyway_with_flags (dynobj, ".tdata.dyn", -+ SEC_ALLOC | SEC_THREAD_LOCAL); -+ } -+ -+ if (!htab->elf.splt || !htab->elf.srelplt || !htab->sdynbss -+ || (!info->shared && (!htab->srelbss || !htab->sdyntdata))) -+ abort (); -+ -+ return TRUE; -+} -+ -+/* Copy the extra info we tack onto an elf_link_hash_entry. */ -+ -+static void -+riscv_elf_copy_indirect_symbol (struct bfd_link_info *info, -+ struct elf_link_hash_entry *dir, -+ struct elf_link_hash_entry *ind) -+{ -+ struct riscv_elf_link_hash_entry *edir, *eind; -+ -+ edir = (struct riscv_elf_link_hash_entry *) dir; -+ eind = (struct riscv_elf_link_hash_entry *) ind; -+ -+ if (eind->dyn_relocs != NULL) -+ { -+ if (edir->dyn_relocs != NULL) -+ { -+ struct riscv_elf_dyn_relocs **pp; -+ struct riscv_elf_dyn_relocs *p; -+ -+ /* Add reloc counts against the indirect sym to the direct sym -+ list. Merge any entries against the same section. */ -+ for (pp = &eind->dyn_relocs; (p = *pp) != NULL; ) -+ { -+ struct riscv_elf_dyn_relocs *q; -+ -+ for (q = edir->dyn_relocs; q != NULL; q = q->next) -+ if (q->sec == p->sec) -+ { -+ q->pc_count += p->pc_count; -+ q->count += p->count; -+ *pp = p->next; -+ break; -+ } -+ if (q == NULL) -+ pp = &p->next; -+ } -+ *pp = edir->dyn_relocs; -+ } -+ -+ edir->dyn_relocs = eind->dyn_relocs; -+ eind->dyn_relocs = NULL; -+ } -+ -+ if (ind->root.type == bfd_link_hash_indirect -+ && dir->got.refcount <= 0) -+ { -+ edir->tls_type = eind->tls_type; -+ eind->tls_type = GOT_UNKNOWN; -+ } -+ _bfd_elf_link_hash_copy_indirect (info, dir, ind); -+} -+ -+static bfd_boolean -+riscv_elf_record_tls_type (bfd *abfd, struct elf_link_hash_entry *h, -+ unsigned long symndx, char tls_type) -+{ -+ char *new_tls_type = &_bfd_riscv_elf_tls_type (abfd, h, symndx); -+ *new_tls_type |= tls_type; -+ if ((*new_tls_type & GOT_NORMAL) && (*new_tls_type & ~GOT_NORMAL)) -+ { -+ (*_bfd_error_handler) -+ (_("%B: `%s' accessed both as normal and thread local symbol"), -+ abfd, h ? h->root.root.string : ""); -+ return FALSE; -+ } -+ return TRUE; -+} -+ -+static bfd_boolean -+riscv_elf_record_got_reference (bfd *abfd, struct bfd_link_info *info, -+ struct elf_link_hash_entry *h, long symndx) -+{ -+ struct riscv_elf_link_hash_table *htab = riscv_elf_hash_table (info); -+ Elf_Internal_Shdr *symtab_hdr = &elf_tdata (abfd)->symtab_hdr; -+ -+ if (htab->elf.sgot == NULL) -+ { -+ if (!riscv_elf_create_got_section (htab->elf.dynobj, info)) -+ return FALSE; -+ } -+ -+ if (h != NULL) -+ { -+ h->got.refcount += 1; -+ return TRUE; -+ } -+ -+ /* This is a global offset table entry for a local symbol. */ -+ if (elf_local_got_refcounts (abfd) == NULL) -+ { -+ bfd_size_type size = symtab_hdr->sh_info * (sizeof (bfd_vma) + 1); -+ if (!(elf_local_got_refcounts (abfd) = bfd_zalloc (abfd, size))) -+ return FALSE; -+ _bfd_riscv_elf_local_got_tls_type (abfd) -+ = (char *) (elf_local_got_refcounts (abfd) + symtab_hdr->sh_info); -+ } -+ elf_local_got_refcounts (abfd) [symndx] += 1; -+ -+ return TRUE; -+} -+ -+static bfd_boolean -+bad_static_reloc (bfd *abfd, unsigned r_type, struct elf_link_hash_entry *h) -+{ -+ (*_bfd_error_handler) -+ (_("%B: relocation %s against `%s' can not be used when making a shared object; recompile with -fPIC"), -+ abfd, riscv_elf_rtype_to_howto (r_type)->name, -+ h != NULL ? h->root.root.string : "a local symbol"); -+ bfd_set_error (bfd_error_bad_value); -+ return FALSE; -+} -+/* Look through the relocs for a section during the first phase, and -+ allocate space in the global offset table or procedure linkage -+ table. */ -+ -+static bfd_boolean -+riscv_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, -+ asection *sec, const Elf_Internal_Rela *relocs) -+{ -+ struct riscv_elf_link_hash_table *htab; -+ Elf_Internal_Shdr *symtab_hdr; -+ struct elf_link_hash_entry **sym_hashes; -+ const Elf_Internal_Rela *rel; -+ asection *sreloc = NULL; -+ -+ if (info->relocatable) -+ return TRUE; -+ -+ htab = riscv_elf_hash_table (info); -+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr; -+ sym_hashes = elf_sym_hashes (abfd); -+ -+ if (htab->elf.dynobj == NULL) -+ htab->elf.dynobj = abfd; -+ -+ for (rel = relocs; rel < relocs + sec->reloc_count; rel++) -+ { -+ unsigned int r_type; -+ unsigned long r_symndx; -+ struct elf_link_hash_entry *h; -+ -+ r_symndx = ELFNN_R_SYM (rel->r_info); -+ r_type = ELFNN_R_TYPE (rel->r_info); -+ -+ if (r_symndx >= NUM_SHDR_ENTRIES (symtab_hdr)) -+ { -+ (*_bfd_error_handler) (_("%B: bad symbol index: %d"), -+ abfd, r_symndx); -+ return FALSE; -+ } -+ -+ if (r_symndx < symtab_hdr->sh_info) -+ h = NULL; -+ else -+ { -+ h = sym_hashes[r_symndx - symtab_hdr->sh_info]; -+ while (h->root.type == bfd_link_hash_indirect -+ || h->root.type == bfd_link_hash_warning) -+ h = (struct elf_link_hash_entry *) h->root.u.i.link; -+ -+ /* PR15323, ref flags aren't set for references in the same -+ object. */ -+ h->root.non_ir_ref = 1; -+ } -+ -+ switch (r_type) -+ { -+ case R_RISCV_TLS_GD_HI20: -+ if (!riscv_elf_record_got_reference (abfd, info, h, r_symndx) -+ || !riscv_elf_record_tls_type (abfd, h, r_symndx, GOT_TLS_GD)) -+ return FALSE; -+ break; -+ -+ case R_RISCV_TLS_GOT_HI20: -+ if (info->shared) -+ info->flags |= DF_STATIC_TLS; -+ if (!riscv_elf_record_got_reference (abfd, info, h, r_symndx) -+ || !riscv_elf_record_tls_type (abfd, h, r_symndx, GOT_TLS_IE)) -+ return FALSE; -+ break; -+ -+ case R_RISCV_GOT_HI20: -+ if (!riscv_elf_record_got_reference (abfd, info, h, r_symndx) -+ || !riscv_elf_record_tls_type (abfd, h, r_symndx, GOT_NORMAL)) -+ return FALSE; -+ break; -+ -+ case R_RISCV_CALL_PLT: -+ /* This symbol requires a procedure linkage table entry. We -+ actually build the entry in adjust_dynamic_symbol, -+ because this might be a case of linking PIC code without -+ linking in any dynamic objects, in which case we don't -+ need to generate a procedure linkage table after all. */ -+ -+ if (h != NULL) -+ { -+ h->needs_plt = 1; -+ h->plt.refcount += 1; -+ } -+ break; -+ -+ case R_RISCV_CALL: -+ case R_RISCV_JAL: -+ case R_RISCV_BRANCH: -+ case R_RISCV_PCREL_HI20: -+ /* In shared libs, these relocs are known to bind locally. */ -+ if (info->shared) -+ break; -+ goto static_reloc; -+ -+ case R_RISCV_TPREL_HI20: -+ if (!info->executable) -+ return bad_static_reloc (abfd, r_type, h); -+ if (h != NULL) -+ riscv_elf_record_tls_type (abfd, h, r_symndx, GOT_TLS_LE); -+ goto static_reloc; -+ -+ case R_RISCV_HI20: -+ if (info->shared) -+ return bad_static_reloc (abfd, r_type, h); -+ /* Fall through. */ -+ -+ case R_RISCV_COPY: -+ case R_RISCV_JUMP_SLOT: -+ case R_RISCV_RELATIVE: -+ case R_RISCV_64: -+ case R_RISCV_32: -+ /* Fall through. */ -+ -+ static_reloc: -+ if (h != NULL) -+ h->non_got_ref = 1; -+ -+ if (h != NULL && !info->shared) -+ { -+ /* We may need a .plt entry if the function this reloc -+ refers to is in a shared lib. */ -+ h->plt.refcount += 1; -+ } -+ -+ /* If we are creating a shared library, and this is a reloc -+ against a global symbol, or a non PC relative reloc -+ against a local symbol, then we need to copy the reloc -+ into the shared library. However, if we are linking with -+ -Bsymbolic, we do not need to copy a reloc against a -+ global symbol which is defined in an object we are -+ including in the link (i.e., DEF_REGULAR is set). At -+ this point we have not seen all the input files, so it is -+ possible that DEF_REGULAR is not set now but will be set -+ later (it is never cleared). In case of a weak definition, -+ DEF_REGULAR may be cleared later by a strong definition in -+ a shared library. We account for that possibility below by -+ storing information in the relocs_copied field of the hash -+ table entry. A similar situation occurs when creating -+ shared libraries and symbol visibility changes render the -+ symbol local. -+ -+ If on the other hand, we are creating an executable, we -+ may need to keep relocations for symbols satisfied by a -+ dynamic library if we manage to avoid copy relocs for the -+ symbol. */ -+ if ((info->shared -+ && (sec->flags & SEC_ALLOC) != 0 -+ && (! riscv_elf_rtype_to_howto (r_type)->pc_relative -+ || (h != NULL -+ && (! info->symbolic -+ || h->root.type == bfd_link_hash_defweak -+ || !h->def_regular)))) -+ || (!info->shared -+ && (sec->flags & SEC_ALLOC) != 0 -+ && h != NULL -+ && (h->root.type == bfd_link_hash_defweak -+ || !h->def_regular))) -+ { -+ struct riscv_elf_dyn_relocs *p; -+ struct riscv_elf_dyn_relocs **head; -+ -+ /* When creating a shared object, we must copy these -+ relocs into the output file. We create a reloc -+ section in dynobj and make room for the reloc. */ -+ if (sreloc == NULL) -+ { -+ sreloc = _bfd_elf_make_dynamic_reloc_section -+ (sec, htab->elf.dynobj, RISCV_ELF_LOG_WORD_BYTES, -+ abfd, /*rela?*/ TRUE); -+ -+ if (sreloc == NULL) -+ return FALSE; -+ } -+ -+ /* If this is a global symbol, we count the number of -+ relocations we need for this symbol. */ -+ if (h != NULL) -+ head = &((struct riscv_elf_link_hash_entry *) h)->dyn_relocs; -+ else -+ { -+ /* Track dynamic relocs needed for local syms too. -+ We really need local syms available to do this -+ easily. Oh well. */ -+ -+ asection *s; -+ void *vpp; -+ Elf_Internal_Sym *isym; -+ -+ isym = bfd_sym_from_r_symndx (&htab->sym_cache, -+ abfd, r_symndx); -+ if (isym == NULL) -+ return FALSE; -+ -+ s = bfd_section_from_elf_index (abfd, isym->st_shndx); -+ if (s == NULL) -+ s = sec; -+ -+ vpp = &elf_section_data (s)->local_dynrel; -+ head = (struct riscv_elf_dyn_relocs **) vpp; -+ } -+ -+ p = *head; -+ if (p == NULL || p->sec != sec) -+ { -+ bfd_size_type amt = sizeof *p; -+ p = ((struct riscv_elf_dyn_relocs *) -+ bfd_alloc (htab->elf.dynobj, amt)); -+ if (p == NULL) -+ return FALSE; -+ p->next = *head; -+ *head = p; -+ p->sec = sec; -+ p->count = 0; -+ p->pc_count = 0; -+ } -+ -+ p->count += 1; -+ p->pc_count += riscv_elf_rtype_to_howto (r_type)->pc_relative; -+ } -+ -+ break; -+ -+ case R_RISCV_GNU_VTINHERIT: -+ if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset)) -+ return FALSE; -+ break; -+ -+ case R_RISCV_GNU_VTENTRY: -+ if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend)) -+ return FALSE; -+ break; -+ -+ default: -+ break; -+ } -+ } -+ -+ return TRUE; -+} -+ -+static asection * -+riscv_elf_gc_mark_hook (asection *sec, -+ struct bfd_link_info *info, -+ Elf_Internal_Rela *rel, -+ struct elf_link_hash_entry *h, -+ Elf_Internal_Sym *sym) -+{ -+ if (h != NULL) -+ switch (ELFNN_R_TYPE (rel->r_info)) -+ { -+ case R_RISCV_GNU_VTINHERIT: -+ case R_RISCV_GNU_VTENTRY: -+ return NULL; -+ } -+ -+ return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym); -+} -+ -+/* Update the got entry reference counts for the section being removed. */ -+static bfd_boolean -+riscv_elf_gc_sweep_hook (bfd *abfd, struct bfd_link_info *info, -+ asection *sec, const Elf_Internal_Rela *relocs) -+{ -+ const Elf_Internal_Rela *rel, *relend; -+ Elf_Internal_Shdr *symtab_hdr = &elf_symtab_hdr (abfd); -+ struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (abfd); -+ bfd_signed_vma *local_got_refcounts = elf_local_got_refcounts (abfd); -+ -+ if (info->relocatable) -+ return TRUE; -+ -+ elf_section_data (sec)->local_dynrel = NULL; -+ -+ for (rel = relocs, relend = relocs + sec->reloc_count; rel < relend; rel++) -+ { -+ unsigned long r_symndx; -+ struct elf_link_hash_entry *h = NULL; -+ -+ r_symndx = ELFNN_R_SYM (rel->r_info); -+ if (r_symndx >= symtab_hdr->sh_info) -+ { -+ struct riscv_elf_link_hash_entry *eh; -+ struct riscv_elf_dyn_relocs **pp; -+ struct riscv_elf_dyn_relocs *p; -+ -+ h = sym_hashes[r_symndx - symtab_hdr->sh_info]; -+ while (h->root.type == bfd_link_hash_indirect -+ || h->root.type == bfd_link_hash_warning) -+ h = (struct elf_link_hash_entry *) h->root.u.i.link; -+ eh = (struct riscv_elf_link_hash_entry *) h; -+ for (pp = &eh->dyn_relocs; (p = *pp) != NULL; pp = &p->next) -+ if (p->sec == sec) -+ { -+ /* Everything must go for SEC. */ -+ *pp = p->next; -+ break; -+ } -+ } -+ -+ switch (ELFNN_R_TYPE (rel->r_info)) -+ { -+ case R_RISCV_GOT_HI20: -+ case R_RISCV_TLS_GOT_HI20: -+ case R_RISCV_TLS_GD_HI20: -+ if (h != NULL) -+ { -+ if (h->got.refcount > 0) -+ h->got.refcount--; -+ } -+ else -+ { -+ if (local_got_refcounts && -+ local_got_refcounts[r_symndx] > 0) -+ local_got_refcounts[r_symndx]--; -+ } -+ break; -+ -+ case R_RISCV_HI20: -+ case R_RISCV_PCREL_HI20: -+ case R_RISCV_COPY: -+ case R_RISCV_JUMP_SLOT: -+ case R_RISCV_RELATIVE: -+ case R_RISCV_64: -+ case R_RISCV_32: -+ case R_RISCV_BRANCH: -+ case R_RISCV_CALL: -+ case R_RISCV_JAL: -+ if (info->shared) -+ break; -+ /* Fall through. */ -+ -+ case R_RISCV_CALL_PLT: -+ if (h != NULL) -+ { -+ if (h->plt.refcount > 0) -+ h->plt.refcount--; -+ } -+ break; -+ -+ default: -+ break; -+ } -+ } -+ -+ return TRUE; -+} -+ -+/* Adjust a symbol defined by a dynamic object and referenced by a -+ regular object. The current definition is in some section of the -+ dynamic object, but we're not including those sections. We have to -+ change the definition to something the rest of the link can -+ understand. */ -+ -+static bfd_boolean -+riscv_elf_adjust_dynamic_symbol (struct bfd_link_info *info, -+ struct elf_link_hash_entry *h) -+{ -+ struct riscv_elf_link_hash_table *htab; -+ struct riscv_elf_link_hash_entry * eh; -+ struct riscv_elf_dyn_relocs *p; -+ bfd *dynobj; -+ asection *s; -+ -+ htab = riscv_elf_hash_table (info); -+ BFD_ASSERT (htab != NULL); -+ -+ dynobj = htab->elf.dynobj; -+ -+ /* Make sure we know what is going on here. */ -+ BFD_ASSERT (dynobj != NULL -+ && (h->needs_plt -+ || h->type == STT_GNU_IFUNC -+ || h->u.weakdef != NULL -+ || (h->def_dynamic -+ && h->ref_regular -+ && !h->def_regular))); -+ -+ /* If this is a function, put it in the procedure linkage table. We -+ will fill in the contents of the procedure linkage table later -+ (although we could actually do it here). */ -+ if (h->type == STT_FUNC || h->type == STT_GNU_IFUNC || h->needs_plt) -+ { -+ if (h->plt.refcount <= 0 -+ || SYMBOL_CALLS_LOCAL (info, h) -+ || (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT -+ && h->root.type == bfd_link_hash_undefweak)) -+ { -+ /* This case can occur if we saw a R_RISCV_CALL_PLT reloc in an -+ input file, but the symbol was never referred to by a dynamic -+ object, or if all references were garbage collected. In such -+ a case, we don't actually need to build a PLT entry. */ -+ h->plt.offset = (bfd_vma) -1; -+ h->needs_plt = 0; -+ } -+ -+ return TRUE; -+ } -+ else -+ h->plt.offset = (bfd_vma) -1; -+ -+ /* If this is a weak symbol, and there is a real definition, the -+ processor independent code will have arranged for us to see the -+ real definition first, and we can just use the same value. */ -+ if (h->u.weakdef != NULL) -+ { -+ BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined -+ || h->u.weakdef->root.type == bfd_link_hash_defweak); -+ h->root.u.def.section = h->u.weakdef->root.u.def.section; -+ h->root.u.def.value = h->u.weakdef->root.u.def.value; -+ return TRUE; -+ } -+ -+ /* This is a reference to a symbol defined by a dynamic object which -+ is not a function. */ -+ -+ /* If we are creating a shared library, we must presume that the -+ only references to the symbol are via the global offset table. -+ For such cases we need not do anything here; the relocations will -+ be handled correctly by relocate_section. */ -+ if (info->shared) -+ return TRUE; -+ -+ /* If there are no references to this symbol that do not use the -+ GOT, we don't need to generate a copy reloc. */ -+ if (!h->non_got_ref) -+ return TRUE; -+ -+ /* If -z nocopyreloc was given, we won't generate them either. */ -+ if (info->nocopyreloc) -+ { -+ h->non_got_ref = 0; -+ return TRUE; -+ } -+ -+ eh = (struct riscv_elf_link_hash_entry *) h; -+ for (p = eh->dyn_relocs; p != NULL; p = p->next) -+ { -+ s = p->sec->output_section; -+ if (s != NULL && (s->flags & SEC_READONLY) != 0) -+ break; -+ } -+ -+ /* If we didn't find any dynamic relocs in read-only sections, then -+ we'll be keeping the dynamic relocs and avoiding the copy reloc. */ -+ if (p == NULL) -+ { -+ h->non_got_ref = 0; -+ return TRUE; -+ } -+ -+ /* We must allocate the symbol in our .dynbss section, which will -+ become part of the .bss section of the executable. There will be -+ an entry for this symbol in the .dynsym section. The dynamic -+ object will contain position independent code, so all references -+ from the dynamic object to this symbol will go through the global -+ offset table. The dynamic linker will use the .dynsym entry to -+ determine the address it must put in the global offset table, so -+ both the dynamic object and the regular object will refer to the -+ same memory location for the variable. */ -+ -+ /* We must generate a R_RISCV_COPY reloc to tell the dynamic linker -+ to copy the initial value out of the dynamic object and into the -+ runtime process image. We need to remember the offset into the -+ .rel.bss section we are going to use. */ -+ if ((h->root.u.def.section->flags & SEC_ALLOC) != 0 && h->size != 0) -+ { -+ htab->srelbss->size += sizeof (ElfNN_External_Rela); -+ h->needs_copy = 1; -+ } -+ -+ if (eh->tls_type & ~GOT_NORMAL) -+ return _bfd_elf_adjust_dynamic_copy (h, htab->sdyntdata); -+ -+ return _bfd_elf_adjust_dynamic_copy (h, htab->sdynbss); -+} -+ -+/* Allocate space in .plt, .got and associated reloc sections for -+ dynamic relocs. */ -+ -+static bfd_boolean -+allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf) -+{ -+ struct bfd_link_info *info; -+ struct riscv_elf_link_hash_table *htab; -+ struct riscv_elf_link_hash_entry *eh; -+ struct riscv_elf_dyn_relocs *p; -+ -+ if (h->root.type == bfd_link_hash_indirect) -+ return TRUE; -+ -+ info = (struct bfd_link_info *) inf; -+ htab = riscv_elf_hash_table (info); -+ BFD_ASSERT (htab != NULL); -+ -+ if (htab->elf.dynamic_sections_created -+ && h->plt.refcount > 0) -+ { -+ /* Make sure this symbol is output as a dynamic symbol. -+ Undefined weak syms won't yet be marked as dynamic. */ -+ if (h->dynindx == -1 -+ && !h->forced_local) -+ { -+ if (! bfd_elf_link_record_dynamic_symbol (info, h)) -+ return FALSE; -+ } -+ -+ if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (1, info->shared, h)) -+ { -+ asection *s = htab->elf.splt; -+ -+ if (s->size == 0) -+ s->size = PLT_HEADER_SIZE; -+ -+ h->plt.offset = s->size; -+ -+ /* Make room for this entry. */ -+ s->size += PLT_ENTRY_SIZE; -+ -+ /* We also need to make an entry in the .got.plt section. */ -+ htab->elf.sgotplt->size += GOT_ENTRY_SIZE; -+ -+ /* We also need to make an entry in the .rela.plt section. */ -+ htab->elf.srelplt->size += sizeof (ElfNN_External_Rela); -+ -+ /* If this symbol is not defined in a regular file, and we are -+ not generating a shared library, then set the symbol to this -+ location in the .plt. This is required to make function -+ pointers compare as equal between the normal executable and -+ the shared library. */ -+ if (! info->shared -+ && !h->def_regular) -+ { -+ h->root.u.def.section = s; -+ h->root.u.def.value = h->plt.offset; -+ } -+ } -+ else -+ { -+ h->plt.offset = (bfd_vma) -1; -+ h->needs_plt = 0; -+ } -+ } -+ else -+ { -+ h->plt.offset = (bfd_vma) -1; -+ h->needs_plt = 0; -+ } -+ -+ if (h->got.refcount > 0) -+ { -+ asection *s; -+ bfd_boolean dyn; -+ int tls_type = riscv_elf_hash_entry(h)->tls_type; -+ -+ /* Make sure this symbol is output as a dynamic symbol. -+ Undefined weak syms won't yet be marked as dynamic. */ -+ if (h->dynindx == -1 -+ && !h->forced_local) -+ { -+ if (! bfd_elf_link_record_dynamic_symbol (info, h)) -+ return FALSE; -+ } -+ -+ s = htab->elf.sgot; -+ h->got.offset = s->size; -+ dyn = htab->elf.dynamic_sections_created; -+ if (tls_type & (GOT_TLS_GD | GOT_TLS_IE)) -+ { -+ /* TLS_GD needs two dynamic relocs and two GOT slots. */ -+ if (tls_type & GOT_TLS_GD) -+ { -+ s->size += 2 * RISCV_ELF_WORD_BYTES; -+ htab->elf.srelgot->size += 2 * sizeof (ElfNN_External_Rela); -+ } -+ -+ /* TLS_IE needs one dynamic reloc and one GOT slot. */ -+ if (tls_type & GOT_TLS_IE) -+ { -+ s->size += RISCV_ELF_WORD_BYTES; -+ htab->elf.srelgot->size += sizeof (ElfNN_External_Rela); -+ } -+ } -+ else -+ { -+ s->size += RISCV_ELF_WORD_BYTES; -+ if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h)) -+ htab->elf.srelgot->size += sizeof (ElfNN_External_Rela); -+ } -+ } -+ else -+ h->got.offset = (bfd_vma) -1; -+ -+ eh = (struct riscv_elf_link_hash_entry *) h; -+ if (eh->dyn_relocs == NULL) -+ return TRUE; -+ -+ /* In the shared -Bsymbolic case, discard space allocated for -+ dynamic pc-relative relocs against symbols which turn out to be -+ defined in regular objects. For the normal shared case, discard -+ space for pc-relative relocs that have become local due to symbol -+ visibility changes. */ -+ -+ if (info->shared) -+ { -+ if (SYMBOL_CALLS_LOCAL (info, h)) -+ { -+ struct riscv_elf_dyn_relocs **pp; -+ -+ for (pp = &eh->dyn_relocs; (p = *pp) != NULL; ) -+ { -+ p->count -= p->pc_count; -+ p->pc_count = 0; -+ if (p->count == 0) -+ *pp = p->next; -+ else -+ pp = &p->next; -+ } -+ } -+ -+ /* Also discard relocs on undefined weak syms with non-default -+ visibility. */ -+ if (eh->dyn_relocs != NULL -+ && h->root.type == bfd_link_hash_undefweak) -+ { -+ if (ELF_ST_VISIBILITY (h->other) != STV_DEFAULT) -+ eh->dyn_relocs = NULL; -+ -+ /* Make sure undefined weak symbols are output as a dynamic -+ symbol in PIEs. */ -+ else if (h->dynindx == -1 -+ && !h->forced_local) -+ { -+ if (! bfd_elf_link_record_dynamic_symbol (info, h)) -+ return FALSE; -+ } -+ } -+ } -+ else -+ { -+ /* For the non-shared case, discard space for relocs against -+ symbols which turn out to need copy relocs or are not -+ dynamic. */ -+ -+ if (!h->non_got_ref -+ && ((h->def_dynamic -+ && !h->def_regular) -+ || (htab->elf.dynamic_sections_created -+ && (h->root.type == bfd_link_hash_undefweak -+ || h->root.type == bfd_link_hash_undefined)))) -+ { -+ /* Make sure this symbol is output as a dynamic symbol. -+ Undefined weak syms won't yet be marked as dynamic. */ -+ if (h->dynindx == -1 -+ && !h->forced_local) -+ { -+ if (! bfd_elf_link_record_dynamic_symbol (info, h)) -+ return FALSE; -+ } -+ -+ /* If that succeeded, we know we'll be keeping all the -+ relocs. */ -+ if (h->dynindx != -1) -+ goto keep; -+ } -+ -+ eh->dyn_relocs = NULL; -+ -+ keep: ; -+ } -+ -+ /* Finally, allocate space. */ -+ for (p = eh->dyn_relocs; p != NULL; p = p->next) -+ { -+ asection *sreloc = elf_section_data (p->sec)->sreloc; -+ sreloc->size += p->count * sizeof (ElfNN_External_Rela); -+ } -+ -+ return TRUE; -+} -+ -+/* Find any dynamic relocs that apply to read-only sections. */ -+ -+static bfd_boolean -+readonly_dynrelocs (struct elf_link_hash_entry *h, void *inf) -+{ -+ struct riscv_elf_link_hash_entry *eh; -+ struct riscv_elf_dyn_relocs *p; -+ -+ eh = (struct riscv_elf_link_hash_entry *) h; -+ for (p = eh->dyn_relocs; p != NULL; p = p->next) -+ { -+ asection *s = p->sec->output_section; -+ -+ if (s != NULL && (s->flags & SEC_READONLY) != 0) -+ { -+ ((struct bfd_link_info *) inf)->flags |= DF_TEXTREL; -+ -+ /* Short-circuit the traversal. */ -+ return FALSE; -+ } -+ } -+ return TRUE; -+} -+ -+static bfd_boolean -+riscv_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info) -+{ -+ struct riscv_elf_link_hash_table *htab; -+ bfd *dynobj; -+ asection *s; -+ bfd *ibfd; -+ -+ htab = riscv_elf_hash_table (info); -+ BFD_ASSERT (htab != NULL); -+ dynobj = htab->elf.dynobj; -+ BFD_ASSERT (dynobj != NULL); -+ -+ if (elf_hash_table (info)->dynamic_sections_created) -+ { -+ /* Set the contents of the .interp section to the interpreter. */ -+ if (info->executable) -+ { -+ s = bfd_get_linker_section (dynobj, ".interp"); -+ BFD_ASSERT (s != NULL); -+ s->size = strlen (ELFNN_DYNAMIC_INTERPRETER) + 1; -+ s->contents = (unsigned char *) ELFNN_DYNAMIC_INTERPRETER; -+ } -+ } -+ -+ /* Set up .got offsets for local syms, and space for local dynamic -+ relocs. */ -+ for (ibfd = info->input_bfds; ibfd != NULL; ibfd = ibfd->link_next) -+ { -+ bfd_signed_vma *local_got; -+ bfd_signed_vma *end_local_got; -+ char *local_tls_type; -+ bfd_size_type locsymcount; -+ Elf_Internal_Shdr *symtab_hdr; -+ asection *srel; -+ -+ if (! is_riscv_elf (ibfd)) -+ continue; -+ -+ for (s = ibfd->sections; s != NULL; s = s->next) -+ { -+ struct riscv_elf_dyn_relocs *p; -+ -+ for (p = elf_section_data (s)->local_dynrel; p != NULL; p = p->next) -+ { -+ if (!bfd_is_abs_section (p->sec) -+ && bfd_is_abs_section (p->sec->output_section)) -+ { -+ /* Input section has been discarded, either because -+ it is a copy of a linkonce section or due to -+ linker script /DISCARD/, so we'll be discarding -+ the relocs too. */ -+ } -+ else if (p->count != 0) -+ { -+ srel = elf_section_data (p->sec)->sreloc; -+ srel->size += p->count * sizeof (ElfNN_External_Rela); -+ if ((p->sec->output_section->flags & SEC_READONLY) != 0) -+ info->flags |= DF_TEXTREL; -+ } -+ } -+ } -+ -+ local_got = elf_local_got_refcounts (ibfd); -+ if (!local_got) -+ continue; -+ -+ symtab_hdr = &elf_symtab_hdr (ibfd); -+ locsymcount = symtab_hdr->sh_info; -+ end_local_got = local_got + locsymcount; -+ local_tls_type = _bfd_riscv_elf_local_got_tls_type (ibfd); -+ s = htab->elf.sgot; -+ srel = htab->elf.srelgot; -+ for (; local_got < end_local_got; ++local_got, ++local_tls_type) -+ { -+ if (*local_got > 0) -+ { -+ *local_got = s->size; -+ s->size += RISCV_ELF_WORD_BYTES; -+ if (*local_tls_type & GOT_TLS_GD) -+ s->size += RISCV_ELF_WORD_BYTES; -+ if (info->shared -+ || (*local_tls_type & (GOT_TLS_GD | GOT_TLS_IE))) -+ srel->size += sizeof (ElfNN_External_Rela); -+ } -+ else -+ *local_got = (bfd_vma) -1; -+ } -+ } -+ -+ /* Allocate global sym .plt and .got entries, and space for global -+ sym dynamic relocs. */ -+ elf_link_hash_traverse (&htab->elf, allocate_dynrelocs, info); -+ -+ if (htab->elf.sgotplt) -+ { -+ struct elf_link_hash_entry *got; -+ got = elf_link_hash_lookup (elf_hash_table (info), -+ "_GLOBAL_OFFSET_TABLE_", -+ FALSE, FALSE, FALSE); -+ -+ /* Don't allocate .got.plt section if there are no GOT nor PLT -+ entries and there is no refeence to _GLOBAL_OFFSET_TABLE_. */ -+ if ((got == NULL -+ || !got->ref_regular_nonweak) -+ && (htab->elf.sgotplt->size == GOTPLT_HEADER_SIZE) -+ && (htab->elf.splt == NULL -+ || htab->elf.splt->size == 0) -+ && (htab->elf.sgot == NULL -+ || (htab->elf.sgot->size -+ == get_elf_backend_data (output_bfd)->got_header_size))) -+ htab->elf.sgotplt->size = 0; -+ } -+ -+ /* The check_relocs and adjust_dynamic_symbol entry points have -+ determined the sizes of the various dynamic sections. Allocate -+ memory for them. */ -+ for (s = dynobj->sections; s != NULL; s = s->next) -+ { -+ if ((s->flags & SEC_LINKER_CREATED) == 0) -+ continue; -+ -+ if (s == htab->elf.splt -+ || s == htab->elf.sgot -+ || s == htab->elf.sgotplt -+ || s == htab->sdynbss) -+ { -+ /* Strip this section if we don't need it; see the -+ comment below. */ -+ } -+ else if (strncmp (s->name, ".rela", 5) == 0) -+ { -+ if (s->size != 0) -+ { -+ /* We use the reloc_count field as a counter if we need -+ to copy relocs into the output file. */ -+ s->reloc_count = 0; -+ } -+ } -+ else -+ { -+ /* It's not one of our sections. */ -+ continue; -+ } -+ -+ if (s->size == 0) -+ { -+ /* If we don't need this section, strip it from the -+ output file. This is mostly to handle .rela.bss and -+ .rela.plt. We must create both sections in -+ create_dynamic_sections, because they must be created -+ before the linker maps input sections to output -+ sections. The linker does that before -+ adjust_dynamic_symbol is called, and it is that -+ function which decides whether anything needs to go -+ into these sections. */ -+ s->flags |= SEC_EXCLUDE; -+ continue; -+ } -+ -+ if ((s->flags & SEC_HAS_CONTENTS) == 0) -+ continue; -+ -+ /* Allocate memory for the section contents. Zero the memory -+ for the benefit of .rela.plt, which has 4 unused entries -+ at the beginning, and we don't want garbage. */ -+ s->contents = (bfd_byte *) bfd_zalloc (dynobj, s->size); -+ if (s->contents == NULL) -+ return FALSE; -+ } -+ -+ if (elf_hash_table (info)->dynamic_sections_created) -+ { -+ /* Add some entries to the .dynamic section. We fill in the -+ values later, in riscv_elf_finish_dynamic_sections, but we -+ must add the entries now so that we get the correct size for -+ the .dynamic section. The DT_DEBUG entry is filled in by the -+ dynamic linker and used by the debugger. */ -+#define add_dynamic_entry(TAG, VAL) \ -+ _bfd_elf_add_dynamic_entry (info, TAG, VAL) -+ -+ if (info->executable) -+ { -+ if (!add_dynamic_entry (DT_DEBUG, 0)) -+ return FALSE; -+ } -+ -+ if (htab->elf.srelplt->size != 0) -+ { -+ if (!add_dynamic_entry (DT_PLTGOT, 0) -+ || !add_dynamic_entry (DT_PLTRELSZ, 0) -+ || !add_dynamic_entry (DT_PLTREL, DT_RELA) -+ || !add_dynamic_entry (DT_JMPREL, 0)) -+ return FALSE; -+ } -+ -+ if (!add_dynamic_entry (DT_RELA, 0) -+ || !add_dynamic_entry (DT_RELASZ, 0) -+ || !add_dynamic_entry (DT_RELAENT, sizeof (ElfNN_External_Rela))) -+ return FALSE; -+ -+ /* If any dynamic relocs apply to a read-only section, -+ then we need a DT_TEXTREL entry. */ -+ if ((info->flags & DF_TEXTREL) == 0) -+ elf_link_hash_traverse (&htab->elf, readonly_dynrelocs, info); -+ -+ if (info->flags & DF_TEXTREL) -+ { -+ if (!add_dynamic_entry (DT_TEXTREL, 0)) -+ return FALSE; -+ } -+ } -+#undef add_dynamic_entry -+ -+ return TRUE; -+} -+ -+#define TP_OFFSET 0 -+#define DTP_OFFSET 0x800 -+ -+/* Return the relocation value for a TLS dtp-relative reloc. */ -+ -+static bfd_vma -+dtpoff (struct bfd_link_info *info, bfd_vma address) -+{ -+ /* If tls_sec is NULL, we should have signalled an error already. */ -+ if (elf_hash_table (info)->tls_sec == NULL) -+ return 0; -+ return address - elf_hash_table (info)->tls_sec->vma - DTP_OFFSET; -+} -+ -+/* Return the relocation value for a static TLS tp-relative relocation. */ -+ -+static bfd_vma -+tpoff (struct bfd_link_info *info, bfd_vma address) -+{ -+ /* If tls_sec is NULL, we should have signalled an error already. */ -+ if (elf_hash_table (info)->tls_sec == NULL) -+ return 0; -+ return address - elf_hash_table (info)->tls_sec->vma - TP_OFFSET; -+} -+ -+/* Return the global pointer's value, or 0 if it is not in use. */ -+ -+static bfd_vma -+riscv_global_pointer_value (struct bfd_link_info *info) -+{ -+ struct bfd_link_hash_entry *h; -+ -+ h = bfd_link_hash_lookup (info->hash, "_gp", FALSE, FALSE, TRUE); -+ if (h == NULL || h->type != bfd_link_hash_defined) -+ return 0; -+ -+ return h->u.def.value + sec_addr (h->u.def.section); -+} -+ -+/* Emplace a static relocation. */ -+ -+static bfd_reloc_status_type -+perform_relocation (const reloc_howto_type *howto, -+ const Elf_Internal_Rela *rel, -+ bfd_vma value, -+ asection *input_section, -+ bfd *input_bfd, -+ bfd_byte *contents) -+{ -+ if (howto->pc_relative) -+ value -= sec_addr (input_section) + rel->r_offset; -+ value += rel->r_addend; -+ -+ switch (ELFNN_R_TYPE (rel->r_info)) -+ { -+ case R_RISCV_HI20: -+ case R_RISCV_TPREL_HI20: -+ case R_RISCV_PCREL_HI20: -+ case R_RISCV_GOT_HI20: -+ case R_RISCV_TLS_GOT_HI20: -+ case R_RISCV_TLS_GD_HI20: -+ value = ENCODE_UTYPE_IMM (RISCV_CONST_HIGH_PART (value)); -+ break; -+ -+ case R_RISCV_LO12_I: -+ case R_RISCV_TPREL_LO12_I: -+ case R_RISCV_PCREL_LO12_I: -+ value = ENCODE_ITYPE_IMM (value); -+ break; -+ -+ case R_RISCV_LO12_S: -+ case R_RISCV_TPREL_LO12_S: -+ case R_RISCV_PCREL_LO12_S: -+ value = ENCODE_STYPE_IMM (value); -+ break; -+ -+ case R_RISCV_CALL: -+ case R_RISCV_CALL_PLT: -+ if (!VALID_UTYPE_IMM (RISCV_CONST_HIGH_PART (value))) -+ return bfd_reloc_overflow; -+ value = ENCODE_UTYPE_IMM (RISCV_CONST_HIGH_PART (value)) -+ | (ENCODE_ITYPE_IMM (value) << 32); -+ break; -+ -+ case R_RISCV_JAL: -+ if (!VALID_UJTYPE_IMM (value)) -+ return bfd_reloc_overflow; -+ value = ENCODE_UJTYPE_IMM (value); -+ break; -+ -+ case R_RISCV_BRANCH: -+ if (!VALID_SBTYPE_IMM (value)) -+ return bfd_reloc_overflow; -+ value = ENCODE_SBTYPE_IMM (value); -+ break; -+ -+ case R_RISCV_32: -+ case R_RISCV_64: -+ case R_RISCV_ADD8: -+ case R_RISCV_ADD16: -+ case R_RISCV_ADD32: -+ case R_RISCV_ADD64: -+ case R_RISCV_SUB8: -+ case R_RISCV_SUB16: -+ case R_RISCV_SUB32: -+ case R_RISCV_SUB64: -+ case R_RISCV_TLS_DTPREL32: -+ case R_RISCV_TLS_DTPREL64: -+ break; -+ -+ default: -+ return bfd_reloc_notsupported; -+ } -+ -+ bfd_vma word = bfd_get (howto->bitsize, input_bfd, contents + rel->r_offset); -+ word = (word & ~howto->dst_mask) | (value & howto->dst_mask); -+ bfd_put (howto->bitsize, input_bfd, word, contents + rel->r_offset); -+ -+ return bfd_reloc_ok; -+} -+ -+/* Remember all PC-relative high-part relocs we've encountered to help us -+ later resolve the corresponding low-part relocs. */ -+ -+typedef struct { -+ bfd_vma address; -+ bfd_vma value; -+} riscv_pcrel_hi_reloc; -+ -+typedef struct riscv_pcrel_lo_reloc { -+ asection *input_section; -+ struct bfd_link_info *info; -+ reloc_howto_type *howto; -+ const Elf_Internal_Rela *reloc; -+ bfd_vma addr; -+ const char *name; -+ bfd_byte *contents; -+ struct riscv_pcrel_lo_reloc *next; -+} riscv_pcrel_lo_reloc; -+ -+typedef struct { -+ htab_t hi_relocs; -+ riscv_pcrel_lo_reloc *lo_relocs; -+} riscv_pcrel_relocs; -+ -+static hashval_t -+riscv_pcrel_reloc_hash (const void *entry) -+{ -+ const riscv_pcrel_hi_reloc *e = entry; -+ return (hashval_t)(e->address >> 2); -+} -+ -+static bfd_boolean -+riscv_pcrel_reloc_eq (const void *entry1, const void *entry2) -+{ -+ const riscv_pcrel_hi_reloc *e1 = entry1, *e2 = entry2; -+ return e1->address == e2->address; -+} -+ -+static bfd_boolean -+riscv_init_pcrel_relocs (riscv_pcrel_relocs *p) -+{ -+ -+ p->lo_relocs = NULL; -+ p->hi_relocs = htab_create (1024, riscv_pcrel_reloc_hash, -+ riscv_pcrel_reloc_eq, free); -+ return p->hi_relocs != NULL; -+} -+ -+static void -+riscv_free_pcrel_relocs (riscv_pcrel_relocs *p) -+{ -+ riscv_pcrel_lo_reloc *cur = p->lo_relocs; -+ while (cur != NULL) -+ { -+ riscv_pcrel_lo_reloc *next = cur->next; -+ free (cur); -+ cur = next; -+ } -+ -+ htab_delete (p->hi_relocs); -+} -+ -+static bfd_boolean -+riscv_record_pcrel_hi_reloc (riscv_pcrel_relocs *p, bfd_vma addr, bfd_vma value) -+{ -+ riscv_pcrel_hi_reloc entry = {addr, value - addr}; -+ riscv_pcrel_hi_reloc **slot = -+ (riscv_pcrel_hi_reloc **) htab_find_slot (p->hi_relocs, &entry, INSERT); -+ BFD_ASSERT (*slot == NULL); -+ *slot = (riscv_pcrel_hi_reloc *) bfd_malloc (sizeof (riscv_pcrel_hi_reloc)); -+ if (*slot == NULL) -+ return FALSE; -+ **slot = entry; -+ return TRUE; -+} -+ -+static bfd_boolean -+riscv_record_pcrel_lo_reloc (riscv_pcrel_relocs *p, -+ asection *input_section, -+ struct bfd_link_info *info, -+ reloc_howto_type *howto, -+ const Elf_Internal_Rela *reloc, -+ bfd_vma addr, -+ const char *name, -+ bfd_byte *contents) -+{ -+ riscv_pcrel_lo_reloc *entry; -+ entry = (riscv_pcrel_lo_reloc *) bfd_malloc (sizeof (riscv_pcrel_lo_reloc)); -+ if (entry == NULL) -+ return FALSE; -+ *entry = (riscv_pcrel_lo_reloc) {input_section, info, howto, reloc, addr, -+ name, contents, p->lo_relocs}; -+ p->lo_relocs = entry; -+ return TRUE; -+} -+ -+static bfd_boolean -+riscv_resolve_pcrel_lo_relocs (riscv_pcrel_relocs *p) -+{ -+ riscv_pcrel_lo_reloc *r; -+ for (r = p->lo_relocs; r != NULL; r = r->next) -+ { -+ bfd *input_bfd = r->input_section->owner; -+ riscv_pcrel_hi_reloc search = {r->addr, 0}; -+ riscv_pcrel_hi_reloc *entry = htab_find (p->hi_relocs, &search); -+ if (entry == NULL) -+ return ((*r->info->callbacks->reloc_overflow) -+ (r->info, NULL, r->name, r->howto->name, (bfd_vma) 0, -+ input_bfd, r->input_section, r->reloc->r_offset)); -+ -+ perform_relocation (r->howto, r->reloc, entry->value, r->input_section, -+ input_bfd, r->contents); -+ } -+ -+ return TRUE; -+} -+ -+/* Relocate a RISC-V ELF section. -+ -+ The RELOCATE_SECTION function is called by the new ELF backend linker -+ to handle the relocations for a section. -+ -+ The relocs are always passed as Rela structures. -+ -+ This function is responsible for adjusting the section contents as -+ necessary, and (if generating a relocatable output file) adjusting -+ the reloc addend as necessary. -+ -+ This function does not have to worry about setting the reloc -+ address or the reloc symbol index. -+ -+ LOCAL_SYMS is a pointer to the swapped in local symbols. -+ -+ LOCAL_SECTIONS is an array giving the section in the input file -+ corresponding to the st_shndx field of each local symbol. -+ -+ The global hash table entry for the global symbols can be found -+ via elf_sym_hashes (input_bfd). -+ -+ When generating relocatable output, this function must handle -+ STB_LOCAL/STT_SECTION symbols specially. The output symbol is -+ going to be the section symbol corresponding to the output -+ section, which means that the addend must be adjusted -+ accordingly. */ -+ -+static bfd_boolean -+riscv_elf_relocate_section (bfd *output_bfd, struct bfd_link_info *info, -+ bfd *input_bfd, asection *input_section, -+ bfd_byte *contents, Elf_Internal_Rela *relocs, -+ Elf_Internal_Sym *local_syms, -+ asection **local_sections) -+{ -+ Elf_Internal_Rela *rel; -+ Elf_Internal_Rela *relend; -+ riscv_pcrel_relocs pcrel_relocs; -+ bfd_boolean ret = FALSE; -+ asection *sreloc = elf_section_data (input_section)->sreloc; -+ struct riscv_elf_link_hash_table *htab = riscv_elf_hash_table (info); -+ Elf_Internal_Shdr *symtab_hdr = &elf_symtab_hdr (input_bfd); -+ struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (input_bfd); -+ bfd_vma *local_got_offsets = elf_local_got_offsets (input_bfd); -+ -+ if (!riscv_init_pcrel_relocs (&pcrel_relocs)) -+ return FALSE; -+ -+ relend = relocs + input_section->reloc_count; -+ for (rel = relocs; rel < relend; rel++) -+ { -+ unsigned long r_symndx; -+ struct elf_link_hash_entry *h; -+ Elf_Internal_Sym *sym; -+ asection *sec; -+ bfd_vma relocation; -+ bfd_reloc_status_type r = bfd_reloc_ok; -+ const char *name; -+ bfd_vma off, ie_off; -+ bfd_boolean unresolved_reloc, is_ie = FALSE; -+ bfd_vma pc = sec_addr (input_section) + rel->r_offset; -+ int r_type = ELFNN_R_TYPE (rel->r_info), tls_type; -+ reloc_howto_type *howto = riscv_elf_rtype_to_howto (r_type); -+ const char *msg = NULL; -+ -+ if (r_type == R_RISCV_GNU_VTINHERIT || r_type == R_RISCV_GNU_VTENTRY) -+ continue; -+ -+ /* This is a final link. */ -+ r_symndx = ELFNN_R_SYM (rel->r_info); -+ h = NULL; -+ sym = NULL; -+ sec = NULL; -+ unresolved_reloc = FALSE; -+ if (r_symndx < symtab_hdr->sh_info) -+ { -+ sym = local_syms + r_symndx; -+ sec = local_sections[r_symndx]; -+ relocation = _bfd_elf_rela_local_sym (output_bfd, sym, &sec, rel); -+ } -+ else -+ { -+ bfd_boolean warned; -+ /* bfd_boolean ignored; */ -+ -+ RELOC_FOR_GLOBAL_SYMBOL (info, input_bfd, input_section, rel, -+ r_symndx, symtab_hdr, sym_hashes, -+ h, sec, relocation, -+ unresolved_reloc, warned /*, ignored */); -+ if (warned) -+ { -+ /* To avoid generating warning messages about truncated -+ relocations, set the relocation's address to be the same as -+ the start of this section. */ -+ if (input_section->output_section != NULL) -+ relocation = input_section->output_section->vma; -+ else -+ relocation = 0; -+ } -+ } -+ -+ if (sec != NULL && discarded_section (sec)) -+ RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section, -+ rel, 1, relend, howto, 0, contents); -+ -+ if (info->relocatable) -+ continue; -+ -+ if (h != NULL) -+ name = h->root.root.string; -+ else -+ { -+ name = (bfd_elf_string_from_elf_section -+ (input_bfd, symtab_hdr->sh_link, sym->st_name)); -+ if (name == NULL || *name == '\0') -+ name = bfd_section_name (input_bfd, sec); -+ } -+ -+ switch (r_type) -+ { -+ case R_RISCV_NONE: -+ case R_RISCV_TPREL_ADD: -+ case R_RISCV_COPY: -+ case R_RISCV_JUMP_SLOT: -+ case R_RISCV_RELATIVE: -+ /* These require nothing of us at all. */ -+ continue; -+ -+ case R_RISCV_BRANCH: -+ case R_RISCV_HI20: -+ /* These require no special handling beyond perform_relocation. */ -+ break; -+ -+ case R_RISCV_GOT_HI20: -+ if (h != NULL) -+ { -+ bfd_boolean dyn; -+ -+ off = h->got.offset; -+ BFD_ASSERT (off != (bfd_vma) -1); -+ dyn = elf_hash_table (info)->dynamic_sections_created; -+ -+ if (! WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h) -+ || (info->shared -+ && SYMBOL_REFERENCES_LOCAL (info, h))) -+ { -+ /* This is actually a static link, or it is a -+ -Bsymbolic link and the symbol is defined -+ locally, or the symbol was forced to be local -+ because of a version file. We must initialize -+ this entry in the global offset table. Since the -+ offset must always be a multiple of the word size, -+ we use the least significant bit to record whether -+ we have initialized it already. -+ -+ When doing a dynamic link, we create a .rela.got -+ relocation entry to initialize the value. This -+ is done in the finish_dynamic_symbol routine. */ -+ if ((off & 1) != 0) -+ off &= ~1; -+ else -+ { -+ bfd_put_NN (output_bfd, relocation, -+ htab->elf.sgot->contents + off); -+ h->got.offset |= 1; -+ } -+ } -+ else -+ unresolved_reloc = FALSE; -+ } -+ else -+ { -+ BFD_ASSERT (local_got_offsets != NULL -+ && local_got_offsets[r_symndx] != (bfd_vma) -1); -+ -+ off = local_got_offsets[r_symndx]; -+ -+ /* The offset must always be a multiple of 8 on 64-bit. -+ We use the least significant bit to record -+ whether we have already processed this entry. */ -+ if ((off & 1) != 0) -+ off &= ~1; -+ else -+ { -+ if (info->shared) -+ { -+ asection *s; -+ Elf_Internal_Rela outrel; -+ -+ /* We need to generate a R_RISCV_RELATIVE reloc -+ for the dynamic linker. */ -+ s = htab->elf.srelgot; -+ BFD_ASSERT (s != NULL); -+ -+ outrel.r_offset = sec_addr (htab->elf.sgot) + off; -+ outrel.r_info = -+ ELFNN_R_INFO (0, R_RISCV_RELATIVE); -+ outrel.r_addend = relocation; -+ relocation = 0; -+ riscv_elf_append_rela (output_bfd, s, &outrel); -+ } -+ -+ bfd_put_NN (output_bfd, relocation, -+ htab->elf.sgot->contents + off); -+ local_got_offsets[r_symndx] |= 1; -+ } -+ } -+ relocation = sec_addr (htab->elf.sgot) + off; -+ if (!riscv_record_pcrel_hi_reloc (&pcrel_relocs, pc, relocation)) -+ r = bfd_reloc_overflow; -+ break; -+ -+ case R_RISCV_ADD8: -+ case R_RISCV_ADD16: -+ case R_RISCV_ADD32: -+ case R_RISCV_ADD64: -+ { -+ bfd_vma old_value = bfd_get (howto->bitsize, input_bfd, -+ contents + rel->r_offset); -+ relocation = old_value + relocation; -+ } -+ break; -+ -+ case R_RISCV_SUB8: -+ case R_RISCV_SUB16: -+ case R_RISCV_SUB32: -+ case R_RISCV_SUB64: -+ { -+ bfd_vma old_value = bfd_get (howto->bitsize, input_bfd, -+ contents + rel->r_offset); -+ relocation = old_value - relocation; -+ } -+ break; -+ -+ case R_RISCV_CALL_PLT: -+ case R_RISCV_CALL: -+ case R_RISCV_JAL: -+ if (info->shared && h != NULL && h->plt.offset != MINUS_ONE) -+ { -+ /* Refer to the PLT entry. */ -+ relocation = sec_addr (htab->elf.splt) + h->plt.offset; -+ unresolved_reloc = FALSE; -+ } -+ break; -+ -+ case R_RISCV_TPREL_HI20: -+ relocation = tpoff (info, relocation); -+ break; -+ -+ case R_RISCV_TPREL_LO12_I: -+ case R_RISCV_TPREL_LO12_S: -+ relocation = tpoff (info, relocation); -+ if (VALID_ITYPE_IMM (relocation + rel->r_addend)) -+ { -+ /* We can use tp as the base register. */ -+ bfd_vma insn = bfd_get_32 (input_bfd, contents + rel->r_offset); -+ insn &= ~(OP_MASK_RS1 << OP_SH_RS1); -+ insn |= X_TP << OP_SH_RS1; -+ bfd_put_32 (input_bfd, insn, contents + rel->r_offset); -+ } -+ break; -+ -+ case R_RISCV_LO12_I: -+ case R_RISCV_LO12_S: -+ { -+ bfd_vma gp = riscv_global_pointer_value (info); -+ bfd_boolean x0_base = VALID_ITYPE_IMM (relocation + rel->r_addend); -+ if (x0_base || VALID_ITYPE_IMM (relocation + rel->r_addend - gp)) -+ { -+ /* We can use x0 or gp as the base register. */ -+ bfd_vma insn = bfd_get_32 (input_bfd, contents + rel->r_offset); -+ insn &= ~(OP_MASK_RS1 << OP_SH_RS1); -+ if (!x0_base) -+ { -+ rel->r_addend -= gp; -+ insn |= X_GP << OP_SH_RS1; -+ } -+ bfd_put_32 (input_bfd, insn, contents + rel->r_offset); -+ } -+ break; -+ } -+ -+ case R_RISCV_PCREL_HI20: -+ if (!riscv_record_pcrel_hi_reloc (&pcrel_relocs, pc, -+ relocation + rel->r_addend)) -+ r = bfd_reloc_overflow; -+ break; -+ -+ case R_RISCV_PCREL_LO12_I: -+ case R_RISCV_PCREL_LO12_S: -+ if (riscv_record_pcrel_lo_reloc (&pcrel_relocs, input_section, info, -+ howto, rel, relocation, name, -+ contents)) -+ continue; -+ r = bfd_reloc_overflow; -+ break; -+ -+ case R_RISCV_TLS_DTPREL32: -+ case R_RISCV_TLS_DTPREL64: -+ relocation = dtpoff (info, relocation); -+ break; -+ -+ case R_RISCV_32: -+ case R_RISCV_64: -+ if ((input_section->flags & SEC_ALLOC) == 0) -+ break; -+ -+ if ((info->shared -+ && (h == NULL -+ || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT -+ || h->root.type != bfd_link_hash_undefweak) -+ && (! howto->pc_relative -+ || !SYMBOL_CALLS_LOCAL (info, h))) -+ || (!info->shared -+ && h != NULL -+ && h->dynindx != -1 -+ && !h->non_got_ref -+ && ((h->def_dynamic -+ && !h->def_regular) -+ || h->root.type == bfd_link_hash_undefweak -+ || h->root.type == bfd_link_hash_undefined))) -+ { -+ Elf_Internal_Rela outrel; -+ bfd_boolean skip_static_relocation, skip_dynamic_relocation; -+ -+ /* When generating a shared object, these relocations -+ are copied into the output file to be resolved at run -+ time. */ -+ -+ outrel.r_offset = -+ _bfd_elf_section_offset (output_bfd, info, input_section, -+ rel->r_offset); -+ skip_static_relocation = outrel.r_offset != (bfd_vma) -2; -+ skip_dynamic_relocation = outrel.r_offset >= (bfd_vma) -2; -+ outrel.r_offset += sec_addr (input_section); -+ -+ if (skip_dynamic_relocation) -+ memset (&outrel, 0, sizeof outrel); -+ else if (h != NULL && h->dynindx != -1 -+ && !(info->shared -+ && SYMBOLIC_BIND (info, h) -+ && h->def_regular)) -+ { -+ outrel.r_info = ELFNN_R_INFO (h->dynindx, r_type); -+ outrel.r_addend = rel->r_addend; -+ } -+ else -+ { -+ outrel.r_info = ELFNN_R_INFO (0, R_RISCV_RELATIVE); -+ outrel.r_addend = relocation + rel->r_addend; -+ } -+ -+ riscv_elf_append_rela (output_bfd, sreloc, &outrel); -+ if (skip_static_relocation) -+ continue; -+ } -+ break; -+ -+ case R_RISCV_TLS_GOT_HI20: -+ is_ie = TRUE; -+ /* Fall through. */ -+ -+ case R_RISCV_TLS_GD_HI20: -+ if (h != NULL) -+ { -+ off = h->got.offset; -+ h->got.offset |= 1; -+ } -+ else -+ { -+ off = local_got_offsets[r_symndx]; -+ local_got_offsets[r_symndx] |= 1; -+ } -+ -+ tls_type = _bfd_riscv_elf_tls_type (input_bfd, h, r_symndx); -+ BFD_ASSERT (tls_type & (GOT_TLS_IE | GOT_TLS_GD)); -+ /* If this symbol is referenced by both GD and IE TLS, the IE -+ reference's GOT slot follows the GD reference's slots. */ -+ ie_off = 0; -+ if ((tls_type & GOT_TLS_GD) && (tls_type & GOT_TLS_IE)) -+ ie_off = 2 * GOT_ENTRY_SIZE; -+ -+ if ((off & 1) != 0) -+ off &= ~1; -+ else -+ { -+ Elf_Internal_Rela outrel; -+ int indx = 0; -+ bfd_boolean need_relocs = FALSE; -+ -+ if (htab->elf.srelgot == NULL) -+ abort (); -+ -+ if (h != NULL) -+ { -+ bfd_boolean dyn; -+ dyn = htab->elf.dynamic_sections_created; -+ -+ if (WILL_CALL_FINISH_DYNAMIC_SYMBOL (dyn, info->shared, h) -+ && (!info->shared -+ || !SYMBOL_REFERENCES_LOCAL (info, h))) -+ { -+ indx = h->dynindx; -+ } -+ } -+ -+ /* The GOT entries have not been initialized yet. Do it -+ now, and emit any relocations. */ -+ if ((info->shared || indx != 0) -+ && (h == NULL -+ || ELF_ST_VISIBILITY (h->other) == STV_DEFAULT -+ || h->root.type != bfd_link_hash_undefweak)) -+ need_relocs = TRUE; -+ -+ if (tls_type & GOT_TLS_GD) -+ { -+ if (need_relocs) -+ { -+ outrel.r_offset = sec_addr (htab->elf.sgot) + off; -+ outrel.r_addend = 0; -+ outrel.r_info = ELFNN_R_INFO (indx, R_RISCV_TLS_DTPMODNN); -+ bfd_put_NN (output_bfd, 0, -+ htab->elf.sgot->contents + off); -+ riscv_elf_append_rela (output_bfd, htab->elf.srelgot, &outrel); -+ if (indx == 0) -+ { -+ BFD_ASSERT (! unresolved_reloc); -+ bfd_put_NN (output_bfd, -+ dtpoff (info, relocation), -+ (htab->elf.sgot->contents + off + -+ RISCV_ELF_WORD_BYTES)); -+ } -+ else -+ { -+ bfd_put_NN (output_bfd, 0, -+ (htab->elf.sgot->contents + off + -+ RISCV_ELF_WORD_BYTES)); -+ outrel.r_info = ELFNN_R_INFO (indx, R_RISCV_TLS_DTPRELNN); -+ outrel.r_offset += RISCV_ELF_WORD_BYTES; -+ riscv_elf_append_rela (output_bfd, htab->elf.srelgot, &outrel); -+ } -+ } -+ else -+ { -+ /* If we are not emitting relocations for a -+ general dynamic reference, then we must be in a -+ static link or an executable link with the -+ symbol binding locally. Mark it as belonging -+ to module 1, the executable. */ -+ bfd_put_NN (output_bfd, 1, -+ htab->elf.sgot->contents + off); -+ bfd_put_NN (output_bfd, -+ dtpoff (info, relocation), -+ (htab->elf.sgot->contents + off + -+ RISCV_ELF_WORD_BYTES)); -+ } -+ } -+ -+ if (tls_type & GOT_TLS_IE) -+ { -+ if (need_relocs) -+ { -+ bfd_put_NN (output_bfd, 0, -+ htab->elf.sgot->contents + off + ie_off); -+ outrel.r_offset = sec_addr (htab->elf.sgot) -+ + off + ie_off; -+ outrel.r_addend = 0; -+ if (indx == 0) -+ outrel.r_addend = tpoff (info, relocation); -+ outrel.r_info = ELFNN_R_INFO (indx, R_RISCV_TLS_TPRELNN); -+ riscv_elf_append_rela (output_bfd, htab->elf.srelgot, &outrel); -+ } -+ else -+ { -+ bfd_put_NN (output_bfd, tpoff (info, relocation), -+ htab->elf.sgot->contents + off + ie_off); -+ } -+ } -+ } -+ -+ BFD_ASSERT (off < (bfd_vma) -2); -+ relocation = sec_addr (htab->elf.sgot) + off + (is_ie ? ie_off : 0); -+ if (!riscv_record_pcrel_hi_reloc (&pcrel_relocs, pc, relocation)) -+ r = bfd_reloc_overflow; -+ unresolved_reloc = FALSE; -+ break; -+ -+ default: -+ r = bfd_reloc_notsupported; -+ } -+ -+ /* Dynamic relocs are not propagated for SEC_DEBUGGING sections -+ because such sections are not SEC_ALLOC and thus ld.so will -+ not process them. */ -+ if (unresolved_reloc -+ && !((input_section->flags & SEC_DEBUGGING) != 0 -+ && h->def_dynamic) -+ && _bfd_elf_section_offset (output_bfd, info, input_section, -+ rel->r_offset) != (bfd_vma) -1) -+ { -+ (*_bfd_error_handler) -+ (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"), -+ input_bfd, -+ input_section, -+ (long) rel->r_offset, -+ howto->name, -+ h->root.root.string); -+ continue; -+ } -+ -+ if (r == bfd_reloc_ok) -+ r = perform_relocation (howto, rel, relocation, input_section, -+ input_bfd, contents); -+ -+ switch (r) -+ { -+ case bfd_reloc_ok: -+ continue; -+ -+ case bfd_reloc_overflow: -+ r = info->callbacks->reloc_overflow -+ (info, (h ? &h->root : NULL), name, howto->name, -+ (bfd_vma) 0, input_bfd, input_section, rel->r_offset); -+ break; -+ -+ case bfd_reloc_undefined: -+ r = info->callbacks->undefined_symbol -+ (info, name, input_bfd, input_section, rel->r_offset, -+ TRUE); -+ break; -+ -+ case bfd_reloc_outofrange: -+ msg = _("internal error: out of range error"); -+ break; -+ -+ case bfd_reloc_notsupported: -+ msg = _("internal error: unsupported relocation error"); -+ break; -+ -+ case bfd_reloc_dangerous: -+ msg = _("internal error: dangerous relocation"); -+ break; -+ -+ default: -+ msg = _("internal error: unknown error"); -+ break; -+ } -+ -+ if (msg) -+ r = info->callbacks->warning -+ (info, msg, name, input_bfd, input_section, rel->r_offset); -+ goto out; -+ } -+ -+ ret = riscv_resolve_pcrel_lo_relocs (&pcrel_relocs); -+out: -+ riscv_free_pcrel_relocs (&pcrel_relocs); -+ return ret; -+} -+ -+/* Finish up dynamic symbol handling. We set the contents of various -+ dynamic sections here. */ -+ -+static bfd_boolean -+riscv_elf_finish_dynamic_symbol (bfd *output_bfd, -+ struct bfd_link_info *info, -+ struct elf_link_hash_entry *h, -+ Elf_Internal_Sym *sym) -+{ -+ struct riscv_elf_link_hash_table *htab = riscv_elf_hash_table (info); -+ const struct elf_backend_data *bed = get_elf_backend_data (output_bfd); -+ -+ if (h->plt.offset != (bfd_vma) -1) -+ { -+ /* We've decided to create a PLT entry for this symbol. */ -+ bfd_byte *loc; -+ bfd_vma i, header_address, plt_idx, got_address; -+ uint32_t plt_entry[PLT_ENTRY_INSNS]; -+ Elf_Internal_Rela rela; -+ -+ BFD_ASSERT (h->dynindx != -1); -+ -+ /* Calculate the address of the PLT header. */ -+ header_address = sec_addr (htab->elf.splt); -+ -+ /* Calculate the index of the entry. */ -+ plt_idx = (h->plt.offset - PLT_HEADER_SIZE) / PLT_ENTRY_SIZE; -+ -+ /* Calculate the address of the .got.plt entry. */ -+ got_address = riscv_elf_got_plt_val (plt_idx, info); -+ -+ /* Find out where the .plt entry should go. */ -+ loc = htab->elf.splt->contents + h->plt.offset; -+ -+ /* Fill in the PLT entry itself. */ -+ riscv_make_plt_entry (got_address, header_address + h->plt.offset, -+ plt_entry); -+ for (i = 0; i < PLT_ENTRY_INSNS; i++) -+ bfd_put_32 (output_bfd, plt_entry[i], loc + 4*i); -+ -+ /* Fill in the initial value of the .got.plt entry. */ -+ loc = htab->elf.sgotplt->contents -+ + (got_address - sec_addr (htab->elf.sgotplt)); -+ bfd_put_NN (output_bfd, sec_addr (htab->elf.splt), loc); -+ -+ /* Fill in the entry in the .rela.plt section. */ -+ rela.r_offset = got_address; -+ rela.r_addend = 0; -+ rela.r_info = ELFNN_R_INFO (h->dynindx, R_RISCV_JUMP_SLOT); -+ -+ loc = htab->elf.srelplt->contents + plt_idx * sizeof (ElfNN_External_Rela); -+ bed->s->swap_reloca_out (output_bfd, &rela, loc); -+ -+ if (!h->def_regular) -+ { -+ /* Mark the symbol as undefined, rather than as defined in -+ the .plt section. Leave the value alone. */ -+ sym->st_shndx = SHN_UNDEF; -+ /* If the symbol is weak, we do need to clear the value. -+ Otherwise, the PLT entry would provide a definition for -+ the symbol even if the symbol wasn't defined anywhere, -+ and so the symbol would never be NULL. */ -+ if (!h->ref_regular_nonweak) -+ sym->st_value = 0; -+ } -+ } -+ -+ if (h->got.offset != (bfd_vma) -1 -+ && !(riscv_elf_hash_entry(h)->tls_type & (GOT_TLS_GD | GOT_TLS_IE))) -+ { -+ asection *sgot; -+ asection *srela; -+ Elf_Internal_Rela rela; -+ -+ /* This symbol has an entry in the GOT. Set it up. */ -+ -+ sgot = htab->elf.sgot; -+ srela = htab->elf.srelgot; -+ BFD_ASSERT (sgot != NULL && srela != NULL); -+ -+ rela.r_offset = sec_addr (sgot) + (h->got.offset &~ (bfd_vma) 1); -+ -+ /* If this is a -Bsymbolic link, and the symbol is defined -+ locally, we just want to emit a RELATIVE reloc. Likewise if -+ the symbol was forced to be local because of a version file. -+ The entry in the global offset table will already have been -+ initialized in the relocate_section function. */ -+ if (info->shared -+ && (info->symbolic || h->dynindx == -1) -+ && h->def_regular) -+ { -+ asection *sec = h->root.u.def.section; -+ rela.r_info = ELFNN_R_INFO (0, R_RISCV_RELATIVE); -+ rela.r_addend = (h->root.u.def.value -+ + sec->output_section->vma -+ + sec->output_offset); -+ } -+ else -+ { -+ BFD_ASSERT (h->dynindx != -1); -+ rela.r_info = ELFNN_R_INFO (h->dynindx, R_RISCV_NN); -+ rela.r_addend = 0; -+ } -+ -+ bfd_put_NN (output_bfd, 0, -+ sgot->contents + (h->got.offset & ~(bfd_vma) 1)); -+ riscv_elf_append_rela (output_bfd, srela, &rela); -+ } -+ -+ if (h->needs_copy) -+ { -+ Elf_Internal_Rela rela; -+ -+ /* This symbols needs a copy reloc. Set it up. */ -+ BFD_ASSERT (h->dynindx != -1); -+ -+ rela.r_offset = sec_addr (h->root.u.def.section) + h->root.u.def.value; -+ rela.r_info = ELFNN_R_INFO (h->dynindx, R_RISCV_COPY); -+ rela.r_addend = 0; -+ riscv_elf_append_rela (output_bfd, htab->srelbss, &rela); -+ } -+ -+ /* Mark some specially defined symbols as absolute. */ -+ if (/*h == htab->elf.hdynamic*/ -+ strcmp (h->root.root.string, "_DYNAMIC") == 0 -+ || (h == htab->elf.hgot || h == htab->elf.hplt)) -+ sym->st_shndx = SHN_ABS; -+ -+ return TRUE; -+} -+ -+/* Finish up the dynamic sections. */ -+ -+static bfd_boolean -+riscv_finish_dyn (bfd *output_bfd, struct bfd_link_info *info, -+ bfd *dynobj, asection *sdyn) -+{ -+ struct riscv_elf_link_hash_table *htab = riscv_elf_hash_table (info); -+ const struct elf_backend_data *bed = get_elf_backend_data (output_bfd); -+ size_t dynsize = bed->s->sizeof_dyn; -+ bfd_byte *dyncon, *dynconend; -+ -+ dynconend = sdyn->contents + sdyn->size; -+ for (dyncon = sdyn->contents; dyncon < dynconend; dyncon += dynsize) -+ { -+ Elf_Internal_Dyn dyn; -+ asection *s; -+ -+ bed->s->swap_dyn_in (dynobj, dyncon, &dyn); -+ -+ switch (dyn.d_tag) -+ { -+ case DT_PLTGOT: -+ s = htab->elf.sgotplt; -+ dyn.d_un.d_ptr = s->output_section->vma + s->output_offset; -+ break; -+ case DT_JMPREL: -+ s = htab->elf.srelplt; -+ dyn.d_un.d_ptr = s->output_section->vma + s->output_offset; -+ break; -+ case DT_PLTRELSZ: -+ s = htab->elf.srelplt; -+ dyn.d_un.d_val = s->size; -+ break; -+ default: -+ continue; -+ } -+ -+ bed->s->swap_dyn_out (output_bfd, &dyn, dyncon); -+ } -+ return TRUE; -+} -+ -+static bfd_boolean -+riscv_elf_finish_dynamic_sections (bfd *output_bfd, -+ struct bfd_link_info *info) -+{ -+ bfd *dynobj; -+ asection *sdyn; -+ struct riscv_elf_link_hash_table *htab; -+ -+ htab = riscv_elf_hash_table (info); -+ BFD_ASSERT (htab != NULL); -+ dynobj = htab->elf.dynobj; -+ -+ sdyn = bfd_get_linker_section (dynobj, ".dynamic"); -+ -+ if (elf_hash_table (info)->dynamic_sections_created) -+ { -+ asection *splt; -+ bfd_boolean ret; -+ -+ splt = htab->elf.splt; -+ BFD_ASSERT (splt != NULL && sdyn != NULL); -+ -+ ret = riscv_finish_dyn (output_bfd, info, dynobj, sdyn); -+ -+ if (ret != TRUE) -+ return ret; -+ -+ /* Fill in the head and tail entries in the procedure linkage table. */ -+ if (splt->size > 0) -+ { -+ int i; -+ uint32_t plt_header[PLT_HEADER_INSNS]; -+ riscv_make_plt0_entry (sec_addr (htab->elf.sgotplt), -+ sec_addr (splt), plt_header); -+ -+ for (i = 0; i < PLT_HEADER_INSNS; i++) -+ bfd_put_32 (output_bfd, plt_header[i], splt->contents + 4*i); -+ } -+ -+ elf_section_data (splt->output_section)->this_hdr.sh_entsize -+ = PLT_ENTRY_SIZE; -+ } -+ -+ if (htab->elf.sgotplt) -+ { -+ if (bfd_is_abs_section (htab->elf.sgotplt->output_section)) -+ { -+ (*_bfd_error_handler) -+ (_("discarded output section: `%A'"), htab->elf.sgotplt); -+ return FALSE; -+ } -+ -+ if (htab->elf.sgotplt->size > 0) -+ { -+ /* Write the first two entries in .got.plt, needed for the dynamic -+ linker. */ -+ bfd_put_NN (output_bfd, (bfd_vma) -1, htab->elf.sgotplt->contents); -+ bfd_put_NN (output_bfd, (bfd_vma) 0, -+ htab->elf.sgotplt->contents + GOT_ENTRY_SIZE); -+ } -+ -+ elf_section_data (htab->elf.sgotplt->output_section)->this_hdr.sh_entsize = -+ GOT_ENTRY_SIZE; -+ } -+ -+ if (htab->elf.sgot) -+ { -+ if (htab->elf.sgot->size > 0) -+ { -+ /* Set the first entry in the global offset table to the address of -+ the dynamic section. */ -+ bfd_vma val = sdyn ? sec_addr (sdyn) : 0; -+ bfd_put_NN (output_bfd, val, htab->elf.sgot->contents); -+ } -+ -+ elf_section_data (htab->elf.sgot->output_section)->this_hdr.sh_entsize = -+ GOT_ENTRY_SIZE; -+ } -+ -+ return TRUE; -+} -+ -+/* Return address for Ith PLT stub in section PLT, for relocation REL -+ or (bfd_vma) -1 if it should not be included. */ -+ -+static bfd_vma -+riscv_elf_plt_sym_val (bfd_vma i, const asection *plt, -+ const arelent *rel ATTRIBUTE_UNUSED) -+{ -+ return plt->vma + PLT_HEADER_SIZE + i * PLT_ENTRY_SIZE; -+} -+ -+static enum elf_reloc_type_class -+riscv_reloc_type_class (/*const struct bfd_link_info *info ATTRIBUTE_UNUSED, -+ const asection *rel_sec ATTRIBUTE_UNUSED,*/ -+ const Elf_Internal_Rela *rela) -+{ -+ switch (ELFNN_R_TYPE (rela->r_info)) -+ { -+ case R_RISCV_RELATIVE: -+ return reloc_class_relative; -+ case R_RISCV_JUMP_SLOT: -+ return reloc_class_plt; -+ case R_RISCV_COPY: -+ return reloc_class_copy; -+ default: -+ return reloc_class_normal; -+ } -+} -+ -+/* Return true if bfd machine EXTENSION is an extension of machine BASE. */ -+ -+static bfd_boolean -+riscv_mach_extends_p (unsigned long base, unsigned long extension) -+{ -+ return extension == base; -+} -+ -+/* Merge backend specific data from an object file to the output -+ object file when linking. */ -+ -+static bfd_boolean -+_bfd_riscv_elf_merge_private_bfd_data (bfd *ibfd, bfd *obfd) -+{ -+ flagword old_flags; -+ flagword new_flags; -+ -+ if (!is_riscv_elf (ibfd) || !is_riscv_elf (obfd)) -+ return TRUE; -+ -+ if (strcmp (bfd_get_target (ibfd), bfd_get_target (obfd)) != 0) -+ { -+ (*_bfd_error_handler) -+ (_("%B: ABI is incompatible with that of the selected emulation"), -+ ibfd); -+ return FALSE; -+ } -+ -+ if (!_bfd_elf_merge_object_attributes (ibfd, obfd)) -+ return FALSE; -+ -+ new_flags = elf_elfheader (ibfd)->e_flags; -+ old_flags = elf_elfheader (obfd)->e_flags; -+ -+ if (! elf_flags_init (obfd)) -+ { -+ elf_flags_init (obfd) = TRUE; -+ elf_elfheader (obfd)->e_flags = new_flags; -+ elf_elfheader (obfd)->e_ident[EI_CLASS] -+ = elf_elfheader (ibfd)->e_ident[EI_CLASS]; -+ -+ if (bfd_get_arch (obfd) == bfd_get_arch (ibfd) -+ && (bfd_get_arch_info (obfd)->the_default -+ || riscv_mach_extends_p (bfd_get_mach (obfd), -+ bfd_get_mach (ibfd)))) -+ { -+ if (! bfd_set_arch_mach (obfd, bfd_get_arch (ibfd), -+ bfd_get_mach (ibfd))) -+ return FALSE; -+ } -+ -+ return TRUE; -+ } -+ -+ /* Check flag compatibility. */ -+ -+ if (new_flags == old_flags) -+ return TRUE; -+ -+ /* Don't link RV32 and RV64. */ -+ if (elf_elfheader (ibfd)->e_ident[EI_CLASS] -+ != elf_elfheader (obfd)->e_ident[EI_CLASS]) -+ { -+ (*_bfd_error_handler) -+ (_("%B: ELF class mismatch: can't link 32- and 64-bit modules"), ibfd); -+ goto fail; -+ } -+ -+ /* Warn about any other mismatches. */ -+ if (new_flags != old_flags) -+ { -+ if (!EF_IS_RISCV_EXT_Xcustom (new_flags) && -+ !EF_IS_RISCV_EXT_Xcustom (old_flags)) -+ { -+ (*_bfd_error_handler) -+ (_("%B: uses different e_flags (0x%lx) fields than previous modules (0x%lx)"), -+ ibfd, (unsigned long) new_flags, -+ (unsigned long) old_flags); -+ goto fail; -+ } -+ else if (EF_IS_RISCV_EXT_Xcustom(new_flags)) -+ EF_SET_RISCV_EXT (elf_elfheader (obfd)->e_flags, -+ EF_GET_RISCV_EXT (old_flags)); -+ } -+ -+ return TRUE; -+ -+fail: -+ bfd_set_error (bfd_error_bad_value); -+ return FALSE; -+} -+ -+/* Delete some bytes from a section while relaxing. */ -+ -+static bfd_boolean -+riscv_relax_delete_bytes (bfd *abfd, asection *sec, bfd_vma addr, size_t count) -+{ -+ unsigned int i, symcount; -+ bfd_vma toaddr = sec->size; -+ struct elf_link_hash_entry **sym_hashes = elf_sym_hashes (abfd); -+ Elf_Internal_Shdr *symtab_hdr = &elf_tdata (abfd)->symtab_hdr; -+ unsigned int sec_shndx = _bfd_elf_section_from_bfd_section (abfd, sec); -+ struct bfd_elf_section_data *data = elf_section_data (sec); -+ bfd_byte *contents = data->this_hdr.contents; -+ -+ /* Actually delete the bytes. */ -+ sec->size -= count; -+ memmove (contents + addr, contents + addr + count, toaddr - addr - count); -+ -+ /* Adjust the location of all of the relocs. Note that we need not -+ adjust the addends, since all PC-relative references must be against -+ symbols, which we will adjust below. */ -+ for (i = 0; i < sec->reloc_count; i++) -+ if (data->relocs[i].r_offset > addr && data->relocs[i].r_offset < toaddr) -+ data->relocs[i].r_offset -= count; -+ -+ /* Adjust the local symbols defined in this section. */ -+ for (i = 0; i < symtab_hdr->sh_info; i++) -+ { -+ Elf_Internal_Sym *sym = (Elf_Internal_Sym *) symtab_hdr->contents + i; -+ if (sym->st_shndx == sec_shndx) -+ { -+ /* If the symbol is in the range of memory we just moved, we -+ have to adjust its value. */ -+ if (sym->st_value > addr && sym->st_value <= toaddr) -+ sym->st_value -= count; -+ -+ /* If the symbol *spans* the bytes we just deleted (i.e. its -+ *end* is in the moved bytes but its *start* isn't), then we -+ must adjust its size. */ -+ if (sym->st_value <= addr -+ && sym->st_value + sym->st_size > addr -+ && sym->st_value + sym->st_size <= toaddr) -+ sym->st_size -= count; -+ } -+ } -+ -+ /* Now adjust the global symbols defined in this section. */ -+ symcount = ((symtab_hdr->sh_size / sizeof(ElfNN_External_Sym)) -+ - symtab_hdr->sh_info); -+ -+ for (i = 0; i < symcount; i++) -+ { -+ struct elf_link_hash_entry *sym_hash = sym_hashes[i]; -+ -+ if ((sym_hash->root.type == bfd_link_hash_defined -+ || sym_hash->root.type == bfd_link_hash_defweak) -+ && sym_hash->root.u.def.section == sec) -+ { -+ /* As above, adjust the value if needed. */ -+ if (sym_hash->root.u.def.value > addr -+ && sym_hash->root.u.def.value <= toaddr) -+ sym_hash->root.u.def.value -= count; -+ -+ /* As above, adjust the size if needed. */ -+ if (sym_hash->root.u.def.value <= addr -+ && sym_hash->root.u.def.value + sym_hash->size > addr -+ && sym_hash->root.u.def.value + sym_hash->size <= toaddr) -+ sym_hash->size -= count; -+ } -+ } -+ -+ return TRUE; -+} -+ -+/* Relax AUIPC + JALR into JAL. */ -+ -+static bfd_boolean -+_bfd_riscv_relax_call (bfd *abfd, asection *sec, -+ struct bfd_link_info *link_info, -+ Elf_Internal_Rela *rel, -+ bfd_vma symval, -+ bfd_boolean *again) -+{ -+ bfd_byte *contents = elf_section_data (sec)->this_hdr.contents; -+ bfd_signed_vma foff = symval - (sec_addr (sec) + rel->r_offset); -+ bfd_boolean near_zero = (symval + RISCV_IMM_REACH/2) < RISCV_IMM_REACH; -+ bfd_vma auipc, jalr; -+ int r_type; -+ -+ /* See if this function call can be shortened. */ -+ if (!VALID_UJTYPE_IMM (foff) && !(!link_info->shared && near_zero)) -+ return TRUE; -+ -+ /* Shorten the function call. */ -+ BFD_ASSERT (rel->r_offset + 8 <= sec->size); -+ -+ auipc = bfd_get_32 (abfd, contents + rel->r_offset); -+ jalr = bfd_get_32 (abfd, contents + rel->r_offset + 4); -+ -+ if (VALID_UJTYPE_IMM (foff)) -+ { -+ /* Relax to JAL rd, addr. */ -+ r_type = R_RISCV_JAL; -+ auipc = (jalr & (OP_MASK_RD << OP_SH_RD)) | MATCH_JAL; -+ } -+ else /* near_zero */ -+ { -+ /* Relax to JALR rd, x0, addr. */ -+ r_type = R_RISCV_LO12_I; -+ auipc = (jalr & (OP_MASK_RD << OP_SH_RD)) | MATCH_JALR; -+ } -+ -+ /* Replace the R_RISCV_CALL reloc. */ -+ rel->r_info = ELFNN_R_INFO (ELFNN_R_SYM (rel->r_info), r_type); -+ /* Replace the AUIPC. */ -+ bfd_put_32 (abfd, auipc, contents + rel->r_offset); -+ -+ /* Delete unnecessary JALR. */ -+ *again = TRUE; -+ return riscv_relax_delete_bytes (abfd, sec, rel->r_offset + 4, 4); -+} -+ -+/* Relax non-PIC global variable references. */ -+ -+static bfd_boolean -+_bfd_riscv_relax_lui (bfd *abfd, asection *sec, -+ struct bfd_link_info *link_info, -+ Elf_Internal_Rela *rel, -+ bfd_vma symval, -+ bfd_boolean *again) -+{ -+ bfd_vma gp = riscv_global_pointer_value (link_info); -+ -+ /* Bail out if this symbol isn't in range of either gp or x0. */ -+ if (!VALID_ITYPE_IMM (symval - gp) && !(symval < RISCV_IMM_REACH/2)) -+ return TRUE; -+ -+ /* We can delete the unnecessary AUIPC. The corresponding LO12 reloc -+ will be converted to GPREL during relocation. */ -+ BFD_ASSERT (rel->r_offset + 4 <= sec->size); -+ rel->r_info = ELFNN_R_INFO (0, R_RISCV_NONE); -+ -+ *again = TRUE; -+ return riscv_relax_delete_bytes (abfd, sec, rel->r_offset, 4); -+} -+ -+/* Relax non-PIC TLS references. */ -+ -+static bfd_boolean -+_bfd_riscv_relax_tls_le (bfd *abfd, asection *sec, -+ struct bfd_link_info *link_info, -+ Elf_Internal_Rela *rel, -+ bfd_vma symval, -+ bfd_boolean *again) -+{ -+ /* See if this symbol is in range of tp. */ -+ if (RISCV_CONST_HIGH_PART (tpoff (link_info, symval)) != 0) -+ return TRUE; -+ -+ /* We can delete the unnecessary LUI and tp add. The LO12 reloc will be -+ made directly tp-relative. */ -+ BFD_ASSERT (rel->r_offset + 4 <= sec->size); -+ rel->r_info = ELFNN_R_INFO (0, R_RISCV_NONE); -+ -+ *again = TRUE; -+ return riscv_relax_delete_bytes (abfd, sec, rel->r_offset, 4); -+} -+ -+/* Implement R_RISCV_ALIGN by deleting excess alignment NOPs. */ -+ -+static bfd_boolean -+_bfd_riscv_relax_align (bfd *abfd, asection *sec, -+ struct bfd_link_info *link_info ATTRIBUTE_UNUSED, -+ Elf_Internal_Rela *rel, -+ bfd_vma symval, -+ bfd_boolean *again ATTRIBUTE_UNUSED) -+{ -+ bfd_vma alignment = 1; -+ while (alignment <= rel->r_addend) -+ alignment *= 2; -+ -+ symval -= rel->r_addend; -+ bfd_vma aligned_addr = ((symval - 1) & ~(alignment - 1)) + alignment; -+ bfd_vma nop_bytes_needed = aligned_addr - symval; -+ -+ /* Make sure there are enough NOPs to actually achieve the alignment. */ -+ if (rel->r_addend < nop_bytes_needed) -+ return FALSE; -+ -+ /* Delete the reloc. */ -+ rel->r_info = ELFNN_R_INFO (0, R_RISCV_NONE); -+ -+ /* If the number of NOPs is already correct, there's nothing to do. */ -+ if (nop_bytes_needed == rel->r_addend) -+ return TRUE; -+ -+ /* Delete the excess NOPs. */ -+ return riscv_relax_delete_bytes (abfd, sec, rel->r_offset, -+ rel->r_addend - nop_bytes_needed); -+} -+ -+/* Relax a section. Pass 0 shortens code sequences unless disabled. -+ Pass 1, which cannot be disabled, handles code alignment directives. */ -+ -+static bfd_boolean -+_bfd_riscv_relax_section (bfd *abfd, asection *sec, -+ struct bfd_link_info *info, bfd_boolean *again) -+{ -+ Elf_Internal_Shdr *symtab_hdr = &elf_symtab_hdr (abfd); -+ struct riscv_elf_link_hash_table *htab = riscv_elf_hash_table (info); -+ struct bfd_elf_section_data *data = elf_section_data (sec); -+ Elf_Internal_Rela *relocs; -+ bfd_boolean ret = FALSE; -+ unsigned int i; -+ -+ *again = FALSE; -+ -+ if (info->relocatable -+ || (sec->flags & SEC_RELOC) == 0 -+ || sec->reloc_count == 0 -+ || (/*info->disable_target_specific_optimizations*/ 0 -+ && info->relax_pass == 0)) -+ return TRUE; -+ -+ /* Read this BFD's relocs if we haven't done so already. */ -+ if (data->relocs) -+ relocs = data->relocs; -+ else if (!(relocs = _bfd_elf_link_read_relocs (abfd, sec, NULL, NULL, -+ info->keep_memory))) -+ goto fail; -+ -+ /* Examine and consider relaxing each reloc. */ -+ for (i = 0; i < sec->reloc_count; i++) -+ { -+ Elf_Internal_Rela *rel = data->relocs + i; -+ typeof(&_bfd_riscv_relax_call) relax_func = NULL; -+ int type = ELFNN_R_TYPE (rel->r_info); -+ bfd_vma symval; -+ -+ if (info->relax_pass == 0) -+ { -+ if (type == R_RISCV_CALL || type == R_RISCV_CALL_PLT) -+ relax_func = _bfd_riscv_relax_call; -+ else if (type == R_RISCV_HI20) -+ relax_func = _bfd_riscv_relax_lui; -+ else if (type == R_RISCV_TPREL_HI20 || type == R_RISCV_TPREL_ADD) -+ relax_func = _bfd_riscv_relax_tls_le; -+ } -+ else if (type == R_RISCV_ALIGN) -+ relax_func = _bfd_riscv_relax_align; -+ -+ if (!relax_func) -+ continue; -+ -+ data->relocs = relocs; -+ -+ /* Read this BFD's contents if we haven't done so already. */ -+ if (!data->this_hdr.contents -+ && !bfd_malloc_and_get_section (abfd, sec, &data->this_hdr.contents)) -+ goto fail; -+ -+ /* Read this BFD's symbols if we haven't done so already. */ -+ if (symtab_hdr->sh_info != 0 -+ && !symtab_hdr->contents -+ && !(symtab_hdr->contents = -+ (unsigned char *) bfd_elf_get_elf_syms (abfd, symtab_hdr, -+ symtab_hdr->sh_info, -+ 0, NULL, NULL, NULL))) -+ goto fail; -+ -+ /* Get the value of the symbol referred to by the reloc. */ -+ if (ELFNN_R_SYM (rel->r_info) < symtab_hdr->sh_info) -+ { -+ /* A local symbol. */ -+ Elf_Internal_Sym *isym = ((Elf_Internal_Sym *) symtab_hdr->contents -+ + ELFNN_R_SYM (rel->r_info)); -+ -+ if (isym->st_shndx == SHN_UNDEF) -+ symval = sec_addr (sec) + rel->r_offset; -+ else -+ { -+ asection *isec; -+ BFD_ASSERT (isym->st_shndx < elf_numsections (abfd)); -+ isec = elf_elfsections (abfd)[isym->st_shndx]->bfd_section; -+ if (sec_addr (isec) == 0) -+ continue; -+ symval = sec_addr (isec) + isym->st_value; -+ } -+ } -+ else -+ { -+ unsigned long indx; -+ struct elf_link_hash_entry *h; -+ -+ indx = ELFNN_R_SYM (rel->r_info) - symtab_hdr->sh_info; -+ h = elf_sym_hashes (abfd)[indx]; -+ -+ while (h->root.type == bfd_link_hash_indirect -+ || h->root.type == bfd_link_hash_warning) -+ h = (struct elf_link_hash_entry *) h->root.u.i.link; -+ -+ if (h->plt.offset != MINUS_ONE) -+ symval = sec_addr (htab->elf.splt) + h->plt.offset; -+ else if (h->root.type == bfd_link_hash_undefweak) -+ symval = 0; -+ else if (h->root.u.def.section->output_section == NULL -+ || (h->root.type != bfd_link_hash_defined -+ && h->root.type != bfd_link_hash_defweak)) -+ continue; -+ else -+ symval = sec_addr (h->root.u.def.section) + h->root.u.def.value; -+ } -+ -+ symval += rel->r_addend; -+ -+ if (!relax_func (abfd, sec, info, rel, symval, again)) -+ goto fail; -+ } -+ -+ ret = TRUE; -+ -+fail: -+ if (relocs != data->relocs) -+ free (relocs); -+ -+ return ret; -+} -+ -+#define ELF_ARCH bfd_arch_riscv -+#define ELF_TARGET_ID RISCV_ELF_DATA -+#define ELF_MACHINE_CODE EM_RISCV -+#define ELF_MAXPAGESIZE 0x2000 -+#define ELF_COMMONPAGESIZE 0x2000 -+ -+#define TARGET_LITTLE_SYM bfd_elfNN_riscv_vec -+#define TARGET_LITTLE_NAME "elfNN-littleriscv" -+ -+#define elf_backend_reloc_type_class riscv_reloc_type_class -+ -+#define bfd_elfNN_bfd_reloc_name_lookup riscv_reloc_name_lookup -+#define bfd_elfNN_bfd_link_hash_table_create riscv_elf_link_hash_table_create -+#define bfd_elfNN_bfd_reloc_type_lookup riscv_reloc_type_lookup -+#define bfd_elfNN_bfd_merge_private_bfd_data \ -+ _bfd_riscv_elf_merge_private_bfd_data -+ -+#define elf_backend_copy_indirect_symbol riscv_elf_copy_indirect_symbol -+#define elf_backend_create_dynamic_sections riscv_elf_create_dynamic_sections -+#define elf_backend_check_relocs riscv_elf_check_relocs -+#define elf_backend_adjust_dynamic_symbol riscv_elf_adjust_dynamic_symbol -+#define elf_backend_size_dynamic_sections riscv_elf_size_dynamic_sections -+#define elf_backend_relocate_section riscv_elf_relocate_section -+#define elf_backend_finish_dynamic_symbol riscv_elf_finish_dynamic_symbol -+#define elf_backend_finish_dynamic_sections riscv_elf_finish_dynamic_sections -+#define elf_backend_gc_mark_hook riscv_elf_gc_mark_hook -+#define elf_backend_gc_sweep_hook riscv_elf_gc_sweep_hook -+#define elf_backend_plt_sym_val riscv_elf_plt_sym_val -+#define elf_info_to_howto_rel NULL -+#define elf_info_to_howto riscv_info_to_howto_rela -+#define bfd_elfNN_bfd_relax_section _bfd_riscv_relax_section -+ -+#define elf_backend_init_index_section _bfd_elf_init_1_index_section -+ -+#define elf_backend_can_gc_sections 1 -+#define elf_backend_can_refcount 1 -+#define elf_backend_want_got_plt 1 -+#define elf_backend_plt_readonly 1 -+#define elf_backend_plt_alignment 4 -+#define elf_backend_want_plt_sym 1 -+#define elf_backend_got_header_size (ARCH_SIZE / 8) -+#define elf_backend_rela_normal 1 -+#define elf_backend_default_execstack 0 -+ -+#include "elfNN-target.h" -diff -rNU3 dist.orig/bfd/elfxx-mips.c dist/bfd/elfxx-mips.c ---- dist.orig/bfd/elfxx-mips.c 2013-03-25 09:06:20.000000000 +0100 -+++ dist/bfd/elfxx-mips.c 2015-10-18 13:11:13.000000000 +0200 -@@ -8191,10 +8191,24 @@ - reloc types into the output file as R_MIPS_REL32 - relocs. Make room for this reloc in .rel(a).dyn. */ - mips_elf_allocate_dynamic_relocations (dynobj, info, 1); -- if (MIPS_ELF_READONLY_SECTION (sec)) -- /* We tell the dynamic linker that there are -- relocations against the text segment. */ -- info->flags |= DF_TEXTREL; -+ /* In the N32 and 64-bit ABIs there may be multiple -+ consecutive relocations for the same offset. If we have -+ a R_MIPS_GPREL32 followed by a R_MIPS_64 then that -+ relocation is complete and needs no futher adjustment. */ -+ if ((rel == relocs -+ || rel[-1].r_offset != rel->r_offset -+ || r_type != R_MIPS_64 -+ || ELF_R_TYPE(abfd, rel[-1].r_info) != R_MIPS_GPREL32) -+ && MIPS_ELF_READONLY_SECTION (sec)) -+ { -+ /* We tell the dynamic linker that there are -+ relocations against the text segment. */ -+ info->flags |= DF_TEXTREL; -+ info->callbacks->warning -+ (info, -+ _("relocation emitted against readonly section"), -+ NULL, abfd, sec, rel->r_offset); -+ } - } - else - { -@@ -8612,6 +8626,7 @@ - /* Make sure we know what is going on here. */ - BFD_ASSERT (dynobj != NULL - && (h->needs_plt -+ || h->type == STT_GNU_IFUNC - || h->u.weakdef != NULL - || (h->def_dynamic - && h->ref_regular -diff -rNU3 dist.orig/bfd/elfxx-riscv.c dist/bfd/elfxx-riscv.c ---- dist.orig/bfd/elfxx-riscv.c 1970-01-01 01:00:00.000000000 +0100 -+++ dist/bfd/elfxx-riscv.c 2015-10-18 13:11:13.000000000 +0200 -@@ -0,0 +1,730 @@ -+/* RISC-V-specific support for ELF. -+ Copyright 2011-2014 Free Software Foundation, Inc. -+ -+ Contributed by Andrew Waterman (waterman@cs.berkeley.edu) at UC Berkeley. -+ Based on TILE-Gx and MIPS targets. -+ -+ This file is part of BFD, the Binary File Descriptor library. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, write to the Free Software -+ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, -+ MA 02110-1301, USA. */ -+ -+#include "sysdep.h" -+#include "bfd.h" -+#include "libbfd.h" -+#include "elf-bfd.h" -+#include "elf/riscv.h" -+#include "opcode/riscv.h" -+#include "libiberty.h" -+#include "elfxx-riscv.h" -+#include -+ -+#define MINUS_ONE ((bfd_vma)0 - 1) -+ -+/* The relocation table used for SHT_RELA sections. */ -+ -+static reloc_howto_type howto_table[] = -+{ -+ /* No relocation. */ -+ HOWTO (R_RISCV_NONE, /* type */ -+ 0, /* rightshift */ -+ 0, /* size (0 = byte, 1 = short, 2 = long) */ -+ 0, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_NONE", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ 0, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ /* 32 bit relocation. */ -+ HOWTO (R_RISCV_32, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 32, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_32", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ 0xffffffff, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ /* 64 bit relocation. */ -+ HOWTO (R_RISCV_64, /* type */ -+ 0, /* rightshift */ -+ 4, /* size (0 = byte, 1 = short, 2 = long) */ -+ 64, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_64", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ MINUS_ONE, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ /* Relocation against a local symbol in a shared object. */ -+ HOWTO (R_RISCV_RELATIVE, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 32, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_RELATIVE", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ 0xffffffff, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ HOWTO (R_RISCV_COPY, /* type */ -+ 0, /* rightshift */ -+ 0, /* this one is variable size */ -+ 0, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_bitfield, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_COPY", /* name */ -+ FALSE, /* partial_inplace */ -+ 0x0, /* src_mask */ -+ 0x0, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ HOWTO (R_RISCV_JUMP_SLOT, /* type */ -+ 0, /* rightshift */ -+ 4, /* size (0 = byte, 1 = short, 2 = long) */ -+ 64, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_bitfield, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_JUMP_SLOT", /* name */ -+ FALSE, /* partial_inplace */ -+ 0x0, /* src_mask */ -+ 0x0, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ /* Dynamic TLS relocations. */ -+ HOWTO (R_RISCV_TLS_DTPMOD32, /* type */ -+ 0, /* rightshift */ -+ 4, /* size (0 = byte, 1 = short, 2 = long) */ -+ 32, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_TLS_DTPMOD32", /* name */ -+ FALSE, /* partial_inplace */ -+ MINUS_ONE, /* src_mask */ -+ MINUS_ONE, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ HOWTO (R_RISCV_TLS_DTPMOD64, /* type */ -+ 0, /* rightshift */ -+ 4, /* size (0 = byte, 1 = short, 2 = long) */ -+ 64, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_TLS_DTPMOD64", /* name */ -+ FALSE, /* partial_inplace */ -+ MINUS_ONE, /* src_mask */ -+ MINUS_ONE, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ HOWTO (R_RISCV_TLS_DTPREL32, /* type */ -+ 0, /* rightshift */ -+ 4, /* size (0 = byte, 1 = short, 2 = long) */ -+ 32, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_TLS_DTPREL32", /* name */ -+ TRUE, /* partial_inplace */ -+ MINUS_ONE, /* src_mask */ -+ MINUS_ONE, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ HOWTO (R_RISCV_TLS_DTPREL64, /* type */ -+ 0, /* rightshift */ -+ 4, /* size (0 = byte, 1 = short, 2 = long) */ -+ 64, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_TLS_DTPREL64", /* name */ -+ TRUE, /* partial_inplace */ -+ MINUS_ONE, /* src_mask */ -+ MINUS_ONE, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ HOWTO (R_RISCV_TLS_TPREL32, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 32, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_TLS_TPREL32", /* name */ -+ FALSE, /* partial_inplace */ -+ MINUS_ONE, /* src_mask */ -+ MINUS_ONE, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ HOWTO (R_RISCV_TLS_TPREL64, /* type */ -+ 0, /* rightshift */ -+ 4, /* size (0 = byte, 1 = short, 2 = long) */ -+ 64, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_TLS_TPREL64", /* name */ -+ FALSE, /* partial_inplace */ -+ MINUS_ONE, /* src_mask */ -+ MINUS_ONE, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ EMPTY_HOWTO (12), -+ EMPTY_HOWTO (13), -+ EMPTY_HOWTO (14), -+ EMPTY_HOWTO (15), -+ -+ /* 12-bit PC-relative branch offset. */ -+ HOWTO (R_RISCV_BRANCH, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 32, /* bitsize */ -+ TRUE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_signed, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_BRANCH", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ ENCODE_SBTYPE_IMM(-1U),/* dst_mask */ -+ TRUE), /* pcrel_offset */ -+ -+ /* 20-bit PC-relative jump offset. */ -+ HOWTO (R_RISCV_JAL, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 32, /* bitsize */ -+ TRUE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ /* This needs complex overflow -+ detection, because the upper 36 -+ bits must match the PC + 4. */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_JAL", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ ENCODE_UJTYPE_IMM(-1U), /* dst_mask */ -+ TRUE), /* pcrel_offset */ -+ -+ /* 32-bit PC-relative function call (AUIPC/JALR). */ -+ HOWTO (R_RISCV_CALL, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 64, /* bitsize */ -+ TRUE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_CALL", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ ENCODE_UTYPE_IMM(-1U) | ((bfd_vma) ENCODE_ITYPE_IMM(-1U) << 32), /* dst_mask */ -+ TRUE), /* pcrel_offset */ -+ -+ /* 32-bit PC-relative function call (AUIPC/JALR). */ -+ HOWTO (R_RISCV_CALL_PLT, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 64, /* bitsize */ -+ TRUE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_CALL_PLT", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ ENCODE_UTYPE_IMM(-1U) | ((bfd_vma) ENCODE_ITYPE_IMM(-1U) << 32), /* dst_mask */ -+ TRUE), /* pcrel_offset */ -+ -+ /* High 20 bits of 32-bit PC-relative GOT access. */ -+ HOWTO (R_RISCV_GOT_HI20, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 32, /* bitsize */ -+ TRUE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_GOT_HI20", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ ENCODE_UTYPE_IMM(-1U), /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ /* High 20 bits of 32-bit PC-relative TLS IE GOT access. */ -+ HOWTO (R_RISCV_TLS_GOT_HI20, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 32, /* bitsize */ -+ TRUE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_TLS_GOT_HI20", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ ENCODE_UTYPE_IMM(-1U), /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ /* High 20 bits of 32-bit PC-relative TLS GD GOT reference. */ -+ HOWTO (R_RISCV_TLS_GD_HI20, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 32, /* bitsize */ -+ TRUE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_TLS_GD_HI20", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ ENCODE_UTYPE_IMM(-1U), /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ /* High 20 bits of 32-bit PC-relative reference. */ -+ HOWTO (R_RISCV_PCREL_HI20, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 32, /* bitsize */ -+ TRUE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_PCREL_HI20", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ ENCODE_UTYPE_IMM(-1U), /* dst_mask */ -+ TRUE), /* pcrel_offset */ -+ -+ /* Low 12 bits of a 32-bit PC-relative load or add. */ -+ HOWTO (R_RISCV_PCREL_LO12_I, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 32, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_PCREL_LO12_I",/* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ ENCODE_ITYPE_IMM(-1U), /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ /* Low 12 bits of a 32-bit PC-relative store. */ -+ HOWTO (R_RISCV_PCREL_LO12_S, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 32, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_PCREL_LO12_S",/* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ ENCODE_STYPE_IMM(-1U), /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ /* High 20 bits of 32-bit absolute address. */ -+ HOWTO (R_RISCV_HI20, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 32, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_HI20", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ ENCODE_UTYPE_IMM(-1U), /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ /* High 12 bits of 32-bit load or add. */ -+ HOWTO (R_RISCV_LO12_I, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 32, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_LO12_I", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ ENCODE_ITYPE_IMM(-1U), /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ /* High 12 bits of 32-bit store. */ -+ HOWTO (R_RISCV_LO12_S, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 32, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_LO12_S", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ ENCODE_STYPE_IMM(-1U), /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ /* High 20 bits of TLS LE thread pointer offset. */ -+ HOWTO (R_RISCV_TPREL_HI20, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 32, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_signed, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_TPREL_HI20", /* name */ -+ TRUE, /* partial_inplace */ -+ 0, /* src_mask */ -+ ENCODE_UTYPE_IMM(-1U), /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ /* Low 12 bits of TLS LE thread pointer offset for loads and adds. */ -+ HOWTO (R_RISCV_TPREL_LO12_I, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 32, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_signed, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_TPREL_LO12_I",/* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ ENCODE_ITYPE_IMM(-1U), /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ /* Low 12 bits of TLS LE thread pointer offset for stores. */ -+ HOWTO (R_RISCV_TPREL_LO12_S, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 32, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_signed, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_TPREL_LO12_S",/* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ ENCODE_STYPE_IMM(-1U), /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ /* TLS LE thread pointer usage. */ -+ HOWTO (R_RISCV_TPREL_ADD, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 32, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont,/* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_TPREL_ADD", /* name */ -+ TRUE, /* partial_inplace */ -+ 0, /* src_mask */ -+ 0, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ /* 8-bit in-place addition, for local label subtraction. */ -+ HOWTO (R_RISCV_ADD8, /* type */ -+ 0, /* rightshift */ -+ 0, /* size (0 = byte, 1 = short, 2 = long) */ -+ 32, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_ADD8", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ MINUS_ONE, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ /* 16-bit in-place addition, for local label subtraction. */ -+ HOWTO (R_RISCV_ADD16, /* type */ -+ 0, /* rightshift */ -+ 1, /* size (0 = byte, 1 = short, 2 = long) */ -+ 16, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_ADD16", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ MINUS_ONE, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ /* 32-bit in-place addition, for local label subtraction. */ -+ HOWTO (R_RISCV_ADD32, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 32, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_ADD32", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ MINUS_ONE, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ /* 64-bit in-place addition, for local label subtraction. */ -+ HOWTO (R_RISCV_ADD64, /* type */ -+ 0, /* rightshift */ -+ 4, /* size (0 = byte, 1 = short, 2 = long) */ -+ 64, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_ADD64", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ MINUS_ONE, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ /* 8-bit in-place addition, for local label subtraction. */ -+ HOWTO (R_RISCV_SUB8, /* type */ -+ 0, /* rightshift */ -+ 0, /* size (0 = byte, 1 = short, 2 = long) */ -+ 8, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_SUB8", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ MINUS_ONE, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ /* 16-bit in-place addition, for local label subtraction. */ -+ HOWTO (R_RISCV_SUB16, /* type */ -+ 0, /* rightshift */ -+ 1, /* size (0 = byte, 1 = short, 2 = long) */ -+ 16, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_SUB16", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ MINUS_ONE, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ /* 32-bit in-place addition, for local label subtraction. */ -+ HOWTO (R_RISCV_SUB32, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 32, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_SUB32", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ MINUS_ONE, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ /* 64-bit in-place addition, for local label subtraction. */ -+ HOWTO (R_RISCV_SUB64, /* type */ -+ 0, /* rightshift */ -+ 4, /* size (0 = byte, 1 = short, 2 = long) */ -+ 64, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_SUB64", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ MINUS_ONE, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ /* GNU extension to record C++ vtable hierarchy */ -+ HOWTO (R_RISCV_GNU_VTINHERIT, /* type */ -+ 0, /* rightshift */ -+ 4, /* size (0 = byte, 1 = short, 2 = long) */ -+ 0, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont,/* complain_on_overflow */ -+ NULL, /* special_function */ -+ "R_RISCV_GNU_VTINHERIT", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ 0, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ /* GNU extension to record C++ vtable member usage */ -+ HOWTO (R_RISCV_GNU_VTENTRY, /* type */ -+ 0, /* rightshift */ -+ 4, /* size (0 = byte, 1 = short, 2 = long) */ -+ 0, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont,/* complain_on_overflow */ -+ _bfd_elf_rel_vtable_reloc_fn, /* special_function */ -+ "R_RISCV_GNU_VTENTRY", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ 0, /* dst_mask */ -+ FALSE), /* pcrel_offset */ -+ -+ /* Indicates an alignment statement. The addend field encodes how many -+ bytes of NOPs follow the statement. The desired alignment is the -+ addend rounded up to the next power of two. */ -+ HOWTO (R_RISCV_ALIGN, /* type */ -+ 0, /* rightshift */ -+ 2, /* size (0 = byte, 1 = short, 2 = long) */ -+ 0, /* bitsize */ -+ FALSE, /* pc_relative */ -+ 0, /* bitpos */ -+ complain_overflow_dont, /* complain_on_overflow */ -+ bfd_elf_generic_reloc, /* special_function */ -+ "R_RISCV_ALIGN", /* name */ -+ FALSE, /* partial_inplace */ -+ 0, /* src_mask */ -+ 0, /* dst_mask */ -+ TRUE), /* pcrel_offset */ -+}; -+ -+/* A mapping from BFD reloc types to RISC-V ELF reloc types. */ -+ -+struct elf_reloc_map { -+ bfd_reloc_code_real_type bfd_val; -+ enum elf_riscv_reloc_type elf_val; -+}; -+ -+static const struct elf_reloc_map riscv_reloc_map[] = -+{ -+ { BFD_RELOC_NONE, R_RISCV_NONE }, -+ { BFD_RELOC_32, R_RISCV_32 }, -+ { BFD_RELOC_64, R_RISCV_64 }, -+ { BFD_RELOC_RISCV_ADD8, R_RISCV_ADD8 }, -+ { BFD_RELOC_RISCV_ADD16, R_RISCV_ADD16 }, -+ { BFD_RELOC_RISCV_ADD32, R_RISCV_ADD32 }, -+ { BFD_RELOC_RISCV_ADD64, R_RISCV_ADD64 }, -+ { BFD_RELOC_RISCV_SUB8, R_RISCV_SUB8 }, -+ { BFD_RELOC_RISCV_SUB16, R_RISCV_SUB16 }, -+ { BFD_RELOC_RISCV_SUB32, R_RISCV_SUB32 }, -+ { BFD_RELOC_RISCV_SUB64, R_RISCV_SUB64 }, -+ { BFD_RELOC_CTOR, R_RISCV_64 }, -+ { BFD_RELOC_12_PCREL, R_RISCV_BRANCH }, -+ { BFD_RELOC_RISCV_HI20, R_RISCV_HI20 }, -+ { BFD_RELOC_RISCV_LO12_I, R_RISCV_LO12_I }, -+ { BFD_RELOC_RISCV_LO12_S, R_RISCV_LO12_S }, -+ { BFD_RELOC_RISCV_PCREL_LO12_I, R_RISCV_PCREL_LO12_I }, -+ { BFD_RELOC_RISCV_PCREL_LO12_S, R_RISCV_PCREL_LO12_S }, -+ { BFD_RELOC_RISCV_CALL, R_RISCV_CALL }, -+ { BFD_RELOC_RISCV_CALL_PLT, R_RISCV_CALL_PLT }, -+ { BFD_RELOC_RISCV_PCREL_HI20, R_RISCV_PCREL_HI20 }, -+ { BFD_RELOC_RISCV_JMP, R_RISCV_JAL }, -+ { BFD_RELOC_RISCV_GOT_HI20, R_RISCV_GOT_HI20 }, -+ { BFD_RELOC_RISCV_TLS_DTPMOD32, R_RISCV_TLS_DTPMOD32 }, -+ { BFD_RELOC_RISCV_TLS_DTPREL32, R_RISCV_TLS_DTPREL32 }, -+ { BFD_RELOC_RISCV_TLS_DTPMOD64, R_RISCV_TLS_DTPMOD64 }, -+ { BFD_RELOC_RISCV_TLS_DTPREL64, R_RISCV_TLS_DTPREL64 }, -+ { BFD_RELOC_RISCV_TLS_TPREL32, R_RISCV_TLS_TPREL32 }, -+ { BFD_RELOC_RISCV_TLS_TPREL64, R_RISCV_TLS_TPREL64 }, -+ { BFD_RELOC_RISCV_TPREL_HI20, R_RISCV_TPREL_HI20 }, -+ { BFD_RELOC_RISCV_TPREL_ADD, R_RISCV_TPREL_ADD }, -+ { BFD_RELOC_RISCV_TPREL_LO12_S, R_RISCV_TPREL_LO12_S }, -+ { BFD_RELOC_RISCV_TPREL_LO12_I, R_RISCV_TPREL_LO12_I }, -+ { BFD_RELOC_RISCV_TLS_GOT_HI20, R_RISCV_TLS_GOT_HI20 }, -+ { BFD_RELOC_RISCV_TLS_GD_HI20, R_RISCV_TLS_GD_HI20 }, -+ { BFD_RELOC_RISCV_ALIGN, R_RISCV_ALIGN }, -+}; -+ -+/* Given a BFD reloc type, return a howto structure. */ -+ -+reloc_howto_type * -+riscv_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, -+ bfd_reloc_code_real_type code) -+{ -+ unsigned int i; -+ -+ for (i = 0; i < ARRAY_SIZE (riscv_reloc_map); i++) -+ if (riscv_reloc_map[i].bfd_val == code) -+ return &howto_table[(int) riscv_reloc_map[i].elf_val]; -+ -+ bfd_set_error (bfd_error_bad_value); -+ return NULL; -+} -+ -+reloc_howto_type * -+riscv_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, -+ const char *r_name) -+{ -+ unsigned int i; -+ -+ for (i = 0; i < ARRAY_SIZE (howto_table); i++) -+ if (howto_table[i].name && strcasecmp (howto_table[i].name, r_name) == 0) -+ return &howto_table[i]; -+ -+ return NULL; -+} -+ -+reloc_howto_type * -+riscv_elf_rtype_to_howto (unsigned int r_type) -+{ -+ if ((unsigned int)r_type >= ARRAY_SIZE (howto_table)) -+ { -+ (*_bfd_error_handler)(_("unrecognized relocation (0x%x)"), r_type); -+ bfd_set_error (bfd_error_bad_value); -+ return NULL; -+ } -+ return &howto_table[r_type]; -+} -diff -rNU3 dist.orig/bfd/elfxx-riscv.h dist/bfd/elfxx-riscv.h ---- dist.orig/bfd/elfxx-riscv.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/bfd/elfxx-riscv.h 2015-10-18 13:11:13.000000000 +0200 -@@ -0,0 +1,34 @@ -+/* RISC-V ELF specific backend routines. -+ Copyright 2011-2014 Free Software Foundation, Inc. -+ -+ Contributed by Andrew Waterman (waterman@cs.berkeley.edu) at UC Berkeley. -+ Based on MIPS target. -+ -+ This file is part of BFD, the Binary File Descriptor library. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, write to the Free Software -+ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, -+ MA 02110-1301, USA. */ -+ -+#include "elf/common.h" -+#include "elf/internal.h" -+ -+extern reloc_howto_type * -+riscv_reloc_name_lookup (bfd *, const char *); -+ -+extern reloc_howto_type * -+riscv_reloc_type_lookup (bfd *, bfd_reloc_code_real_type); -+ -+extern reloc_howto_type * -+riscv_elf_rtype_to_howto (unsigned int r_type); -diff -rNU3 dist.orig/bfd/elfxx-sparc.c dist/bfd/elfxx-sparc.c ---- dist.orig/bfd/elfxx-sparc.c 2013-03-25 09:06:20.000000000 +0100 -+++ dist/bfd/elfxx-sparc.c 2015-10-18 13:11:13.000000000 +0200 -@@ -2508,6 +2508,10 @@ - { - struct bfd_link_info *info = (struct bfd_link_info *) inf; - -+ if (info->warn_shared_textrel) -+ (*_bfd_error_handler) -+ (_("warning: dynamic relocation in readonly section `%s'"), -+ h->root.root.string); - info->flags |= DF_TEXTREL; - - /* Not an error, just cut short the traversal. */ -@@ -3460,10 +3464,8 @@ - memset (&outrel, 0, sizeof outrel); - /* h->dynindx may be -1 if the symbol was marked to - become local. */ -- else if (h != NULL && -- h->dynindx != -1 -- && (! is_plt -- || !info->shared -+ else if (h != NULL && h->dynindx != -1 && ! is_plt -+ && (!info->shared - || !SYMBOLIC_BIND (info, h) - || !h->def_regular)) - { -diff -rNU3 dist.orig/bfd/libbfd.h dist/bfd/libbfd.h ---- dist.orig/bfd/libbfd.h 2012-09-04 14:53:42.000000000 +0200 -+++ dist/bfd/libbfd.h 2015-10-18 13:11:13.000000000 +0200 -@@ -2295,8 +2295,65 @@ - "BFD_RELOC_860_HIGH", - "BFD_RELOC_860_HIGOT", - "BFD_RELOC_860_HIGOTOFF", -- "BFD_RELOC_OPENRISC_ABS_26", -- "BFD_RELOC_OPENRISC_REL_26", -+ "BFD_RELOC_OR1K_REL_26", -+ "BFD_RELOC_OR1K_GOTPC_HI16", -+ "BFD_RELOC_OR1K_GOTPC_LO16", -+ "BFD_RELOC_OR1K_GOT16", -+ "BFD_RELOC_OR1K_PLT26", -+ "BFD_RELOC_OR1K_GOTOFF_HI16", -+ "BFD_RELOC_OR1K_GOTOFF_LO16", -+ "BFD_RELOC_OR1K_COPY", -+ "BFD_RELOC_OR1K_GLOB_DAT", -+ "BFD_RELOC_OR1K_JMP_SLOT", -+ "BFD_RELOC_OR1K_RELATIVE", -+ "BFD_RELOC_OR1K_TLS_GD_HI16", -+ "BFD_RELOC_OR1K_TLS_GD_LO16", -+ "BFD_RELOC_OR1K_TLS_LDM_HI16", -+ "BFD_RELOC_OR1K_TLS_LDM_LO16", -+ "BFD_RELOC_OR1K_TLS_LDO_HI16", -+ "BFD_RELOC_OR1K_TLS_LDO_LO16", -+ "BFD_RELOC_OR1K_TLS_IE_HI16", -+ "BFD_RELOC_OR1K_TLS_IE_LO16", -+ "BFD_RELOC_OR1K_TLS_LE_HI16", -+ "BFD_RELOC_OR1K_TLS_LE_LO16", -+ "BFD_RELOC_OR1K_TLS_TPOFF", -+ "BFD_RELOC_OR1K_TLS_DTPOFF", -+ "BFD_RELOC_OR1K_TLS_DTPMOD", -+ "BFD_RELOC_RISCV_ADD32", -+ "BFD_RELOC_RISCV_ADD64", -+ "BFD_RELOC_RISCV_SUB32", -+ "BFD_RELOC_RISCV_SUB64", -+ "BFD_RELOC_RISCV_HI20", -+ "BFD_RELOC_RISCV_LO12_I", -+ "BFD_RELOC_RISCV_LO12_S", -+ "BFD_RELOC_RISCV_PCREL_LO12_I", -+ "BFD_RELOC_RISCV_PCREL_LO12_S", -+ "BFD_RELOC_RISCV_CALL", -+ "BFD_RELOC_RISCV_CALL_PLT", -+ "BFD_RELOC_RISCV_PCREL_HI20", -+ "BFD_RELOC_RISCV_JMP", -+ "BFD_RELOC_RISCV_GOT_HI20", -+ "BFD_RELOC_RISCV_GOT_LO12", -+ "BFD_RELOC_RISCV_TLS_DTPMOD32", -+ "BFD_RELOC_RISCV_TLS_DTPREL32", -+ "BFD_RELOC_RISCV_TLS_DTPMOD64", -+ "BFD_RELOC_RISCV_TLS_DTPREL64", -+ "BFD_RELOC_RISCV_TLS_TPREL32", -+ "BFD_RELOC_RISCV_TLS_TPREL64", -+ "BFD_RELOC_RISCV_TPREL_HI20", -+ "BFD_RELOC_RISCV_TPREL_ADD", -+ "BFD_RELOC_RISCV_TPREL_LO12_S", -+ "BFD_RELOC_RISCV_TPREL_LO12_I", -+ "BFD_RELOC_RISCV_TLS_IE_HI20", -+ "BFD_RELOC_RISCV_TLS_IE_LO12", -+ "BFD_RELOC_RISCV_TLS_IE_ADD", -+ "BFD_RELOC_RISCV_TLS_IE_LO12_S", -+ "BFD_RELOC_RISCV_TLS_IE_LO12_I", -+ "BFD_RELOC_RISCV_TLS_GOT_HI20", -+ "BFD_RELOC_RISCV_TLS_GOT_LO12", -+ "BFD_RELOC_RISCV_TLS_GD_HI20", -+ "BFD_RELOC_RISCV_TLS_GD_LO12", -+ "BFD_RELOC_RISCV_TLS_PCREL_LO12", - "BFD_RELOC_H8_DIR16A8", - "BFD_RELOC_H8_DIR16R8", - "BFD_RELOC_H8_DIR24A8", -@@ -2313,6 +2370,7 @@ - "BFD_RELOC_XC16X_SEG", - "BFD_RELOC_XC16X_SOF", - "BFD_RELOC_VAX_GLOB_DAT", -+ "BFD_RELOC_VAX_GLOB_REF", - "BFD_RELOC_VAX_JMP_SLOT", - "BFD_RELOC_VAX_RELATIVE", - "BFD_RELOC_MT_PC16", -diff -rNU3 dist.orig/bfd/reloc.c dist/bfd/reloc.c ---- dist.orig/bfd/reloc.c 2012-09-04 14:53:42.000000000 +0200 -+++ dist/bfd/reloc.c 2015-10-18 13:11:13.000000000 +0200 -@@ -1776,6 +1776,17 @@ - Relocations used by 68K ELF. - - ENUM -+ BFD_RELOC_VAX_GLOB_DAT -+ENUMX -+ BFD_RELOC_VAX_GLOB_REF -+ENUMX -+ BFD_RELOC_VAX_JMP_SLOT -+ENUMX -+ BFD_RELOC_VAX_RELATIVE -+ENUMDOC -+ Relocations used by VAX ELF. -+ -+ENUM - BFD_RELOC_32_BASEREL - ENUMX - BFD_RELOC_16_BASEREL -diff -rNU3 dist.orig/bfd/targets.c dist/bfd/targets.c ---- dist.orig/bfd/targets.c 2012-09-04 14:53:42.000000000 +0200 -+++ dist/bfd/targets.c 2015-10-18 13:11:13.000000000 +0200 -@@ -670,13 +670,14 @@ - extern const bfd_target bfd_elf32_ntradbigmips_freebsd_vec; - extern const bfd_target bfd_elf32_ntradlittlemips_freebsd_vec; - extern const bfd_target bfd_elf32_openrisc_vec; --extern const bfd_target bfd_elf32_or32_big_vec; -+extern const bfd_target bfd_elf32_or1k_big_vec; - extern const bfd_target bfd_elf32_pj_vec; - extern const bfd_target bfd_elf32_pjl_vec; - extern const bfd_target bfd_elf32_powerpc_vec; - extern const bfd_target bfd_elf32_powerpcle_vec; - extern const bfd_target bfd_elf32_powerpc_freebsd_vec; - extern const bfd_target bfd_elf32_powerpc_vxworks_vec; -+extern const bfd_target bfd_elf32_riscv_vec; - extern const bfd_target bfd_elf32_rl78_vec; - extern const bfd_target bfd_elf32_rx_le_vec; - extern const bfd_target bfd_elf32_rx_be_vec; -@@ -729,8 +730,8 @@ - extern const bfd_target bfd_elf64_alpha_freebsd_vec; - extern const bfd_target bfd_elf64_alpha_vec; - extern const bfd_target bfd_elf64_big_generic_vec; --extern const bfd_target bfd_elf64_bigmips_vec; - extern const bfd_target bfd_elf64_bigaarch64_vec; -+extern const bfd_target bfd_elf64_bigmips_vec; - extern const bfd_target bfd_elf64_hppa_linux_vec; - extern const bfd_target bfd_elf64_hppa_vec; - extern const bfd_target bfd_elf64_ia64_big_vec; -@@ -738,12 +739,13 @@ - extern const bfd_target bfd_elf64_ia64_little_vec; - extern const bfd_target bfd_elf64_ia64_vms_vec; - extern const bfd_target bfd_elf64_little_generic_vec; --extern const bfd_target bfd_elf64_littlemips_vec; - extern const bfd_target bfd_elf64_littleaarch64_vec; -+extern const bfd_target bfd_elf64_littlemips_vec; - extern const bfd_target bfd_elf64_mmix_vec; - extern const bfd_target bfd_elf64_powerpc_vec; - extern const bfd_target bfd_elf64_powerpcle_vec; - extern const bfd_target bfd_elf64_powerpc_freebsd_vec; -+extern const bfd_target bfd_elf64_riscv_vec; - extern const bfd_target bfd_elf64_s390_vec; - extern const bfd_target bfd_elf64_sh64_vec; - extern const bfd_target bfd_elf64_sh64l_vec; -@@ -833,7 +835,7 @@ - extern const bfd_target nlm32_powerpc_vec; - extern const bfd_target nlm32_sparc_vec; - extern const bfd_target oasys_vec; --extern const bfd_target or32coff_big_vec; -+extern const bfd_target or1kcoff_big_vec; - extern const bfd_target pc532machaout_vec; - extern const bfd_target pc532netbsd_vec; - extern const bfd_target pdp11_aout_vec; -@@ -1046,13 +1048,14 @@ - &bfd_elf32_ntradlittlemips_freebsd_vec, - #endif - &bfd_elf32_openrisc_vec, -- &bfd_elf32_or32_big_vec, -+ &bfd_elf32_or1k_big_vec, - &bfd_elf32_pj_vec, - &bfd_elf32_pjl_vec, - &bfd_elf32_powerpc_vec, - &bfd_elf32_powerpc_vxworks_vec, - &bfd_elf32_powerpcle_vec, - &bfd_elf32_powerpc_freebsd_vec, -+ &bfd_elf32_riscv_vec, - &bfd_elf32_rl78_vec, - &bfd_elf32_rx_be_vec, - &bfd_elf32_rx_be_ns_vec, -@@ -1106,8 +1109,8 @@ - &bfd_elf64_alpha_freebsd_vec, - &bfd_elf64_alpha_vec, - &bfd_elf64_big_generic_vec, -- &bfd_elf64_bigmips_vec, - &bfd_elf64_bigaarch64_vec, -+ &bfd_elf64_bigmips_vec, - &bfd_elf64_hppa_linux_vec, - &bfd_elf64_hppa_vec, - &bfd_elf64_ia64_big_vec, -@@ -1115,12 +1118,13 @@ - &bfd_elf64_ia64_little_vec, - &bfd_elf64_ia64_vms_vec, - &bfd_elf64_little_generic_vec, -- &bfd_elf64_littlemips_vec, - &bfd_elf64_littleaarch64_vec, -+ &bfd_elf64_littlemips_vec, - &bfd_elf64_mmix_vec, - &bfd_elf64_powerpc_vec, - &bfd_elf64_powerpcle_vec, - &bfd_elf64_powerpc_freebsd_vec, -+ &bfd_elf64_riscv_vec, - &bfd_elf64_s390_vec, - &bfd_elf64_sh64_vec, - &bfd_elf64_sh64l_vec, -@@ -1252,7 +1256,7 @@ - &oasys_vec, - #endif - /* Entry for the OpenRISC family. */ -- &or32coff_big_vec, -+ &or1kcoff_big_vec, - - &pc532machaout_vec, - &pc532netbsd_vec, -diff -rNU3 dist.orig/binutils/Makefile.in dist/binutils/Makefile.in ---- dist.orig/binutils/Makefile.in 2012-05-18 00:23:39.000000000 +0200 -+++ dist/binutils/Makefile.in 2015-10-18 13:11:13.000000000 +0200 -@@ -1,4 +1,4 @@ --# Makefile.in generated by automake 1.11.1 from Makefile.am. -+# Makefile.in generated by automake 1.11 from Makefile.am. - # @configure_input@ - - # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -@@ -49,10 +49,12 @@ - DIST_COMMON = NEWS README ChangeLog $(srcdir)/Makefile.in \ - $(srcdir)/Makefile.am $(top_srcdir)/configure \ - $(am__configure_deps) $(srcdir)/config.in \ -- $(srcdir)/../mkinstalldirs $(top_srcdir)/po/Make-in arparse.h \ -- arparse.c arlex.c defparse.h defparse.c deflex.c nlmheader.h \ -- nlmheader.c arparse.h arparse.c arlex.c mcparse.h mcparse.c \ -- rcparse.h rcparse.c $(srcdir)/../depcomp $(srcdir)/../ylwrap -+ $(srcdir)/../mkinstalldirs $(srcdir)/../mkinstalldirs \ -+ $(top_srcdir)/po/Make-in arparse.h arparse.c arlex.c \ -+ defparse.h defparse.c deflex.c nlmheader.h nlmheader.c \ -+ arparse.h arparse.c arlex.c mcparse.h mcparse.c rcparse.h \ -+ rcparse.c $(srcdir)/../depcomp $(srcdir)/../depcomp \ -+ $(srcdir)/../ylwrap $(srcdir)/../ylwrap - ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 - am__aclocal_m4_deps = $(top_srcdir)/../bfd/acinclude.m4 \ - $(top_srcdir)/../config/zlib.m4 \ -@@ -385,6 +387,7 @@ - libexecdir = @libexecdir@ - localedir = @localedir@ - localstatedir = @localstatedir@ -+lt_ECHO = @lt_ECHO@ - mandir = @mandir@ - mkdir_p = @mkdir_p@ - oldincludedir = @oldincludedir@ -@@ -931,7 +934,7 @@ - # (which will cause the Makefiles to be regenerated when you run `make'); - # (2) otherwise, pass the desired values on the `make' command line. - $(RECURSIVE_TARGETS): -- @fail= failcom='exit 1'; \ -+ @failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ -@@ -956,7 +959,7 @@ - fi; test -z "$$fail" - - $(RECURSIVE_CLEAN_TARGETS): -- @fail= failcom='exit 1'; \ -+ @failcom='exit 1'; \ - for f in x $$MAKEFLAGS; do \ - case $$f in \ - *=* | --[!k]*);; \ -diff -rNU3 dist.orig/binutils/aclocal.m4 dist/binutils/aclocal.m4 ---- dist.orig/binutils/aclocal.m4 2012-05-18 00:23:39.000000000 +0200 -+++ dist/binutils/aclocal.m4 2015-10-18 13:11:13.000000000 +0200 -@@ -1,4 +1,4 @@ --# generated automatically by aclocal 1.11.1 -*- Autoconf -*- -+# generated automatically by aclocal 1.11 -*- Autoconf -*- - - # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, - # 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. -@@ -19,6 +19,31 @@ - If you have problems, you may need to regenerate the build system entirely. - To do so, use the procedure documented by the package, typically `autoreconf'.])]) - -+# isc-posix.m4 serial 2 (gettext-0.11.2) -+dnl Copyright (C) 1995-2002 Free Software Foundation, Inc. -+dnl This file is free software; the Free Software Foundation -+dnl gives unlimited permission to copy and/or distribute it, -+dnl with or without modifications, as long as this notice is preserved. -+ -+# This file is not needed with autoconf-2.53 and newer. Remove it in 2005. -+ -+# This test replaces the one in autoconf. -+# Currently this macro should have the same name as the autoconf macro -+# because gettext's gettext.m4 (distributed in the automake package) -+# still uses it. Otherwise, the use in gettext.m4 makes autoheader -+# give these diagnostics: -+# configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX -+# configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX -+ -+undefine([AC_ISC_POSIX]) -+ -+AC_DEFUN([AC_ISC_POSIX], -+ [ -+ dnl This test replaces the obsolescent AC_ISC_POSIX kludge. -+ AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"]) -+ ] -+) -+ - # Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. - # - # This file is free software; the Free Software Foundation -@@ -34,7 +59,7 @@ - [am__api_version='1.11' - dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to - dnl require some minimum version. Point them to the right macro. --m4_if([$1], [1.11.1], [], -+m4_if([$1], [1.11], [], - [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl - ]) - -@@ -50,7 +75,7 @@ - # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. - # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. - AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], --[AM_AUTOMAKE_VERSION([1.11.1])dnl -+[AM_AUTOMAKE_VERSION([1.11])dnl - m4_ifndef([AC_AUTOCONF_VERSION], - [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl - _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) -diff -rNU3 dist.orig/binutils/bucomm.c dist/binutils/bucomm.c ---- dist.orig/binutils/bucomm.c 2012-06-29 14:59:49.000000000 +0200 -+++ dist/binutils/bucomm.c 2015-10-18 13:11:13.000000000 +0200 -@@ -580,7 +580,14 @@ - file_name, strerror (errno)); - } - else if (! S_ISREG (statbuf.st_mode)) -- non_fatal (_("Warning: '%s' is not an ordinary file"), file_name); -+ { -+ if (!S_ISCHR(statbuf.st_mode)) -+ { -+ non_fatal (_("Warning: '%s' is not an ordinary file"), file_name); -+ return 0; -+ } -+ return statbuf.st_size ? statbuf.st_size : 1; -+ } - else if (statbuf.st_size < 0) - non_fatal (_("Warning: '%s' has negative size, probably it is too large"), - file_name); -diff -rNU3 dist.orig/binutils/doc/Makefile.am dist/binutils/doc/Makefile.am ---- dist.orig/binutils/doc/Makefile.am 2010-01-06 17:52:14.000000000 +0100 -+++ dist/binutils/doc/Makefile.am 2015-10-18 13:11:13.000000000 +0200 -@@ -42,6 +42,8 @@ - - # Man page generation from texinfo - addr2line.1: $(binutils_TEXI) $(binutils_TEXINFOS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_addr2line.1: - touch $@ - -$(TEXI2POD) $(MANCONF) -Daddr2line < $(binutils_TEXI) > addr2line.pod - -($(POD2MAN) addr2line.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ -@@ -49,6 +51,8 @@ - rm -f addr2line.pod - - ar.1: $(binutils_TEXI) $(binutils_TEXINFOS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_ar.1: - touch $@ - -$(TEXI2POD) $(MANCONF) -Dar < $(binutils_TEXI) > ar.pod - -($(POD2MAN) ar.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ -@@ -56,6 +60,8 @@ - rm -f ar.pod - - dlltool.1: $(binutils_TEXI) $(binutils_TEXINFOS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_dlltool.1: - touch $@ - -$(TEXI2POD) $(MANCONF) -Ddlltool < $(binutils_TEXI) > dlltool.pod - -($(POD2MAN) dlltool.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ -@@ -63,6 +69,8 @@ - rm -f dlltool.pod - - nlmconv.1: $(binutils_TEXI) $(binutils_TEXINFOS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_nlmconv.1: - touch $@ - -$(TEXI2POD) $(MANCONF) -Dnlmconv < $(binutils_TEXI) > nlmconv.pod - -($(POD2MAN) nlmconv.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ -@@ -70,6 +78,8 @@ - rm -f nlmconv.pod - - nm.1: $(binutils_TEXI) $(binutils_TEXINFOS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_nm.1: - touch $@ - -$(TEXI2POD) $(MANCONF) -Dnm < $(binutils_TEXI) > nm.pod - -($(POD2MAN) nm.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ -@@ -77,6 +87,8 @@ - rm -f nm.pod - - objcopy.1: $(binutils_TEXI) $(binutils_TEXINFOS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_objcopy.1: - touch $@ - -$(TEXI2POD) $(MANCONF) -Dobjcopy < $(binutils_TEXI) > objcopy.pod - -($(POD2MAN) objcopy.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ -@@ -84,6 +96,8 @@ - rm -f objcopy.pod - - objdump.1: $(binutils_TEXI) $(binutils_TEXINFOS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_objdump.1: - touch $@ - -$(TEXI2POD) $(MANCONF) -Dobjdump < $(binutils_TEXI) > objdump.pod - -($(POD2MAN) objdump.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ -@@ -91,6 +105,8 @@ - rm -f objdump.pod - - ranlib.1: $(binutils_TEXI) $(binutils_TEXINFOS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_ranlib.1: - touch $@ - -$(TEXI2POD) $(MANCONF) -Dranlib < $(binutils_TEXI) > ranlib.pod - -($(POD2MAN) ranlib.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ -@@ -98,6 +114,8 @@ - rm -f ranlib.pod - - readelf.1: $(binutils_TEXI) $(binutils_TEXINFOS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_readelf.1: - touch $@ - -$(TEXI2POD) $(MANCONF) -Dreadelf < $(binutils_TEXI) > readelf.pod - -($(POD2MAN) readelf.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ -@@ -105,6 +123,8 @@ - rm -f readelf.pod - - size.1: $(binutils_TEXI) $(binutils_TEXINFOS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_size.1: - touch $@ - -$(TEXI2POD) $(MANCONF) -Dsize < $(binutils_TEXI) > size.pod - -($(POD2MAN) size.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ -@@ -112,6 +132,8 @@ - rm -f size.pod - - strings.1: $(binutils_TEXI) $(binutils_TEXINFOS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_strings.1: - touch $@ - -$(TEXI2POD) $(MANCONF) -Dstrings < $(binutils_TEXI) > strings.pod - -($(POD2MAN) strings.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ -@@ -119,6 +141,8 @@ - rm -f strings.pod - - strip.1: $(binutils_TEXI) $(binutils_TEXINFOS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_strip.1: - touch $@ - -$(TEXI2POD) $(MANCONF) -Dstrip < $(binutils_TEXI) > strip.pod - -($(POD2MAN) strip.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ -@@ -133,6 +157,8 @@ - rm -f elfedit.pod - - windres.1: $(binutils_TEXI) $(binutils_TEXINFOS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_windres.1: - touch $@ - -$(TEXI2POD) $(MANCONF) -Dwindres < $(binutils_TEXI) > windres.pod - -($(POD2MAN) windres.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ -@@ -140,6 +166,8 @@ - rm -f windres.pod - - windmc.1: $(binutils_TEXI) $(binutils_TEXINFOS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_windmc.1: - touch $@ - -$(TEXI2POD) $(MANCONF) -Dwindmc < $(binutils_TEXI) > windmc.pod - -($(POD2MAN) windmc.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ -@@ -147,6 +175,8 @@ - rm -f windmc.pod - - cxxfilt.man: $(binutils_TEXI) $(binutils_TEXINFOS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_cxxfilt.man: - touch $@ - -$(TEXI2POD) $(MANCONF) -Dcxxfilt < $(binutils_TEXI) > $(DEMANGLER_NAME).pod - -($(POD2MAN) $(DEMANGLER_NAME).pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ -diff -rNU3 dist.orig/binutils/doc/Makefile.in dist/binutils/doc/Makefile.in ---- dist.orig/binutils/doc/Makefile.in 2012-09-04 14:53:44.000000000 +0200 -+++ dist/binutils/doc/Makefile.in 2015-10-18 13:11:13.000000000 +0200 -@@ -1,4 +1,4 @@ --# Makefile.in generated by automake 1.11.1 from Makefile.am. -+# Makefile.in generated by automake 1.11 from Makefile.am. - # @configure_input@ - - # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, -@@ -242,6 +242,7 @@ - libexecdir = @libexecdir@ - localedir = @localedir@ - localstatedir = @localstatedir@ -+lt_ECHO = @lt_ECHO@ - mandir = @mandir@ - mkdir_p = @mkdir_p@ - oldincludedir = @oldincludedir@ -@@ -349,6 +350,8 @@ - -rm -rf .libs _libs - - binutils.info: binutils.texi -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_binutils.info: binutils.texi - restore=: && backupdir="$(am__leading_dot)am$$$$" && \ - rm -rf $$backupdir && mkdir $$backupdir && \ - if ($(MAKEINFO) --version) >/dev/null 2>&1; then \ -@@ -735,6 +738,8 @@ - - # Man page generation from texinfo - addr2line.1: $(binutils_TEXI) $(binutils_TEXINFOS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_addr2line.1: - touch $@ - -$(TEXI2POD) $(MANCONF) -Daddr2line < $(binutils_TEXI) > addr2line.pod - -($(POD2MAN) addr2line.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ -@@ -742,6 +747,8 @@ - rm -f addr2line.pod - - ar.1: $(binutils_TEXI) $(binutils_TEXINFOS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_ar.1: - touch $@ - -$(TEXI2POD) $(MANCONF) -Dar < $(binutils_TEXI) > ar.pod - -($(POD2MAN) ar.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ -@@ -749,6 +756,8 @@ - rm -f ar.pod - - dlltool.1: $(binutils_TEXI) $(binutils_TEXINFOS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_dlltool.1: - touch $@ - -$(TEXI2POD) $(MANCONF) -Ddlltool < $(binutils_TEXI) > dlltool.pod - -($(POD2MAN) dlltool.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ -@@ -756,6 +765,8 @@ - rm -f dlltool.pod - - nlmconv.1: $(binutils_TEXI) $(binutils_TEXINFOS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_nlmconv.1: - touch $@ - -$(TEXI2POD) $(MANCONF) -Dnlmconv < $(binutils_TEXI) > nlmconv.pod - -($(POD2MAN) nlmconv.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ -@@ -763,6 +774,8 @@ - rm -f nlmconv.pod - - nm.1: $(binutils_TEXI) $(binutils_TEXINFOS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_nm.1: - touch $@ - -$(TEXI2POD) $(MANCONF) -Dnm < $(binutils_TEXI) > nm.pod - -($(POD2MAN) nm.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ -@@ -770,6 +783,8 @@ - rm -f nm.pod - - objcopy.1: $(binutils_TEXI) $(binutils_TEXINFOS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_objcopy.1: - touch $@ - -$(TEXI2POD) $(MANCONF) -Dobjcopy < $(binutils_TEXI) > objcopy.pod - -($(POD2MAN) objcopy.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ -@@ -777,6 +792,8 @@ - rm -f objcopy.pod - - objdump.1: $(binutils_TEXI) $(binutils_TEXINFOS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_objdump.1: - touch $@ - -$(TEXI2POD) $(MANCONF) -Dobjdump < $(binutils_TEXI) > objdump.pod - -($(POD2MAN) objdump.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ -@@ -784,6 +801,8 @@ - rm -f objdump.pod - - ranlib.1: $(binutils_TEXI) $(binutils_TEXINFOS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_ranlib.1: - touch $@ - -$(TEXI2POD) $(MANCONF) -Dranlib < $(binutils_TEXI) > ranlib.pod - -($(POD2MAN) ranlib.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ -@@ -791,6 +810,8 @@ - rm -f ranlib.pod - - readelf.1: $(binutils_TEXI) $(binutils_TEXINFOS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_readelf.1: - touch $@ - -$(TEXI2POD) $(MANCONF) -Dreadelf < $(binutils_TEXI) > readelf.pod - -($(POD2MAN) readelf.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ -@@ -798,6 +819,8 @@ - rm -f readelf.pod - - size.1: $(binutils_TEXI) $(binutils_TEXINFOS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_size.1: - touch $@ - -$(TEXI2POD) $(MANCONF) -Dsize < $(binutils_TEXI) > size.pod - -($(POD2MAN) size.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ -@@ -805,6 +828,8 @@ - rm -f size.pod - - strings.1: $(binutils_TEXI) $(binutils_TEXINFOS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_strings.1: - touch $@ - -$(TEXI2POD) $(MANCONF) -Dstrings < $(binutils_TEXI) > strings.pod - -($(POD2MAN) strings.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ -@@ -812,6 +837,8 @@ - rm -f strings.pod - - strip.1: $(binutils_TEXI) $(binutils_TEXINFOS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_strip.1: - touch $@ - -$(TEXI2POD) $(MANCONF) -Dstrip < $(binutils_TEXI) > strip.pod - -($(POD2MAN) strip.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ -@@ -819,6 +846,8 @@ - rm -f strip.pod - - elfedit.1: $(binutils_TEXI) $(binutils_TEXINFOS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_elfedit.1: - touch $@ - -$(TEXI2POD) $(MANCONF) -Delfedit < $(binutils_TEXI) > elfedit.pod - -($(POD2MAN) elfedit.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ -@@ -826,6 +855,8 @@ - rm -f elfedit.pod - - windres.1: $(binutils_TEXI) $(binutils_TEXINFOS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_windres.1: - touch $@ - -$(TEXI2POD) $(MANCONF) -Dwindres < $(binutils_TEXI) > windres.pod - -($(POD2MAN) windres.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ -@@ -833,6 +864,8 @@ - rm -f windres.pod - - windmc.1: $(binutils_TEXI) $(binutils_TEXINFOS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_windmc.1: - touch $@ - -$(TEXI2POD) $(MANCONF) -Dwindmc < $(binutils_TEXI) > windmc.pod - -($(POD2MAN) windmc.pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ -@@ -840,6 +873,8 @@ - rm -f windmc.pod - - cxxfilt.man: $(binutils_TEXI) $(binutils_TEXINFOS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_cxxfilt.man: - touch $@ - -$(TEXI2POD) $(MANCONF) -Dcxxfilt < $(binutils_TEXI) > $(DEMANGLER_NAME).pod - -($(POD2MAN) $(DEMANGLER_NAME).pod | sed -e '/^.if n .na/d' > $@.T$$$$ && \ -diff -rNU3 dist.orig/binutils/doc/readelf.1 dist/binutils/doc/readelf.1 ---- dist.orig/binutils/doc/readelf.1 2013-03-25 10:10:25.000000000 +0100 -+++ dist/binutils/doc/readelf.1 2015-10-18 13:11:13.000000000 +0200 -@@ -146,6 +146,7 @@ - [\fB\-r\fR|\fB\-\-relocs\fR] - [\fB\-u\fR|\fB\-\-unwind\fR] - [\fB\-d\fR|\fB\-\-dynamic\fR] -+ [\fB\-f\fR|\fB\-\-special-files\fR] - [\fB\-V\fR|\fB\-\-version\-info\fR] - [\fB\-A\fR|\fB\-\-arch\-specific\fR] - [\fB\-D\fR|\fB\-\-use\-dynamic\fR] -@@ -282,6 +283,13 @@ - .IX Item "--dynamic" - .PD - Displays the contents of the file's dynamic section, if it has one. -+.IP "\fB\-f\fR" 4 -+.IX Item "-f" -+.PD 0 -+.IP "\fB\-\-special-files\fR" 4 -+.IX Item "--special-files" -+.PD -+Allows processing of non-plain files. - .IP "\fB\-V\fR" 4 - .IX Item "-V" - .PD 0 -diff -rNU3 dist.orig/binutils/doc/strings.1 dist/binutils/doc/strings.1 ---- dist.orig/binutils/doc/strings.1 2013-03-25 10:10:26.000000000 +0100 -+++ dist/binutils/doc/strings.1 2015-10-18 13:11:13.000000000 +0200 -@@ -208,7 +208,7 @@ - characters (\s-1ASCII\s0, \s-1ISO\s0 8859, etc., default), \fBS\fR = - single\-8\-bit\-byte characters, \fBb\fR = 16\-bit bigendian, \fBl\fR = - 16\-bit littleendian, \fBB\fR = 32\-bit bigendian, \fBL\fR = 32\-bit --littleendian. Useful for finding wide character strings. (\fBl\fR -+littleendian. Useful for finding wide-character strings. (\fBl\fR - and \fBb\fR apply to, for example, Unicode \s-1UTF\-16/UCS\-2\s0 encodings). - .IP "\fB\-T\fR \fIbfdname\fR" 4 - .IX Item "-T bfdname" -diff -rNU3 dist.orig/binutils/objcopy.c dist/binutils/objcopy.c ---- dist.orig/binutils/objcopy.c 2013-03-25 09:06:21.000000000 +0100 -+++ dist/binutils/objcopy.c 2015-10-18 13:11:13.000000000 +0200 -@@ -30,6 +30,8 @@ - #include "filenames.h" - #include "fnmatch.h" - #include "elf-bfd.h" -+#include -+#include - #include "libbfd.h" - #include "coff/internal.h" - #include "libcoff.h" -diff -rNU3 dist.orig/binutils/readelf.c dist/binutils/readelf.c ---- dist.orig/binutils/readelf.c 2013-03-25 09:06:21.000000000 +0100 -+++ dist/binutils/readelf.c 2015-10-18 13:11:13.000000000 +0200 -@@ -126,13 +126,14 @@ - #include "elf/mep.h" - #include "elf/microblaze.h" - #include "elf/mips.h" -+#include "elf/riscv.h" - #include "elf/mmix.h" - #include "elf/mn10200.h" - #include "elf/mn10300.h" - #include "elf/moxie.h" - #include "elf/mt.h" - #include "elf/msp430.h" --#include "elf/or32.h" -+#include "elf/or1k.h" - #include "elf/pj.h" - #include "elf/ppc.h" - #include "elf/ppc64.h" -@@ -184,6 +185,7 @@ - static Elf_Internal_Dyn * dynamic_section; - static Elf_Internal_Shdr * symtab_shndx_hdr; - static int show_name; -+static int do_special_files; - static int do_dynamic; - static int do_syms; - static int do_dyn_syms; -@@ -555,8 +557,7 @@ - case EM_MIPS: - case EM_MIPS_RS3_LE: - case EM_CYGNUS_M32R: -- case EM_OPENRISC: -- case EM_OR32: -+ case EM_OR1K: - case EM_SCORE: - case EM_XGATE: - return FALSE; -@@ -604,6 +605,7 @@ - case EM_NIOS32: - case EM_PPC64: - case EM_PPC: -+ case EM_RISCV: - case EM_RL78: - case EM_RX: - case EM_S390: -@@ -1134,9 +1136,8 @@ - rtype = elf_h8_reloc_type (type); - break; - -- case EM_OPENRISC: -- case EM_OR32: -- rtype = elf_or32_reloc_type (type); -+ case EM_OR1K: -+ rtype = elf_or1k_reloc_type (type); - break; - - case EM_PJ: -@@ -1234,6 +1235,10 @@ - rtype = elf_microblaze_reloc_type (type); - break; - -+ case EM_RISCV: -+ rtype = elf_riscv_reloc_type (type); -+ break; -+ - case EM_RL78: - rtype = elf_rl78_reloc_type (type); - break; -@@ -1941,8 +1946,7 @@ - case EM_S390: return "IBM S/390"; - case EM_SCORE: return "SUNPLUS S+Core"; - case EM_XSTORMY16: return "Sanyo XStormy16 CPU core"; -- case EM_OPENRISC: -- case EM_OR32: return "OpenRISC"; -+ case EM_OR1K: return "OpenRISC"; - case EM_ARC_A5: return "ARC International ARCompact processor"; - case EM_CRX: return "National Semiconductor CRX microprocessor"; - case EM_ADAPTEVA_EPIPHANY: return "Adapteva EPIPHANY"; -@@ -2005,6 +2009,7 @@ - case EM_CR16: - case EM_MICROBLAZE: - case EM_MICROBLAZE_OLD: return "Xilinx MicroBlaze"; -+ case EM_RISCV: return "RISC-V"; - case EM_RL78: return "Renesas RL78"; - case EM_RX: return "Renesas RX"; - case EM_METAG: return "Imagination Technologies META processor architecture"; -@@ -2488,6 +2493,14 @@ - strcat (buf, ", fdpic"); - break; - -+ case EM_RISCV: -+ { -+ unsigned int riscv_extension = EF_GET_RISCV_EXT(e_flags); -+ strcat (buf, ", "); -+ strcat (buf, riscv_elf_flag_to_name (riscv_extension)); -+ } -+ break; -+ - case EM_SH: - switch ((e_flags & EF_SH_MACH_MASK)) - { -@@ -3198,6 +3211,7 @@ - {"relocs", no_argument, 0, 'r'}, - {"notes", no_argument, 0, 'n'}, - {"dynamic", no_argument, 0, 'd'}, -+ {"special-files", no_argument, 0, 'f'}, - {"arch-specific", no_argument, 0, 'A'}, - {"version-info", no_argument, 0, 'V'}, - {"use-dynamic", no_argument, 0, 'D'}, -@@ -3243,6 +3257,7 @@ - -r --relocs Display the relocations (if present)\n\ - -u --unwind Display the unwind info (if present)\n\ - -d --dynamic Display the dynamic section (if present)\n\ -+ -f --special-files Process non-plain files too\n\ - -V --version-info Display the version sections (if present)\n\ - -A --arch-specific Display architecture specific information (if any)\n\ - -c --archive-index Display the symbol/file index in an archive\n\ -@@ -3362,7 +3377,7 @@ - usage (stderr); - - while ((c = getopt_long -- (argc, argv, "ADHINR:SVWacdeghi:lnp:rstuvw::x:", options, NULL)) != EOF) -+ (argc, argv, "ADHINR:SVWacdefghi:lnp:rstuvw::x:", options, NULL)) != EOF) - { - switch (c) - { -@@ -3412,6 +3427,9 @@ - case 'u': - do_unwind++; - break; -+ case 'f': -+ do_special_files++; -+ break; - case 'h': - do_header++; - break; -@@ -3801,7 +3819,7 @@ - if (elf_header.e_phnum > 1) - printf (_("\nProgram Headers:\n")); - else -- printf (_("\nProgram Headers:\n")); -+ printf (_("\nProgram Header:\n")); - - if (is_32bit_elf) - printf -@@ -6974,6 +6992,11 @@ - - remaining = 4; - } -+ else -+ { -+ addr.section = SHN_UNDEF; -+ addr.offset = 0; -+ } - - if ((word & 0x80000000) == 0) - { -@@ -8842,6 +8865,20 @@ - } - - static const char * -+get_alpha_symbol_other (unsigned int other) -+{ -+ switch (other) -+ { -+ case STO_ALPHA_NOPV: -+ return "NOPV"; -+ case STO_ALPHA_STD_GPLOAD: -+ return "STD GPLOAD"; -+ default: -+ return NULL; -+ } -+} -+ -+static const char * - get_mips_symbol_other (unsigned int other) - { - switch (other) -@@ -8935,6 +8972,9 @@ - - switch (elf_header.e_machine) - { -+ case EM_ALPHA: -+ result = get_alpha_symbol_other (other); -+ break; - case EM_MIPS: - result = get_mips_symbol_other (other); - break; -@@ -9902,9 +9942,8 @@ - case EM_ALTERA_NIOS2: - case EM_NIOS32: - return reloc_type == 1; /* R_NIOS_32. */ -- case EM_OPENRISC: -- case EM_OR32: -- return reloc_type == 1; /* R_OR32_32. */ -+ case EM_OR1K: -+ return reloc_type == 1; /* R_OR1K_32. */ - case EM_PARISC: - return (reloc_type == 1 /* R_PARISC_DIR32. */ - || reloc_type == 41); /* R_PARISC_SECREL32. */ -@@ -9915,6 +9954,8 @@ - return reloc_type == 1; /* R_PPC64_ADDR32. */ - case EM_PPC: - return reloc_type == 1; /* R_PPC_ADDR32. */ -+ case EM_RISCV: -+ return reloc_type == 1; /* R_RISCV_32. */ - case EM_RL78: - return reloc_type == 1; /* R_RL78_DIR32. */ - case EM_RX: -@@ -10015,6 +10056,8 @@ - case EM_L1OM: - case EM_K1OM: - return reloc_type == 2; /* R_X86_64_PC32. */ -+ case EM_VAX: -+ return reloc_type == 4; /* R_VAX_PCREL32. */ - case EM_XTENSA_OLD: - case EM_XTENSA: - return reloc_type == 14; /* R_XTENSA_32_PCREL. */ -@@ -10046,6 +10089,8 @@ - return reloc_type == 80; /* R_PARISC_DIR64. */ - case EM_PPC64: - return reloc_type == 38; /* R_PPC64_ADDR64. */ -+ case EM_RISCV: -+ return reloc_type == 2; /* R_RISCV_64. */ - case EM_SPARC32PLUS: - case EM_SPARCV9: - case EM_SPARC: -@@ -10187,6 +10232,7 @@ - case EM_ADAPTEVA_EPIPHANY: - case EM_PPC: /* R_PPC_NONE. */ - case EM_PPC64: /* R_PPC64_NONE. */ -+ case EM_RISCV: /* R_RISCV_NONE. */ - case EM_ARM: /* R_ARM_NONE. */ - case EM_IA_64: /* R_IA64_NONE. */ - case EM_SH: /* R_SH_NONE. */ -@@ -12665,6 +12711,48 @@ - return buff; - } - -+static int -+process_netbsd_elf_note (Elf_Internal_Note * pnote) -+{ -+ unsigned int version; -+ -+ switch (pnote->type) -+ { -+ case NT_NETBSD_IDENT: -+ version = byte_get((unsigned char *)pnote->descdata, sizeof(version)); -+ if ((version / 10000) % 100) -+ printf (" NetBSD\t0x%08lx\tIDENT %u (%u.%u%s%c)\n", pnote->descsz, -+ version, version / 100000000, (version / 1000000) % 100, -+ (version / 10000) % 100 > 26 ? "Z" : "", -+ 'A' + (version / 10000) % 26); -+ else -+ printf (" NetBSD\t\t0x%08lx\tIDENT %u (%u.%u.%u)\n", pnote->descsz, -+ version, version / 100000000, (version / 1000000) % 100, -+ (version / 100) % 100); -+ return 1; -+ case NT_NETBSD_MARCH: -+ printf (" NetBSD\t\t0x%08lx\tMARCH <%s>\n", pnote->descsz, -+ pnote->descdata); -+ return 1; -+ case NT_NETBSD_PAX: -+ version = byte_get((unsigned char *)pnote->descdata, sizeof(version)); -+ printf (" NetBSD\t\t0x%08lx\tPaX <%s%s%s%s%s%s>\n", pnote->descsz, -+ ((version & NT_NETBSD_PAX_MPROTECT) ? "+mprotect" : ""), -+ ((version & NT_NETBSD_PAX_NOMPROTECT) ? "-mprotect" : ""), -+ ((version & NT_NETBSD_PAX_GUARD) ? "+guard" : ""), -+ ((version & NT_NETBSD_PAX_NOGUARD) ? "-guard" : ""), -+ ((version & NT_NETBSD_PAX_ASLR) ? "+ASLR" : ""), -+ ((version & NT_NETBSD_PAX_NOASLR) ? "-ASLR" : "")); -+ return 1; -+ default: -+ break; -+ } -+ -+ printf (" NetBSD\t0x%08lx\tUnknown note type: (0x%08lx)\n", pnote->descsz, -+ pnote->type); -+ return 1; -+} -+ - static int - print_gnu_note (Elf_Internal_Note *pnote) - { -@@ -12765,6 +12853,23 @@ - } - break; - -+ /* On SuperH, PT_GETREGS == mach+3 and PT_GETFPREGS == mach+5. -+ There's also old PT___GETREGS40 == mach + 1 for old reg -+ structure which lacks GBR. */ -+ case EM_SH: -+ switch (e_type) -+ { -+ case NT_NETBSDCORE_FIRSTMACH + 1: -+ return _("PT___GETREGS40 (old reg structure)"); -+ case NT_NETBSDCORE_FIRSTMACH + 3: -+ return _("PT_GETREGS (reg structure)"); -+ case NT_NETBSDCORE_FIRSTMACH + 5: -+ return _("PT_GETFPREGS (fpreg structure)"); -+ default: -+ break; -+ } -+ break; -+ - /* On all other arch's, PT_GETREGS == mach+1 and - PT_GETFPREGS == mach+3. */ - default: -@@ -12971,6 +13076,14 @@ - /* GNU-specific object file notes. */ - nt = get_gnu_elf_note_type (pnote->type); - -+ else if (const_strneq (pnote->namedata, "NetBSD")) -+ /* NetBSD-specific core file notes. */ -+ return process_netbsd_elf_note (pnote); -+ -+ else if (const_strneq (pnote->namedata, "PaX")) -+ /* NetBSD-specific core file notes. */ -+ return process_netbsd_elf_note (pnote); -+ - else if (const_strneq (pnote->namedata, "NetBSD-CORE")) - /* NetBSD-specific core file notes. */ - nt = get_netbsd_elfcore_note_type (pnote->type); -@@ -13710,7 +13823,7 @@ - return 1; - } - -- if (! S_ISREG (statbuf.st_mode)) -+ if (!do_special_files && ! S_ISREG (statbuf.st_mode)) - { - error (_("'%s' is not an ordinary file\n"), file_name); - return 1; -diff -rNU3 dist.orig/binutils/strings.c dist/binutils/strings.c ---- dist.orig/binutils/strings.c 2012-02-09 05:51:44.000000000 +0100 -+++ dist/binutils/strings.c 2015-10-18 13:11:13.000000000 +0200 -@@ -598,7 +598,7 @@ - else - #elif !BFD_HOST_64BIT_LONG - if (start != (unsigned long) start) -- printf ("++%7ld ", (unsigned long) start); -+ printf ("++%7llu ", (unsigned long) start); - else - #endif - printf ("%7ld ", (long) start); -diff -rNU3 dist.orig/config.guess dist/config.guess ---- dist.orig/config.guess 2011-06-06 12:36:06.000000000 +0200 -+++ dist/config.guess 2015-10-18 13:11:13.000000000 +0200 -@@ -160,14 +160,28 @@ - case "${UNAME_MACHINE_ARCH}" in - armeb) machine=armeb-unknown ;; - arm*) machine=arm-unknown ;; -+ coldfire) machine=m5407-unknown ;; -+ earm*eb*) machine=armeb-unknown ;; -+ earm*) machine=arm-unknown ;; - sh3el) machine=shl-unknown ;; - sh3eb) machine=sh-unknown ;; - sh5el) machine=sh5le-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; - esac - # The Operating System including object format, if it has switched -- # to ELF recently, or will in the future. -+ # to ELF recently, or will in the future and ABI. - case "${UNAME_MACHINE_ARCH}" in -+ coldfire) os=netbsdelf ;; -+ earm*) -+ eval $set_cc_for_build -+ if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ -+ | grep -q __ARM_PCS_VFP -+ then -+ os=netbsdelf-eabi -+ else -+ os=netbsdelf-eabihf -+ fi -+ ;; - arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build - if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ -diff -rNU3 dist.orig/config.sub dist/config.sub ---- dist.orig/config.sub 2012-04-25 17:53:25.000000000 +0200 -+++ dist/config.sub 2015-10-18 13:11:13.000000000 +0200 -@@ -122,9 +122,9 @@ - # Here we must recognize all the valid KERNEL-OS combinations. - maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` - case $maybe_os in -- nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ -- linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ -- knetbsd*-gnu* | netbsd*-gnu* | \ -+ nto-qnx* | linux-gnu* | linux-dietlibc | linux-newlib* | linux-uclibc* | \ -+ uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | \ -+ netbsd*-gnu* | netbsd*-eabi* | \ - kopensolaris*-gnu* | \ - storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os -@@ -300,7 +300,7 @@ - | nios | nios2 \ - | ns16k | ns32k \ - | open8 \ -- | or32 \ -+ | or1k | or1knd \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle \ - | pyramid \ -@@ -332,12 +332,21 @@ - basic_machine=$basic_machine-unknown - os=-none - ;; -- m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) -+ m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | m5407 \ -+ | v70 | w65 | z8k) - ;; - ms1) - basic_machine=mt-unknown - ;; - -+ riscv32-*) -+ basic_machine=riscv32-ucb -+ ;; -+ -+ riscv*-*) -+ basic_machine=riscv-ucb -+ ;; -+ - strongarm | thumb | xscale) - basic_machine=arm-unknown - ;; -@@ -375,7 +384,7 @@ - | avr-* | avr32-* \ - | be32-* | be64-* \ - | bfin-* | bs2000-* \ -- | c[123]* | c30-* | [cjt]90-* | c4x-* \ -+ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ - | clipper-* | craynv-* | cydra-* \ - | d10v-* | d30v-* | dlx-* \ - | elxsi-* \ -@@ -388,6 +397,7 @@ - | le32-* | le64-* \ - | lm32-* \ - | m32c-* | m32r-* | m32rle-* \ -+ | m5200-* | m5407-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* | microblaze-* \ - | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ -@@ -528,15 +538,6 @@ - basic_machine=powerpc-ibm - os=-cnk - ;; -- c54x-*) -- basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; -- c55x-*) -- basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; -- c6x-*) -- basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'` -- ;; - c90) - basic_machine=c90-cray - os=-unicos -@@ -916,8 +917,11 @@ - basic_machine=hppa1.1-oki - os=-proelf - ;; -- openrisc | openrisc-*) -- basic_machine=or32-unknown -+ or1k | or1k-*) -+ basic_machine=or1k-unknown -+ ;; -+ or1knd | or1knd-*) -+ basic_machine=or1knd-unknown - ;; - os400) - basic_machine=powerpc-ibm -@@ -1543,15 +1547,6 @@ - c4x-* | tic4x-*) - os=-coff - ;; -- tic54x-*) -- os=-coff -- ;; -- tic55x-*) -- os=-coff -- ;; -- tic6x-*) -- os=-coff -- ;; - # This must come before the *-dec entry. - pdp10-*) - os=-tops20 -@@ -1583,8 +1578,11 @@ - mips*-*) - os=-elf - ;; -- or32-*) -- os=-coff -+ or1k-*) -+ os=-elf -+ ;; -+ or1knd-*) -+ os=-elf - ;; - *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 -diff -rNU3 dist.orig/cpu/openrisc.cpu dist/cpu/openrisc.cpu ---- dist.orig/cpu/openrisc.cpu 2011-08-22 17:25:07.000000000 +0200 -+++ dist/cpu/openrisc.cpu 1970-01-01 01:00:00.000000000 +0100 -@@ -1,774 +0,0 @@ --; OpenRISC family. -*- Scheme -*- --; Copyright 2000, 2001, 2011 Free Software Foundation, Inc. --; Contributed by Johan Rydberg, jrydberg@opencores.org --; --; This program is free software; you can redistribute it and/or modify --; it under the terms of the GNU General Public License as published by --; the Free Software Foundation; either version 2 of the License, or --; (at your option) any later version. --; --; This program is distributed in the hope that it will be useful, --; but WITHOUT ANY WARRANTY; without even the implied warranty of --; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --; GNU General Public License for more details. --; --; You should have received a copy of the GNU General Public License --; along with this program; if not, write to the Free Software --; Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. -- --(include "simplify.inc") -- --; OpenRISC 1000 is an architecture of a family of open source, --; synthesizeable RISC microprocessor cores. It is a 32-bit load --; and store RISC architecture designed with emphasis on speed, --; compact instruction set and scalability. OpenRISC 1000 targets --; wide range of embedded environments. -- --(define-arch -- (name openrisc) -- (comment "OpenRISC 1000") -- (insn-lsb0? #t) -- (machs openrisc or1300) -- (isas or32) --) -- -- --; Attributes -- --; An attribute to describe if a model has insn and/or data caches. --(define-attr -- (for model) -- (type enum) -- (name HAS-CACHE) -- (comment "if this model has caches") -- (values DATA-CACHE INSN-CACHE) --) -- --; An attribute to describe if an insn can be in the delay slot or not. --(define-attr -- (for insn) -- (type boolean) -- (name NOT-IN-DELAY-SLOT) -- (comment "insn can't go in delay slot") --) -- --; IDOC attribute for instruction documentation. -- --(define-attr -- (for insn) -- (type enum) -- (name IDOC) -- (comment "insn kind for documentation") -- (attrs META) -- (values -- (MEM - () "Memory") -- (ALU - () "ALU") -- (FPU - () "FPU") -- (BR - () "Branch") -- (PRIV - () "Priviledged") -- (MISC - () "Miscellaneous") -- ) --) -- --; Enum for exception vectors. --(define-enum -- (name e-exception) -- (comment "exception vectors") -- (attrs) -- (prefix E_) -- (values (("RESET") ("BUSERR" -) ("DPF" -) ("IPF" -) ("EXTINT" -) ("ALIGN" -) -- ("ILLEGAL" -) ("PEINT" -) ("DTLBMISS" -) ("ITLBMISS" -) ("RRANGE" -) -- ("SYSCALL" -) ("BREAK" -) ("RESERVED" -))) --) -- -- --; Instruction set parameters. -- --(define-isa -- ; Name of the ISA. -- (name or32) -- -- ; Base insturction length. The insns is always 32 bits wide. -- (base-insn-bitsize 32) -- -- ; Address of insn in delay slot -- (setup-semantics (set-quiet (reg h-delay-insn) (add pc 4))) --) -- -- --; CPU family definitions. -- --(define-cpu -- ; CPU names must be distinct from the architecture name and machine names. -- ; The "b" suffix stands for "base" and is the convention. -- ; The "f" suffix stands for "family" and is the convention. -- (name openriscbf) -- (comment "OpenRISC base family") -- (endian big) -- (word-bitsize 32) --) -- --; Generic machine --(define-mach -- (name openrisc) -- (comment "Generic OpenRISC cpu") -- (cpu openriscbf) -- (bfd-name "openrisc") --) -- --; OpenRISC 1300 machine --(define-mach -- (name or1300) -- (comment "OpenRISC 1300") -- (cpu openriscbf) -- (bfd-name "openrisc:1300") --) -- -- --; Model descriptions -- --; Generic OpenRISC model --(define-model -- (name openrisc-1) (comment "OpenRISC generic model") (attrs) -- (mach openrisc) -- -- ; Nothing special about this. -- (unit u-exec "Execution Unit" () 1 1 () () () ()) --) -- --; OpenRISC 1320 --(define-model -- (name or1320-1) (comment "OpenRISC 1320 model") -- -- ; This model has both instruction and data cache -- (attrs (HAS-CACHE INSN-CACHE,DATA-CACHE)) -- (mach or1300) -- -- ; Nothing special about this. -- (unit u-exec "Execution Unit" () 1 1 () () () ()) --) -- -- --; Instruction fields. -- --; Attributes: --; . PCREL-ADDR pc relative value (for reloc and disassembly purposes) --; . ABS-ADDR absolute address (for reloc and disassembly purposes?) --; . RESERVED bits are not used to decode insn, must be all 0 -- --; Instruction classes. --(dnf f-class "insn class" () 31 2) --(dnf f-sub "sub class" () 29 4) -- --; Register fields. --(dnf f-r1 "r1" () 25 5) --(dnf f-r2 "r2" () 20 5) --(dnf f-r3 "r3" () 15 5) -- --; Immediates. --(df f-simm16 "signed imm (16)" () 15 16 INT #f #f) --(dnf f-uimm16 "unsigned imm (16)" () 15 16) --(dnf f-uimm5 "unsigned imm (5)" () 4 5) --(df f-hi16 "high 16" () 15 16 INT #f #f) --(df f-lo16 "low 16" () 15 16 INT #f #f) -- --; Sub fields --(dnf f-op1 "op1" () 31 2) --(dnf f-op2 "op2" () 29 4) --(dnf f-op3 "op3" () 25 2) --(dnf f-op4 "op4" () 23 3) --(dnf f-op5 "op3" () 25 5) --(dnf f-op6 "op4" () 7 3) --(dnf f-op7 "op5" () 3 4) -- --(dnf f-i16-1 "uimm16-1" () 10 11) --(dnf f-i16-2 "uimm16-2" () 25 5) -- --; PC relative, 26-bit (2 shifted to right) --(df f-disp26 "disp26" (PCREL-ADDR) 25 26 INT -- ((value pc) (sra WI (sub WI value pc) (const 2))) -- ((value pc) (add WI (sll WI value (const 2)) pc))) -- --; absolute, 26-bit (2 shifted to right) --(df f-abs26 "abs26" (ABS-ADDR) 25 26 INT -- ((value pc) (sra WI pc (const 2))) -- ((value pc) (sll WI value (const 2)))) -- --(define-multi-ifield -- (name f-i16nc) -- (comment "16 bit signed") -- (attrs SIGN-OPT) -- (mode HI) -- (subfields f-i16-1 f-i16-2) -- (insert (sequence () -- (set (ifield f-i16-2) (and (sra (ifield f-i16nc) -- (const 11)) -- (const #x1f))) -- (set (ifield f-i16-1) (and (ifield f-i16nc) -- (const #x7ff))))) -- (extract (sequence () -- (set (ifield f-i16nc) (c-raw-call SI "@arch@_sign_extend_16bit" -- (or (sll (ifield f-i16-2) -- (const 11)) -- (ifield f-i16-1)))))) --) -- -- --; Enums. -- --; insn-class: bits 31-30 --(define-normal-insn-enum insn-class "FIXME" () OP1_ f-class -- (.map .str (.iota 4)) --) -- --(define-normal-insn-enum insn-sub "FIXME" () OP2_ f-sub -- (.map .str (.iota 16)) --) -- --(define-normal-insn-enum insn-op3 "FIXME" () OP3_ f-op3 -- (.map .str (.iota 4)) --) -- --(define-normal-insn-enum insn-op4 "FIXME" () OP4_ f-op4 -- (.map .str (.iota 8)) --) -- --(define-normal-insn-enum insn-op5 "FIXME" () OP5_ f-op5 -- (.map .str (.iota 32)) --) -- --(define-normal-insn-enum insn-op6 "FIXME" () OP6_ f-op6 -- (.map .str (.iota 8)) --) -- --(define-normal-insn-enum insn-op7 "FIXME" () OP7_ f-op7 -- (.map .str (.iota 16)) --) -- -- -- --; Hardware pieces. --; These entries list the elements of the raw hardware. --; They're also used to provide tables and other elements of the assembly --; language. -- --(dnh h-pc "program counter" (PC PROFILE) (pc) () () ()) -- --(define-hardware -- (name h-gr) (comment "general registers") (attrs PROFILE) -- (type register WI (32)) -- (indices keyword "" -- ((r0 0) (r1 1) (r2 2) (r3 3) (r4 4) (r5 5) (r6 6) (r7 7) -- (r8 8) (r9 9) (r10 10) (r11 11) (r12 12) (r13 13) (r14 14) -- (r15 15) (r16 16) (r17 17) (r18 18) (r19 19) (r20 20) -- (r21 21) (r22 22) (r23 23) (r24 24) (r25 25) (r26 26) -- (r27 27) (r28 28) (r29 29) (r30 30) (r31 31) (lr 11) -- (sp 1) (fp 2))) --) -- --(define-hardware -- (name h-sr) (comment "special registers") -- (type register WI (#x20000)) -- (get (index) (c-call SI "@arch@_h_sr_get_handler" index)) -- (set (index newval) (c-call VOID "@arch@_h_sr_set_handler" index newval)) --) -- --(dnh h-hi16 "high 16 bits" () (immediate (INT 16)) () () ()) --(dnh h-lo16 "low 16 bits" () (immediate (INT 16)) () () ()) -- --(dsh h-cbit "condition bit" () (register BI)) --(dsh h-delay-insn "delay insn addr" () (register SI)) -- -- --; Instruction operands. -- --(dnop sr "special register" (SEM-ONLY) h-sr f-nil) --(dnop cbit "condition bit" (SEM-ONLY) h-cbit f-nil) --(dnop simm-16 "16 bit signed immediate" () h-sint f-simm16) --(dnop uimm-16 "16 bit unsigned immediate" () h-uint f-uimm16) --(dnop disp-26 "pc-rel 26 bit" () h-iaddr f-disp26) --(dnop abs-26 "abs 26 bit" () h-iaddr f-abs26) --(dnop uimm-5 "imm5" () h-uint f-uimm5) -- --(dnop rD "destination register" () h-gr f-r1) --(dnop rA "source register A" () h-gr f-r2) --(dnop rB "source register B" () h-gr f-r3) -- --(dnop op-f-23 "f-op23" () h-uint f-op4) --(dnop op-f-3 "f-op3" () h-uint f-op5) -- --; For hi(foo). --(define-operand -- (name hi16) (comment "high 16 bit immediate, sign optional") -- (attrs SIGN-OPT) -- (type h-hi16) -- (index f-simm16) -- (handlers (parse "hi16")) --) -- --; For lo(foo) --(define-operand -- (name lo16) (comment "low 16 bit immediate, sign optional") -- (attrs SIGN-OPT) -- (type h-lo16) -- (index f-lo16) -- (handlers (parse "lo16")) --) -- --(define-operand -- (name ui16nc) -- (comment "16 bit immediate, sign optional") -- (attrs) -- (type h-lo16) -- (index f-i16nc) -- (handlers (parse "lo16")) --) -- -- --; Instructions. -- --; Branch releated instructions -- --(dni l-j "jump (absolute iaddr)" -- ; This function may not be in delay slot -- (NOT-IN-DELAY-SLOT) -- -- "l.j ${abs-26}" -- (+ OP1_0 OP2_0 abs-26) -- -- ; We execute the delay slot before doin' the real branch -- (delay 1 (set pc abs-26)) -- () --) -- --(dni l-jal "jump and link (absolute iaddr)" -- ; This function may not be in delay slot -- (NOT-IN-DELAY-SLOT) -- -- "l.jal ${abs-26}" -- (+ OP1_0 OP2_1 abs-26) -- -- ; We execute the delay slot before doin' the real branch -- ; Set LR to (delay insn addr + 4) -- (sequence () -- (set (reg h-gr 11) (add (reg h-delay-insn) 4)) -- (delay 1 (set pc abs-26))) -- () --) -- --(dni l-jr "jump register (absolute iaddr)" -- ; This function may not be in delay slot -- (NOT-IN-DELAY-SLOT) -- -- "l.jr $rA" -- (+ OP1_0 OP2_5 OP3_0 OP4_0 rA uimm-16) -- -- ; We execute the delay slot before doin' the real branch -- (delay 1 (set pc rA)) -- () --) -- --(dni l-jalr "jump register and link (absolute iaddr)" -- ; This function may not be in delay slot -- (NOT-IN-DELAY-SLOT) -- -- "l.jalr $rA" -- (+ OP1_0 OP2_5 OP3_0 OP4_1 rA uimm-16) -- -- ; We save the value of rA in a temporary slot before setting -- ; the link register. This because "l.jalr r11" would cause -- ; a forever-and-ever loop otherwise. -- ; -- ; We execute the delay slot before doin' the real branch -- (sequence ((WI tmp-slot)) -- (set tmp-slot rA) -- (set (reg h-gr 11) (add (reg h-delay-insn) 4)) -- (delay 1 (set pc tmp-slot))) -- () --) -- --(dni l-bal "branch and link (pc relative iaddr)" -- ; This function may not be in delay slot -- (NOT-IN-DELAY-SLOT) -- -- "l.bal ${disp-26}" -- (+ OP1_0 OP2_2 disp-26) -- -- ; We execute the delay slot before doin' the real branch -- ; Set LR to (delay insn addr + 4) -- (sequence () -- (set (reg h-gr 11) (add (reg h-delay-insn) 4)) -- (delay 1 (set pc disp-26))) -- () --) -- --(dni l-bnf "branch if condition bit not set (pc relative iaddr)" -- ; This function may not be in delay slot -- (NOT-IN-DELAY-SLOT) -- -- "l.bnf ${disp-26}" -- (+ OP1_0 OP2_3 disp-26) -- -- ; We execute the delay slot before doin' the real branch -- (if (eq cbit 0) -- (sequence () -- (delay 1 (set pc disp-26)))) -- () --) -- --(dni l-bf "branch if condition bit is set (pc relative iaddr)" -- ; This function may not be in delay slot -- (NOT-IN-DELAY-SLOT) -- -- "l.bf ${disp-26}" -- (+ OP1_0 OP2_4 disp-26) -- -- ; We execute the delay slot before doin' the real branch -- (if (eq cbit 1) -- (sequence () -- (delay 1 (set pc disp-26)))) -- () --) -- --(dni l-brk "break (exception)" -- ; This function may not be in delay slot -- (NOT-IN-DELAY-SLOT) -- -- "l.brk ${uimm-16}" -- (+ OP1_0 OP2_5 OP3_3 OP4_0 rA uimm-16) -- -- ; FIXME should we do it like this ?? -- (c-call VOID "@cpu@_cpu_brk" uimm-16) -- () --) -- --(dni l-rfe "return from exception" -- ; This function may not be in delay slot -- (NOT-IN-DELAY-SLOT) -- -- "l.rfe $rA" -- (+ OP1_0 OP2_5 OP3_0 OP4_2 rA uimm-16) -- (sequence () -- (delay 1 (set pc (c-call SI "@cpu@_cpu_rfe" rA)))) -- () --) -- --(dni l-sys "syscall (exception)" -- ; This function may not be in delay slot -- (NOT-IN-DELAY-SLOT) -- -- "l.sys ${uimm-16}" -- (+ OP1_0 OP2_5 OP3_2 OP4_0 rA uimm-16) -- (sequence() -- (delay 1 (set pc (c-call SI "@cpu@_except" pc -- #xc00 uimm-16)))) -- () --) -- -- --; Misc instructions -- --(dni l-nop "nop" -- () -- "l.nop" -- (+ OP1_0 OP2_5 OP3_1 OP4_0 rA uimm-16) -- (nop) -- () --) -- --(dnmi l-ret "ret" () -- "l.ret" -- (emit l-jr (rA 11) (uimm-16 0)) --) -- --(dni l-movhi "movhi" -- (DELAY-SLOT) -- "l.movhi $rD,$hi16" -- (+ OP1_0 OP2_6 hi16 rD rA) -- (set rD (sll WI hi16 (const 16))) -- () --) -- -- --; System releated instructions -- --(dni l-mfsr "mfsr" -- (DELAY-SLOT) -- "l.mfsr $rD,$rA" -- (+ OP1_0 OP2_7 rD rA uimm-16) -- (set rD (c-call SI "@cpu@_cpu_mfsr" rA)) -- () --) -- --(dni l-mtsr "mtsr" -- (DELAY-SLOT) -- "l.mtsr $rA,$rB" -- (+ OP1_1 OP2_0 rA rB rD (f-i16-1 0)) -- (c-call VOID "@cpu@_cpu_mtsr" rA rB) -- () --) -- -- -- --; Load instructions -- --(dni l-lw "load word" -- (DELAY-SLOT) -- "l.lw $rD,${simm-16}($rA)" -- (+ OP1_2 OP2_0 rD rA simm-16) -- (set rD (mem SI (add rA simm-16))) -- () --) -- --(dni l-lbz "load byte (zero extend)" -- (DELAY-SLOT) -- "l.lbz $rD,${simm-16}($rA)" -- (+ OP1_2 OP2_1 rD rA simm-16) -- (set rD (zext SI (mem QI (add rA simm-16)))) -- () --) -- --(dni l-lbs "load byte (sign extend)" -- (DELAY-SLOT) -- "l.lbs $rD,${simm-16}($rA)" -- (+ OP1_2 OP2_2 rD rA simm-16) -- (set rD (ext SI (mem QI (add rA simm-16)))) -- () --) -- --(dni l-lhz "load halfword (zero extend)" -- (DELAY-SLOT) -- "l.lhz $rD,${simm-16}($rA)" -- (+ OP1_2 OP2_3 rD simm-16 rA) -- (set rD (zext SI (mem HI (add rA simm-16)))) -- () --) -- --(dni l-lhs "load halfword (sign extend)" -- (DELAY-SLOT) -- "l.lhs $rD,${simm-16}($rA)" -- (+ OP1_2 OP2_4 rD rA simm-16) -- (set rD (ext SI (mem HI (add rA simm-16)))) -- () --) -- -- --; Store instructions --; --; We have to use a multi field since the integer is splited over 2 fields -- --(define-pmacro (store-insn mnemonic op2-op mode-op) -- (begin -- (dni (.sym l- mnemonic) -- (.str "l." mnemonic " imm(reg)/reg") -- (DELAY-SLOT) -- (.str "l." mnemonic " ${ui16nc}($rA),$rB") -- (+ OP1_3 op2-op rB rD ui16nc) -- (set (mem mode-op (add rA ui16nc)) rB) -- () -- ) -- ) --) -- --(store-insn sw OP2_5 SI) --(store-insn sb OP2_6 QI) --(store-insn sh OP2_7 HI) -- -- -- --; Shift and rotate instructions -- --; Reserved fields. --(dnf f-f-15-8 "nop" (RESERVED) 15 8) --(dnf f-f-10-3 "nop" (RESERVED) 10 3) --(dnf f-f-4-1 "nop" (RESERVED) 4 1) --(dnf f-f-7-3 "nop" (RESERVED) 7 3) -- --(define-pmacro (shift-insn mnemonic op4-op) -- (begin -- (dni (.sym l- mnemonic) -- (.str "l." mnemonic " reg/reg/reg") -- () -- (.str "l." mnemonic " $rD,$rA,$rB") -- (+ OP1_3 OP2_8 rD rA rB (f-f-10-3 0) op4-op (f-f-4-1 0) OP7_8) -- (set rD (mnemonic rA rB)) -- () -- ) -- (dni (.sym l- mnemonic "i") -- (.str "l." mnemonic " reg/reg/imm") -- () -- (.str "l." mnemonic "i $rD,$rA,${uimm-5}") -- (+ OP1_2 OP2_13 rD rA (f-f-15-8 0) op4-op uimm-5) -- (set rD (mnemonic rA uimm-5)) -- () -- ) -- ) --) -- --(shift-insn sll OP6_0) --(shift-insn srl OP6_1) --(shift-insn sra OP6_2) --(shift-insn ror OP6_4) -- -- --; Arethmetic insns -- --; Reserved fields. --(dnf f-f-10-7 "nop" (RESERVED) 10 7) -- --(define-pmacro (ar-insn-u mnemonic op2-op op5-op) -- (begin -- (dni (.sym l- mnemonic) -- (.str "l." mnemonic " reg/reg/reg") -- () -- (.str "l." mnemonic " $rD,$rA,$rB") -- (+ OP1_3 OP2_8 rD rA rB (f-f-10-7 0) op5-op) -- (set rD (mnemonic rA rB)) -- () -- ) -- (dni (.sym l- mnemonic "i") -- (.str "l." mnemonic " reg/reg/lo16") -- () -- (.str "l." mnemonic "i $rD,$rA,$lo16") -- (+ OP1_2 op2-op rD rA lo16) -- (set rD (mnemonic rA (and lo16 #xffff))) -- () -- ) -- ) --) -- --(define-pmacro (ar-insn-s mnemonic op2-op op5-op) -- (begin -- (dni (.sym l- mnemonic) -- (.str "l." mnemonic " reg/reg/reg") -- () -- (.str "l." mnemonic " $rD,$rA,$rB") -- (+ OP1_3 OP2_8 rD rA rB (f-f-10-7 0) op5-op) -- (set rD (mnemonic rA rB)) -- () -- ) -- (dni (.sym l- mnemonic "i") -- (.str "l." mnemonic " reg/reg/lo16") -- () -- (.str "l." mnemonic "i $rD,$rA,$lo16") -- (+ OP1_2 op2-op rD rA lo16) -- (set rD (mnemonic rA lo16)) -- () -- ) -- ) --) -- --(ar-insn-s add OP2_5 OP7_0) --;;(ar-op-s addc OP2_5 OP7_0) --(ar-insn-s sub OP2_7 OP7_2) --(ar-insn-u and OP2_8 OP7_3) --(ar-insn-u or OP2_9 OP7_4) --(ar-insn-u xor OP2_10 OP7_5) --(ar-insn-u mul OP2_11 OP7_6) --;;(ar-op-u mac OP2_12 OP7_7) -- -- --(dni l-div "divide (signed)" -- (DELAY-SLOT) -- "l.div $rD,$rA,$rB" -- (+ OP1_3 OP2_8 rD rA rB (f-f-10-7 0) OP7_9) -- (if VOID (eq rB (const 0)) -- (c-call VOID "@arch@_cpu_trap" pc (enum SI E_ILLEGAL)) -- (set rD (div rA rB))) -- () --) -- --(dni l-divu "divide (unsigned)" -- (DELAY-SLOT) -- "l.divu $rD,$rA,$rB" -- (+ OP1_3 OP2_8 rD rA rB (f-f-10-7 0) OP7_10) -- (if VOID (eq rB (const 0)) -- (c-call VOID "@arch@_cpu_trap" pc (enum SI E_ILLEGAL)) -- (set rD (udiv rA rB))) -- () --) -- -- --; Compare instructions -- --; Reserved fields. --(dnf f-f-10-11 "nop" (RESERVED) 10 11) -- --; Register compare (both signed and unsigned) --(define-pmacro (sf-insn-r op1-op op2-op op3-op op3-op-2 sem-op) -- (begin -- (dni (.sym l- "sf" (.sym sem-op "s")) -- (.str "l." mnemonic " reg/reg") -- (DELAY-SLOT) -- (.str "l.sf" (.str sem-op) "s $rA,$rB") -- (+ op1-op op2-op op3-op-2 rA rB (f-f-10-11 0)) -- (set cbit (sem-op rA rB)) -- () -- ) -- (dni (.sym l- "sf" (.sym sem-op "u")) -- (.str "l." mnemonic " reg/reg") -- (DELAY-SLOT) -- (.str "l.sf" (.str sem-op) "u $rA,$rB") -- (+ op1-op op2-op op3-op rA rB (f-f-10-11 0)) -- (set cbit (sem-op rA rB)) -- () -- ) -- ) --) -- --; Immediate compare (both signed and unsigned) --(define-pmacro (sf-insn-i op1-op op2-op op3-op op3-op-2 sem-op) -- (begin -- (dni (.sym l- "sf" (.sym sem-op "si")) -- (.str "l." mnemonic "si reg/imm") -- (DELAY-SLOT) -- (.str "l.sf" (.str sem-op) "si $rA,${simm-16}") -- (+ op1-op op2-op op3-op-2 rA simm-16) -- (set cbit (sem-op rA simm-16)) -- () -- ) -- (dni (.sym l- "sf" (.sym sem-op "ui")) -- (.str "l." mnemonic "ui reg/imm") -- (DELAY-SLOT) -- (.str "l.sf" (.str sem-op) "ui $rA,${uimm-16}") -- (+ op1-op op2-op op3-op rA uimm-16) -- (set cbit (sem-op rA uimm-16)) -- () -- ) -- ) --) -- --(define-pmacro (sf-insn op5-op sem-op) -- (begin -- (dni (.sym l- "sf" sem-op) -- (.str "l." mnemonic " reg/reg") -- (DELAY-SLOT) -- (.str "l.sf" (.str sem-op) " $rA,$rB") -- (+ OP1_3 OP2_9 op5-op rA rB (f-f-10-11 0)) -- (set cbit (sem-op rA rB)) -- () -- ) -- (dni (.sym l- "sf" (.sym sem-op "i")) -- (.str "l." mnemonic "i reg/imm") -- (DELAY-SLOT) -- (.str "l.sf" (.str sem-op) "i $rA,${simm-16}") -- (+ OP1_2 OP2_14 op5-op rA simm-16) -- (set cbit (sem-op rA simm-16)) -- () -- ) -- ) --) -- -- --(sf-insn-r OP1_3 OP2_9 OP5_2 OP5_6 gt) --(sf-insn-r OP1_3 OP2_9 OP5_3 OP5_7 ge) --(sf-insn-r OP1_3 OP2_9 OP5_4 OP5_8 lt) --(sf-insn-r OP1_3 OP2_9 OP5_5 OP5_9 le) -- --(sf-insn-i OP1_2 OP2_14 OP5_2 OP5_6 gt) --(sf-insn-i OP1_2 OP2_14 OP5_3 OP5_7 ge) --(sf-insn-i OP1_2 OP2_14 OP5_4 OP5_8 lt) --(sf-insn-i OP1_2 OP2_14 OP5_5 OP5_9 le) -- --(sf-insn OP5_0 eq) --(sf-insn OP5_1 ne) -diff -rNU3 dist.orig/cpu/openrisc.opc dist/cpu/openrisc.opc ---- dist.orig/cpu/openrisc.opc 2011-08-22 17:25:07.000000000 +0200 -+++ dist/cpu/openrisc.opc 1970-01-01 01:00:00.000000000 +0100 -@@ -1,164 +0,0 @@ --/* OpenRISC opcode support. -*- C -*- -- Copyright 2000, 2001, 2003, 2005, 2011 Free Software Foundation, Inc. -- -- Contributed by Red Hat Inc; -- -- This file is part of the GNU Binutils. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, -- MA 02110-1301, USA. */ -- --/* This file is an addendum to or32.cpu. Heavy use of C code isn't -- appropriate in .cpu files, so it resides here. This especially applies -- to assembly/disassembly where parsing/printing can be quite involved. -- Such things aren't really part of the specification of the cpu, per se, -- so .cpu files provide the general framework and .opc files handle the -- nitty-gritty details as necessary. -- -- Each section is delimited with start and end markers. -- -- -opc.h additions use: "-- opc.h" -- -opc.c additions use: "-- opc.c" -- -asm.c additions use: "-- asm.c" -- -dis.c additions use: "-- dis.c" -- -ibd.h additions use: "-- ibd.h" */ -- --/* -- opc.h */ --#undef CGEN_DIS_HASH_SIZE --#define CGEN_DIS_HASH_SIZE 64 --#undef CGEN_DIS_HASH --#define CGEN_DIS_HASH(buffer, value) (((unsigned char *) (buffer))[0] >> 2) -- --extern long openrisc_sign_extend_16bit (long); --/* -- */ -- --/* -- opc.c */ --/* -- */ -- --/* -- asm.c */ -- --static const char * MISSING_CLOSING_PARENTHESIS = N_("missing `)'"); -- --#define CGEN_VERBOSE_ASSEMBLER_ERRORS -- --long --openrisc_sign_extend_16bit (long value) --{ -- return ((value & 0xffff) ^ 0x8000) - 0x8000; --} -- --/* Handle hi(). */ -- --static const char * --parse_hi16 (CGEN_CPU_DESC cd, const char ** strp, int opindex, long * valuep) --{ -- const char *errmsg; -- enum cgen_parse_operand_result result_type; -- unsigned long ret; -- -- if (**strp == '#') -- ++*strp; -- -- if (strncasecmp (*strp, "hi(", 3) == 0) -- { -- bfd_vma value; -- -- *strp += 3; -- errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_HI16, -- & result_type, & value); -- if (**strp != ')') -- return MISSING_CLOSING_PARENTHESIS; -- -- ++*strp; -- if (errmsg == NULL -- && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -- value >>= 16; -- ret = value; -- } -- else -- { -- if (**strp == '-') -- { -- long value; -- -- errmsg = cgen_parse_signed_integer (cd, strp, opindex, &value); -- ret = value; -- } -- else -- { -- unsigned long value; -- -- errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, &value); -- ret = value; -- } -- } -- -- *valuep = ((ret & 0xffff) ^ 0x8000) - 0x8000; -- return errmsg; --} -- --/* Handle lo(). */ -- --static const char * --parse_lo16 (CGEN_CPU_DESC cd, const char ** strp, int opindex, long * valuep) --{ -- const char *errmsg; -- enum cgen_parse_operand_result result_type; -- unsigned long ret; -- -- if (**strp == '#') -- ++*strp; -- -- if (strncasecmp (*strp, "lo(", 3) == 0) -- { -- bfd_vma value; -- -- *strp += 3; -- errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_LO16, -- & result_type, & value); -- if (**strp != ')') -- return MISSING_CLOSING_PARENTHESIS; -- -- ++*strp; -- ret = value; -- } -- else -- { -- if (**strp == '-') -- { -- long value; -- -- errmsg = cgen_parse_signed_integer (cd, strp, opindex, &value); -- ret = value; -- } -- else -- { -- unsigned long value; -- -- errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, &value); -- ret = value; -- } -- } -- -- *valuep = ((ret & 0xffff) ^ 0x8000) - 0x8000; -- return errmsg; --} -- --/* -- */ -- --/* -- ibd.h */ --extern long openrisc_sign_extend_16bit (long); -- --/* -- */ -diff -rNU3 dist.orig/cpu/or1k.cpu dist/cpu/or1k.cpu ---- dist.orig/cpu/or1k.cpu 1970-01-01 01:00:00.000000000 +0100 -+++ dist/cpu/or1k.cpu 2015-10-18 13:11:13.000000000 +0200 -@@ -0,0 +1,131 @@ -+; OpenRISC 1000 architecture. -*- Scheme -*- -+; Copyright 2000-2014 Free Software Foundation, Inc. -+; Contributed for OR32 by Johan Rydberg, jrydberg@opencores.org -+; Modified by Julius Baxter, juliusbaxter@gmail.com -+; Modified by Peter Gavin, pgavin@gmail.com -+; -+; This program is free software; you can redistribute it and/or modify -+; it under the terms of the GNU General Public License as published by -+; the Free Software Foundation; either version 3 of the License, or -+; (at your option) any later version. -+; -+; This program is distributed in the hope that it will be useful, -+; but WITHOUT ANY WARRANTY; without even the implied warranty of -+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+; GNU General Public License for more details. -+; -+; You should have received a copy of the GNU General Public License -+; along with this program; if not, see -+ -+(include "simplify.inc") -+ -+; The OpenRISC family is a set of RISC microprocessor architectures with an -+; emphasis on scalability and is targetted at embedded use. -+; The CPU RTL development is a collaborative open source effort. -+; http://opencores.org/or1k -+; http://openrisc.net -+ -+(define-arch -+ (name or1k) -+ (comment "OpenRISC 1000") -+ (default-alignment aligned) -+ (insn-lsb0? #t) -+ (machs or32 or32nd or64 or64nd) -+ (isas openrisc) -+) -+ -+; Instruction set parameters. -+(define-isa -+ ; Name of the ISA. -+ (name openrisc) -+ ; Base insturction length. The insns are always 32 bits wide. -+ (base-insn-bitsize 32) -+ ) -+ -+(define-pmacro OR32-MACHS or32,or32nd) -+(define-pmacro OR64-MACHS or64,or64nd) -+(define-pmacro ORBIS-MACHS or32,or32nd,or64,or64nd) -+(define-pmacro ORFPX-MACHS or32,or32nd,or64,or64nd) -+(define-pmacro ORFPX32-MACHS or32,or32nd,or64,or64nd) -+(define-pmacro ORFPX64-MACHS or64,or64nd) -+ -+(define-attr -+ (for model) -+ (type boolean) -+ (name NO-DELAY-SLOT) -+ (comment "does not have delay slots") -+ ) -+ -+(if (keep-mach? (or32 or32nd)) -+ (begin -+ (define-cpu -+ (name or1k32bf) -+ (comment "OpenRISC 1000 32-bit CPU family") -+ (insn-endian big) -+ (data-endian big) -+ (word-bitsize 32) -+ (file-transform "") -+ ) -+ -+ (define-mach -+ (name or32) -+ (comment "Generic OpenRISC 1000 32-bit CPU") -+ (cpu or1k32bf) -+ (bfd-name "or1k") -+ ) -+ -+ (define-mach -+ (name or32nd) -+ (comment "Generic OpenRISC 1000 32-bit CPU") -+ (cpu or1k32bf) -+ (bfd-name "or1knd") -+ ) -+ -+ ; OpenRISC 1200 - 32-bit or1k CPU implementation -+ (define-model -+ (name or1200) (comment "OpenRISC 1200 model") -+ (attrs) -+ (mach or32) -+ (unit u-exec "Execution Unit" () 1 1 () () () ()) -+ ) -+ -+ ; OpenRISC 1200 - 32-bit or1k CPU implementation -+ (define-model -+ (name or1200nd) (comment "OpenRISC 1200 model") -+ (attrs NO-DELAY-SLOT) -+ (mach or32nd) -+ (unit u-exec "Execution Unit" () 1 1 () () () ()) -+ ) -+ ) -+ ) -+ -+(if (keep-mach? (or64 or64nd)) -+ (begin -+ (define-cpu -+ (name or1k64bf) -+ (comment "OpenRISC 1000 64-bit CPU family") -+ (insn-endian big) -+ (data-endian big) -+ (word-bitsize 64) -+ (file-transform "64") -+ ) -+ -+ (define-mach -+ (name or64) -+ (comment "Generic OpenRISC 1000 64-bit CPU") -+ (cpu or1k64bf) -+ (bfd-name "or1k64") -+ ) -+ -+ (define-mach -+ (name or64nd) -+ (comment "Generic OpenRISC 1000 ND 64-bit CPU") -+ (cpu or1k64bf) -+ (bfd-name "or1k64nd") -+ ) -+ ) -+ ) -+ -+(include "or1kcommon.cpu") -+(include "or1korbis.cpu") -+(include "or1korfpx.cpu") -diff -rNU3 dist.orig/cpu/or1k.opc dist/cpu/or1k.opc ---- dist.orig/cpu/or1k.opc 1970-01-01 01:00:00.000000000 +0100 -+++ dist/cpu/or1k.opc 2015-10-18 13:11:13.000000000 +0200 -@@ -0,0 +1,421 @@ -+/* OpenRISC 1000 opcode support. -*- C -*- -+ Copyright 2000-2014 Free Software Foundation, Inc. -+ -+ Originally ontributed for OR32 by Red Hat Inc; -+ -+ This file is part of the GNU Binutils. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, see . */ -+ -+/* This file is an addendum to or1k.cpu. Heavy use of C code isn't -+ appropriate in .cpu files, so it resides here. This especially applies -+ to assembly/disassembly where parsing/printing can be quite involved. -+ Such things aren't really part of the specification of the cpu, per se, -+ so .cpu files provide the general framework and .opc files handle the -+ nitty-gritty details as necessary. -+ -+ Each section is delimited with start and end markers. -+ -+ -opc.h additions use: "-- opc.h" -+ -opc.c additions use: "-- opc.c" -+ -asm.c additions use: "-- asm.c" -+ -dis.c additions use: "-- dis.c" -+ -ibd.h additions use: "-- ibd.h" */ -+ -+/* -- opc.h */ -+ -+#undef CGEN_DIS_HASH_SIZE -+#define CGEN_DIS_HASH_SIZE 256 -+#undef CGEN_DIS_HASH -+#define CGEN_DIS_HASH(buffer, value) (((unsigned char *) (buffer))[0] >> 2) -+ -+/* -- */ -+ -+/* -- opc.c */ -+/* -- */ -+ -+/* -- asm.c */ -+ -+static const char * MISSING_CLOSING_PARENTHESIS = N_("missing `)'"); -+ -+#define CGEN_VERBOSE_ASSEMBLER_ERRORS -+ -+static const char * -+parse_disp26 (CGEN_CPU_DESC cd, -+ const char ** strp, -+ int opindex, -+ int opinfo, -+ enum cgen_parse_operand_result * resultp, -+ bfd_vma * valuep) -+{ -+ const char *errmsg = NULL; -+ enum cgen_parse_operand_result result_type; -+ -+ if (strncasecmp (*strp, "plt(", 4) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 4; -+ errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_OR1K_PLT26, -+ & result_type, & value); -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ value = (value >> 2) & 0xffff; -+ *valuep = value; -+ return errmsg; -+ } -+ return cgen_parse_address (cd, strp, opindex, opinfo, resultp, valuep); -+} -+ -+static const char * -+parse_simm16 (CGEN_CPU_DESC cd, const char ** strp, int opindex, long * valuep) -+{ -+ const char *errmsg; -+ enum cgen_parse_operand_result result_type; -+ long ret; -+ -+ if (**strp == '#') -+ ++*strp; -+ -+ if (strncasecmp (*strp, "hi(", 3) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 3; -+ errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_HI16, -+ & result_type, & value); -+ if (**strp != ')') -+ errmsg = MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ -+ ret = value; -+ -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ { -+ ret >>= 16; -+ ret &= 0xffff; -+ ret = (ret ^ 0x8000) - 0x8000; -+ } -+ } -+ else if (strncasecmp (*strp, "lo(", 3) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 3; -+ errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_LO16, -+ & result_type, & value); -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ -+ ret = value; -+ -+ if (result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ { -+ ret &= 0xffff; -+ ret = (ret ^ 0x8000) - 0x8000; -+ } -+ } -+ else if (strncasecmp (*strp, "got(", 4) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 4; -+ errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_OR1K_GOT16, -+ & result_type, & value); -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ value &= 0xffff; -+ *valuep = value; -+ return errmsg; -+ } -+ else if (strncasecmp (*strp, "gotpchi(", 8) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 8; -+ errmsg = cgen_parse_address (cd, strp, opindex, -+ BFD_RELOC_OR1K_GOTPC_HI16, -+ & result_type, & value); -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ value = (value >> 16) & 0xffff; -+ *valuep = value; -+ return errmsg; -+ } -+ else if (strncasecmp (*strp, "gotpclo(", 8) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 8; -+ errmsg = cgen_parse_address (cd, strp, opindex, -+ BFD_RELOC_OR1K_GOTPC_LO16, -+ &result_type, &value); -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ value &= 0xffff; -+ *valuep = value; -+ return errmsg; -+ } -+ else if (strncasecmp (*strp, "gotoffhi(", 9) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 9; -+ errmsg = cgen_parse_address (cd, strp, opindex, -+ BFD_RELOC_OR1K_GOTOFF_HI16, -+ & result_type, & value); -+ -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ value = (value >> 16) & 0xffff; -+ *valuep = value; -+ return errmsg; -+ } -+ else if (strncasecmp (*strp, "gotofflo(", 9) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 9; -+ errmsg = cgen_parse_address (cd, strp, opindex, -+ BFD_RELOC_OR1K_GOTOFF_LO16, -+ &result_type, &value); -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ value &= 0xffff; -+ *valuep = value; -+ return errmsg; -+ } -+ else if (strncasecmp (*strp, "tlsgdhi(", 8) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 8; -+ errmsg = cgen_parse_address (cd, strp, opindex, -+ BFD_RELOC_OR1K_TLS_GD_HI16, -+ & result_type, & value); -+ -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ value = (value >> 16) & 0xffff; -+ *valuep = value; -+ return errmsg; -+ } -+ else if (strncasecmp (*strp, "tlsgdlo(", 8) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 8; -+ errmsg = cgen_parse_address (cd, strp, opindex, -+ BFD_RELOC_OR1K_TLS_GD_LO16, -+ &result_type, &value); -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ value &= 0xffff; -+ *valuep = value; -+ return errmsg; -+ } -+ else if (strncasecmp (*strp, "tlsldmhi(", 9) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 9; -+ errmsg = cgen_parse_address (cd, strp, opindex, -+ BFD_RELOC_OR1K_TLS_LDM_HI16, -+ & result_type, & value); -+ -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ value = (value >> 16) & 0xffff; -+ *valuep = value; -+ return errmsg; -+ } -+ else if (strncasecmp (*strp, "tlsldmlo(", 9) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 9; -+ errmsg = cgen_parse_address (cd, strp, opindex, -+ BFD_RELOC_OR1K_TLS_LDM_LO16, -+ &result_type, &value); -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ value &= 0xffff; -+ *valuep = value; -+ return errmsg; -+ } -+ else if (strncasecmp (*strp, "dtpoffhi(", 9) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 9; -+ errmsg = cgen_parse_address (cd, strp, opindex, -+ BFD_RELOC_OR1K_TLS_LDO_HI16, -+ & result_type, & value); -+ -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ value = (value >> 16) & 0xffff; -+ *valuep = value; -+ return errmsg; -+ } -+ else if (strncasecmp (*strp, "dtpofflo(", 9) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 9; -+ errmsg = cgen_parse_address (cd, strp, opindex, -+ BFD_RELOC_OR1K_TLS_LDO_LO16, -+ &result_type, &value); -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ value &= 0xffff; -+ *valuep = value; -+ return errmsg; -+ } -+ else if (strncasecmp (*strp, "gottpoffhi(", 11) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 11; -+ errmsg = cgen_parse_address (cd, strp, opindex, -+ BFD_RELOC_OR1K_TLS_IE_HI16, -+ & result_type, & value); -+ -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ value = (value >> 16) & 0xffff; -+ *valuep = value; -+ return errmsg; -+ } -+ else if (strncasecmp (*strp, "gottpofflo(", 11) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 11; -+ errmsg = cgen_parse_address (cd, strp, opindex, -+ BFD_RELOC_OR1K_TLS_IE_LO16, -+ &result_type, &value); -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ value &= 0xffff; -+ *valuep = value; -+ return errmsg; -+ } -+ else if (strncasecmp (*strp, "tpoffhi(", 8) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 8; -+ errmsg = cgen_parse_address (cd, strp, opindex, -+ BFD_RELOC_OR1K_TLS_LE_HI16, -+ & result_type, & value); -+ -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ value = (value >> 16) & 0xffff; -+ *valuep = value; -+ return errmsg; -+ } -+ else if (strncasecmp (*strp, "tpofflo(", 8) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 8; -+ errmsg = cgen_parse_address (cd, strp, opindex, -+ BFD_RELOC_OR1K_TLS_LE_LO16, -+ &result_type, &value); -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ value &= 0xffff; -+ *valuep = value; -+ return errmsg; -+ } -+ else -+ { -+ long value; -+ errmsg = cgen_parse_signed_integer (cd, strp, opindex, &value); -+ ret = value; -+ } -+ -+ if (errmsg == NULL) -+ *valuep = ret; -+ -+ return errmsg; -+} -+ -+static const char * -+parse_uimm16 (CGEN_CPU_DESC cd, const char ** strp, int opindex, unsigned long * valuep) -+{ -+ const char *errmsg = parse_simm16(cd, strp, opindex, (long *) valuep); -+ -+ if (errmsg == NULL) -+ *valuep &= 0xffff; -+ return errmsg; -+} -+ -+/* -- */ -+ -+/* -- ibd.h */ -+ -+/* -- */ -diff -rNU3 dist.orig/cpu/or1kcommon.cpu dist/cpu/or1kcommon.cpu ---- dist.orig/cpu/or1kcommon.cpu 1970-01-01 01:00:00.000000000 +0100 -+++ dist/cpu/or1kcommon.cpu 2015-10-18 13:11:13.000000000 +0200 -@@ -0,0 +1,360 @@ -+; OpenRISC 1000 32-bit CPU hardware description. -*- Scheme -*- -+; Copyright 2000-2014 Free Software Foundation, Inc. -+; Contributed for OR32 by Johan Rydberg, jrydberg@opencores.org -+; Modified by Julius Baxter, juliusbaxter@gmail.com -+; -+; This program is free software; you can redistribute it and/or modify -+; it under the terms of the GNU General Public License as published by -+; the Free Software Foundation; either version 3 of the License, or -+; (at your option) any later version. -+; -+; This program is distributed in the hope that it will be useful, -+; but WITHOUT ANY WARRANTY; without even the implied warranty of -+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+; GNU General Public License for more details. -+; -+; You should have received a copy of the GNU General Public License -+; along with this program; if not, see -+ -+; Hardware pieces. -+; These entries list the elements of the raw hardware. -+; They're also used to provide tables and other elements of the assembly -+; language. -+ -+(define-hardware -+ (name h-pc) -+ (comment "program counter") -+ (attrs PC (MACH ORBIS-MACHS)) -+ (type pc UWI) -+ ) -+ -+(define-pmacro REG-INDICES -+ ((r0 0) -+ (r1 1) -+ (r2 2) -+ (r3 3) -+ (r4 4) -+ (r5 5) -+ (r6 6) -+ (r7 7) -+ (r8 8) -+ (r9 9) -+ (r10 10) -+ (r11 11) -+ (r12 12) -+ (r13 13) -+ (r14 14) -+ (r15 15) -+ (r16 16) -+ (r17 17) -+ (r18 18) -+ (r19 19) -+ (r20 20) -+ (r21 21) -+ (r22 22) -+ (r23 23) -+ (r24 24) -+ (r25 25) -+ (r26 26) -+ (r27 27) -+ (r28 28) -+ (r29 29) -+ (r30 30) -+ (r31 31) -+ (lr 9) -+ (sp 1) -+ (fp 2)) -+ ) -+ -+(define-hardware -+ (name h-fsr) -+ (comment "floating point registers (single, virtual)") -+ (attrs VIRTUAL (MACH ORFPX32-MACHS)) -+ (type register SF (32)) -+ (indices keyword "" REG-INDICES) -+ (get (index) (subword SF (trunc SI (reg h-gpr index)) 0)) -+ (set (index newval) (set UWI (reg h-gpr index) (zext UWI (subword SI newval 0)))) -+ ) -+ -+(define-hardware -+ (name h-fdr) (comment "floating point registers (double, virtual)") -+ (attrs VIRTUAL (MACH ORFPX64-MACHS)) -+ (type register DF (32)) -+ (indices keyword "" REG-INDICES) -+ (get (index) (subword DF (trunc DI (reg h-gpr index)) 0)) -+ (set (index newval) (set UDI (reg h-gpr index) (zext UDI (subword DI newval 0)))) -+ ) -+ -+(define-hardware -+ (name h-spr) (comment "special purpose registers") -+ (attrs VIRTUAL (MACH ORBIS-MACHS)) -+ (type register UWI (#x20000)) -+ (get (index) (c-call UWI "@cpu@_h_spr_get_raw" index)) -+ (set (index newval) (c-call VOID "@cpu@_h_spr_set_raw" index newval)) -+) -+ -+(define-pmacro spr-shift 11) -+(define-pmacro (spr-address spr-group spr-index) -+ (or (sll UWI (enum UWI (.sym "SPR-GROUP-" spr-group)) spr-shift) -+ (enum UWI (.sym "SPR-INDEX-" spr-group "-" spr-index)))) -+ -+(define-hardware -+ (name h-gpr) (comment "general registers") -+ (attrs (MACH ORBIS-MACHS)) -+ (type register UWI (32)) -+ (indices keyword "" REG-INDICES) -+ (get (index) (reg UWI h-spr (add index (spr-address SYS GPR0)))) -+ (set (index newval) (set UWI (reg UWI h-spr (add index (spr-address SYS GPR0))) newval)) -+ ) -+ -+(define-normal-enum -+ except-number -+ "Exception numbers" -+ () -+ EXCEPT- -+ (("NONE" #x00) -+ ("RESET" #x01) -+ ("BUSERR" #x02) -+ ("DPF" #x03) -+ ("IPF" #x04) -+ ("TICK" #x05) -+ ("ALIGN" #x06) -+ ("ILLEGAL" #x07) -+ ("INT" #x08) -+ ("DTLBMISS" #x09) -+ ("ITLBMISS" #x0a) -+ ("RANGE" #x0b) -+ ("SYSCALL" #x0c) -+ ("FPE" #x0d) -+ ("TRAP" #x0e) -+ ) -+ ) -+ -+(define-pmacro (raise-exception exnum) -+ (c-call VOID "@cpu@_exception" pc exnum)) -+ -+(define-normal-enum -+ spr-groups -+ "special purpose register groups" -+ () -+ SPR-GROUP- -+ (("SYS" #x0) -+ ("DMMU" #x1) -+ ("IMMU" #x2) -+ ("DCACHE" #x3) -+ ("ICACHE" #x4) -+ ("MAC" #x5) -+ ("DEBUG" #x6) -+ ("PERF" #x7) -+ ("POWER" #x8) -+ ("PIC" #x9) -+ ("TICK" #xa) -+ ("FPU" #xb) -+ ) -+ ) -+ -+(define-pmacro (spr-reg-info) -+ (.splice -+ (SYS VR #x000 "version register") -+ (SYS UPR #x001 "unit present register") -+ (SYS CPUCFGR #x002 "cpu configuration register") -+ (SYS DMMUCFGR #x003 "Data MMU configuration register") -+ (SYS IMMUCFGR #x004 "Insn MMU configuration register") -+ (SYS DCCFGR #x005 "Data cache configuration register") -+ (SYS ICCFGR #x006 "Insn cache configuration register") -+ (SYS DCFGR #x007 "Debug configuration register") -+ (SYS PCCFGR #x008 "Performance counters configuration register") -+ (SYS NPC #x010 "Next program counter") -+ (SYS SR #x011 "Supervision Regsiter") -+ (SYS PPC #x012 "Previous program counter") -+ (SYS FPCSR #x014 "Floating point control status register") -+ (.unsplice -+ (.map (.pmacro (n) (.splice SYS (.sym "EPCR" n) (.add n #x20) (.str "Exception PC register " n))) -+ (.iota #x10))) -+ (.unsplice -+ (.map (.pmacro (n) (.splice SYS (.sym "EEAR" n) (.add n #x30) (.str "Exception effective address register " n))) -+ (.iota #x10))) -+ (.unsplice -+ (.map (.pmacro (n) (.splice SYS (.sym "ESR" n) (.add n #x40) (.str "Exception supervision register " n))) -+ (.iota #x10))) -+ (.unsplice -+ (.map (.pmacro (n) (.splice SYS (.sym "GPR" n) (.add n #x400) (.str "General purpose register " n))) -+ (.iota #x200))) -+ -+ (MAC MACLO #x001 "Multiply and accumulate result (low)") -+ (MAC MACHI #x002 "Multiply and accumulate result (high)") -+ (TICK TTMR #x000 "Tick timer mode register") -+ ) -+ ) -+ -+(define-normal-enum -+ spr-reg-indices -+ "special purpose register indicies" -+ () -+ SPR-INDEX- -+ (.map (.pmacro (args) -+ (.apply (.pmacro (group index n comment) -+ ((.sym group "-" index) n)) -+ args) -+ ) -+ (spr-reg-info) -+ ) -+ ) -+ -+(define-pmacro (define-h-spr-reg spr-group spr-index n spr-comment) -+ (define-hardware -+ (name (.sym "h-" (.downcase spr-group) "-" (.downcase spr-index))) -+ (comment spr-comment) -+ (attrs VIRTUAL (MACH ORBIS-MACHS)) -+ (type register UWI) -+ (get () (reg UWI h-spr (spr-address spr-group spr-index))) -+ (set (newval) (set (reg UWI h-spr (spr-address spr-group spr-index)) newval)) -+ ) -+ ) -+(.splice begin (.unsplice (.map (.pmacro (args) (.apply define-h-spr-reg args)) (spr-reg-info)))) -+ -+(define-pmacro (spr-field-info) -+ ((SYS VR REV 5 0 "revision field") -+ (SYS VR CFG 23 16 "configuration template field") -+ (SYS VR VER 31 24 "version field") -+ (SYS UPR UP 0 0 "UPR present bit") -+ (SYS UPR DCP 1 1 "data cache present bit") -+ (SYS UPR ICP 2 2 "insn cache present bit") -+ (SYS UPR DMP 3 3 "data MMU present bit") -+ (SYS UPR MP 4 4 "MAC unit present bit") -+ (SYS UPR IMP 5 5 "insn MMU present bit") -+ (SYS UPR DUP 6 6 "debug unit present bit") -+ (SYS UPR PCUP 7 7 "performance counters unit present bit") -+ (SYS UPR PICP 8 8 "programmable interrupt controller present bit") -+ (SYS UPR PMP 9 9 "power management present bit") -+ (SYS UPR TTP 10 10 "tick timer present bit") -+ (SYS UPR CUP 31 24 "custom units present field") -+ (SYS CPUCFGR NSGR 3 0 "number of shadow GPR files field") -+ (SYS CPUCFGR CGF 4 4 "custom GPR file bit") -+ (SYS CPUCFGR OB32S 5 5 "ORBIS32 supported bit") -+ (SYS CPUCFGR OB64S 6 6 "ORBIS64 supported bit") -+ (SYS CPUCFGR OF32S 7 7 "ORFPX32 supported bit") -+ (SYS CPUCFGR OF64S 8 8 "ORFPX64 supported bit") -+ (SYS CPUCFGR OV64S 9 9 "ORVDX64 supported bit") -+ (SYS CPUCFGR ND 10 10 "no transfer delay bit") -+ (SYS SR SM 0 0 "supervisor mode bit") -+ (SYS SR TEE 1 1 "tick timer exception enabled bit") -+ (SYS SR IEE 2 2 "interrupt exception enabled bit") -+ (SYS SR DCE 3 3 "data cache enabled bit") -+ (SYS SR ICE 4 4 "insn cache enabled bit") -+ (SYS SR DME 5 5 "data MMU enabled bit") -+ (SYS SR IME 6 6 "insn MMU enabled bit") -+ (SYS SR LEE 7 7 "little endian enabled bit") -+ (SYS SR CE 8 8 "CID enable bit") -+ (SYS SR F 9 9 "flag bit") -+ (SYS SR CY 10 10 "carry bit") -+ (SYS SR OV 11 11 "overflow bit") -+ (SYS SR OVE 12 12 "overflow exception enabled bit") -+ (SYS SR DSX 13 13 "delay slot exception bit") -+ (SYS SR EPH 14 14 "exception prefix high bit") -+ (SYS SR FO 15 15 "fixed one bit") -+ (SYS SR SUMRA 16 16 "SPRs user mode read access bit") -+ (SYS SR CID 31 28 "context ID field") -+ (SYS FPCSR FPEE 0 0 "floating point exceptions enabled bit") -+ (SYS FPCSR RM 2 1 "floating point rounding mode field") -+ (SYS FPCSR OVF 3 3 "floating point overflow flag bit") -+ (SYS FPCSR UNF 4 4 "floating point underflow bit") -+ (SYS FPCSR SNF 5 5 "floating point SNAN flag bit") -+ (SYS FPCSR QNF 6 6 "floating point QNAN flag bit") -+ (SYS FPCSR ZF 7 7 "floating point zero flag bit") -+ (SYS FPCSR IXF 8 8 "floating point inexact flag bit") -+ (SYS FPCSR IVF 9 9 "floating point invalid flag bit") -+ (SYS FPCSR INF 10 10 "floating point infinity flag bit") -+ (SYS FPCSR DZF 11 11 "floating point divide by zero flag bit") -+ ) -+ ) -+ -+(define-normal-enum -+ spr-field-msbs -+ "SPR field msb positions" -+ () -+ SPR-FIELD-MSB- -+ (.map (.pmacro (args) -+ (.apply (.pmacro (group index field msb lsb comment) -+ ((.sym group "-" index "-" field) msb) -+ ) -+ args -+ ) -+ ) -+ (spr-field-info) -+ ) -+ ) -+ -+(define-normal-enum -+ spr-field-lsbs -+ "SPR field lsb positions" -+ () -+ SPR-FIELD-SIZE- -+ (.map (.pmacro (args) -+ (.apply (.pmacro (group index field msb lsb comment) -+ ((.sym group "-" index "-" field) lsb) -+ ) -+ args -+ ) -+ ) -+ (spr-field-info) -+ ) -+ ) -+ -+(define-normal-enum -+ spr-field-masks -+ "SPR field masks" -+ () -+ SPR-FIELD-MASK- -+ (.map (.pmacro (args) -+ (.apply (.pmacro (group index field msb lsb comment) -+ (.splice (.str group "-" index "-" field) (.sll (.inv (.sll (.inv 0) (.add (.sub msb lsb) 1))) lsb)) -+ ) -+ args -+ ) -+ ) -+ (spr-field-info) -+ ) -+ ) -+ -+(define-pmacro (define-h-spr-field spr-group spr-index spr-field spr-field-msb spr-field-lsb spr-field-comment) -+ (.let ((spr-field-name (.sym "h-" (.downcase spr-group) "-" (.downcase spr-index) "-" (.downcase spr-field))) -+ ) -+ (begin -+ (define-hardware -+ (name spr-field-name) -+ (comment spr-field-comment) -+ (attrs VIRTUAL (MACH ORBIS-MACHS)) -+ (type register UWI) -+ (get () (c-call UWI "@cpu@_h_spr_field_get_raw" (spr-address spr-group spr-index) spr-field-msb spr-field-lsb)) -+ (set (value) (c-call VOID "@cpu@_h_spr_field_set_raw" (spr-address spr-group spr-index) spr-field-msb spr-field-lsb value)) -+ ) -+ ) -+ ) -+ ) -+(.splice begin (.unsplice (.map (.pmacro (args) (.apply define-h-spr-field args)) (spr-field-info)))) -+ -+(define-attr -+ (type boolean) -+ (for insn) -+ (name DELAYED-CTI) -+ (comment "delayed control transfer instruction") -+ (values #f #t) -+ (default #f) -+ ) -+ -+(define-attr -+ (for insn) -+ (type boolean) -+ (name NOT-IN-DELAY-SLOT) -+ (comment "instruction cannot be in delay slot") -+ (values #f #t) -+ (default #f) -+ ) -+ -+(define-attr -+ (for insn) -+ (type boolean) -+ (name FORCED-CTI) -+ (comment "instruction may forcefully transfer control (e.g., rfe)") -+ ) -diff -rNU3 dist.orig/cpu/or1korbis.cpu dist/cpu/or1korbis.cpu ---- dist.orig/cpu/or1korbis.cpu 1970-01-01 01:00:00.000000000 +0100 -+++ dist/cpu/or1korbis.cpu 2015-10-18 13:11:13.000000000 +0200 -@@ -0,0 +1,1145 @@ -+; OpenRISC Basic Instruction Set 32-bit (ORBIS) -*- Scheme -*- -+; Copyright 2000-2014 Free Software Foundation, Inc. -+; Contributed for OR32 by Johan Rydberg, jrydberg@opencores.org -+; Modified by Julius Baxter, juliusbaxter@gmail.com -+; Modified by Peter Gavin, pgavin@gmail.com -+; -+; This program is free software; you can redistribute it and/or modify -+; it under the terms of the GNU General Public License as published by -+; the Free Software Foundation; either version 3 of the License, or -+; (at your option) any later version. -+; -+; This program is distributed in the hope that it will be useful, -+; but WITHOUT ANY WARRANTY; without even the implied warranty of -+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+; GNU General Public License for more details. -+; -+; You should have received a copy of the GNU General Public License -+; along with this program; if not, see -+ -+; Instruction fields. -+ -+; Hardware for immediate operands -+(dnh h-simm16 "16-bit signed immediate" ((MACH ORBIS-MACHS)) (immediate (INT 16)) () () ()) -+(dnh h-uimm16 "16-bit unsigned immediate" () (immediate (UINT 16)) () () ()) -+(dnh h-uimm6 "6-bit unsigned immediate" () (immediate (UINT 6)) () () ()) -+ -+; Hardware for the (internal) atomic registers -+(dsh h-atomic-reserve "atomic reserve flag" () (register BI)) -+(dsh h-atomic-address "atomic reserve address" () (register SI)) -+ -+; Instruction classes. -+(dnf f-opcode "insn opcode" ((MACH ORBIS-MACHS)) 31 6) -+ -+; Register fields. -+(dnf f-r1 "r1" ((MACH ORBIS-MACHS)) 25 5) -+(dnf f-r2 "r2" ((MACH ORBIS-MACHS)) 20 5) -+(dnf f-r3 "r3" ((MACH ORBIS-MACHS)) 15 5) -+ -+; Sub fields -+(dnf f-op-25-2 "op-25-2" ((MACH ORBIS-MACHS)) 25 2) ;; nop -+(dnf f-op-25-5 "op-25-5" ((MACH ORBIS-MACHS)) 25 5) ;; sys, trap, *sync, sf* -+(dnf f-op-16-1 "op-16-1" ((MACH ORBIS-MACHS)) 16 1) ;; movhi,macrc -+(dnf f-op-7-4 "op-7-4" ((MACH ORBIS-MACHS)) 7 4) -+(dnf f-op-3-4 "op-3-4" ((MACH ORBIS-MACHS)) 3 4) -+(dnf f-op-9-2 "op-9-2" ((MACH ORBIS-MACHS)) 9 2) ;; alu ops upper opcode -+(dnf f-op-9-4 "op-9-4" ((MACH ORBIS-MACHS)) 9 4) ;; -+(dnf f-op-7-8 "op-7-8" ((MACH ORBIS-MACHS)) 7 8) -+(dnf f-op-7-2 "op-7-2" ((MACH ORBIS-MACHS)) 7 2) ;; alu lower upper opc,shroti -+ -+; Reserved fields -+(dnf f-resv-25-26 "resv-25-26" ((MACH ORBIS-MACHS) RESERVED) 25 26) -+(dnf f-resv-25-10 "resv-25-10" ((MACH ORBIS-MACHS) RESERVED) 25 10) -+(dnf f-resv-25-5 "resv-25-5" ((MACH ORBIS-MACHS) RESERVED) 25 5) -+(dnf f-resv-23-8 "resv-23-8" ((MACH ORBIS-MACHS) RESERVED) 23 8) -+(dnf f-resv-20-21 "resv-20-21" ((MACH ORBIS-MACHS) RESERVED) 20 21) -+(dnf f-resv-20-5 "resv-20-5" ((MACH ORBIS-MACHS) RESERVED) 20 5) -+(dnf f-resv-20-4 "resv-20-4" ((MACH ORBIS-MACHS) RESERVED) 20 4) -+(dnf f-resv-15-8 "resv-15-8" ((MACH ORBIS-MACHS) RESERVED) 15 8) -+(dnf f-resv-15-6 "resv-15-6" ((MACH ORBIS-MACHS) RESERVED) 15 6) -+(dnf f-resv-10-11 "resv-10-11" ((MACH ORBIS-MACHS) RESERVED) 10 11) -+(dnf f-resv-10-7 "resv-10-7" ((MACH ORBIS-MACHS) RESERVED) 10 7) -+(dnf f-resv-10-3 "resv-10-3" ((MACH ORBIS-MACHS) RESERVED) 10 3) -+(dnf f-resv-10-1 "resv-10-1" ((MACH ORBIS-MACHS) RESERVED) 10 1) -+(dnf f-resv-7-4 "resv-7-4" ((MACH ORBIS-MACHS) RESERVED) 7 4) -+(dnf f-resv-5-2 "resv-5-2" ((MACH ORBIS-MACHS) RESERVED) 5 2) -+ -+(dnf f-imm16-25-5 "imm16-25-5" ((MACH ORBIS-MACHS)) 25 5) -+(dnf f-imm16-10-11 "imm16-10-11" ((MACH ORBIS-MACHS)) 10 11) -+ -+; PC relative, 26-bit (2 shifted to right) -+(df f-disp26 -+ "disp26" -+ ((MACH ORBIS-MACHS) PCREL-ADDR) -+ 25 -+ 26 -+ INT -+ ((value pc) (sra SI (sub IAI value pc) (const 2))) -+ ((value pc) (add IAI (sll IAI value (const 2)) pc)) -+ ) -+ -+; Immediates. -+(dnf f-uimm16 "uimm16" ((MACH ORBIS-MACHS)) 15 16) -+(df f-simm16 "simm16" ((MACH ORBIS-MACHS) SIGN-OPT) 15 16 INT #f #f) -+(dnf f-uimm6 "uimm6" ((MACH ORBIS-MACHS)) 5 6) ;; shroti -+ -+(define-multi-ifield -+ (name f-uimm16-split) -+ (comment "16-bit split unsigned immediate") -+ (attrs (MACH ORBIS-MACHS)) -+ (mode UINT) -+ (subfields f-imm16-25-5 f-imm16-10-11) -+ (insert (sequence () -+ (set (ifield f-imm16-25-5) -+ (and (srl (ifield f-uimm16-split) -+ (const 11)) -+ (const #x1f))) -+ (set (ifield f-imm16-10-11) -+ (and (ifield f-uimm16-split) -+ (const #x7ff))))) -+ (extract -+ (set (ifield f-uimm16-split) -+ (trunc UHI -+ (or (sll (ifield f-imm16-25-5) -+ (const 11)) -+ (ifield f-imm16-10-11))))) -+ ) -+ -+(define-multi-ifield -+ (name f-simm16-split) -+ (comment "16-bit split signed immediate") -+ (attrs (MACH ORBIS-MACHS) SIGN-OPT) -+ (mode INT) -+ (subfields f-imm16-25-5 f-imm16-10-11) -+ (insert (sequence () -+ (set (ifield f-imm16-25-5) -+ (and (sra (ifield f-simm16-split) -+ (const 11)) -+ (const #x1f))) -+ (set (ifield f-imm16-10-11) -+ (and (ifield f-simm16-split) -+ (const #x7ff))))) -+ (extract -+ (set (ifield f-simm16-split) -+ (trunc HI -+ (or (sll (ifield f-imm16-25-5) -+ (const 11)) -+ (ifield f-imm16-10-11))))) -+ ) -+ -+; Enums. -+ -+; insn-opcode: bits 31-26 -+(define-normal-insn-enum -+ insn-opcode "insn main opcode enums" ((MACH ORBIS-MACHS)) OPC_ f-opcode -+ (("J" #x00) -+ ("JAL" #x01) -+ ("BNF" #x03) -+ ("BF" #x04) -+ ("NOP" #x05) -+ ("MOVHIMACRC" #x06) -+ ("SYSTRAPSYNCS" #x08) -+ ("RFE" #x09) -+ ("VECTOR" #x0a) -+ ("JR" #x11) -+ ("JALR" #x12) -+ ("MACI" #x13) -+ ("LWA" #x1b) -+ ("CUST1" #x1c) -+ ("CUST2" #x1d) -+ ("CUST3" #x1e) -+ ("CUST4" #x1f) -+ ("LD" #x20) -+ ("LWZ" #x21) -+ ("LWS" #x22) -+ ("LBZ" #x23) -+ ("LBS" #x24) -+ ("LHZ" #x25) -+ ("LHS" #x26) -+ ("ADDI" #x27) -+ ("ADDIC" #x28) -+ ("ANDI" #x29) -+ ("ORI" #x2a) -+ ("XORI" #x2b) -+ ("MULI" #x2c) -+ ("MFSPR" #x2d) -+ ("SHROTI" #x2e) -+ ("SFI" #x2f) -+ ("MTSPR" #x30) -+ ("MAC" #x31) -+ ("FLOAT" #x32) -+ ("SWA" #x33) -+ ("SD" #x34) -+ ("SW" #x35) -+ ("SB" #x36) -+ ("SH" #x37) -+ ("ALU" #x38) -+ ("SF" #x39) -+ ("CUST5" #x3c) -+ ("CUST6" #x3d) -+ ("CUST7" #x3e) -+ ("CUST8" #x3f) -+ ) -+) -+ -+(define-normal-insn-enum insn-opcode-systrapsyncs -+ "systrapsync insn opcode enums" ((MACH ORBIS-MACHS)) -+ OPC_SYSTRAPSYNCS_ f-op-25-5 -+ (("SYSCALL" #x00 ) -+ ("TRAP" #x08 ) -+ ("MSYNC" #x10 ) -+ ("PSYNC" #x14 ) -+ ("CSYNC" #x18 ) -+ ) -+) -+ -+(define-normal-insn-enum insn-opcode-movehimacrc -+ "movhi/macrc insn opcode enums" ((MACH ORBIS-MACHS)) -+ OPC_MOVHIMACRC_ f-op-16-1 -+ (("MOVHI" #x0) -+ ("MACRC" #x1) -+ ) -+) -+ -+(define-normal-insn-enum insn-opcode-mac -+ "multiply/accumulate insn opcode enums" ((MACH ORBIS-MACHS)) -+ OPC_MAC_ f-op-3-4 -+ (("MAC" #x1) -+ ("MSB" #x2) -+ ) -+ ) -+ -+(define-normal-insn-enum insn-opcode-shorts -+ "shift/rotate insn opcode enums" ((MACH ORBIS-MACHS)) -+ OPC_SHROTS_ f-op-7-2 -+ (("SLL" #x0 ) -+ ("SRL" #x1 ) -+ ("SRA" #x2 ) -+ ("ROR" #x3 ) -+ ) -+) -+ -+(define-normal-insn-enum insn-opcode-extbhs -+ "extend byte/half opcode enums" ((MACH ORBIS-MACHS)) -+ OPC_EXTBHS_ f-op-9-4 -+ (("EXTHS" #x0) -+ ("EXTBS" #x1) -+ ("EXTHZ" #x2) -+ ("EXTBZ" #x3) -+ ) -+) -+ -+(define-normal-insn-enum insn-opcode-extws -+ "extend word opcode enums" ((MACH ORBIS-MACHS)) -+ OPC_EXTWS_ f-op-9-4 -+ (("EXTWS" #x0) -+ ("EXTWZ" #x1) -+ ) -+) -+ -+(define-normal-insn-enum insn-opcode-alu-regreg -+ "alu reg/reg insn opcode enums" ((MACH ORBIS-MACHS)) -+ OPC_ALU_REGREG_ f-op-3-4 -+ (("ADD" #x0) -+ ("ADDC" #x1) -+ ("SUB" #x2) -+ ("AND" #x3) -+ ("OR" #x4) -+ ("XOR" #x5) -+ ("MUL" #x6) -+ ("SHROT" #x8) -+ ("DIV" #x9) -+ ("DIVU" #xA) -+ ("MULU" #xB) -+ ("EXTBH" #xC) -+ ("EXTW" #xD) -+ ("CMOV" #xE) -+ ("FFL1" #xF) -+ ) -+) -+ -+(define-normal-insn-enum insn-opcode-setflag -+ "setflag insn opcode enums" ((MACH ORBIS-MACHS)) -+ OPC_SF_ f-op-25-5 -+ (("EQ" #x00) -+ ("NE" #x01) -+ ("GTU" #x02) -+ ("GEU" #x03) -+ ("LTU" #x04) -+ ("LEU" #x05) -+ ("GTS" #x0A) -+ ("GES" #x0B) -+ ("LTS" #x0C) -+ ("LES" #x0D) -+ ) -+) -+ -+ -+; Instruction operands. -+ -+(dnop sys-sr "supervision register" ((MACH ORBIS-MACHS) SEM-ONLY) h-sys-sr f-nil) -+(dnop sys-esr0 "exception supervision register 0" ((MACH ORBIS-MACHS) SEM-ONLY) h-sys-esr0 f-nil) -+(dnop sys-epcr0 "exception PC register 0" ((MACH ORBIS-MACHS) SEM-ONLY) h-sys-epcr0 f-nil) -+ -+(dnop sys-sr-lee "SR little endian enable bit" ((MACH ORBIS-MACHS) SEM-ONLY) h-sys-sr-lee f-nil) -+(dnop sys-sr-f "SR flag bit" ((MACH ORBIS-MACHS) SEM-ONLY) h-sys-sr-f f-nil) -+(dnop sys-sr-cy "SR carry bit" ((MACH ORBIS-MACHS) SEM-ONLY) h-sys-sr-cy f-nil) -+(dnop sys-sr-ov "SR overflow bit" ((MACH ORBIS-MACHS) SEM-ONLY) h-sys-sr-ov f-nil) -+(dnop sys-sr-ove "SR overflow exception enable bit" ((MACH ORBIS-MACHS) SEM-ONLY) h-sys-sr-ove f-nil) -+(dnop sys-cpucfgr-ob64s "CPUCFGR ORBIS64 supported bit" ((MACH ORBIS-MACHS) SEM-ONLY) h-sys-cpucfgr-ob64s f-nil) -+(dnop sys-cpucfgr-nd "CPUCFGR no delay bit" ((MACH ORBIS-MACHS) SEM-ONLY) h-sys-cpucfgr-nd f-nil) -+(dnop sys-fpcsr-rm "floating point round mode" ((MACH ORBIS-MACHS) SEM-ONLY) h-sys-fpcsr-rm f-nil) -+ -+(dnop mac-machi "MAC HI result register" ((MACH ORBIS-MACHS) SEM-ONLY) h-mac-machi f-nil) -+(dnop mac-maclo "MAC LO result register" ((MACH ORBIS-MACHS) SEM-ONLY) h-mac-maclo f-nil) -+ -+(dnop atomic-reserve "atomic reserve flag" ((MACH ORBIS-MACHS) SEM-ONLY) h-atomic-reserve f-nil) -+(dnop atomic-address "atomic address" ((MACH ORBIS-MACHS) SEM-ONLY) h-atomic-address f-nil) -+ -+(dnop uimm6 "uimm6" ((MACH ORBIS-MACHS)) h-uimm6 f-uimm6) -+ -+(dnop rD "destination register" ((MACH ORBIS-MACHS)) h-gpr f-r1) -+(dnop rA "source register A" ((MACH ORBIS-MACHS)) h-gpr f-r2) -+(dnop rB "source register B" ((MACH ORBIS-MACHS)) h-gpr f-r3) -+ -+(define-operand -+ (name disp26) -+ (comment "pc-rel 26 bit") -+ (attrs (MACH ORBIS-MACHS)) -+ (type h-iaddr) -+ (index f-disp26) -+ (handlers (parse "disp26")) -+ ) -+ -+(define-operand -+ (name simm16) -+ (comment "16-bit signed immediate") -+ (attrs (MACH ORBIS-MACHS) SIGN-OPT) -+ (type h-simm16) -+ (index f-simm16) -+ (handlers (parse "simm16")) -+ ) -+ -+(define-operand -+ (name uimm16) -+ (comment "16-bit unsigned immediate") -+ (attrs (MACH ORBIS-MACHS)) -+ (type h-uimm16) -+ (index f-uimm16) -+ (handlers (parse "uimm16")) -+ ) -+ -+(define-operand -+ (name simm16-split) -+ (comment "split 16-bit signed immediate") -+ (attrs (MACH ORBIS-MACHS) SIGN-OPT) -+ (type h-simm16) -+ (index f-simm16-split) -+ (handlers (parse "simm16")) -+) -+ -+(define-operand -+ (name uimm16-split) -+ (comment "split 16-bit unsigned immediate") -+ (attrs (MACH ORBIS-MACHS)) -+ (type h-uimm16) -+ (index f-uimm16-split) -+ (handlers (parse "uimm16")) -+) -+ -+; Instructions. -+ -+; Branch releated instructions -+ -+(define-pmacro (cti-link-return) -+ (set IAI (reg h-gpr 9) (add pc (if sys-cpucfgr-nd 4 8))) -+ ) -+(define-pmacro (cti-transfer-control condition target) -+ ;; this mess is necessary because we're -+ ;; skipping the delay slot, but it's -+ ;; actually the start of the next basic -+ ;; block -+ (sequence () -+ (if condition -+ (delay 1 (set IAI pc target)) -+ (if sys-cpucfgr-nd -+ (delay 1 (set IAI pc (add pc 4)))) -+ ) -+ (if sys-cpucfgr-nd -+ (skip 1) -+ ) -+ ) -+ ) -+ -+(define-pmacro -+ (define-cti -+ cti-name -+ cti-comment -+ cti-attrs -+ cti-syntax -+ cti-format -+ cti-semantics) -+ (begin -+ (dni -+ cti-name -+ cti-comment -+ (.splice (MACH ORBIS-MACHS) DELAYED-CTI NOT-IN-DELAY-SLOT (.unsplice cti-attrs)) -+ cti-syntax -+ cti-format -+ (cti-semantics) -+ () -+ ) -+ ) -+ ) -+ -+(define-cti -+ l-j -+ "jump (pc-relative iaddr)" -+ (!COND-CTI UNCOND-CTI) -+ "l.j ${disp26}" -+ (+ OPC_J disp26) -+ (.pmacro () -+ (cti-transfer-control 1 disp26) -+ ) -+ ) -+ -+(define-cti -+ l-jal -+ "jump and link (pc-relative iaddr)" -+ (!COND-CTI UNCOND-CTI) -+ "l.jal ${disp26}" -+ (+ OPC_JAL disp26) -+ (.pmacro () -+ (sequence () -+ (cti-link-return) -+ (cti-transfer-control 1 disp26) -+ ) -+ ) -+ ) -+ -+(define-cti -+ l-jr -+ "jump register (absolute iaddr)" -+ (!COND-CTI UNCOND-CTI) -+ "l.jr $rB" -+ (+ OPC_JR (f-resv-25-10 0) rB (f-resv-10-11 0)) -+ (.pmacro () -+ (cti-transfer-control 1 rB) -+ ) -+ ) -+ -+(define-cti -+ l-jalr -+ "jump register and link (absolute iaddr)" -+ (!COND-CTI UNCOND-CTI) -+ "l.jalr $rB" -+ (+ OPC_JALR (f-resv-25-10 0) rB (f-resv-10-11 0) ) -+ (.pmacro () -+ (sequence () -+ (cti-link-return) -+ (cti-transfer-control 1 rB) -+ ) -+ ) -+ ) -+ -+(define-cti -+ l-bnf -+ "branch if condition bit not set (pc relative iaddr)" -+ (COND-CTI !UNCOND-CTI) -+ "l.bnf ${disp26}" -+ (+ OPC_BNF disp26) -+ (.pmacro () -+ (cti-transfer-control (not sys-sr-f) disp26) -+ ) -+ ) -+ -+(define-cti -+ l-bf -+ "branch if condition bit set (pc relative iaddr)" -+ (COND-CTI !UNCOND-CTI) -+ "l.bf ${disp26}" -+ (+ OPC_BF disp26) -+ (.pmacro () -+ (cti-transfer-control sys-sr-f disp26) -+ ) -+ ) -+ -+(dni l-trap "trap (exception)" -+ ((MACH ORBIS-MACHS) NOT-IN-DELAY-SLOT) -+ "l.trap ${uimm16}" -+ (+ OPC_SYSTRAPSYNCS OPC_SYSTRAPSYNCS_TRAP (f-resv-20-5 0) uimm16) -+ ; Do exception entry handling in C function, PC set based on SR state -+ (raise-exception EXCEPT-TRAP) -+ () -+) -+ -+ -+(dni l-sys "syscall (exception)" -+ ; This function may not be in delay slot -+ ((MACH ORBIS-MACHS) NOT-IN-DELAY-SLOT) -+ -+ "l.sys ${uimm16}" -+ (+ OPC_SYSTRAPSYNCS OPC_SYSTRAPSYNCS_SYSCALL (f-resv-20-5 0) uimm16) -+ ; Do exception entry handling in C function, PC set based on SR state -+ (raise-exception EXCEPT-SYSCALL) -+ () -+) -+ -+(dni l-msync "memory sync" -+ ((MACH ORBIS-MACHS)) -+ "l.msync" -+ (+ OPC_SYSTRAPSYNCS OPC_SYSTRAPSYNCS_MSYNC (f-resv-20-21 0)) -+ (nop) -+ () -+) -+ -+(dni l-psync "pipeline sync" -+ ((MACH ORBIS-MACHS)) -+ "l.psync" -+ (+ OPC_SYSTRAPSYNCS OPC_SYSTRAPSYNCS_PSYNC (f-resv-20-21 0)) -+ (nop) -+ () -+) -+ -+(dni l-csync "context sync" -+ ((MACH ORBIS-MACHS)) -+ "l.csync" -+ (+ OPC_SYSTRAPSYNCS OPC_SYSTRAPSYNCS_CSYNC (f-resv-20-21 0)) -+ (nop) -+ () -+) -+ -+(dni l-rfe "return from exception" -+ ; This function may not be in delay slot -+ ((MACH ORBIS-MACHS) NOT-IN-DELAY-SLOT FORCED-CTI) -+ -+ "l.rfe" -+ (+ OPC_RFE (f-resv-25-26 0)) -+ (c-call VOID "@cpu@_rfe") -+ () -+) -+ -+ -+; Misc instructions -+ -+; l.nop with immediate must be first so it handles all l.nops in sim -+(dni l-nop-imm "nop uimm16" -+ ((MACH ORBIS-MACHS)) -+ "l.nop ${uimm16}" -+ (+ OPC_NOP (f-op-25-2 #x1) (f-resv-23-8 0) uimm16) -+ (c-call VOID "@cpu@_nop" (zext UWI uimm16)) -+ () -+ ) -+ -+(if (application-is? SIMULATOR) -+ (begin) -+ (begin -+ (dni l-nop "nop" -+ ((MACH ORBIS-MACHS)) -+ "l.nop" -+ (+ OPC_NOP (f-op-25-2 #x1) (f-resv-23-8 0) uimm16) -+ (nop) -+ () -+ ) -+ ) -+) -+ -+(dni l-movhi "movhi reg/uimm16" -+ ((MACH ORBIS-MACHS)) -+ "l.movhi $rD,$uimm16" -+ (+ OPC_MOVHIMACRC rD (f-resv-20-4 0) OPC_MOVHIMACRC_MOVHI uimm16) -+ (set UWI rD (sll UWI (zext UWI uimm16) (const 16))) -+ () -+) -+ -+(dni l-macrc "macrc reg" -+ ((MACH ORBIS-MACHS)) -+ "l.macrc $rD" -+ (+ OPC_MOVHIMACRC rD (f-resv-20-4 0) OPC_MOVHIMACRC_MACRC (f-uimm16 0)) -+ (sequence () -+ (set UWI rD mac-maclo) -+ (set UWI mac-maclo 0) -+ (set UWI mac-machi 0) -+ ) -+ () -+ ) -+ -+ -+; System releated instructions -+ -+(dni l-mfspr "mfspr" -+ ((MACH ORBIS-MACHS)) -+ "l.mfspr $rD,$rA,${uimm16}" -+ (+ OPC_MFSPR rD rA uimm16) -+ (set UWI rD (c-call UWI "@cpu@_mfspr" (or rA (zext UWI uimm16)))) -+ () -+) -+ -+(dni l-mtspr "mtspr" -+ ((MACH ORBIS-MACHS)) -+ "l.mtspr $rA,$rB,${uimm16-split}" -+ (+ OPC_MTSPR rA rB uimm16-split ) -+ (c-call VOID "@cpu@_mtspr" (or rA (zext WI uimm16-split)) rB) -+ () -+) -+ -+ -+; Load instructions -+(define-pmacro (load-store-addr base offset size) -+ (c-call AI "@cpu@_make_load_store_addr" base (ext SI offset) size)) -+ -+(dni l-lwz "l.lwz reg/simm16(reg)" -+ ((MACH ORBIS-MACHS)) -+ "l.lwz $rD,${simm16}($rA)" -+ (+ OPC_LWZ rD rA simm16) -+ (set UWI rD (zext UWI (mem USI (load-store-addr rA simm16 4)))) -+ () -+) -+ -+ -+(dni l-lws "l.lws reg/simm16(reg)" -+ ((MACH ORBIS-MACHS)) -+ "l.lws $rD,${simm16}($rA)" -+ (+ OPC_LWS rD rA simm16) -+ (set WI rD (ext WI (mem SI (load-store-addr rA simm16 4)))) -+ () -+) -+ -+(dni l-lwa "l.lwa reg/simm16(reg)" -+ ((MACH ORBIS-MACHS)) -+ "l.lwa $rD,${simm16}($rA)" -+ (+ OPC_LWA rD rA simm16) -+ (sequence () -+ (set UWI rD (zext UWI (mem USI (load-store-addr rA simm16 4)))) -+ (set atomic-reserve (const 1)) -+ (set atomic-address (load-store-addr rA simm16 4)) -+ ) -+ () -+) -+ -+(dni l-lbz "l.lbz reg/simm16(reg)" -+ ((MACH ORBIS-MACHS)) -+ "l.lbz $rD,${simm16}($rA)" -+ (+ OPC_LBZ rD rA simm16) -+ (set UWI rD (zext UWI (mem UQI (load-store-addr rA simm16 1)))) -+ () -+) -+ -+(dni l-lbs "l.lbs reg/simm16(reg)" -+ ((MACH ORBIS-MACHS)) -+ "l.lbs $rD,${simm16}($rA)" -+ (+ OPC_LBS rD rA simm16) -+ (set WI rD (ext WI (mem QI (load-store-addr rA simm16 1)))) -+ () -+) -+ -+(dni l-lhz "l.lhz reg/simm16(reg)" -+ ((MACH ORBIS-MACHS)) -+ "l.lhz $rD,${simm16}($rA)" -+ (+ OPC_LHZ rD simm16 rA) -+ (set UWI rD (zext UWI (mem UHI (load-store-addr rA simm16 2)))) -+ () -+) -+ -+(dni l-lhs "l.lhs reg/simm16(reg)" -+ ((MACH ORBIS-MACHS)) -+ "l.lhs $rD,${simm16}($rA)" -+ (+ OPC_LHS rD rA simm16) -+ (set WI rD (ext WI (mem HI (load-store-addr rA simm16 2)))) -+ () -+) -+ -+ -+; Store instructions -+ -+(define-pmacro (store-insn mnemonic opc-op mode size) -+ (begin -+ (dni (.sym l- mnemonic) -+ (.str "l." mnemonic " simm16(reg)/reg") -+ ((MACH ORBIS-MACHS)) -+ (.str "l." mnemonic " ${simm16-split}($rA),$rB") -+ (+ opc-op rA rB simm16-split) -+ (sequence ((SI addr)) -+ (set addr (load-store-addr rA simm16-split size)) -+ (set mode (mem mode addr) (trunc mode rB)) -+ (if (eq (and addr #xffffffc) atomic-address) -+ (set atomic-reserve (const 0)) -+ ) -+ ) -+ () -+ ) -+ ) -+) -+ -+(store-insn sw OPC_SW USI 4) -+(store-insn sb OPC_SB UQI 1) -+(store-insn sh OPC_SH UHI 2) -+ -+(dni l-swa "l.swa simm16(reg)/reg" -+ ((MACH ORBIS-MACHS)) -+ "l.swa ${simm16-split}($rA),$rB" -+ (+ OPC_SWA rA rB simm16) -+ (sequence ((SI addr) (BI flag)) -+ (set addr (load-store-addr rA simm16-split 4)) -+ (set sys-sr-f (and atomic-reserve (eq addr atomic-address))) -+ (if sys-sr-f -+ (set USI (mem USI addr) (trunc USI rB)) -+ ) -+ (set atomic-reserve (const 0)) -+ ) -+ () -+) -+ -+ -+; Shift and rotate instructions -+ -+(define-pmacro (shift-insn mnemonic) -+ (begin -+ (dni (.sym l- mnemonic) -+ (.str "l." mnemonic " reg/reg/reg") -+ ((MACH ORBIS-MACHS)) -+ (.str "l." mnemonic " $rD,$rA,$rB") -+ (+ OPC_ALU rD rA rB (f-resv-10-3 0) (.sym OPC_SHROTS_ (.upcase mnemonic)) (f-resv-5-2 0) -+ OPC_ALU_REGREG_SHROT ) -+ (set UWI rD (mnemonic rA rB)) -+ () -+ ) -+ (dni (.sym l- mnemonic "i") -+ (.str "l." mnemonic " reg/reg/uimm6") -+ ((MACH ORBIS-MACHS)) -+ (.str "l." mnemonic "i $rD,$rA,${uimm6}") -+ (+ OPC_SHROTI rD rA (f-resv-15-8 0) (.sym OPC_SHROTS_ (.upcase mnemonic)) uimm6) -+ (set rD (mnemonic rA uimm6)) -+ () -+ ) -+ ) -+) -+ -+(shift-insn sll) -+(shift-insn srl) -+(shift-insn sra) -+(shift-insn ror) -+ -+ -+; Arithmetic insns -+ -+; ALU op macro -+(define-pmacro (alu-insn mnemonic) -+ (begin -+ (dni (.sym l- mnemonic) -+ (.str "l." mnemonic " reg/reg/reg") -+ ((MACH ORBIS-MACHS)) -+ (.str "l." mnemonic " $rD,$rA,$rB") -+ (+ OPC_ALU rD rA rB (f-resv-10-7 0) (.sym OPC_ALU_REGREG_ (.upcase mnemonic))) -+ (set rD (mnemonic rA rB)) -+ () -+ ) -+ ) -+) -+ -+(alu-insn and) -+(alu-insn or) -+(alu-insn xor) -+ -+(define-pmacro (alu-carry-insn mnemonic) -+ (begin -+ (dni (.sym l- mnemonic) -+ (.str "l." mnemonic " reg/reg/reg") -+ ((MACH ORBIS-MACHS)) -+ (.str "l." mnemonic " $rD,$rA,$rB") -+ (+ OPC_ALU rD rA rB (f-resv-10-7 #x00) (.sym OPC_ALU_REGREG_ (.upcase mnemonic))) -+ (sequence () -+ (sequence () -+ (set BI sys-sr-cy ((.sym mnemonic "c-cflag") WI rA rB 0)) -+ (set BI sys-sr-ov ((.sym mnemonic "c-oflag") WI rA rB 0)) -+ (set rD (mnemonic WI rA rB)) -+ ) -+ (if (andif sys-sr-ov sys-sr-ove) -+ (raise-exception EXCEPT-RANGE)) -+ ) -+ () -+ ) -+ ) -+ ) -+ -+(alu-carry-insn add) -+(alu-carry-insn sub) -+ -+(dni (l-addc) "l.addc reg/reg/reg" -+ ((MACH ORBIS-MACHS)) -+ ("l.addc $rD,$rA,$rB") -+ (+ OPC_ALU rD rA rB (f-resv-10-7 #x00) OPC_ALU_REGREG_ADDC) -+ (sequence () -+ (sequence ((BI tmp-sys-sr-cy)) -+ (set BI tmp-sys-sr-cy sys-sr-cy) -+ (set BI sys-sr-cy (addc-cflag WI rA rB tmp-sys-sr-cy)) -+ (set BI sys-sr-ov (addc-oflag WI rA rB tmp-sys-sr-cy)) -+ (set rD (addc WI rA rB tmp-sys-sr-cy)) -+ ) -+ (if (andif sys-sr-ov sys-sr-ove) -+ (raise-exception EXCEPT-RANGE)) -+ ) -+ () -+) -+ -+(dni (l-mul) "l.mul reg/reg/reg" -+ ((MACH ORBIS-MACHS)) -+ ("l.mul $rD,$rA,$rB") -+ (+ OPC_ALU rD rA rB (f-resv-10-7 #x30) OPC_ALU_REGREG_MUL) -+ (sequence () -+ (sequence () -+ ; 2's complement overflow -+ (set BI sys-sr-ov (mul-o2flag WI rA rB)) -+ ; 1's complement overflow -+ (set BI sys-sr-cy (mul-o1flag WI rA rB)) -+ (set rD (mul WI rA rB)) -+ ) -+ (if (andif sys-sr-ov sys-sr-ove) -+ (raise-exception EXCEPT-RANGE)) -+ ) -+ () -+) -+ -+(dni (l-mulu) "l.mulu reg/reg/reg" -+ ((MACH ORBIS-MACHS)) -+ ("l.mulu $rD,$rA,$rB") -+ (+ OPC_ALU rD rA rB (f-resv-10-7 #x30) OPC_ALU_REGREG_MULU) -+ (sequence () -+ (sequence () -+ ; 2's complement overflow -+ (set BI sys-sr-ov 0) -+ ; 1's complement overflow -+ (set BI sys-sr-cy (mul-o1flag UWI rA rB)) -+ (set rD (mul UWI rA rB)) -+ ) -+ (if (andif sys-sr-ov sys-sr-ove) -+ (raise-exception EXCEPT-RANGE)) -+ ) -+ () -+) -+ -+(dni l-div "divide (signed)" -+ ((MACH ORBIS-MACHS)) -+ "l.div $rD,$rA,$rB" -+ (+ OPC_ALU rD rA rB (f-resv-10-7 #x30) OPC_ALU_REGREG_DIV) -+ (sequence () -+ (if (ne rB 0) -+ (sequence () -+ (set BI sys-sr-cy 0) -+ (set WI rD (div WI rA rB)) -+ ) -+ (set BI sys-sr-cy 1) -+ ) -+ (set BI sys-sr-ov 0) -+ (if (andif sys-sr-cy sys-sr-ove) -+ (raise-exception EXCEPT-RANGE)) -+ ) -+ () -+) -+ -+(dni l-divu "divide (unsigned)" -+ ((MACH ORBIS-MACHS)) -+ "l.divu $rD,$rA,$rB" -+ (+ OPC_ALU rD rA rB (f-resv-10-7 #x30) OPC_ALU_REGREG_DIVU) -+ (sequence () -+ (if (ne rB 0) -+ (sequence () -+ (set BI sys-sr-cy 0) -+ (set rD (udiv UWI rA rB)) -+ ) -+ (set BI sys-sr-cy 1) -+ ) -+ (set BI sys-sr-ov 0) -+ (if (andif sys-sr-cy sys-sr-ove) -+ (raise-exception EXCEPT-RANGE)) -+ ) -+ () -+) -+ -+(dni l-ff1 "find first '1'" -+ ((MACH ORBIS-MACHS)) -+ "l.ff1 $rD,$rA" -+ (+ OPC_ALU rD rA rB (f-resv-10-7 #x00) OPC_ALU_REGREG_FFL1) -+ (set rD (c-call UWI "@cpu@_ff1" rA)) -+ () -+) -+ -+(dni l-fl1 "find last '1'" -+ ((MACH ORBIS-MACHS)) -+ "l.fl1 $rD,$rA" -+ (+ OPC_ALU rD rA rB (f-resv-10-7 #x10) OPC_ALU_REGREG_FFL1) -+ (set rD (c-call UWI "@cpu@_fl1" rA)) -+ () -+) -+ -+ -+(define-pmacro (alu-insn-simm mnemonic) -+ (begin -+ (dni (.sym l- mnemonic "i") -+ (.str "l." mnemonic " reg/reg/simm16") -+ ((MACH ORBIS-MACHS)) -+ (.str "l." mnemonic "i $rD,$rA,$simm16") -+ (+ (.sym OPC_ (.upcase mnemonic) "I") rD rA simm16) -+ (set rD (mnemonic rA (ext WI simm16))) -+ () -+ ) -+ ) -+) -+ -+(define-pmacro (alu-insn-uimm mnemonic) -+ (begin -+ (dni (.sym l- mnemonic "i") -+ (.str "l." mnemonic " reg/reg/uimm16") -+ ((MACH ORBIS-MACHS)) -+ (.str "l." mnemonic "i $rD,$rA,$uimm16") -+ (+ (.sym OPC_ (.upcase mnemonic) "I") rD rA uimm16) -+ (set rD (mnemonic rA (zext UWI uimm16))) -+ () -+ ) -+ ) -+) -+ -+(alu-insn-uimm and) -+(alu-insn-uimm or) -+(alu-insn-simm xor) -+ -+(define-pmacro (alu-carry-insn-simm mnemonic) -+ (begin -+ (dni (.sym l- mnemonic "i") -+ (.str "l." mnemonic "i reg/reg/simm16") -+ ((MACH ORBIS-MACHS)) -+ (.str "l." mnemonic "i $rD,$rA,$simm16") -+ (+ (.sym OPC_ (.upcase mnemonic) "I") rD rA simm16) -+ (sequence () -+ (sequence () -+ (set BI sys-sr-cy ((.sym mnemonic "c-cflag") WI rA (ext WI simm16) 0)) -+ (set BI sys-sr-ov ((.sym mnemonic "c-oflag") WI rA (ext WI simm16) 0)) -+ (set rD (mnemonic WI rA (ext WI simm16))) -+ ) -+ (if (andif sys-sr-ov sys-sr-ove) -+ (raise-exception EXCEPT-RANGE)) -+ ) -+ () -+ ) -+ ) -+ ) -+ -+(alu-carry-insn-simm add) -+ -+(dni (l-addic) -+ ("l.addic reg/reg/simm16") -+ ((MACH ORBIS-MACHS)) -+ ("l.addic $rD,$rA,$simm16") -+ (+ OPC_ADDIC rD rA simm16) -+ (sequence () -+ (sequence ((BI tmp-sys-sr-cy)) -+ (set BI tmp-sys-sr-cy sys-sr-cy) -+ (set BI sys-sr-cy (addc-cflag WI rA (ext WI simm16) tmp-sys-sr-cy)) -+ (set BI sys-sr-ov (addc-oflag WI rA (ext WI simm16) tmp-sys-sr-cy)) -+ (set WI rD (addc WI rA (ext WI simm16) tmp-sys-sr-cy)) -+ ) -+ (if (andif sys-sr-ov sys-sr-ove) -+ (raise-exception EXCEPT-RANGE)) -+ ) -+ () -+) -+ -+(dni (l-muli) -+ "l.muli reg/reg/simm16" -+ ((MACH ORBIS-MACHS)) -+ ("l.muli $rD,$rA,$simm16") -+ (+ OPC_MULI rD rA simm16) -+ (sequence () -+ (sequence () -+ ; 2's complement overflow -+ (set sys-sr-ov (mul-o2flag WI rA (ext WI simm16))) -+ ; 1's complement overflow -+ (set sys-sr-cy (mul-o1flag UWI rA (ext UWI simm16))) -+ (set rD (mul WI rA (ext WI simm16))) -+ ) -+ (if (andif sys-sr-ov sys-sr-ove) -+ (raise-exception EXCEPT-RANGE)) -+ ) -+ () -+ ) -+ -+(define-pmacro (extbh-insn mnemonic extop extmode truncmode) -+ (begin -+ (dni (.sym l- mnemonic) -+ (.str "l." mnemonic " reg/reg") -+ ((MACH ORBIS-MACHS)) -+ (.str "l." mnemonic " $rD,$rA") -+ (+ OPC_ALU rD rA (f-resv-15-6 0) (.sym OPC_EXTBHS_ (.upcase mnemonic)) (f-resv-5-2 0) OPC_ALU_REGREG_EXTBH) -+ (set rD (extop extmode (trunc truncmode rA))) -+ () -+ ) -+ ) -+ ) -+ -+(extbh-insn exths ext WI HI) -+(extbh-insn extbs ext WI QI) -+(extbh-insn exthz zext UWI UHI) -+(extbh-insn extbz zext UWI UQI) -+ -+(define-pmacro (extw-insn mnemonic extop extmode truncmode) -+ (begin -+ (dni (.sym l- mnemonic) -+ (.str "l." mnemonic " reg/reg") -+ ((MACH ORBIS-MACHS)) -+ (.str "l." mnemonic " $rD,$rA") -+ (+ OPC_ALU rD rA (f-resv-15-6 0) (.sym OPC_EXTWS_ (.upcase mnemonic)) (f-resv-5-2 0) OPC_ALU_REGREG_EXTW) -+ (set rD (extop extmode (trunc truncmode rA))) -+ () -+ ) -+ ) -+ ) -+ -+(extw-insn extws ext WI SI) -+(extw-insn extwz zext USI USI) -+ -+(dni l-cmov -+ "l.cmov reg/reg/reg" -+ ((MACH ORBIS-MACHS)) -+ "l.cmov $rD,$rA,$rB" -+ (+ OPC_ALU rD rA rB (f-resv-10-1 0) (f-op-9-2 0) (f-resv-7-4 0) OPC_ALU_REGREG_CMOV) -+ (if sys-sr-f -+ (set UWI rD rA) -+ (set UWI rD rB) -+ ) -+ () -+ ) -+ -+; Compare instructions -+ -+; Ordering compare -+(define-pmacro (sf-insn op) -+ (begin -+ (dni (.sym l- "sf" op "s") ; l-sfgts -+ (.str "l.sf" op "s reg/reg") ; "l.sfgts reg/reg" -+ ((MACH ORBIS-MACHS)) -+ (.str "l.sf" op "s $rA,$rB") ; "l.sfgts $rA,$rB" -+ (+ OPC_SF (.sym "OPC_SF_" (.upcase op) "S") rA rB (f-resv-10-11 0)) ; (+ OPC_SF OPC_SF_GTS rA rB (f-resv-10-11 0)) -+ (set sys-sr-f (op WI rA rB)) ; (set sys-sr-f (gt WI rA rB)) -+ () -+ ) -+ (dni (.sym l- "sf" op "si") ; l-sfgtsi -+ (.str "l.sf" op "si reg/simm16") ; "l.sfgtsi reg/simm16" -+ ((MACH ORBIS-MACHS)) -+ (.str "l.sf" op "si $rA,$simm16") ; "l.sfgtsi $rA,$simm16" -+ (+ OPC_SFI (.sym "OPC_SF_" (.upcase op) "S") rA simm16) ; (+ OPC_SFI OPC_SF_GTS rA simm16) -+ (set sys-sr-f (op WI rA (ext WI simm16))) ; (set sys-sr-f (gt WI rA (ext WI simm16))) -+ () -+ ) -+ (dni (.sym l- "sf" op "u") ; l-sfgtu -+ (.str "l.sf" op "u reg/reg") ; "l.sfgtu reg/reg" -+ ((MACH ORBIS-MACHS)) -+ (.str "l.sf" op "u $rA,$rB") ; "l.sfgtu $rA,$rB" -+ (+ OPC_SF (.sym "OPC_SF_" (.upcase op) "U") rA rB (f-resv-10-11 0)) ; (+ OPC_SF OPC_SF_GTU rA rB (f-resv-10-11 0)) -+ (set sys-sr-f ((.sym op "u") WI rA rB)) ; (set sys-sr-f (gtu WI rA rB)) -+ () -+ ) -+ ; immediate is sign extended even for unsigned compare -+ (dni (.sym l- "sf" op "ui") ; l-sfgtui -+ (.str "l.sf" op "ui reg/simm16") ; "l.sfgtui reg/uimm16" -+ ((MACH ORBIS-MACHS)) -+ (.str "l.sf" op "ui $rA,$simm16") ; "l.sfgtui $rA,$simm16" -+ (+ OPC_SFI (.sym "OPC_SF_" (.upcase op) "U") rA simm16) ; (+ OPC_SFI OPC_SF_GTU rA simm16) -+ (set sys-sr-f ((.sym op "u") WI rA (ext WI simm16))) ; (set sys-sr-f (gtu WI rA (ext WI simm16))) -+ () -+ ) -+ ) -+ ) -+ -+(sf-insn gt) -+(sf-insn ge) -+(sf-insn lt) -+(sf-insn le) -+ -+; Equality compare -+(define-pmacro (sf-insn-eq op) -+ (begin -+ (dni (.sym l- "sf" op) -+ (.str "l." op " reg/reg") -+ ((MACH ORBIS-MACHS)) -+ (.str "l.sf" op " $rA,$rB") -+ (+ OPC_SF (.sym "OPC_SF_" (.upcase op)) rA rB (f-resv-10-11 0)) -+ (set sys-sr-f (op WI rA rB)) -+ () -+ ) -+ (dni (.sym l- "sf" op "i") -+ (.str "l.sf" op "i reg/simm16") -+ ((MACH ORBIS-MACHS)) -+ (.str "l.sf" op "i $rA,$simm16") -+ (+ OPC_SFI (.sym "OPC_SF_" (.upcase op)) rA simm16) -+ (set sys-sr-f (op WI rA (ext WI simm16))) -+ () -+ ) -+ ) -+) -+ -+(sf-insn-eq eq) -+(sf-insn-eq ne) -+ -+(dni l-mac -+ "l.mac reg/reg" -+ ((MACH ORBIS-MACHS)) -+ "l.mac $rA,$rB" -+ (+ OPC_MAC (f-op-25-5 0) rA rB (f-resv-10-7 0) OPC_MAC_MAC) -+ (sequence ((WI prod) (DI result)) -+ (set WI prod (mul WI rA rB)) -+ (set DI result (add (join DI SI mac-machi mac-maclo) (ext DI prod))) -+ (set SI mac-machi (subword SI result 0)) -+ (set SI mac-maclo (subword SI result 1)) -+ ) -+ () -+ ) -+ -+(dni l-msb -+ "l.msb reg/reg" -+ ((MACH ORBIS-MACHS)) -+ "l.msb $rA,$rB" -+ (+ OPC_MAC (f-op-25-5 0) rA rB (f-resv-10-7 0) OPC_MAC_MSB) -+ (sequence ((WI prod) (DI result)) -+ (set WI prod (mul WI rA rB)) -+ (set DI result (sub (join DI SI mac-machi mac-maclo) (ext DI prod))) -+ (set SI mac-machi (subword SI result 0)) -+ (set SI mac-maclo (subword SI result 1)) -+ ) -+ () -+ ) -+ -+(dni l-maci -+ "l.maci reg/simm16" -+ ((MACH ORBIS-MACHS)) -+ "l.maci $rA,${simm16}" -+ (+ OPC_MACI (f-resv-25-5 0) rA simm16) -+ (sequence ((WI prod) (DI result)) -+ (set WI prod (mul WI (ext WI simm16) rA)) -+ (set DI result (add (join DI SI mac-machi mac-maclo) (ext DI prod))) -+ (set SI mac-machi (subword SI result 0)) -+ (set SI mac-maclo (subword SI result 1)) -+ ) -+ () -+ ) -+ -+(define-pmacro (cust-insn cust-num) -+ (begin -+ (dni (.sym l- "cust" cust-num) -+ (.str "l.cust" cust-num) -+ ((MACH ORBIS-MACHS)) -+ (.str "l.cust" cust-num) -+ (+ (.sym OPC_CUST cust-num) (f-resv-25-26 0)) -+ (nop) -+ () -+ ) -+ ) -+ ) -+ -+(cust-insn "1") -+(cust-insn "2") -+(cust-insn "3") -+(cust-insn "4") -+(cust-insn "5") -+(cust-insn "6") -+(cust-insn "7") -+(cust-insn "8") -diff -rNU3 dist.orig/cpu/or1korfpx.cpu dist/cpu/or1korfpx.cpu ---- dist.orig/cpu/or1korfpx.cpu 1970-01-01 01:00:00.000000000 +0100 -+++ dist/cpu/or1korfpx.cpu 2015-10-18 13:11:13.000000000 +0200 -@@ -0,0 +1,222 @@ -+; OpenRISC 1000 architecture. -*- Scheme -*- -+; Copyright 2000-2014 Free Software Foundation, Inc. -+; Contributed by Peter Gavin, pgavin@gmail.com -+; -+; This program is free software; you can redistribute it and/or modify -+; it under the terms of the GNU General Public License as published by -+; the Free Software Foundation; either version 3 of the License, or -+; (at your option) any later version. -+; -+; This program is distributed in the hope that it will be useful, -+; but WITHOUT ANY WARRANTY; without even the implied warranty of -+; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+; GNU General Public License for more details. -+; -+; You should have received a copy of the GNU General Public License -+; along with this program; if not, see -+ -+; Initial ORFPX32 instruction set -+ -+; I'm not sure how CGEN handles rounding in FP operations, except for -+; in conversions to/from integers. So lf.add, lf.sub, lf.mul, and -+; lf.div do not round according to the FPCSR RM field. -+; NaN, overflow, and underflow are not yet handled either. -+ -+(define-normal-insn-enum insn-opcode-float-regreg -+ "floating point reg/reg insn opcode enums" () -+ OPC_FLOAT_REGREG_ f-op-7-8 -+ (("ADD_S" #x00) -+ ("SUB_S" #x01) -+ ("MUL_S" #x02) -+ ("DIV_S" #x03) -+ ("ITOF_S" #x04) -+ ("FTOI_S" #x05) -+ ("REM_S" #x06) -+ ("MADD_S" #x07) -+ ("SFEQ_S" #x08) -+ ("SFNE_S" #x09) -+ ("SFGT_S" #x0a) -+ ("SFGE_S" #x0b) -+ ("SFLT_S" #x0c) -+ ("SFLE_S" #x0d) -+ ("ADD_D" #x10) -+ ("SUB_D" #x11) -+ ("MUL_D" #x12) -+ ("DIV_D" #x13) -+ ("ITOF_D" #x14) -+ ("FTOI_D" #x15) -+ ("REM_D" #x16) -+ ("MADD_D" #x17) -+ ("SFEQ_D" #x18) -+ ("SFNE_D" #x19) -+ ("SFGT_D" #x1a) -+ ("SFGE_D" #x1b) -+ ("SFLT_D" #x1c) -+ ("SFLE_D" #x1d) -+ ("CUST1_S" #xd0) -+ ("CUST1_D" #xe0) -+ ) -+ ) -+ -+(dnop rDSF "destination register (single floating point mode)" () h-fsr f-r1) -+(dnop rASF "source register A (single floating point mode)" () h-fsr f-r2) -+(dnop rBSF "source register B (single floating point mode)" () h-fsr f-r3) -+ -+(dnop rDDF "destination register (double floating point mode)" ((MACH ORFPX64-MACHS)) h-fdr f-r1) -+(dnop rADF "source register A (double floating point mode)" ((MACH ORFPX64-MACHS)) h-fdr f-r1) -+(dnop rBDF "source register B (double floating point mode)" ((MACH ORFPX64-MACHS)) h-fdr f-r1) -+ -+(define-pmacro (float-regreg-insn mnemonic) -+ (begin -+ (dni (.sym lf- mnemonic -s) -+ (.str "lf." mnemonic ".s reg/reg/reg") -+ ((MACH ORFPX-MACHS)) -+ (.str "lf." mnemonic ".s $rDSF,$rASF,$rBSF") -+ (+ OPC_FLOAT rDSF rASF rBSF (f-resv-10-3 0) (.sym OPC_FLOAT_REGREG_ (.upcase mnemonic) _S)) -+ (set SF rDSF (mnemonic SF rASF rBSF)) -+ () -+ ) -+ (dni (.sym lf- mnemonic -d) -+ (.str "lf." mnemonic ".d reg/reg/reg") -+ ((MACH ORFPX64-MACHS)) -+ (.str "lf." mnemonic ".d $rDDF,$rADF,$rBDF") -+ (+ OPC_FLOAT rDDF rADF rBDF (f-resv-10-3 0) (.sym OPC_FLOAT_REGREG_ (.upcase mnemonic) _D)) -+ (set DF rDDF (mnemonic DF rADF rBDF)) -+ () -+ ) -+ ) -+ ) -+ -+(float-regreg-insn add) -+(float-regreg-insn sub) -+(float-regreg-insn mul) -+(float-regreg-insn div) -+ -+(dni lf-rem-s -+ "lf.rem.s reg/reg/reg" -+ ((MACH ORFPX-MACHS)) -+ "lf.rem.s $rDSF,$rASF,$rBSF" -+ (+ OPC_FLOAT rDSF rASF rBSF (f-resv-10-3 0) OPC_FLOAT_REGREG_REM_S) -+ (set SF rDSF (rem SF rASF rBSF)) -+ () -+ ) -+(dni lf-rem-d -+ "lf.rem.d reg/reg/reg" -+ ((MACH ORFPX64-MACHS)) -+ "lf.rem.d $rDDF,$rADF,$rBDF" -+ (+ OPC_FLOAT rDDF rADF rBDF (f-resv-10-3 0) OPC_FLOAT_REGREG_REM_D) -+ (set DF rDDF (mod DF rADF rBDF)) -+ () -+ ) -+ -+(define-pmacro (get-rounding-mode) -+ (case INT sys-fpcsr-rm -+ ((0) 1) ; TIES-TO-EVEN -- I'm assuming this is what is meant by "round to nearest" -+ ((1) 3) ; TOWARD-ZERO -+ ((2) 4) ; TOWARD-POSITIVE -+ (else 5) ; TOWARD-NEGATIVE -+ ) -+ ) -+ -+(dni lf-itof-s -+ "lf.itof.s reg/reg" -+ ((MACH ORFPX-MACHS)) -+ "lf.itof.s $rDSF,$rA" -+ (+ OPC_FLOAT rDSF rA (f-r3 0) (f-resv-10-3 0) OPC_FLOAT_REGREG_ITOF_S) -+ (set SF rDSF (float SF (get-rounding-mode) (trunc SI rA))) -+ () -+ ) -+(dni lf-itof-d -+ "lf.itof.d reg/reg" -+ ((MACH ORFPX64-MACHS)) -+ "lf.itof.d $rDSF,$rA" -+ (+ OPC_FLOAT rDSF rA (f-r3 0) (f-resv-10-3 0) OPC_FLOAT_REGREG_ITOF_D) -+ (set DF rDDF (float DF (get-rounding-mode) rA)) -+ () -+ ) -+ -+(dni lf-ftoi-s -+ "lf.ftoi.s reg/reg" -+ ((MACH ORFPX-MACHS)) -+ "lf.ftoi.s $rD,$rASF" -+ (+ OPC_FLOAT rD rASF (f-r3 0) (f-resv-10-3 0) OPC_FLOAT_REGREG_FTOI_S) -+ (set WI rD (ext WI (fix SI (get-rounding-mode) rASF))) -+ () -+ ) -+ -+(dni lf-ftoi-d -+ "lf.ftoi.d reg/reg" -+ ((MACH ORFPX64-MACHS)) -+ "lf.ftoi.d $rD,$rADF" -+ (+ OPC_FLOAT rD rADF (f-r3 0) (f-resv-10-3 0) OPC_FLOAT_REGREG_FTOI_D) -+ (set DI rD (fix DI (get-rounding-mode) rADF)) -+ () -+ ) -+ -+(define-pmacro (float-setflag-insn mnemonic) -+ (begin -+ (dni (.sym lf- mnemonic -s) -+ (.str "lf.sf" mnemonic ".s reg/reg") -+ ((MACH ORFPX-MACHS)) -+ (.str "lf.sf" mnemonic ".s $rASF,$rBSF") -+ (+ OPC_FLOAT (f-r1 0) rASF rBSF (f-resv-10-3 0) (.sym OPC_FLOAT_REGREG_SF (.upcase mnemonic) _S)) -+ (set BI sys-sr-f (mnemonic SF rASF rBSF)) -+ () -+ ) -+ (dni (.sym lf- mnemonic -d) -+ (.str "lf.sf" mnemonic ".d reg/reg") -+ ((MACH ORFPX64-MACHS)) -+ (.str "lf.sf" mnemonic ".d $rASF,$rBSF") -+ (+ OPC_FLOAT (f-r1 0) rASF rBSF (f-resv-10-3 0) (.sym OPC_FLOAT_REGREG_SF (.upcase mnemonic) _D)) -+ (set BI sys-sr-f (mnemonic DF rADF rBDF)) -+ () -+ ) -+ ) -+ ) -+ -+(float-setflag-insn eq) -+(float-setflag-insn ne) -+(float-setflag-insn ge) -+(float-setflag-insn gt) -+(float-setflag-insn lt) -+(float-setflag-insn le) -+ -+(dni lf-madd-s -+ "lf.madd.s reg/reg/reg" -+ ((MACH ORFPX-MACHS)) -+ "lf.madd.s $rDSF,$rASF,$rBSF" -+ (+ OPC_FLOAT rDSF rASF rBSF (f-resv-10-3 0) OPC_FLOAT_REGREG_MADD_S) -+ (set SF rDSF (add SF (mul SF rASF rBSF) rDSF)) -+ () -+ ) -+(dni lf-madd-d -+ "lf.madd.d reg/reg/reg" -+ ((MACH ORFPX64-MACHS)) -+ "lf.madd.d $rDDF,$rADF,$rBDF" -+ (+ OPC_FLOAT rDDF rADF rBDF (f-resv-10-3 0) OPC_FLOAT_REGREG_MADD_D) -+ (set DF rDDF (add DF (mul DF rADF rBDF) rDDF)) -+ () -+ ) -+ -+(define-pmacro (float-cust-insn cust-num) -+ (begin -+ (dni (.sym "lf-cust" cust-num "-s") -+ (.str "lf.cust" cust-num ".s") -+ ((MACH ORFPX-MACHS)) -+ (.str "lf.cust" cust-num ".s $rASF,$rBSF") -+ (+ OPC_FLOAT (f-resv-25-5 0) rASF rBSF (f-resv-10-3 0) (.sym "OPC_FLOAT_REGREG_CUST" cust-num "_S")) -+ (nop) -+ () -+ ) -+ (dni (.sym "lf-cust" cust-num "-d") -+ (.str "lf.cust" cust-num ".d") -+ ((MACH ORFPX64-MACHS)) -+ (.str "lf.cust" cust-num ".d") -+ (+ OPC_FLOAT (f-resv-25-5 0) rADF rBDF (f-resv-10-3 0) (.sym "OPC_FLOAT_REGREG_CUST" cust-num "_D")) -+ (nop) -+ () -+ ) -+ ) -+ ) -+ -+(float-cust-insn "1") -diff -rNU3 dist.orig/gas/Makefile.am dist/gas/Makefile.am ---- dist.orig/gas/Makefile.am 2012-09-04 14:53:45.000000000 +0200 -+++ dist/gas/Makefile.am 2015-10-18 13:11:13.000000000 +0200 -@@ -147,11 +147,11 @@ - config/tc-msp430.c \ - config/tc-mt.c \ - config/tc-ns32k.c \ -- config/tc-openrisc.c \ -- config/tc-or32.c \ -+ config/tc-or1k.c \ - config/tc-pdp11.c \ - config/tc-pj.c \ - config/tc-ppc.c \ -+ config/tc-riscv.c \ - config/tc-rl78.c \ - config/tc-rx.c \ - config/tc-s390.c \ -@@ -216,11 +216,11 @@ - config/tc-msp430.h \ - config/tc-mt.h \ - config/tc-ns32k.h \ -- config/tc-openrisc.h \ -- config/tc-or32.h \ -+ config/tc-or1k.h \ - config/tc-pdp11.h \ - config/tc-pj.h \ - config/tc-ppc.h \ -+ config/tc-riscv.h \ - config/tc-rl78.h \ - config/tc-rx.h \ - config/tc-s390.h \ -diff -rNU3 dist.orig/gas/Makefile.in dist/gas/Makefile.in ---- dist.orig/gas/Makefile.in 2012-09-04 14:53:45.000000000 +0200 -+++ dist/gas/Makefile.in 2015-10-18 13:11:13.000000000 +0200 -@@ -415,11 +415,11 @@ - config/tc-msp430.c \ - config/tc-mt.c \ - config/tc-ns32k.c \ -- config/tc-openrisc.c \ -- config/tc-or32.c \ -+ config/tc-or1k.c \ - config/tc-pdp11.c \ - config/tc-pj.c \ - config/tc-ppc.c \ -+ config/tc-riscv.c \ - config/tc-rl78.c \ - config/tc-rx.c \ - config/tc-s390.c \ -@@ -484,11 +484,11 @@ - config/tc-msp430.h \ - config/tc-mt.h \ - config/tc-ns32k.h \ -- config/tc-openrisc.h \ -- config/tc-or32.h \ -+ config/tc-or1k.h \ - config/tc-pdp11.h \ - config/tc-pj.h \ - config/tc-ppc.h \ -+ config/tc-riscv.h \ - config/tc-rl78.h \ - config/tc-rx.h \ - config/tc-s390.h \ -@@ -835,11 +835,11 @@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-msp430.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-mt.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-ns32k.Po@am__quote@ --@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-openrisc.Po@am__quote@ --@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-or32.Po@am__quote@ -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-or1k.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-pdp11.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-pj.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-ppc.Po@am__quote@ -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-riscv.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-rl78.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-rx.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tc-s390.Po@am__quote@ -@@ -1447,33 +1447,19 @@ - @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tc-ns32k.obj `if test -f 'config/tc-ns32k.c'; then $(CYGPATH_W) 'config/tc-ns32k.c'; else $(CYGPATH_W) '$(srcdir)/config/tc-ns32k.c'; fi` - --tc-openrisc.o: config/tc-openrisc.c --@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tc-openrisc.o -MD -MP -MF $(DEPDIR)/tc-openrisc.Tpo -c -o tc-openrisc.o `test -f 'config/tc-openrisc.c' || echo '$(srcdir)/'`config/tc-openrisc.c --@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tc-openrisc.Tpo $(DEPDIR)/tc-openrisc.Po --@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='config/tc-openrisc.c' object='tc-openrisc.o' libtool=no @AMDEPBACKSLASH@ -+tc-or1k.o: config/tc-or1k.c -+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tc-or1k.o -MD -MP -MF $(DEPDIR)/tc-or1k.Tpo -c -o tc-or1k.o `test -f 'config/tc-or1k.c' || echo '$(srcdir)/'`config/tc-or1k.c -+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tc-or1k.Tpo $(DEPDIR)/tc-or1k.Po -+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='config/tc-or1k.c' object='tc-or1k.o' libtool=no @AMDEPBACKSLASH@ -+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tc-or1k.o `test -f 'config/tc-or1k.c' || echo '$(srcdir)/'`config/tc-or1k.c -+ -+tc-or1k.obj: config/tc-or1k.c -+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tc-or1k.obj -MD -MP -MF $(DEPDIR)/tc-or1k.Tpo -c -o tc-or1k.obj `if test -f 'config/tc-or1k.c'; then $(CYGPATH_W) 'config/tc-or1k.c'; else $(CYGPATH_W) '$(srcdir)/config/tc-or1k.c'; fi` -+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tc-or1k.Tpo $(DEPDIR)/tc-or1k.Po -+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='config/tc-or1k.c' object='tc-or1k.obj' libtool=no @AMDEPBACKSLASH@ - @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ --@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tc-openrisc.o `test -f 'config/tc-openrisc.c' || echo '$(srcdir)/'`config/tc-openrisc.c -- --tc-openrisc.obj: config/tc-openrisc.c --@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tc-openrisc.obj -MD -MP -MF $(DEPDIR)/tc-openrisc.Tpo -c -o tc-openrisc.obj `if test -f 'config/tc-openrisc.c'; then $(CYGPATH_W) 'config/tc-openrisc.c'; else $(CYGPATH_W) '$(srcdir)/config/tc-openrisc.c'; fi` --@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tc-openrisc.Tpo $(DEPDIR)/tc-openrisc.Po --@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='config/tc-openrisc.c' object='tc-openrisc.obj' libtool=no @AMDEPBACKSLASH@ --@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ --@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tc-openrisc.obj `if test -f 'config/tc-openrisc.c'; then $(CYGPATH_W) 'config/tc-openrisc.c'; else $(CYGPATH_W) '$(srcdir)/config/tc-openrisc.c'; fi` -- --tc-or32.o: config/tc-or32.c --@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tc-or32.o -MD -MP -MF $(DEPDIR)/tc-or32.Tpo -c -o tc-or32.o `test -f 'config/tc-or32.c' || echo '$(srcdir)/'`config/tc-or32.c --@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tc-or32.Tpo $(DEPDIR)/tc-or32.Po --@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='config/tc-or32.c' object='tc-or32.o' libtool=no @AMDEPBACKSLASH@ --@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ --@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tc-or32.o `test -f 'config/tc-or32.c' || echo '$(srcdir)/'`config/tc-or32.c -- --tc-or32.obj: config/tc-or32.c --@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tc-or32.obj -MD -MP -MF $(DEPDIR)/tc-or32.Tpo -c -o tc-or32.obj `if test -f 'config/tc-or32.c'; then $(CYGPATH_W) 'config/tc-or32.c'; else $(CYGPATH_W) '$(srcdir)/config/tc-or32.c'; fi` --@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tc-or32.Tpo $(DEPDIR)/tc-or32.Po --@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='config/tc-or32.c' object='tc-or32.obj' libtool=no @AMDEPBACKSLASH@ --@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ --@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tc-or32.obj `if test -f 'config/tc-or32.c'; then $(CYGPATH_W) 'config/tc-or32.c'; else $(CYGPATH_W) '$(srcdir)/config/tc-or32.c'; fi` -+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tc-or1k.obj `if test -f 'config/tc-or1k.c'; then $(CYGPATH_W) 'config/tc-or1k.c'; else $(CYGPATH_W) '$(srcdir)/config/tc-or1k.c'; fi` - - tc-pdp11.o: config/tc-pdp11.c - @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tc-pdp11.o -MD -MP -MF $(DEPDIR)/tc-pdp11.Tpo -c -o tc-pdp11.o `test -f 'config/tc-pdp11.c' || echo '$(srcdir)/'`config/tc-pdp11.c -@@ -1517,6 +1503,20 @@ - @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ - @am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tc-ppc.obj `if test -f 'config/tc-ppc.c'; then $(CYGPATH_W) 'config/tc-ppc.c'; else $(CYGPATH_W) '$(srcdir)/config/tc-ppc.c'; fi` - -+tc-riscv.o: config/tc-riscv.c -+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tc-riscv.o -MD -MP -MF $(DEPDIR)/tc-riscv.Tpo -c -o tc-riscv.o `test -f 'config/tc-riscv.c' || echo '$(srcdir)/'`config/tc-riscv.c -+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tc-riscv.Tpo $(DEPDIR)/tc-riscv.Po -+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='config/tc-riscv.c' object='tc-riscv.o' libtool=no @AMDEPBACKSLASH@ -+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tc-riscv.o `test -f 'config/tc-riscv.c' || echo '$(srcdir)/'`config/tc-riscv.c -+ -+tc-riscv.obj: config/tc-riscv.c -+@am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tc-riscv.obj -MD -MP -MF $(DEPDIR)/tc-riscv.Tpo -c -o tc-riscv.obj `if test -f 'config/tc-riscv.c'; then $(CYGPATH_W) 'config/tc-riscv.c'; else $(CYGPATH_W) '$(srcdir)/config/tc-riscv.c'; fi` -+@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tc-riscv.Tpo $(DEPDIR)/tc-riscv.Po -+@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='config/tc-riscv.c' object='tc-riscv.obj' libtool=no @AMDEPBACKSLASH@ -+@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -+@am__fastdepCC_FALSE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o tc-riscv.obj `if test -f 'config/tc-riscv.c'; then $(CYGPATH_W) 'config/tc-riscv.c'; else $(CYGPATH_W) '$(srcdir)/config/tc-riscv.c'; fi` -+ - tc-rl78.o: config/tc-rl78.c - @am__fastdepCC_TRUE@ $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT tc-rl78.o -MD -MP -MF $(DEPDIR)/tc-rl78.Tpo -c -o tc-rl78.o `test -f 'config/tc-rl78.c' || echo '$(srcdir)/'`config/tc-rl78.c - @am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/tc-rl78.Tpo $(DEPDIR)/tc-rl78.Po -diff -rNU3 dist.orig/gas/atof-generic.c dist/gas/atof-generic.c ---- dist.orig/gas/atof-generic.c 2009-09-02 09:24:19.000000000 +0200 -+++ dist/gas/atof-generic.c 2015-10-18 13:11:13.000000000 +0200 -@@ -121,6 +121,32 @@ - - switch (first_digit[0]) - { -+ case 's': -+ case 'S': -+ if (!strncasecmp ("snan", first_digit, 4)) -+ { -+ address_of_generic_floating_point_number->sign = 0; -+ address_of_generic_floating_point_number->exponent = 0; -+ address_of_generic_floating_point_number->leader = -+ address_of_generic_floating_point_number->low; -+ *address_of_string_pointer = first_digit + 4; -+ return 0; -+ } -+ break; -+ -+ case 'q': -+ case 'Q': -+ if (!strncasecmp ("qnan", first_digit, 4)) -+ { -+ address_of_generic_floating_point_number->sign = 0; -+ address_of_generic_floating_point_number->exponent = 0; -+ address_of_generic_floating_point_number->leader = -+ address_of_generic_floating_point_number->low; -+ *address_of_string_pointer = first_digit + 4; -+ return 0; -+ } -+ break; -+ - case 'n': - case 'N': - if (!strncasecmp ("nan", first_digit, 3)) -diff -rNU3 dist.orig/gas/config/atof-vax.c dist/gas/config/atof-vax.c ---- dist.orig/gas/config/atof-vax.c 2007-10-17 18:45:54.000000000 +0200 -+++ dist/gas/config/atof-vax.c 2015-10-18 13:11:13.000000000 +0200 -@@ -268,10 +268,27 @@ - int exponent_skippage; - LITTLENUM_TYPE word1; - -- /* JF: Deal with new Nan, +Inf and -Inf codes. */ - if (f->sign != '-' && f->sign != '+') - { -- make_invalid_floating_point_number (words); -+ if (f->sign == 0) -+ { -+ /* All NaNs are 0. */ -+ memset (words, 0x00, sizeof (LITTLENUM_TYPE) * precision); -+ } -+ else if (f->sign == 'P') -+ { -+ /* Positive Infinity. */ -+ memset (words, 0xff, sizeof (LITTLENUM_TYPE) * precision); -+ words[0] &= 0x7fff; -+ } -+ else if (f->sign == 'N') -+ { -+ /* Negative Infinity. */ -+ memset (words, 0x00, sizeof (LITTLENUM_TYPE) * precision); -+ words[0] = 0x0080; -+ } -+ else -+ make_invalid_floating_point_number (words); - return return_value; - } - -diff -rNU3 dist.orig/gas/config/obj-elf.c dist/gas/config/obj-elf.c ---- dist.orig/gas/config/obj-elf.c 2012-06-30 08:32:29.000000000 +0200 -+++ dist/gas/config/obj-elf.c 2015-10-18 13:11:13.000000000 +0200 -@@ -1705,12 +1705,14 @@ - const struct elf_backend_data *bed; - - bed = get_elf_backend_data (stdoutput); -+#if 0 - if (!(bed->elf_osabi == ELFOSABI_GNU - || bed->elf_osabi == ELFOSABI_FREEBSD - /* GNU is still using the default value 0. */ - || bed->elf_osabi == ELFOSABI_NONE)) - as_bad (_("symbol type \"%s\" is supported only by GNU and FreeBSD targets"), - type_name); -+#endif - type = BSF_FUNCTION | BSF_GNU_INDIRECT_FUNCTION; - } - else if (strcmp (type_name, "gnu_unique_object") == 0) -diff -rNU3 dist.orig/gas/config/tc-arm.c dist/gas/config/tc-arm.c ---- dist.orig/gas/config/tc-arm.c 2013-03-25 09:06:21.000000000 +0100 -+++ dist/gas/config/tc-arm.c 2015-10-18 13:11:13.000000000 +0200 -@@ -6936,7 +6936,7 @@ - - /* Functions for operand encoding. ARM, then Thumb. */ - --#define rotate_left(v, n) (v << n | v >> (32 - n)) -+#define rotate_left(v, n) (v << (n & 31) | v >> ((32 - n) & 31)) - - /* If VAL can be encoded in the immediate field of an ARM instruction, - return the encoded form. Otherwise, return FAIL. */ -@@ -17290,12 +17290,16 @@ - asection *sect; - - for (sect = stdoutput->sections; sect != NULL; sect = sect->next) -- if (seg_info (sect)->tc_segment_info_data.current_it.state -- == MANUAL_IT_BLOCK) -- { -- as_warn (_("section '%s' finished with an open IT block."), -- sect->name); -- } -+ { -+ segment_info_type *seginfo = seg_info (sect); -+ -+ if (seginfo && seginfo->tc_segment_info_data.current_it.state -+ == MANUAL_IT_BLOCK) -+ { -+ as_warn (_("section '%s' finished with an open IT block."), -+ sect->name); -+ } -+ } - #else - if (now_it.state == MANUAL_IT_BLOCK) - as_warn (_("file finished with an open IT block.")); -diff -rNU3 dist.orig/gas/config/tc-m68k.c dist/gas/config/tc-m68k.c ---- dist.orig/gas/config/tc-m68k.c 2012-05-16 12:26:47.000000000 +0200 -+++ dist/gas/config/tc-m68k.c 2015-10-18 13:11:13.000000000 +0200 -@@ -7426,12 +7426,12 @@ - } - } - -- /* Remove 'm' or 'mc' prefix from 68k variants. */ -+ /* Remove 'm' or 'mc' prefix from 68k or coldfire variants. */ - if (allow_m) - { - if (arg[0] == 'm') - { -- if (arg[1] == '6') -+ if (arg[1] == '6' || arg[1] == '5') - arg += 1; - else if (arg[1] == 'c' && arg[2] == '6') - arg += 2; -diff -rNU3 dist.orig/gas/config/tc-mips.c dist/gas/config/tc-mips.c ---- dist.orig/gas/config/tc-mips.c 2012-09-04 16:21:03.000000000 +0200 -+++ dist/gas/config/tc-mips.c 2015-10-18 13:11:13.000000000 +0200 -@@ -909,6 +909,9 @@ - NUM_FIX_VR4120_CLASSES - }; - -+/* ...likewise -mtrap-zero-jump. */ -+static bfd_boolean mips_trap_zero_jump; -+ - /* ...likewise -mfix-loongson2f-jump. */ - static bfd_boolean mips_fix_loongson2f_jump; - -@@ -941,6 +944,8 @@ - efficient expansion. */ - - static int mips_relax_branch; -+ -+static int mips_fix_loongson2f_btb; - - /* The expansion of many macros depends on the type of symbol that - they refer to. For example, when generating position-dependent code, -@@ -1316,6 +1321,7 @@ - static void mips16_macro_build - (expressionS *, const char *, const char *, va_list *); - static void load_register (int, expressionS *, int); -+static void macro_build (expressionS *, const char *, const char *, ...); - static void macro_start (void); - static void macro_end (void); - static void macro (struct mips_cl_insn * ip); -@@ -3626,6 +3632,35 @@ - return nops; - } - -+static void -+trap_zero_jump (struct mips_cl_insn * ip) -+{ -+ if (strcmp (ip->insn_mo->name, "j") == 0 -+ || strcmp (ip->insn_mo->name, "jr") == 0 -+ || strcmp (ip->insn_mo->name, "jalr") == 0) -+ { -+ int sreg; -+ -+ if (mips_opts.warn_about_macros) -+ return; -+ -+ sreg = EXTRACT_OPERAND (0, RS, *ip); -+ if (mips_opts.isa == ISA_MIPS32 -+ || mips_opts.isa == ISA_MIPS32R2 -+ || mips_opts.isa == ISA_MIPS64 -+ || mips_opts.isa == ISA_MIPS64R2) -+ { -+ expressionS ep; -+ ep.X_op = O_constant; -+ ep.X_add_number = 4096; -+ macro_build (&ep, "tltiu", "s,j", sreg, BFD_RELOC_LO16); -+ } -+ else if (mips_opts.isa != ISA_UNKNOWN -+ && mips_opts.isa != ISA_MIPS1) -+ macro_build (NULL, "teq", "s,t", sreg, 0); -+ } -+} -+ - /* Fix NOP issue: Replace nops by "or at,at,zero". */ - - static void -@@ -3663,6 +3698,16 @@ - ep.X_add_number = 0xffff; - macro_build (&ep, "ori", "t,r,i", ATREG, ATREG, BFD_RELOC_LO16); - macro_build (NULL, "and", "d,v,t", sreg, sreg, ATREG); -+ /* Hide these three instructions to avoid getting a ``macro expanded into -+ multiple instructions'' warning. */ -+ if (mips_relax.sequence != 2) { -+ mips_macro_warning.sizes[0] -= 3 * 4; -+ mips_macro_warning.insns[0] -= 3; -+ } -+ if (mips_relax.sequence != 1) { -+ mips_macro_warning.sizes[1] -= 3 * 4; -+ mips_macro_warning.insns[1] -= 3; -+ } - } - } - -@@ -3718,6 +3763,11 @@ - if (mips_opts.mips16 && history[0].fixp[0]) - return FALSE; - -+ if (mips_fix_loongson2f) -+ fix_loongson2f (ip); -+ if (mips_trap_zero_jump) -+ trap_zero_jump (ip); -+ - /* If the branch is itself the target of a branch, we can not swap. - We cheat on this; all we check for is whether there is a label on - this instruction. If there are any branches to anything other than -@@ -4764,6 +4814,45 @@ - r[i] = (bfd_reloc_code_real_type) va_arg (*args, int); - } - -+/* Fix jump through register issue on loongson2f processor for kernel code: -+ force a BTB clear before the jump to prevent it from being incorrectly -+ prefetched by the branch prediction engine. */ -+ -+static void -+macro_build_jrpatch (expressionS *ep, unsigned int sreg) -+{ -+ if (!mips_fix_loongson2f_btb) -+ return; -+ -+ if (sreg == ZERO || sreg == KT0 || sreg == KT1 || sreg == AT) -+ return; -+ -+ if (!mips_opts.at) -+ { -+ as_warn (_("unable to apply loongson2f BTB workaround when .set noat")); -+ return; -+ } -+ -+ /* li $at, COP_0_BTB_CLEAR | COP_0_RAS_DISABLE */ -+ ep->X_op = O_constant; -+ ep->X_add_number = 3; -+ macro_build (ep, "ori", "t,r,i", AT, ZERO, BFD_RELOC_LO16); -+ -+ /* dmtc0 $at, COP_0_DIAG */ -+ macro_build (NULL, "dmtc0", "t,G", AT, 22); -+ -+ /* Hide these two instructions to avoid getting a ``macro expanded into -+ multiple instructions'' warning. */ -+ if (mips_relax.sequence != 2) { -+ mips_macro_warning.sizes[0] -= 2 * 4; -+ mips_macro_warning.insns[0] -= 2; -+ } -+ if (mips_relax.sequence != 1) { -+ mips_macro_warning.sizes[1] -= 2 * 4; -+ mips_macro_warning.insns[1] -= 2; -+ } -+} -+ - /* Build an instruction created by a macro expansion. This is passed - a pointer to the count of instructions created so far, an - expression, the name of the instruction to build, an operand format -@@ -7637,6 +7726,26 @@ - macro_build (NULL, ADDRESS_ADD_INSN, "d,v,t", treg, tempreg, breg); - break; - -+ case M_JR_S: -+ macro_build_jrpatch (&expr1, sreg); -+ macro_build (NULL, "jr", "s", sreg); -+ return; /* didn't modify $at */ -+ -+ case M_J_S: -+ macro_build_jrpatch (&expr1, sreg); -+ macro_build (NULL, "j", "s", sreg); -+ return; /* didn't modify $at */ -+ -+ case M_JALR_S: -+ macro_build_jrpatch (&expr1, sreg); -+ macro_build (NULL, "jalr", "s", sreg); -+ return; /* didn't modify $at */ -+ -+ case M_JALR_DS: -+ macro_build_jrpatch (&expr1, sreg); -+ macro_build (NULL, "jalr", "d,s", dreg, sreg); -+ return; /* didn't modify $at */ -+ - case M_MSGSND: - gas_assert (!mips_opts.micromips); - { -@@ -9126,18 +9235,28 @@ - - - case M_SAA_AB: -- ab = 1; -+ ab = (offset_expr.X_op != O_constant || offset_expr.X_add_number != 0); - case M_SAA_OB: - s = "saa"; - off0 = 1; - fmt = "t,(b)"; -+ if (!ab) -+ { -+ tempreg = AT; -+ goto ld_noat; -+ } - goto ld_st; - case M_SAAD_AB: -- ab = 1; -+ ab = (offset_expr.X_op != O_constant || offset_expr.X_add_number != 0); - case M_SAAD_OB: - s = "saad"; - off0 = 1; - fmt = "t,(b)"; -+ if (!ab) -+ { -+ tempreg = AT; -+ goto ld_noat; -+ } - goto ld_st; - - /* New code added to support COPZ instructions. -@@ -14350,6 +14469,8 @@ - OPTION_SINGLE_FLOAT, - OPTION_DOUBLE_FLOAT, - OPTION_32, -+ OPTION_TRAP_ZERO_JUMP, -+ OPTION_NO_TRAP_ZERO_JUMP, - #ifdef OBJ_ELF - OPTION_CALL_SHARED, - OPTION_CALL_NONPIC, -@@ -14364,6 +14485,8 @@ - OPTION_NO_PDR, - OPTION_MVXWORKS_PIC, - #endif /* OBJ_ELF */ -+ OPTION_FIX_LOONGSON2F_BTB, -+ OPTION_NO_FIX_LOONGSON2F_BTB, - OPTION_END_OF_ENUM - }; - -@@ -14421,6 +14544,8 @@ - {"mno-fix-loongson2f-jump", no_argument, NULL, OPTION_NO_FIX_LOONGSON2F_JUMP}, - {"mfix-loongson2f-nop", no_argument, NULL, OPTION_FIX_LOONGSON2F_NOP}, - {"mno-fix-loongson2f-nop", no_argument, NULL, OPTION_NO_FIX_LOONGSON2F_NOP}, -+ {"mfix-loongson2f-btb", no_argument, NULL, OPTION_FIX_LOONGSON2F_BTB}, -+ {"mno-fix-loongson2f-btb", no_argument, NULL, OPTION_NO_FIX_LOONGSON2F_BTB}, - {"mfix-vr4120", no_argument, NULL, OPTION_FIX_VR4120}, - {"mno-fix-vr4120", no_argument, NULL, OPTION_NO_FIX_VR4120}, - {"mfix-vr4130", no_argument, NULL, OPTION_FIX_VR4130}, -@@ -14459,6 +14584,9 @@ - make testing easier. */ - {"32", no_argument, NULL, OPTION_32}, - -+ {"mtrap-zero-jump", no_argument, NULL, OPTION_TRAP_ZERO_JUMP}, -+ {"mno-trap-zero-jump", no_argument, NULL, OPTION_NO_TRAP_ZERO_JUMP}, -+ - /* ELF-specific options. */ - #ifdef OBJ_ELF - {"KPIC", no_argument, NULL, OPTION_CALL_SHARED}, -@@ -14750,6 +14878,14 @@ - mips_fix_vr4130 = 0; - break; - -+ case OPTION_FIX_LOONGSON2F_BTB: -+ mips_fix_loongson2f_btb = 1; -+ break; -+ -+ case OPTION_NO_FIX_LOONGSON2F_BTB: -+ mips_fix_loongson2f_btb = 0; -+ break; -+ - case OPTION_FIX_CN63XXP1: - mips_fix_cn63xxp1 = TRUE; - break; -@@ -14782,6 +14918,14 @@ - mips_opts.sym32 = FALSE; - break; - -+ case OPTION_TRAP_ZERO_JUMP: -+ mips_trap_zero_jump = TRUE; -+ break; -+ -+ case OPTION_NO_TRAP_ZERO_JUMP: -+ mips_trap_zero_jump = FALSE; -+ break; -+ - #ifdef OBJ_ELF - /* When generating ELF code, we permit -KPIC and -call_shared to - select SVR4_PIC, and -non_shared to select no PIC. This is -@@ -19411,6 +19555,7 @@ - fprintf (stream, _("\ - -mfix-loongson2f-jump work around Loongson2F JUMP instructions\n\ - -mfix-loongson2f-nop work around Loongson2F NOP errata\n\ -+-mfix-loongson2f-btb work around Loongson2F BTB errata\n\ - -mfix-vr4120 work around certain VR4120 errata\n\ - -mfix-vr4130 work around VR4130 mflo/mfhi errata\n\ - -mfix-24k insert a nop after ERET and DERET instructions\n\ -diff -rNU3 dist.orig/gas/config/tc-openrisc.c dist/gas/config/tc-openrisc.c ---- dist.orig/gas/config/tc-openrisc.c 2009-07-24 13:45:00.000000000 +0200 -+++ dist/gas/config/tc-openrisc.c 1970-01-01 01:00:00.000000000 +0100 -@@ -1,363 +0,0 @@ --/* tc-openrisc.c -- Assembler for the OpenRISC family. -- Copyright 2001, 2002, 2003, 2005, 2006, 2007, 2009 -- Free Software Foundation. -- Contributed by Johan Rydberg, jrydberg@opencores.org -- -- This file is part of GAS, the GNU Assembler. -- -- GAS is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3, or (at your option) -- any later version. -- -- GAS is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with GAS; see the file COPYING. If not, write to -- the Free Software Foundation, 51 Franklin Street - Fifth Floor, -- Boston, MA 02110-1301, USA. */ -- --#include "as.h" --#include "subsegs.h" --#include "symcat.h" --#include "opcodes/openrisc-desc.h" --#include "opcodes/openrisc-opc.h" --#include "cgen.h" -- --/* Structure to hold all of the different components describing -- an individual instruction. */ --typedef struct openrisc_insn openrisc_insn; -- --struct openrisc_insn --{ -- const CGEN_INSN * insn; -- const CGEN_INSN * orig_insn; -- CGEN_FIELDS fields; --#if CGEN_INT_INSN_P -- CGEN_INSN_INT buffer [1]; --#define INSN_VALUE(buf) (*(buf)) --#else -- unsigned char buffer [CGEN_MAX_INSN_SIZE]; --#define INSN_VALUE(buf) (buf) --#endif -- char * addr; -- fragS * frag; -- int num_fixups; -- fixS * fixups [GAS_CGEN_MAX_FIXUPS]; -- int indices [MAX_OPERAND_INSTANCES]; --}; -- -- --const char comment_chars[] = "#"; --const char line_comment_chars[] = "#"; --const char line_separator_chars[] = ";"; --const char EXP_CHARS[] = "eE"; --const char FLT_CHARS[] = "dD"; -- -- --#define OPENRISC_SHORTOPTS "m:" --const char * md_shortopts = OPENRISC_SHORTOPTS; -- --struct option md_longopts[] = --{ -- {NULL, no_argument, NULL, 0} --}; --size_t md_longopts_size = sizeof (md_longopts); -- --unsigned long openrisc_machine = 0; /* default */ -- --int --md_parse_option (int c ATTRIBUTE_UNUSED, char * arg ATTRIBUTE_UNUSED) --{ -- return 0; --} -- --void --md_show_usage (FILE * stream ATTRIBUTE_UNUSED) --{ --} -- --static void --ignore_pseudo (int val ATTRIBUTE_UNUSED) --{ -- discard_rest_of_line (); --} -- --const char openrisc_comment_chars [] = ";#"; -- --/* The target specific pseudo-ops which we support. */ --const pseudo_typeS md_pseudo_table[] = --{ -- { "word", cons, 4 }, -- { "proc", ignore_pseudo, 0 }, -- { "endproc", ignore_pseudo, 0 }, -- { NULL, NULL, 0 } --}; -- -- -- --void --md_begin (void) --{ -- /* Initialize the `cgen' interface. */ -- -- /* Set the machine number and endian. */ -- gas_cgen_cpu_desc = openrisc_cgen_cpu_open (CGEN_CPU_OPEN_MACHS, 0, -- CGEN_CPU_OPEN_ENDIAN, -- CGEN_ENDIAN_BIG, -- CGEN_CPU_OPEN_END); -- openrisc_cgen_init_asm (gas_cgen_cpu_desc); -- -- /* This is a callback from cgen to gas to parse operands. */ -- cgen_set_parse_operand_fn (gas_cgen_cpu_desc, gas_cgen_parse_operand); --} -- --void --md_assemble (char * str) --{ -- static int last_insn_had_delay_slot = 0; -- openrisc_insn insn; -- char * errmsg; -- -- /* Initialize GAS's cgen interface for a new instruction. */ -- gas_cgen_init_parse (); -- -- insn.insn = openrisc_cgen_assemble_insn -- (gas_cgen_cpu_desc, str, & insn.fields, insn.buffer, & errmsg); -- -- if (!insn.insn) -- { -- as_bad ("%s", errmsg); -- return; -- } -- -- /* Doesn't really matter what we pass for RELAX_P here. */ -- gas_cgen_finish_insn (insn.insn, insn.buffer, -- CGEN_FIELDS_BITSIZE (& insn.fields), 1, NULL); -- -- last_insn_had_delay_slot -- = CGEN_INSN_ATTR_VALUE (insn.insn, CGEN_INSN_DELAY_SLOT); --} -- -- --/* The syntax in the manual says constants begin with '#'. -- We just ignore it. */ -- --void --md_operand (expressionS * expressionP) --{ -- if (* input_line_pointer == '#') -- { -- input_line_pointer ++; -- expression (expressionP); -- } --} -- --valueT --md_section_align (segT segment, valueT size) --{ -- int align = bfd_get_section_alignment (stdoutput, segment); -- return ((size + (1 << align) - 1) & (-1 << align)); --} -- --symbolS * --md_undefined_symbol (char * name ATTRIBUTE_UNUSED) --{ -- return 0; --} -- -- --/* Interface to relax_segment. */ -- --/* FIXME: Look through this. */ -- --const relax_typeS md_relax_table[] = --{ --/* The fields are: -- 1) most positive reach of this state, -- 2) most negative reach of this state, -- 3) how many bytes this mode will add to the size of the current frag -- 4) which index into the table to try if we can't fit into this one. */ -- -- /* The first entry must be unused because an `rlx_more' value of zero ends -- each list. */ -- {1, 1, 0, 0}, -- -- /* The displacement used by GAS is from the end of the 2 byte insn, -- so we subtract 2 from the following. */ -- /* 16 bit insn, 8 bit disp -> 10 bit range. -- This doesn't handle a branch in the right slot at the border: -- the "& -4" isn't taken into account. It's not important enough to -- complicate things over it, so we subtract an extra 2 (or + 2 in -ve -- case). */ -- {511 - 2 - 2, -512 - 2 + 2, 0, 2 }, -- /* 32 bit insn, 24 bit disp -> 26 bit range. */ -- {0x2000000 - 1 - 2, -0x2000000 - 2, 2, 0 }, -- /* Same thing, but with leading nop for alignment. */ -- {0x2000000 - 1 - 2, -0x2000000 - 2, 4, 0 } --}; -- --/* Return an initial guess of the length by which a fragment must grow to -- hold a branch to reach its destination. -- Also updates fr_type/fr_subtype as necessary. -- -- Called just before doing relaxation. -- Any symbol that is now undefined will not become defined. -- The guess for fr_var is ACTUALLY the growth beyond fr_fix. -- Whatever we do to grow fr_fix or fr_var contributes to our returned value. -- Although it may not be explicit in the frag, pretend fr_var starts with a -- 0 value. */ -- --int --md_estimate_size_before_relax (fragS * fragP, segT segment) --{ -- /* The only thing we have to handle here are symbols outside of the -- current segment. They may be undefined or in a different segment in -- which case linker scripts may place them anywhere. -- However, we can't finish the fragment here and emit the reloc as insn -- alignment requirements may move the insn about. */ -- -- if (S_GET_SEGMENT (fragP->fr_symbol) != segment) -- { -- /* The symbol is undefined in this segment. -- Change the relaxation subtype to the max allowable and leave -- all further handling to md_convert_frag. */ -- fragP->fr_subtype = 2; -- -- { -- const CGEN_INSN * insn; -- int i; -- -- /* Update the recorded insn. -- Fortunately we don't have to look very far. -- FIXME: Change this to record in the instruction the next higher -- relaxable insn to use. */ -- for (i = 0, insn = fragP->fr_cgen.insn; i < 4; i++, insn++) -- { -- if ((strcmp (CGEN_INSN_MNEMONIC (insn), -- CGEN_INSN_MNEMONIC (fragP->fr_cgen.insn)) -- == 0) -- && CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_RELAXED)) -- break; -- } -- if (i == 4) -- abort (); -- -- fragP->fr_cgen.insn = insn; -- return 2; -- } -- } -- -- return md_relax_table[fragP->fr_subtype].rlx_length; --} -- --/* *fragP has been relaxed to its final size, and now needs to have -- the bytes inside it modified to conform to the new size. -- -- Called after relaxation is finished. -- fragP->fr_type == rs_machine_dependent. -- fragP->fr_subtype is the subtype of what the address relaxed to. */ -- --void --md_convert_frag (bfd * abfd ATTRIBUTE_UNUSED, -- segT sec ATTRIBUTE_UNUSED, -- fragS * fragP ATTRIBUTE_UNUSED) --{ -- /* FIXME */ --} -- -- --/* Functions concerning relocs. */ -- --/* The location from which a PC relative jump should be calculated, -- given a PC relative reloc. */ -- --long --md_pcrel_from_section (fixS * fixP, segT sec) --{ -- if (fixP->fx_addsy != (symbolS *) NULL -- && (! S_IS_DEFINED (fixP->fx_addsy) -- || S_GET_SEGMENT (fixP->fx_addsy) != sec)) -- /* The symbol is undefined (or is defined but not in this section). -- Let the linker figure it out. */ -- return 0; -- -- return (fixP->fx_frag->fr_address + fixP->fx_where) & ~1; --} -- -- --/* Return the bfd reloc type for OPERAND of INSN at fixup FIXP. -- Returns BFD_RELOC_NONE if no reloc type can be found. -- *FIXP may be modified if desired. */ -- --bfd_reloc_code_real_type --md_cgen_lookup_reloc (const CGEN_INSN * insn ATTRIBUTE_UNUSED, -- const CGEN_OPERAND * operand, -- fixS * fixP) --{ -- bfd_reloc_code_real_type type; -- -- switch (operand->type) -- { -- case OPENRISC_OPERAND_ABS_26: -- fixP->fx_pcrel = 0; -- type = BFD_RELOC_OPENRISC_ABS_26; -- goto emit; -- case OPENRISC_OPERAND_DISP_26: -- fixP->fx_pcrel = 1; -- type = BFD_RELOC_OPENRISC_REL_26; -- goto emit; -- -- case OPENRISC_OPERAND_HI16: -- type = BFD_RELOC_HI16; -- goto emit; -- -- case OPENRISC_OPERAND_LO16: -- type = BFD_RELOC_LO16; -- goto emit; -- -- emit: -- return type; -- -- default : /* avoid -Wall warning */ -- break; -- } -- -- return BFD_RELOC_NONE; --} -- --/* Write a value out to the object file, using the appropriate endianness. */ -- --void --md_number_to_chars (char * buf, valueT val, int n) --{ -- number_to_chars_bigendian (buf, val, n); --} -- --/* Turn a string in input_line_pointer into a floating point constant of type -- type, and store the appropriate bytes in *litP. The number of LITTLENUMS -- emitted is stored in *sizeP . An error message is returned, or NULL on OK. --*/ -- --/* Equal to MAX_PRECISION in atof-ieee.c */ --#define MAX_LITTLENUMS 6 -- --char * --md_atof (int type, char * litP, int * sizeP) --{ -- return ieee_md_atof (type, litP, sizeP, TRUE); --} -- --bfd_boolean --openrisc_fix_adjustable (fixS * fixP) --{ -- /* We need the symbol name for the VTABLE entries. */ -- if (fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT -- || fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY) -- return 0; -- -- return 1; --} -diff -rNU3 dist.orig/gas/config/tc-openrisc.h dist/gas/config/tc-openrisc.h ---- dist.orig/gas/config/tc-openrisc.h 2007-07-03 13:01:04.000000000 +0200 -+++ dist/gas/config/tc-openrisc.h 1970-01-01 01:00:00.000000000 +0100 -@@ -1,61 +0,0 @@ --/* tc-openrisc.h -- Header file for tc-openrisc.c. -- Copyright 2001, 2002, 2003, 2005, 2007 Free Software Foundation, Inc. -- -- This file is part of GAS, the GNU Assembler. -- -- GAS is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3, or (at your option) -- any later version. -- -- GAS is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with GAS; see the file COPYING. If not, write to -- the Free Software Foundation, 51 Franklin Street - Fifth Floor, -- Boston, MA 02110-1301, USA. */ -- --#define TC_OPENRISC -- --#define LISTING_HEADER "OpenRISC GAS " -- --/* The target BFD architecture. */ --#define TARGET_ARCH bfd_arch_openrisc -- --extern unsigned long openrisc_machine; --#define TARGET_MACH (openrisc_machine) -- --#define TARGET_FORMAT "elf32-openrisc" --#define TARGET_BYTES_BIG_ENDIAN 1 -- --extern const char openrisc_comment_chars []; --#define tc_comment_chars openrisc_comment_chars -- --/* Permit temporary numeric labels. */ --#define LOCAL_LABELS_FB 1 -- --#define DIFF_EXPR_OK 1 /* .-foo gets turned into PC relative relocs */ -- --/* We don't need to handle .word strangely. */ --#define WORKING_DOT_WORD -- --/* Values passed to md_apply_fix don't include the symbol value. */ --#define MD_APPLY_SYM_VALUE(FIX) 0 -- --#define md_apply_fix gas_cgen_md_apply_fix -- --extern bfd_boolean openrisc_fix_adjustable (struct fix *); --#define tc_fix_adjustable(FIX) openrisc_fix_adjustable (FIX) -- --#define tc_gen_reloc gas_cgen_tc_gen_reloc -- --/* Call md_pcrel_from_section(), not md_pcrel_from(). */ --extern long md_pcrel_from_section (struct fix *, segT); --#define MD_PCREL_FROM_SECTION(FIX, SEC) md_pcrel_from_section (FIX, SEC) -- --/* For 8 vs 16 vs 32 bit branch selection. */ --extern const struct relax_type md_relax_table[]; --#define TC_GENERIC_RELAX_TABLE md_relax_table -diff -rNU3 dist.orig/gas/config/tc-or1k.c dist/gas/config/tc-or1k.c ---- dist.orig/gas/config/tc-or1k.c 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gas/config/tc-or1k.c 2015-10-18 13:11:13.000000000 +0200 -@@ -0,0 +1,362 @@ -+/* tc-or1k.c -- Assembler for the OpenRISC family. -+ Copyright 2001-2014 Free Software Foundation. -+ Contributed for OR32 by Johan Rydberg, jrydberg@opencores.org -+ -+ This file is part of GAS, the GNU Assembler. -+ -+ GAS is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3, or (at your option) -+ any later version. -+ -+ GAS is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, see */ -+#include "as.h" -+#include "safe-ctype.h" -+#include "subsegs.h" -+#include "symcat.h" -+#include "opcodes/or1k-desc.h" -+#include "opcodes/or1k-opc.h" -+#include "cgen.h" -+#include "elf/or1k.h" -+#include "dw2gencfi.h" -+ -+/* Structure to hold all of the different components describing -+ an individual instruction. */ -+ -+typedef struct -+{ -+ const CGEN_INSN * insn; -+ const CGEN_INSN * orig_insn; -+ CGEN_FIELDS fields; -+#if CGEN_INT_INSN_P -+ CGEN_INSN_INT buffer [1]; -+#define INSN_VALUE(buf) (*(buf)) -+#else -+ unsigned char buffer [CGEN_MAX_INSN_SIZE]; -+#define INSN_VALUE(buf) (buf) -+#endif -+ char * addr; -+ fragS * frag; -+ int num_fixups; -+ fixS * fixups [GAS_CGEN_MAX_FIXUPS]; -+ int indices [MAX_OPERAND_INSTANCES]; -+} -+or1k_insn; -+ -+const char comment_chars[] = "#"; -+const char line_comment_chars[] = "#"; -+const char line_separator_chars[] = ";"; -+const char EXP_CHARS[] = "eE"; -+const char FLT_CHARS[] = "dD"; -+ -+#define OR1K_SHORTOPTS "m:" -+const char * md_shortopts = OR1K_SHORTOPTS; -+ -+struct option md_longopts[] = -+{ -+ {NULL, no_argument, NULL, 0} -+}; -+size_t md_longopts_size = sizeof (md_longopts); -+ -+unsigned long or1k_machine = 0; /* default */ -+ -+int -+md_parse_option (int c ATTRIBUTE_UNUSED, char * arg ATTRIBUTE_UNUSED) -+{ -+ return 0; -+} -+ -+void -+md_show_usage (FILE * stream ATTRIBUTE_UNUSED) -+{ -+} -+ -+static void -+ignore_pseudo (int val ATTRIBUTE_UNUSED) -+{ -+ discard_rest_of_line (); -+} -+ -+static bfd_boolean nodelay = FALSE; -+static void -+s_nodelay (int val ATTRIBUTE_UNUSED) -+{ -+ nodelay = TRUE; -+} -+ -+const char or1k_comment_chars [] = ";#"; -+ -+/* The target specific pseudo-ops which we support. */ -+const pseudo_typeS md_pseudo_table[] = -+{ -+ { "align", s_align_bytes, 0 }, -+ { "word", cons, 4 }, -+ { "proc", ignore_pseudo, 0 }, -+ { "endproc", ignore_pseudo, 0 }, -+ { "nodelay", s_nodelay, 0 }, -+ { NULL, NULL, 0 } -+}; -+ -+ -+void -+md_begin (void) -+{ -+ /* Initialize the `cgen' interface. */ -+ -+ /* Set the machine number and endian. */ -+ gas_cgen_cpu_desc = or1k_cgen_cpu_open (CGEN_CPU_OPEN_MACHS, 0, -+ CGEN_CPU_OPEN_ENDIAN, -+ CGEN_ENDIAN_BIG, -+ CGEN_CPU_OPEN_END); -+ or1k_cgen_init_asm (gas_cgen_cpu_desc); -+ -+ /* This is a callback from cgen to gas to parse operands. */ -+ cgen_set_parse_operand_fn (gas_cgen_cpu_desc, gas_cgen_parse_operand); -+} -+ -+void -+md_assemble (char * str) -+{ -+ static int last_insn_had_delay_slot = 0; -+ or1k_insn insn; -+ char * errmsg; -+ -+ /* Initialize GAS's cgen interface for a new instruction. */ -+ gas_cgen_init_parse (); -+ -+ insn.insn = or1k_cgen_assemble_insn -+ (gas_cgen_cpu_desc, str, & insn.fields, insn.buffer, & errmsg); -+ -+ if (!insn.insn) -+ { -+ as_bad ("%s", errmsg); -+ return; -+ } -+ -+ /* Doesn't really matter what we pass for RELAX_P here. */ -+ gas_cgen_finish_insn (insn.insn, insn.buffer, -+ CGEN_FIELDS_BITSIZE (& insn.fields), 1, NULL); -+ -+ last_insn_had_delay_slot -+ = CGEN_INSN_ATTR_VALUE (insn.insn, CGEN_INSN_DELAY_SLOT); -+ (void) last_insn_had_delay_slot; -+} -+ -+ -+/* The syntax in the manual says constants begin with '#'. -+ We just ignore it. */ -+ -+void -+md_operand (expressionS * expressionP) -+{ -+ if (* input_line_pointer == '#') -+ { -+ input_line_pointer ++; -+ expression (expressionP); -+ } -+} -+ -+valueT -+md_section_align (segT segment, valueT size) -+{ -+ int align = bfd_get_section_alignment (stdoutput, segment); -+ return ((size + (1 << align) - 1) & (-1 << align)); -+} -+ -+symbolS * -+md_undefined_symbol (char * name ATTRIBUTE_UNUSED) -+{ -+ return 0; -+} -+ -+ -+/* Interface to relax_segment. */ -+ -+const relax_typeS md_relax_table[] = -+{ -+/* The fields are: -+ 1) most positive reach of this state, -+ 2) most negative reach of this state, -+ 3) how many bytes this mode will add to the size of the current frag -+ 4) which index into the table to try if we can't fit into this one. */ -+ -+ /* The first entry must be unused because an `rlx_more' value of zero ends -+ each list. */ -+ {1, 1, 0, 0}, -+ -+ /* The displacement used by GAS is from the end of the 4 byte insn, -+ so we subtract 4 from the following. */ -+ {(((1 << 25) - 1) << 2) - 4, -(1 << 25) - 4, 0, 0}, -+}; -+ -+int -+md_estimate_size_before_relax (fragS * fragP, segT segment ATTRIBUTE_UNUSED) -+{ -+ return md_relax_table[fragP->fr_subtype].rlx_length; -+} -+ -+/* *fragP has been relaxed to its final size, and now needs to have -+ the bytes inside it modified to conform to the new size. -+ -+ Called after relaxation is finished. -+ fragP->fr_type == rs_machine_dependent. -+ fragP->fr_subtype is the subtype of what the address relaxed to. */ -+ -+void -+md_convert_frag (bfd * abfd ATTRIBUTE_UNUSED, -+ segT sec ATTRIBUTE_UNUSED, -+ fragS * fragP ATTRIBUTE_UNUSED) -+{ -+ /* FIXME */ -+} -+ -+ -+/* Functions concerning relocs. */ -+ -+/* The location from which a PC relative jump should be calculated, -+ given a PC relative reloc. */ -+ -+long -+md_pcrel_from_section (fixS * fixP, segT sec) -+{ -+ if (fixP->fx_addsy != (symbolS *) NULL -+ && (! S_IS_DEFINED (fixP->fx_addsy) -+ || (S_GET_SEGMENT (fixP->fx_addsy) != sec) -+ || S_IS_EXTERNAL (fixP->fx_addsy) -+ || S_IS_WEAK (fixP->fx_addsy))) -+ { -+ /* The symbol is undefined (or is defined but not in this section). -+ Let the linker figure it out. */ -+ return 0; -+ } -+ -+ return fixP->fx_frag->fr_address + fixP->fx_where; -+} -+ -+ -+/* Return the bfd reloc type for OPERAND of INSN at fixup FIXP. -+ Returns BFD_RELOC_NONE if no reloc type can be found. -+ *FIXP may be modified if desired. */ -+ -+bfd_reloc_code_real_type -+md_cgen_lookup_reloc (const CGEN_INSN * insn ATTRIBUTE_UNUSED, -+ const CGEN_OPERAND * operand, -+ fixS * fixP) -+{ -+ if (fixP->fx_cgen.opinfo) -+ return fixP->fx_cgen.opinfo; -+ -+ switch (operand->type) -+ { -+ case OR1K_OPERAND_DISP26: -+ fixP->fx_pcrel = 1; -+ return BFD_RELOC_OR1K_REL_26; -+ -+ default: /* avoid -Wall warning */ -+ return BFD_RELOC_NONE; -+ } -+} -+ -+/* Write a value out to the object file, using the appropriate endianness. */ -+ -+void -+md_number_to_chars (char * buf, valueT val, int n) -+{ -+ number_to_chars_bigendian (buf, val, n); -+} -+ -+/* Turn a string in input_line_pointer into a floating point constant of type -+ type, and store the appropriate bytes in *litP. The number of LITTLENUMS -+ emitted is stored in *sizeP . An error message is returned, or NULL on OK. */ -+ -+/* Equal to MAX_PRECISION in atof-ieee.c. */ -+#define MAX_LITTLENUMS 6 -+ -+char * -+md_atof (int type, char * litP, int * sizeP) -+{ -+ return ieee_md_atof (type, litP, sizeP, TRUE); -+} -+ -+bfd_boolean -+or1k_fix_adjustable (fixS * fixP) -+{ -+ /* We need the symbol name for the VTABLE entries. */ -+ if (fixP->fx_r_type == BFD_RELOC_VTABLE_INHERIT -+ || fixP->fx_r_type == BFD_RELOC_VTABLE_ENTRY) -+ return FALSE; -+ -+ return TRUE; -+} -+ -+#define GOT_NAME "_GLOBAL_OFFSET_TABLE_" -+ -+arelent * -+tc_gen_reloc (asection *sec, fixS *fx) -+{ -+ bfd_reloc_code_real_type code = fx->fx_r_type; -+ -+ if (fx->fx_addsy != NULL -+ && strcmp (S_GET_NAME (fx->fx_addsy), GOT_NAME) == 0 -+ && (code == BFD_RELOC_OR1K_GOTPC_HI16 -+ || code == BFD_RELOC_OR1K_GOTPC_LO16)) -+ { -+ arelent * reloc; -+ -+ reloc = xmalloc (sizeof (* reloc)); -+ reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *)); -+ *reloc->sym_ptr_ptr = symbol_get_bfdsym (fx->fx_addsy); -+ reloc->address = fx->fx_frag->fr_address + fx->fx_where; -+ reloc->howto = bfd_reloc_type_lookup (stdoutput, fx->fx_r_type); -+ reloc->addend = fx->fx_offset; -+ return reloc; -+ } -+ -+ return gas_cgen_tc_gen_reloc (sec, fx); -+} -+ -+void -+or1k_apply_fix (struct fix *f, valueT *t, segT s) -+{ -+ gas_cgen_md_apply_fix (f, t, s); -+ -+ switch (f->fx_r_type) -+ { -+ case BFD_RELOC_OR1K_TLS_GD_HI16: -+ case BFD_RELOC_OR1K_TLS_GD_LO16: -+ case BFD_RELOC_OR1K_TLS_LDM_HI16: -+ case BFD_RELOC_OR1K_TLS_LDM_LO16: -+ case BFD_RELOC_OR1K_TLS_LDO_HI16: -+ case BFD_RELOC_OR1K_TLS_LDO_LO16: -+ case BFD_RELOC_OR1K_TLS_IE_HI16: -+ case BFD_RELOC_OR1K_TLS_IE_LO16: -+ case BFD_RELOC_OR1K_TLS_LE_HI16: -+ case BFD_RELOC_OR1K_TLS_LE_LO16: -+ S_SET_THREAD_LOCAL (f->fx_addsy); -+ break; -+ default: -+ break; -+ } -+} -+ -+void -+or1k_elf_final_processing (void) -+{ -+ if (nodelay) -+ elf_elfheader (stdoutput)->e_flags |= EF_OR1K_NODELAY; -+} -+ -+/* Standard calling conventions leave the CFA at SP on entry. */ -+ -+void -+or1k_cfi_frame_initial_instructions (void) -+{ -+ cfi_add_CFA_def_cfa_register (1); -+} -+ -diff -rNU3 dist.orig/gas/config/tc-or1k.h dist/gas/config/tc-or1k.h ---- dist.orig/gas/config/tc-or1k.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gas/config/tc-or1k.h 2015-10-18 13:11:13.000000000 +0200 -@@ -0,0 +1,79 @@ -+/* tc-or1k.h -- Header file for tc-or1k.c. -+ Copyright 2001-2014 Free Software Foundation, Inc. -+ -+ This file is part of GAS, the GNU Assembler. -+ -+ GAS is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3, or (at your option) -+ any later version. -+ -+ GAS is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, see */ -+ -+#define TC_OR1K -+ -+#define LISTING_HEADER "Or1k GAS " -+ -+/* The target BFD architecture. */ -+#define TARGET_ARCH bfd_arch_or1k -+ -+extern unsigned long or1k_machine; -+#define TARGET_MACH (or1k_machine) -+ -+#define TARGET_FORMAT "elf32-or1k" -+#define TARGET_BYTES_BIG_ENDIAN 1 -+ -+extern const char or1k_comment_chars []; -+#define tc_comment_chars or1k_comment_chars -+ -+/* Permit temporary numeric labels. */ -+#define LOCAL_LABELS_FB 1 -+ -+#define DIFF_EXPR_OK 1 /* .-foo gets turned into PC relative relocs. */ -+ -+/* We don't need to handle .word strangely. */ -+#define WORKING_DOT_WORD -+ -+/* Values passed to md_apply_fix don't include the symbol value. */ -+#define MD_APPLY_SYM_VALUE(FIX) 0 -+ -+#define md_apply_fix or1k_apply_fix -+extern void or1k_apply_fix (struct fix *, valueT *, segT); -+ -+extern bfd_boolean or1k_fix_adjustable (struct fix *); -+#define tc_fix_adjustable(FIX) or1k_fix_adjustable (FIX) -+ -+/* Call md_pcrel_from_section(), not md_pcrel_from(). */ -+extern long md_pcrel_from_section (struct fix *, segT); -+#define MD_PCREL_FROM_SECTION(FIX, SEC) md_pcrel_from_section (FIX, SEC) -+ -+/* For 8 vs 16 vs 32 bit branch selection. */ -+extern const struct relax_type md_relax_table[]; -+#define TC_GENERIC_RELAX_TABLE md_relax_table -+ -+#define GAS_CGEN_PCREL_R_TYPE(r_type) gas_cgen_pcrel_r_type(r_type) -+ -+#define elf_tc_final_processing or1k_elf_final_processing -+void or1k_elf_final_processing (void); -+ -+/* Enable cfi directives. */ -+#define TARGET_USE_CFIPOP 1 -+ -+/* Stack grows to lower addresses and wants 4 byte boundary. */ -+#define DWARF2_CIE_DATA_ALIGNMENT -4 -+ -+/* Define the column that represents the PC. */ -+#define DWARF2_DEFAULT_RETURN_COLUMN 9 -+ -+/* or1k instructions are 4 bytes long. */ -+#define DWARF2_LINE_MIN_INSN_LENGTH 4 -+ -+#define tc_cfi_frame_initial_instructions \ -+ or1k_cfi_frame_initial_instructions -+extern void or1k_cfi_frame_initial_instructions (void); -diff -rNU3 dist.orig/gas/config/tc-or32.c dist/gas/config/tc-or32.c ---- dist.orig/gas/config/tc-or32.c 2012-05-17 17:13:16.000000000 +0200 -+++ dist/gas/config/tc-or32.c 1970-01-01 01:00:00.000000000 +0100 -@@ -1,967 +0,0 @@ --/* Assembly backend for the OpenRISC 1000. -- Copyright (C) 2002, 2003, 2005, 2007, 2009, 2010, 2012 -- Free Software Foundation, Inc. -- Contributed by Damjan Lampret . -- Modified bu Johan Rydberg, . -- Based upon a29k port. -- -- This file is part of GAS, the GNU Assembler. -- -- GAS is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3, or (at your option) -- any later version. -- -- GAS is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with GAS; see the file COPYING. If not, write to -- the Free Software Foundation, 51 Franklin Street - Fifth Floor, -- Boston, MA 02110-1301, USA. */ -- --/* tc-a29k.c used as a template. */ -- --#include "as.h" --#include "safe-ctype.h" --#include "opcode/or32.h" --#include "elf/or32.h" -- --#define DEBUG 0 -- --#ifndef REGISTER_PREFIX --#define REGISTER_PREFIX '%' --#endif -- --/* Make it easier to clone this machine desc into another one. */ --#define machine_opcode or32_opcode --#define machine_opcodes or32_opcodes --#define machine_ip or32_ip --#define machine_it or32_it -- --/* Handle of the OPCODE hash table. */ --static struct hash_control *op_hash = NULL; -- --struct machine_it --{ -- char * error; -- unsigned long opcode; -- struct nlist * nlistp; -- expressionS exp; -- int pcrel; -- int reloc_offset; /* Offset of reloc within insn. */ -- int reloc; --} --the_insn; -- --const pseudo_typeS md_pseudo_table[] = --{ -- {"align", s_align_bytes, 4 }, -- {"space", s_space, 0 }, -- {"cputype", s_ignore, 0 }, -- {"reg", s_lsym, 0 }, /* Register equate, same as equ. */ -- {"sect", s_ignore, 0 }, /* Creation of coff sections. */ -- {"proc", s_ignore, 0 }, /* Start of a function. */ -- {"endproc", s_ignore, 0 }, /* Function end. */ -- {"word", cons, 4 }, -- {NULL, 0, 0 }, --}; -- --int md_short_jump_size = 4; --int md_long_jump_size = 4; -- --/* This array holds the chars that always start a comment. -- If the pre-processor is disabled, these aren't very useful. */ --const char comment_chars[] = "#"; -- --/* This array holds the chars that only start a comment at the beginning of -- a line. If the line seems to have the form '# 123 filename' -- .line and .file directives will appear in the pre-processed output. */ --/* Note that input_file.c hand checks for '#' at the beginning of the -- first line of the input file. This is because the compiler outputs -- #NO_APP at the beginning of its output. */ --/* Also note that comments like this one will always work. */ --const char line_comment_chars[] = "#"; -- --/* We needed an unused char for line separation to work around the -- lack of macros, using sed and such. */ --const char line_separator_chars[] = ";"; -- --/* Chars that can be used to separate mant from exp in floating point nums. */ --const char EXP_CHARS[] = "eE"; -- --/* Chars that mean this number is a floating point constant. -- As in 0f12.456 -- or 0d1.2345e12. */ --const char FLT_CHARS[] = "rRsSfFdDxXpP"; -- --/* "l.jalr r9" precalculated opcode. */ --static unsigned long jalr_r9_opcode; -- --static void machine_ip (char *); -- -- --/* Set bits in machine opcode according to insn->encoding -- description and passed operand. */ -- --static void --encode (const struct machine_opcode *insn, -- unsigned long *opcode, -- signed long param_val, -- char param_ch) --{ -- int opc_pos = 0; -- int param_pos = 0; -- char *enc; -- --#if DEBUG -- printf (" encode: opcode=%.8lx param_val=%.8lx abs=%.8lx param_ch=%c\n", -- *opcode, param_val, abs (param_val), param_ch); --#endif -- for (enc = insn->encoding; *enc != '\0'; enc++) -- if (*enc == param_ch) -- { -- if (enc - 2 >= insn->encoding && (*(enc - 2) == '0') && (*(enc - 1) == 'x')) -- continue; -- else -- param_pos ++; -- } -- -- opc_pos = 32; -- -- for (enc = insn->encoding; *enc != '\0';) -- { -- if ((*enc == '0') && (*(enc + 1) == 'x')) -- { -- int tmp = strtol (enc, NULL, 16); -- -- opc_pos -= 4; -- *opcode |= tmp << opc_pos; -- enc += 3; -- } -- else if ((*enc == '0') || (*enc == '-')) -- { -- opc_pos--; -- enc++; -- } -- else if (*enc == '1') -- { -- opc_pos--; -- *opcode |= 1 << opc_pos; -- enc++; -- } -- else if (*enc == param_ch) -- { -- opc_pos--; -- param_pos--; -- *opcode |= ((param_val >> param_pos) & 0x1) << opc_pos; -- enc++; -- } -- else if (ISALPHA (*enc)) -- { -- opc_pos--; -- enc++; -- } -- else -- enc++; -- } -- --#if DEBUG -- printf (" opcode=%.8lx\n", *opcode); --#endif --} -- --/* This function is called once, at assembler startup time. It should -- set up all the tables, etc., that the MD part of the assembler will -- need. */ -- --void --md_begin (void) --{ -- const char *retval = NULL; -- int lose = 0; -- int skipnext = 0; -- unsigned int i; -- -- /* Hash up all the opcodes for fast use later. */ -- op_hash = hash_new (); -- -- for (i = 0; i < or32_num_opcodes; i++) -- { -- const char *name = machine_opcodes[i].name; -- -- if (skipnext) -- { -- skipnext = 0; -- continue; -- } -- -- retval = hash_insert (op_hash, name, (void *) &machine_opcodes[i]); -- if (retval != NULL) -- { -- fprintf (stderr, "internal error: can't hash `%s': %s\n", -- machine_opcodes[i].name, retval); -- lose = 1; -- } -- } -- -- if (lose) -- as_fatal (_("Broken assembler. No assembly attempted.")); -- -- encode (&machine_opcodes[insn_index ("l.jalr")], &jalr_r9_opcode, 9, 'B'); --} -- --/* Returns non zero if instruction is to be used. */ -- --static int --check_invalid_opcode (unsigned long opcode) --{ -- return opcode == jalr_r9_opcode; --} -- --/* Assemble a single instruction. Its label has already been handled -- by the generic front end. We just parse opcode and operands, and -- produce the bytes of data and relocation. */ -- --void --md_assemble (char *str) --{ -- char *toP; -- --#if DEBUG -- printf ("NEW INSTRUCTION\n"); --#endif -- -- know (str); -- machine_ip (str); -- toP = frag_more (4); -- -- /* Put out the opcode. */ -- md_number_to_chars (toP, the_insn.opcode, 4); -- -- /* Put out the symbol-dependent stuff. */ -- if (the_insn.reloc != BFD_RELOC_NONE) -- { -- fix_new_exp (frag_now, -- (toP - frag_now->fr_literal + the_insn.reloc_offset), -- 4, /* size */ -- &the_insn.exp, -- the_insn.pcrel, -- the_insn.reloc); -- } --} -- --/* This is true of the we have issued a "lo(" or "hi"(. */ --static int waiting_for_shift = 0; -- --static int mask_or_shift = 0; -- --static char * --parse_operand (char *s, expressionS *operandp, int opt) --{ -- char *save = input_line_pointer; -- char *new_pointer; -- --#if DEBUG -- printf (" PROCESS NEW OPERAND(%s) == %c (%d)\n", s, opt ? opt : '!', opt); --#endif -- -- input_line_pointer = s; -- -- if (strncasecmp (s, "HI(", 3) == 0) -- { -- waiting_for_shift = 1; -- mask_or_shift = BFD_RELOC_HI16; -- -- input_line_pointer += 3; -- } -- else if (strncasecmp (s, "LO(", 3) == 0) -- { -- mask_or_shift = BFD_RELOC_LO16; -- -- input_line_pointer += 3; -- } -- else -- mask_or_shift = 0; -- -- if ((*s == '(') && (*(s+1) == 'r')) -- s++; -- -- if ((*s == 'r') && ISDIGIT (*(s + 1))) -- { -- operandp->X_add_number = strtol (s + 1, NULL, 10); -- operandp->X_op = O_register; -- for (; (*s != ',') && (*s != '\0');) -- s++; -- input_line_pointer = save; -- return s; -- } -- -- expression (operandp); -- -- if (operandp->X_op == O_absent) -- { -- if (! opt) -- as_bad (_("missing operand")); -- else -- { -- operandp->X_add_number = 0; -- operandp->X_op = O_constant; -- } -- } -- -- new_pointer = input_line_pointer; -- input_line_pointer = save; -- --#if DEBUG -- printf (" %s=parse_operand(%s): operandp->X_op = %u\n", new_pointer, s, -- operandp->X_op); --#endif -- -- return new_pointer; --} -- --/* Instruction parsing. Takes a string containing the opcode. -- Operands are at input_line_pointer. Output is in the_insn. -- Warnings or errors are generated. */ -- --static void --machine_ip (char *str) --{ -- char *s; -- const char *args; -- const struct machine_opcode *insn; -- unsigned long opcode; -- expressionS the_operand; -- expressionS *operand = &the_operand; -- unsigned int regno; -- int reloc = BFD_RELOC_NONE; -- --#if DEBUG -- printf ("machine_ip(%s)\n", str); --#endif -- -- s = str; -- for (; ISALNUM (*s) || *s == '.'; ++s) -- if (ISUPPER (*s)) -- *s = TOLOWER (*s); -- -- switch (*s) -- { -- case '\0': -- break; -- -- case ' ': /* FIXME-SOMEDAY more whitespace. */ -- *s++ = '\0'; -- break; -- -- default: -- as_bad (_("unknown opcode1: `%s'"), str); -- return; -- } -- -- if ((insn = (struct machine_opcode *) hash_find (op_hash, str)) == NULL) -- { -- as_bad (_("unknown opcode2 `%s'."), str); -- return; -- } -- -- opcode = 0; -- memset (&the_insn, '\0', sizeof (the_insn)); -- the_insn.reloc = BFD_RELOC_NONE; -- -- reloc = BFD_RELOC_NONE; -- -- /* Build the opcode, checking as we go to make sure that the -- operands match. -- -- If an operand matches, we modify the_insn or opcode appropriately, -- and do a "continue". If an operand fails to match, we "break". */ -- if (insn->args[0] != '\0') -- /* Prime the pump. */ -- s = parse_operand (s, operand, insn->args[0] == 'I'); -- -- for (args = insn->args;; ++args) -- { --#if DEBUG -- printf (" args = %s\n", args); --#endif -- switch (*args) -- { -- case '\0': /* End of args. */ -- /* We have have 0 args, do the bazoooka! */ -- if (args == insn->args) -- encode (insn, &opcode, 0, 0); -- -- if (*s == '\0') -- { -- /* We are truly done. */ -- the_insn.opcode = opcode; -- if (check_invalid_opcode (opcode)) -- as_bad (_("instruction not allowed: %s"), str); -- return; -- } -- as_bad (_("too many operands: %s"), s); -- break; -- -- case ',': /* Must match a comma. */ -- if (*s++ == ',') -- { -- reloc = BFD_RELOC_NONE; -- -- /* Parse next operand. */ -- s = parse_operand (s, operand, args[1] == 'I'); --#if DEBUG -- printf (" ',' case: operand->X_add_number = %d, *args = %s, *s = %s\n", -- operand->X_add_number, args, s); --#endif -- continue; -- } -- break; -- -- case '(': /* Must match a (. */ -- s = parse_operand (s, operand, args[1] == 'I'); -- continue; -- -- case ')': /* Must match a ). */ -- continue; -- -- case 'r': /* A general register. */ -- args++; -- -- if (operand->X_op != O_register) -- break; /* Only registers. */ -- -- know (operand->X_add_symbol == 0); -- know (operand->X_op_symbol == 0); -- regno = operand->X_add_number; -- encode (insn, &opcode, regno, *args); --#if DEBUG -- printf (" r: operand->X_op = %d\n", operand->X_op); --#endif -- continue; -- -- default: -- /* if (! ISALPHA (*args)) -- break; */ /* Only immediate values. */ -- -- if (mask_or_shift) -- { --#if DEBUG -- printf ("mask_or_shift = %d\n", mask_or_shift); --#endif -- reloc = mask_or_shift; -- } -- mask_or_shift = 0; -- -- if (strncasecmp (args, "LO(", 3) == 0) -- { --#if DEBUG -- printf ("reloc_const\n"); --#endif -- reloc = BFD_RELOC_LO16; -- } -- else if (strncasecmp (args, "HI(", 3) == 0) -- { --#if DEBUG -- printf ("reloc_consth\n"); --#endif -- reloc = BFD_RELOC_HI16; -- } -- -- if (*s == '(') -- operand->X_op = O_constant; -- else if (*s == ')') -- s += 1; --#if DEBUG -- printf (" default case: operand->X_add_number = %d, *args = %s, *s = %s\n", operand->X_add_number, args, s); --#endif -- if (operand->X_op == O_constant) -- { -- if (reloc == BFD_RELOC_NONE) -- { -- bfd_vma v, mask; -- -- mask = 0x3ffffff; -- v = abs (operand->X_add_number) & ~ mask; -- if (v) -- as_bad (_("call/jmp target out of range (1)")); -- } -- -- if (reloc == BFD_RELOC_HI16) -- operand->X_add_number = ((operand->X_add_number >> 16) & 0xffff); -- -- the_insn.pcrel = 0; -- encode (insn, &opcode, operand->X_add_number, *args); -- /* the_insn.reloc = BFD_RELOC_NONE; */ -- continue; -- } -- -- if (reloc == BFD_RELOC_NONE) -- the_insn.reloc = BFD_RELOC_32_GOT_PCREL; -- else -- the_insn.reloc = reloc; -- -- /* the_insn.reloc = insn->reloc; */ --#if DEBUG -- printf (" reloc sym=%d\n", the_insn.reloc); -- printf (" BFD_RELOC_NONE=%d\n", BFD_RELOC_NONE); --#endif -- the_insn.exp = *operand; -- -- /* the_insn.reloc_offset = 1; */ -- the_insn.pcrel = 1; /* Assume PC-relative jump. */ -- -- /* FIXME-SOON, Do we figure out whether abs later, after -- know sym val? */ -- if (reloc == BFD_RELOC_LO16 || reloc == BFD_RELOC_HI16) -- the_insn.pcrel = 0; -- -- encode (insn, &opcode, operand->X_add_number, *args); -- continue; -- } -- -- /* Types or values of args don't match. */ -- as_bad (_("invalid operands")); -- return; -- } --} -- --char * --md_atof (int type, char * litP, int * sizeP) --{ -- return ieee_md_atof (type, litP, sizeP, TRUE); --} -- --/* Write out big-endian. */ -- --void --md_number_to_chars (char *buf, valueT val, int n) --{ -- number_to_chars_bigendian (buf, val, n); --} -- --void --md_apply_fix (fixS * fixP, valueT * val, segT seg ATTRIBUTE_UNUSED) --{ -- char *buf = fixP->fx_where + fixP->fx_frag->fr_literal; -- long t_val; -- -- t_val = (long) *val; -- --#if DEBUG -- printf ("md_apply_fix val:%x\n", t_val); --#endif -- -- fixP->fx_addnumber = t_val; /* Remember value for emit_reloc. */ -- -- switch (fixP->fx_r_type) -- { -- case BFD_RELOC_32: /* XXXXXXXX pattern in a word. */ --#if DEBUG -- printf ("reloc_const: val=%x\n", t_val); --#endif -- buf[0] = t_val >> 24; -- buf[1] = t_val >> 16; -- buf[2] = t_val >> 8; -- buf[3] = t_val; -- break; -- -- case BFD_RELOC_16: /* XXXX0000 pattern in a word. */ --#if DEBUG -- printf ("reloc_const: val=%x\n", t_val); --#endif -- buf[0] = t_val >> 8; -- buf[1] = t_val; -- break; -- -- case BFD_RELOC_8: /* XX000000 pattern in a word. */ --#if DEBUG -- printf ("reloc_const: val=%x\n", t_val); --#endif -- buf[0] = t_val; -- break; -- -- case BFD_RELOC_LO16: /* 0000XXXX pattern in a word. */ --#if DEBUG -- printf ("reloc_const: val=%x\n", t_val); --#endif -- buf[2] = t_val >> 8; /* Holds bits 0000XXXX. */ -- buf[3] = t_val; -- break; -- -- case BFD_RELOC_HI16: /* 0000XXXX pattern in a word. */ --#if DEBUG -- printf ("reloc_consth: val=%x\n", t_val); --#endif -- buf[2] = t_val >> 24; /* Holds bits XXXX0000. */ -- buf[3] = t_val >> 16; -- break; -- -- case BFD_RELOC_32_GOT_PCREL: /* 0000XXXX pattern in a word. */ -- if (!fixP->fx_done) -- ; -- else if (fixP->fx_pcrel) -- { -- long v = t_val >> 28; -- -- if (v != 0 && v != -1) -- as_bad_where (fixP->fx_file, fixP->fx_line, -- _("call/jmp target out of range (2)")); -- } -- else -- /* This case was supposed to be handled in machine_ip. */ -- abort (); -- -- buf[0] |= (t_val >> 26) & 0x03; /* Holds bits 0FFFFFFC of address. */ -- buf[1] = t_val >> 18; -- buf[2] = t_val >> 10; -- buf[3] = t_val >> 2; -- break; -- -- case BFD_RELOC_VTABLE_INHERIT: -- case BFD_RELOC_VTABLE_ENTRY: -- fixP->fx_done = 0; -- break; -- -- case BFD_RELOC_NONE: -- default: -- as_bad (_("bad relocation type: 0x%02x"), fixP->fx_r_type); -- break; -- } -- -- if (fixP->fx_addsy == (symbolS *) NULL) -- fixP->fx_done = 1; --} -- --/* Should never be called for or32. */ -- --void --md_create_short_jump (char * ptr ATTRIBUTE_UNUSED, -- addressT from_addr ATTRIBUTE_UNUSED, -- addressT to_addr ATTRIBUTE_UNUSED, -- fragS * frag ATTRIBUTE_UNUSED, -- symbolS * to_symbol ATTRIBUTE_UNUSED) --{ -- as_fatal ("or32_create_short_jmp\n"); --} -- --/* Should never be called for or32. */ -- --void --md_convert_frag (bfd * headers ATTRIBUTE_UNUSED, -- segT seg ATTRIBUTE_UNUSED, -- fragS * fragP ATTRIBUTE_UNUSED) --{ -- as_fatal ("or32_convert_frag\n"); --} -- --/* Should never be called for or32. */ -- --void --md_create_long_jump (char * ptr ATTRIBUTE_UNUSED, -- addressT from_addr ATTRIBUTE_UNUSED, -- addressT to_addr ATTRIBUTE_UNUSED, -- fragS * frag ATTRIBUTE_UNUSED, -- symbolS * to_symbol ATTRIBUTE_UNUSED) --{ -- as_fatal ("or32_create_long_jump\n"); --} -- --/* Should never be called for or32. */ -- --int --md_estimate_size_before_relax (fragS * fragP ATTRIBUTE_UNUSED, -- segT segtype ATTRIBUTE_UNUSED) --{ -- as_fatal ("or32_estimate_size_before_relax\n"); -- return 0; --} -- --/* Translate internal representation of relocation info to target format. -- -- On sparc/29k: first 4 bytes are normal unsigned long address, next three -- bytes are index, most sig. byte first. Byte 7 is broken up with -- bit 7 as external, bits 6 & 5 unused, and the lower -- five bits as relocation type. Next 4 bytes are long addend. */ --/* Thanx and a tip of the hat to Michael Bloom, mb@ttidca.tti.com. */ -- --#ifdef OBJ_AOUT --void --tc_aout_fix_to_chars (char *where, -- fixS *fixP, -- relax_addressT segment_address_in_file) --{ -- long r_symbolnum; -- --#if DEBUG -- printf ("tc_aout_fix_to_chars\n"); --#endif -- -- know (fixP->fx_r_type < BFD_RELOC_NONE); -- know (fixP->fx_addsy != NULL); -- -- md_number_to_chars -- (where, -- fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file, -- 4); -- -- r_symbolnum = (S_IS_DEFINED (fixP->fx_addsy) -- ? S_GET_TYPE (fixP->fx_addsy) -- : fixP->fx_addsy->sy_number); -- -- where[4] = (r_symbolnum >> 16) & 0x0ff; -- where[5] = (r_symbolnum >> 8) & 0x0ff; -- where[6] = r_symbolnum & 0x0ff; -- where[7] = (((!S_IS_DEFINED (fixP->fx_addsy)) << 7) & 0x80) | (0 & 0x60) | (fixP->fx_r_type & 0x1F); -- -- /* Also easy. */ -- md_number_to_chars (&where[8], fixP->fx_addnumber, 4); --} -- --#endif /* OBJ_AOUT */ -- --const char *md_shortopts = ""; -- --struct option md_longopts[] = --{ -- { NULL, no_argument, NULL, 0 } --}; --size_t md_longopts_size = sizeof (md_longopts); -- --int --md_parse_option (int c ATTRIBUTE_UNUSED, char * arg ATTRIBUTE_UNUSED) --{ -- return 0; --} -- --void --md_show_usage (FILE * stream ATTRIBUTE_UNUSED) --{ --} -- --/* This is called when a line is unrecognized. This is used to handle -- definitions of or32 style local labels. */ -- --int --or32_unrecognized_line (int c) --{ -- int lab; -- char *s; -- -- if (c != '$' -- || ! ISDIGIT ((unsigned char) input_line_pointer[0])) -- return 0; -- -- s = input_line_pointer; -- -- lab = 0; -- while (ISDIGIT ((unsigned char) *s)) -- { -- lab = lab * 10 + *s - '0'; -- ++s; -- } -- -- if (*s != ':') -- /* Not a label definition. */ -- return 0; -- -- if (dollar_label_defined (lab)) -- { -- as_bad (_("label \"$%d\" redefined"), lab); -- return 0; -- } -- -- define_dollar_label (lab); -- colon (dollar_label_name (lab, 0)); -- input_line_pointer = s + 1; -- -- return 1; --} -- --/* Default the values of symbols known that should be "predefined". We -- don't bother to predefine them unless you actually use one, since there -- are a lot of them. */ -- --symbolS * --md_undefined_symbol (char *name ATTRIBUTE_UNUSED) --{ -- return NULL; --} -- --/* Parse an operand that is machine-specific. */ -- --void --md_operand (expressionS *expressionP) --{ --#if DEBUG -- printf (" md_operand(input_line_pointer = %s)\n", input_line_pointer); --#endif -- -- if (input_line_pointer[0] == REGISTER_PREFIX && input_line_pointer[1] == 'r') -- { -- /* We have a numeric register expression. No biggy. */ -- input_line_pointer += 2; /* Skip %r */ -- (void) expression (expressionP); -- -- if (expressionP->X_op != O_constant -- || expressionP->X_add_number > 255) -- as_bad (_("Invalid expression after %%%%\n")); -- expressionP->X_op = O_register; -- } -- else if (input_line_pointer[0] == '&') -- { -- /* We are taking the 'address' of a register...this one is not -- in the manual, but it *is* in traps/fpsymbol.h! What they -- seem to want is the register number, as an absolute number. */ -- input_line_pointer++; /* Skip & */ -- (void) expression (expressionP); -- -- if (expressionP->X_op != O_register) -- as_bad (_("invalid register in & expression")); -- else -- expressionP->X_op = O_constant; -- } -- else if (input_line_pointer[0] == '$' -- && ISDIGIT ((unsigned char) input_line_pointer[1])) -- { -- long lab; -- char *name; -- symbolS *sym; -- -- /* This is a local label. */ -- ++input_line_pointer; -- lab = (long) get_absolute_expression (); -- -- if (dollar_label_defined (lab)) -- { -- name = dollar_label_name (lab, 0); -- sym = symbol_find (name); -- } -- else -- { -- name = dollar_label_name (lab, 1); -- sym = symbol_find_or_make (name); -- } -- -- expressionP->X_op = O_symbol; -- expressionP->X_add_symbol = sym; -- expressionP->X_add_number = 0; -- } -- else if (input_line_pointer[0] == '$') -- { -- char *s; -- char type; -- int fieldnum, fieldlimit; -- LITTLENUM_TYPE floatbuf[8]; -- -- /* $float(), $doubleN(), or $extendN() convert floating values -- to integers. */ -- s = input_line_pointer; -- -- ++s; -- -- fieldnum = 0; -- if (strncmp (s, "double", sizeof "double" - 1) == 0) -- { -- s += sizeof "double" - 1; -- type = 'd'; -- fieldlimit = 2; -- } -- else if (strncmp (s, "float", sizeof "float" - 1) == 0) -- { -- s += sizeof "float" - 1; -- type = 'f'; -- fieldlimit = 1; -- } -- else if (strncmp (s, "extend", sizeof "extend" - 1) == 0) -- { -- s += sizeof "extend" - 1; -- type = 'x'; -- fieldlimit = 4; -- } -- else -- return; -- -- if (ISDIGIT (*s)) -- { -- fieldnum = *s - '0'; -- ++s; -- } -- if (fieldnum >= fieldlimit) -- return; -- -- SKIP_WHITESPACE (); -- if (*s != '(') -- return; -- ++s; -- SKIP_WHITESPACE (); -- -- s = atof_ieee (s, type, floatbuf); -- if (s == NULL) -- return; -- s = s; -- -- SKIP_WHITESPACE (); -- if (*s != ')') -- return; -- ++s; -- SKIP_WHITESPACE (); -- -- input_line_pointer = s; -- expressionP->X_op = O_constant; -- expressionP->X_unsigned = 1; -- expressionP->X_add_number = ((floatbuf[fieldnum * 2] -- << LITTLENUM_NUMBER_OF_BITS) -- + floatbuf[fieldnum * 2 + 1]); -- } --} -- --/* Round up a section size to the appropriate boundary. */ -- --valueT --md_section_align (segT segment ATTRIBUTE_UNUSED, valueT size ATTRIBUTE_UNUSED) --{ -- return size; /* Byte alignment is fine. */ --} -- --/* Exactly what point is a PC-relative offset relative TO? -- On the 29000, they're relative to the address of the instruction, -- which we have set up as the address of the fixup too. */ -- --long --md_pcrel_from (fixS *fixP) --{ -- return fixP->fx_where + fixP->fx_frag->fr_address; --} -- --/* Generate a reloc for a fixup. */ -- --arelent * --tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp) --{ -- arelent *reloc; -- -- reloc = xmalloc (sizeof (arelent)); -- reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *)); -- *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); -- reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; -- /* reloc->address = fixp->fx_frag->fr_address + fixp->fx_where + fixp->fx_addnumber;*/ -- reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type); -- -- if (reloc->howto == (reloc_howto_type *) NULL) -- { -- as_bad_where (fixp->fx_file, fixp->fx_line, -- _("reloc %d not supported by object file format"), -- (int) fixp->fx_r_type); -- return NULL; -- } -- -- if (fixp->fx_r_type == BFD_RELOC_VTABLE_ENTRY) -- reloc->address = fixp->fx_offset; -- -- reloc->addend = fixp->fx_addnumber; -- return reloc; --} -diff -rNU3 dist.orig/gas/config/tc-or32.h dist/gas/config/tc-or32.h ---- dist.orig/gas/config/tc-or32.h 2007-07-03 13:01:04.000000000 +0200 -+++ dist/gas/config/tc-or32.h 1970-01-01 01:00:00.000000000 +0100 -@@ -1,56 +0,0 @@ --/* tc-or32.h -- Assemble for the OpenRISC 1000. -- Copyright (C) 2002, 2003. 2005, 2007 Free Software Foundation, Inc. -- Contributed by Damjan Lampret . -- Based upon a29k port. -- -- This file is part of GAS, the GNU Assembler. -- -- GAS is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3, or (at your option) -- any later version. -- -- GAS is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with GAS; see the file COPYING. If not, write to -- the Free Software Foundation, 51 Franklin Street - Fifth Floor, -- Boston, MA 02110-1301, USA. */ -- --#define TC_OR32 -- --#define TARGET_BYTES_BIG_ENDIAN 1 -- --#define LEX_DOLLAR 1 -- --#ifdef OBJ_ELF --#define TARGET_FORMAT "elf32-or32" --#define TARGET_ARCH bfd_arch_or32 --#endif -- --#ifdef OBJ_COFF --#define TARGET_FORMAT "coff-or32-big" --#define reloc_type int --#endif -- --#define tc_unrecognized_line(c) or32_unrecognized_line (c) -- --extern int or32_unrecognized_line (int); -- --#define tc_coff_symbol_emit_hook(a) ; /* Not used. */ -- --#define COFF_MAGIC SIPFBOMAGIC -- --/* No shared lib support, so we don't need to ensure externally -- visible symbols can be overridden. */ --#define EXTERN_FORCE_RELOC 0 -- --#ifdef OBJ_ELF --/* Values passed to md_apply_fix don't include the symbol value. */ --#define MD_APPLY_SYM_VALUE(FIX) 0 --#endif -- --#define ZERO_BASED_SEGMENTS -diff -rNU3 dist.orig/gas/config/tc-riscv.c dist/gas/config/tc-riscv.c ---- dist.orig/gas/config/tc-riscv.c 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gas/config/tc-riscv.c 2015-10-18 13:11:13.000000000 +0200 -@@ -0,0 +1,2225 @@ -+/* tc-riscv.c -- RISC-V assembler -+ Copyright 2011-2014 Free Software Foundation, Inc. -+ -+ Contributed by Andrew Waterman (waterman@cs.berkeley.edu) at UC Berkeley. -+ Based on MIPS target. -+ -+ This file is part of GAS. -+ -+ GAS is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3, or (at your option) -+ any later version. -+ -+ GAS is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with GAS; see the file COPYING. If not, write to the Free -+ Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA -+ 02110-1301, USA. */ -+ -+#include "as.h" -+#include "config.h" -+#include "subsegs.h" -+#include "safe-ctype.h" -+ -+#include "itbl-ops.h" -+#include "dwarf2dbg.h" -+#include "dw2gencfi.h" -+ -+#include "elf/riscv.h" -+#include "opcode/riscv.h" -+ -+#include -+#include -+ -+/* Information about an instruction, including its format, operands -+ and fixups. */ -+struct riscv_cl_insn -+{ -+ /* The opcode's entry in riscv_opcodes. */ -+ const struct riscv_opcode *insn_mo; -+ -+ /* The encoded instruction bits. */ -+ insn_t insn_opcode; -+ -+ /* The frag that contains the instruction. */ -+ struct frag *frag; -+ -+ /* The offset into FRAG of the first instruction byte. */ -+ long where; -+ -+ /* The relocs associated with the instruction, if any. */ -+ fixS *fixp; -+}; -+ -+bfd_boolean rv64 = TRUE; /* RV64 (true) or RV32 (false) */ -+#define LOAD_ADDRESS_INSN (rv64 ? "ld" : "lw") -+#define ADD32_INSN (rv64 ? "addiw" : "addi") -+ -+struct riscv_subset -+{ -+ const char* name; -+ int version_major; -+ int version_minor; -+ -+ struct riscv_subset* next; -+}; -+ -+static struct riscv_subset* riscv_subsets; -+ -+static int -+riscv_subset_supports(const char* feature) -+{ -+ struct riscv_subset* s; -+ bfd_boolean rv64_insn; -+ -+ if ((rv64_insn = !strncmp(feature, "64", 2)) || !strncmp(feature, "32", 2)) -+ { -+ if (rv64 != rv64_insn) -+ return 0; -+ feature += 2; -+ } -+ -+ for (s = riscv_subsets; s != NULL; s = s->next) -+ if (strcmp(s->name, feature) == 0) -+ /* FIXME: once we support version numbers: -+ return major == s->version_major && minor <= s->version_minor; */ -+ return 1; -+ -+ return 0; -+} -+ -+static void -+riscv_add_subset(const char* subset) -+{ -+ struct riscv_subset* s = xmalloc(sizeof(struct riscv_subset)); -+ s->name = xstrdup(subset); -+ s->version_major = 1; -+ s->version_minor = 0; -+ s->next = riscv_subsets; -+ riscv_subsets = s; -+} -+ -+static void -+riscv_set_arch(const char* arg) -+{ -+ /* Formally, ISA subset names begin with RV, RV32, or RV64, but we allow the -+ prefix to be omitted. We also allow all-lowercase names if version -+ numbers and eXtensions are omitted (i.e. only some combination of imafd -+ is supported in this case). -+ -+ FIXME: Version numbers are not supported yet. */ -+ const char* subsets = "IMAFD"; -+ const char* p; -+ -+ for (p = arg; *p; p++) -+ if (!ISLOWER(*p) || strchr(subsets, TOUPPER(*p)) == NULL) -+ break; -+ -+ if (!*p) -+ { -+ /* Legal all-lowercase name. */ -+ for (p = arg; *p; p++) -+ { -+ char subset[2] = {TOUPPER(*p), 0}; -+ riscv_add_subset(subset); -+ } -+ return; -+ } -+ -+ if (strncmp(arg, "RV32", 4) == 0) -+ { -+ rv64 = FALSE; -+ arg += 4; -+ } -+ else if (strncmp(arg, "RV64", 4) == 0) -+ { -+ rv64 = TRUE; -+ arg += 4; -+ } -+ else if (strncmp(arg, "RV", 2) == 0) -+ arg += 2; -+ -+ if (*arg && *arg != 'I') -+ as_fatal("`I' must be the first ISA subset name specified (got %c)", *arg); -+ -+ for (p = arg; *p; p++) -+ { -+ if (*p == 'X') -+ { -+ const char* q = p+1; -+ while (ISLOWER(*q)) -+ q++; -+ -+ char subset[q-p+1]; -+ memcpy(subset, p, q-p); -+ subset[q-p] = 0; -+ -+ riscv_add_subset(subset); -+ p = q-1; -+ } -+ else if (strchr(subsets, *p) != NULL) -+ { -+ char subset[2] = {*p, 0}; -+ riscv_add_subset(subset); -+ } -+ else -+ as_fatal("unsupported ISA subset %c", *p); -+ } -+} -+ -+/* This is the set of options which may be modified by the .set -+ pseudo-op. We use a struct so that .set push and .set pop are more -+ reliable. */ -+ -+struct riscv_set_options -+{ -+ /* Generate position-independent code. */ -+ int pic; -+ /* Generate RVC code. */ -+ int rvc; -+}; -+ -+static struct riscv_set_options riscv_opts = -+{ -+ 0, /* pic */ -+ 0, /* rvc */ -+}; -+ -+/* handle of the OPCODE hash table */ -+static struct hash_control *op_hash = NULL; -+ -+/* This array holds the chars that always start a comment. If the -+ pre-processor is disabled, these aren't very useful */ -+const char comment_chars[] = "#"; -+ -+/* This array holds the chars that only start a comment at the beginning of -+ a line. If the line seems to have the form '# 123 filename' -+ .line and .file directives will appear in the pre-processed output */ -+/* Note that input_file.c hand checks for '#' at the beginning of the -+ first line of the input file. This is because the compiler outputs -+ #NO_APP at the beginning of its output. */ -+/* Also note that C style comments are always supported. */ -+const char line_comment_chars[] = "#"; -+ -+/* This array holds machine specific line separator characters. */ -+const char line_separator_chars[] = ";"; -+ -+/* Chars that can be used to separate mant from exp in floating point nums */ -+const char EXP_CHARS[] = "eE"; -+ -+/* Chars that mean this number is a floating point constant */ -+/* As in 0f12.456 */ -+/* or 0d1.2345e12 */ -+const char FLT_CHARS[] = "rRsSfFdDxXpP"; -+ -+/* Also be aware that MAXIMUM_NUMBER_OF_CHARS_FOR_FLOAT may have to be -+ changed in read.c . Ideally it shouldn't have to know about it at all, -+ but nothing is ideal around here. -+ */ -+ -+static char *insn_error; -+ -+#define RELAX_BRANCH_ENCODE(uncond, toofar) \ -+ ((relax_substateT) \ -+ (0xc0000000 \ -+ | ((toofar) ? 1 : 0) \ -+ | ((uncond) ? 2 : 0))) -+#define RELAX_BRANCH_P(i) (((i) & 0xf0000000) == 0xc0000000) -+#define RELAX_BRANCH_TOOFAR(i) (((i) & 1) != 0) -+#define RELAX_BRANCH_UNCOND(i) (((i) & 2) != 0) -+ -+/* Is the given value a sign-extended 32-bit value? */ -+#define IS_SEXT_32BIT_NUM(x) \ -+ (((x) &~ (offsetT) 0x7fffffff) == 0 \ -+ || (((x) &~ (offsetT) 0x7fffffff) == ~ (offsetT) 0x7fffffff)) -+ -+#define IS_SEXT_NBIT_NUM(x,n) \ -+ ({ int64_t __tmp = (x); \ -+ __tmp = (__tmp << (64-(n))) >> (64-(n)); \ -+ __tmp == (x); }) -+ -+/* Is the given value a zero-extended 32-bit value? Or a negated one? */ -+#define IS_ZEXT_32BIT_NUM(x) \ -+ (((x) &~ (offsetT) 0xffffffff) == 0 \ -+ || (((x) &~ (offsetT) 0xffffffff) == ~ (offsetT) 0xffffffff)) -+ -+/* Replace bits MASK << SHIFT of STRUCT with the equivalent bits in -+ VALUE << SHIFT. VALUE is evaluated exactly once. */ -+#define INSERT_BITS(STRUCT, VALUE, MASK, SHIFT) \ -+ (STRUCT) = (((STRUCT) & ~((insn_t)(MASK) << (SHIFT))) \ -+ | ((insn_t)((VALUE) & (MASK)) << (SHIFT))) -+ -+/* Extract bits MASK << SHIFT from STRUCT and shift them right -+ SHIFT places. */ -+#define EXTRACT_BITS(STRUCT, MASK, SHIFT) \ -+ (((STRUCT) >> (SHIFT)) & (MASK)) -+ -+/* Change INSN's opcode so that the operand given by FIELD has value VALUE. -+ INSN is a riscv_cl_insn structure and VALUE is evaluated exactly once. */ -+#define INSERT_OPERAND(FIELD, INSN, VALUE) \ -+ INSERT_BITS ((INSN).insn_opcode, VALUE, OP_MASK_##FIELD, OP_SH_##FIELD) -+ -+/* Extract the operand given by FIELD from riscv_cl_insn INSN. */ -+#define EXTRACT_OPERAND(FIELD, INSN) \ -+ EXTRACT_BITS ((INSN).insn_opcode, OP_MASK_##FIELD, OP_SH_##FIELD) -+ -+/* Determine if an instruction matches an opcode. */ -+#define OPCODE_MATCHES(OPCODE, OP) \ -+ (((OPCODE) & MASK_##OP) == MATCH_##OP) -+ -+#define INSN_MATCHES(INSN, OP) \ -+ (((INSN).insn_opcode & MASK_##OP) == MATCH_##OP) -+ -+/* Prototypes for static functions. */ -+ -+#define internalError() \ -+ as_fatal (_("internal Error, line %d, %s"), __LINE__, __FILE__) -+ -+static char *expr_end; -+ -+/* Expressions which appear in instructions. These are set by -+ riscv_ip. */ -+ -+static expressionS imm_expr; -+static expressionS offset_expr; -+ -+/* Relocs associated with imm_expr and offset_expr. */ -+ -+static bfd_reloc_code_real_type imm_reloc = BFD_RELOC_UNUSED; -+static bfd_reloc_code_real_type offset_reloc = BFD_RELOC_UNUSED; -+ -+/* The default target format to use. */ -+ -+const char * -+riscv_target_format (void) -+{ -+ return rv64 ? "elf64-littleriscv" : "elf32-littleriscv"; -+} -+ -+/* Return the length of instruction INSN. */ -+ -+static inline unsigned int -+insn_length (const struct riscv_cl_insn *insn) -+{ -+ return riscv_insn_length (insn->insn_opcode); -+} -+ -+/* Initialise INSN from opcode entry MO. Leave its position unspecified. */ -+ -+static void -+create_insn (struct riscv_cl_insn *insn, const struct riscv_opcode *mo) -+{ -+ insn->insn_mo = mo; -+ insn->insn_opcode = mo->match; -+ insn->frag = NULL; -+ insn->where = 0; -+ insn->fixp = NULL; -+} -+ -+/* Install INSN at the location specified by its "frag" and "where" fields. */ -+ -+static void -+install_insn (const struct riscv_cl_insn *insn) -+{ -+ char *f = insn->frag->fr_literal + insn->where; -+ md_number_to_chars (f, insn->insn_opcode, insn_length(insn)); -+} -+ -+/* Move INSN to offset WHERE in FRAG. Adjust the fixups accordingly -+ and install the opcode in the new location. */ -+ -+static void -+move_insn (struct riscv_cl_insn *insn, fragS *frag, long where) -+{ -+ insn->frag = frag; -+ insn->where = where; -+ if (insn->fixp != NULL) -+ { -+ insn->fixp->fx_frag = frag; -+ insn->fixp->fx_where = where; -+ } -+ install_insn (insn); -+} -+ -+/* Add INSN to the end of the output. */ -+ -+static void -+add_fixed_insn (struct riscv_cl_insn *insn) -+{ -+ char *f = frag_more (insn_length (insn)); -+ move_insn (insn, frag_now, f - frag_now->fr_literal); -+} -+ -+static void -+add_relaxed_insn (struct riscv_cl_insn *insn, int max_chars, int var, -+ relax_substateT subtype, symbolS *symbol, offsetT offset) -+{ -+ frag_grow (max_chars); -+ move_insn (insn, frag_now, frag_more (0) - frag_now->fr_literal); -+ frag_var (rs_machine_dependent, max_chars, var, -+ subtype, symbol, offset, NULL); -+} -+ -+/* Compute the length of a branch sequence, and adjust the -+ RELAX_BRANCH_TOOFAR bit accordingly. If FRAGP is NULL, the -+ worst-case length is computed. */ -+static int -+relaxed_branch_length (fragS *fragp, asection *sec, int update) -+{ -+ bfd_boolean toofar = TRUE; -+ -+ if (fragp) -+ { -+ bfd_boolean uncond = RELAX_BRANCH_UNCOND (fragp->fr_subtype); -+ -+ if (S_IS_DEFINED (fragp->fr_symbol) -+ && sec == S_GET_SEGMENT (fragp->fr_symbol)) -+ { -+ offsetT val = S_GET_VALUE (fragp->fr_symbol) + fragp->fr_offset; -+ bfd_vma range; -+ val -= fragp->fr_address + fragp->fr_fix; -+ -+ if (uncond) -+ range = RISCV_JUMP_REACH; -+ else -+ range = RISCV_BRANCH_REACH; -+ toofar = (bfd_vma)(val + range/2) >= range; -+ } -+ -+ if (update && toofar != RELAX_BRANCH_TOOFAR (fragp->fr_subtype)) -+ fragp->fr_subtype = RELAX_BRANCH_ENCODE (uncond, toofar); -+ } -+ -+ return toofar ? 8 : 4; -+} -+ -+struct regname { -+ const char *name; -+ unsigned int num; -+}; -+ -+enum reg_class { -+ RCLASS_GPR, -+ RCLASS_FPR, -+ RCLASS_CSR, -+ RCLASS_VEC_GPR, -+ RCLASS_VEC_FPR, -+ RCLASS_MAX -+}; -+ -+static struct hash_control *reg_names_hash = NULL; -+ -+#define ENCODE_REG_HASH(cls, n) (void*)(uintptr_t)((n)*RCLASS_MAX + (cls) + 1) -+#define DECODE_REG_CLASS(hash) (((uintptr_t)(hash) - 1) % RCLASS_MAX) -+#define DECODE_REG_NUM(hash) (((uintptr_t)(hash) - 1) / RCLASS_MAX) -+ -+static void -+hash_reg_name (enum reg_class class, const char *name, unsigned n) -+{ -+ void *hash = ENCODE_REG_HASH (class, n); -+ const char *retval = hash_insert (reg_names_hash, name, hash); -+ if (retval != NULL) -+ as_fatal (_("internal error: can't hash `%s': %s"), name, retval); -+} -+ -+static void -+hash_reg_names (enum reg_class class, const char * const names[], unsigned n) -+{ -+ unsigned i; -+ for (i = 0; i < n; i++) -+ hash_reg_name (class, names[i], i); -+} -+ -+static unsigned int -+reg_lookup_internal (const char *s, enum reg_class class) -+{ -+ struct regname *r = (struct regname *) hash_find (reg_names_hash, s); -+ if (r == NULL || DECODE_REG_CLASS (r) != class) -+ return -1; -+ return DECODE_REG_NUM (r); -+} -+ -+static int -+reg_lookup (char **s, enum reg_class class, unsigned int *regnop) -+{ -+ char *e; -+ char save_c; -+ int reg = -1; -+ -+ /* Find end of name. */ -+ e = *s; -+ if (is_name_beginner (*e)) -+ ++e; -+ while (is_part_of_name (*e)) -+ ++e; -+ -+ /* Terminate name. */ -+ save_c = *e; -+ *e = '\0'; -+ -+ /* Look for the register. Advance to next token if one was recognized. */ -+ if ((reg = reg_lookup_internal (*s, class)) >= 0) -+ *s = e; -+ -+ *e = save_c; -+ if (regnop) -+ *regnop = reg; -+ return reg >= 0; -+} -+ -+static int -+arg_lookup(char **s, const char* const* array, size_t size, unsigned *regnop) -+{ -+ const char *p = strchr(*s, ','); -+ size_t i, len = p ? (size_t)(p - *s) : strlen(*s); -+ -+ for (i = 0; i < size; i++) -+ if (array[i] != NULL && strncmp(array[i], *s, len) == 0) -+ { -+ *regnop = i; -+ *s += len; -+ return 1; -+ } -+ -+ return 0; -+} -+ -+/* For consistency checking, verify that all bits are specified either -+ by the match/mask part of the instruction definition, or by the -+ operand list. */ -+static int -+validate_riscv_insn (const struct riscv_opcode *opc) -+{ -+ const char *p = opc->args; -+ char c; -+ insn_t required_bits, used_bits = opc->mask; -+ -+ if ((used_bits & opc->match) != opc->match) -+ { -+ as_bad (_("internal: bad RISC-V opcode (mask error): %s %s"), -+ opc->name, opc->args); -+ return 0; -+ } -+ required_bits = ((insn_t)1 << (8 * riscv_insn_length (opc->match))) - 1; -+ /* Work around for undefined behavior of uint64_t << 64 */ -+ if(riscv_insn_length (opc->match) == 8) -+ required_bits = 0xffffffffffffffff; -+ -+#define USE_BITS(mask,shift) (used_bits |= ((insn_t)(mask) << (shift))) -+ while (*p) -+ switch (c = *p++) -+ { -+ /* Xcustom */ -+ case '^': -+ switch (c = *p++) -+ { -+ case 'd': USE_BITS (OP_MASK_RD, OP_SH_RD); break; -+ case 's': USE_BITS (OP_MASK_RS1, OP_SH_RS1); break; -+ case 't': USE_BITS (OP_MASK_RS2, OP_SH_RS2); break; -+ case 'j': USE_BITS (OP_MASK_CUSTOM_IMM, OP_SH_CUSTOM_IMM); break; -+ } -+ break; -+ /* Xhwacha */ -+ case '#': -+ switch (c = *p++) -+ { -+ case 'g': USE_BITS (OP_MASK_IMMNGPR, OP_SH_IMMNGPR); break; -+ case 'f': USE_BITS (OP_MASK_IMMNFPR, OP_SH_IMMNFPR); break; -+ case 'n': USE_BITS (OP_MASK_IMMSEGNELM, OP_SH_IMMSEGNELM); break; -+ case 'd': USE_BITS (OP_MASK_VRD, OP_SH_VRD); break; -+ case 's': USE_BITS (OP_MASK_VRS, OP_SH_VRS); break; -+ case 't': USE_BITS (OP_MASK_VRT, OP_SH_VRT); break; -+ case 'r': USE_BITS (OP_MASK_VRR, OP_SH_VRR); break; -+ case 'D': USE_BITS (OP_MASK_VFD, OP_SH_VFD); break; -+ case 'S': USE_BITS (OP_MASK_VFS, OP_SH_VFS); break; -+ case 'T': USE_BITS (OP_MASK_VFT, OP_SH_VFT); break; -+ case 'R': USE_BITS (OP_MASK_VFR, OP_SH_VFR); break; -+ -+ default: -+ as_bad (_("internal: bad RISC-V opcode (unknown extension operand type `#%c'): %s %s"), -+ c, opc->name, opc->args); -+ return 0; -+ } -+ break; -+ case ',': break; -+ case '(': break; -+ case ')': break; -+ case '<': USE_BITS (OP_MASK_SHAMTW, OP_SH_SHAMTW); break; -+ case '>': USE_BITS (OP_MASK_SHAMT, OP_SH_SHAMT); break; -+ case 'A': break; -+ case 'D': USE_BITS (OP_MASK_RD, OP_SH_RD); break; -+ case 'Z': USE_BITS (OP_MASK_RS1, OP_SH_RS1); break; -+ case 'E': USE_BITS (OP_MASK_CSR, OP_SH_CSR); break; -+ case 'I': break; -+ case 'R': USE_BITS (OP_MASK_RS3, OP_SH_RS3); break; -+ case 'S': USE_BITS (OP_MASK_RS1, OP_SH_RS1); break; -+ case 'U': USE_BITS (OP_MASK_RS1, OP_SH_RS1); /* fallthru */ -+ case 'T': USE_BITS (OP_MASK_RS2, OP_SH_RS2); break; -+ case 'd': USE_BITS (OP_MASK_RD, OP_SH_RD); break; -+ case 'm': USE_BITS (OP_MASK_RM, OP_SH_RM); break; -+ case 's': USE_BITS (OP_MASK_RS1, OP_SH_RS1); break; -+ case 't': USE_BITS (OP_MASK_RS2, OP_SH_RS2); break; -+ case 'P': USE_BITS (OP_MASK_PRED, OP_SH_PRED); break; -+ case 'Q': USE_BITS (OP_MASK_SUCC, OP_SH_SUCC); break; -+ case 'o': -+ case 'j': used_bits |= ENCODE_ITYPE_IMM(-1U); break; -+ case 'a': used_bits |= ENCODE_UJTYPE_IMM(-1U); break; -+ case 'p': used_bits |= ENCODE_SBTYPE_IMM(-1U); break; -+ case 'q': used_bits |= ENCODE_STYPE_IMM(-1U); break; -+ case 'u': used_bits |= ENCODE_UTYPE_IMM(-1U); break; -+ case '[': break; -+ case ']': break; -+ case '0': break; -+ default: -+ as_bad (_("internal: bad RISC-V opcode (unknown operand type `%c'): %s %s"), -+ c, opc->name, opc->args); -+ return 0; -+ } -+#undef USE_BITS -+ if (used_bits != required_bits) -+ { -+ as_bad (_("internal: bad RISC-V opcode (bits 0x%lx undefined): %s %s"), -+ ~(long)(used_bits & required_bits), opc->name, opc->args); -+ return 0; -+ } -+ return 1; -+} -+ -+struct percent_op_match -+{ -+ const char *str; -+ bfd_reloc_code_real_type reloc; -+}; -+ -+/* This function is called once, at assembler startup time. It should set up -+ all the tables, etc. that the MD part of the assembler will need. */ -+ -+void -+md_begin (void) -+{ -+ const char *retval = NULL; -+ int i = 0; -+ -+ if (! bfd_set_arch_mach (stdoutput, bfd_arch_riscv, 0)) -+ as_warn (_("Could not set architecture and machine")); -+ -+ op_hash = hash_new (); -+ -+ for (i = 0; i < NUMOPCODES;) -+ { -+ const char *name = riscv_opcodes[i].name; -+ -+ if (riscv_subset_supports(riscv_opcodes[i].subset)) -+ retval = hash_insert (op_hash, name, (void *) &riscv_opcodes[i]); -+ -+ if (retval != NULL) -+ { -+ fprintf (stderr, _("internal error: can't hash `%s': %s\n"), -+ riscv_opcodes[i].name, retval); -+ /* Probably a memory allocation problem? Give up now. */ -+ as_fatal (_("Broken assembler. No assembly attempted.")); -+ } -+ do -+ { -+ if (riscv_opcodes[i].pinfo != INSN_MACRO) -+ { -+ if (!validate_riscv_insn (&riscv_opcodes[i])) -+ as_fatal (_("Broken assembler. No assembly attempted.")); -+ } -+ ++i; -+ } -+ while ((i < NUMOPCODES) && !strcmp (riscv_opcodes[i].name, name)); -+ } -+ -+ reg_names_hash = hash_new (); -+ hash_reg_names (RCLASS_GPR, riscv_gpr_names_numeric, NGPR); -+ hash_reg_names (RCLASS_GPR, riscv_gpr_names_abi, NGPR); -+ hash_reg_names (RCLASS_FPR, riscv_fpr_names_numeric, NFPR); -+ hash_reg_names (RCLASS_FPR, riscv_fpr_names_abi, NFPR); -+ hash_reg_names (RCLASS_VEC_GPR, riscv_vec_gpr_names, NVGPR); -+ hash_reg_names (RCLASS_VEC_FPR, riscv_vec_fpr_names, NVFPR); -+ -+#define DECLARE_CSR(name, num) hash_reg_name (RCLASS_CSR, #name, num); -+#include "opcode/riscv-opc.h" -+#undef DECLARE_CSR -+ -+ /* set the default alignment for the text section (2**2) */ -+ record_alignment (text_section, 2); -+} -+ -+/* Output an instruction. IP is the instruction information. -+ ADDRESS_EXPR is an operand of the instruction to be used with -+ RELOC_TYPE. */ -+ -+static void -+append_insn (struct riscv_cl_insn *ip, expressionS *address_expr, -+ bfd_reloc_code_real_type reloc_type) -+{ -+#ifdef OBJ_ELF -+ dwarf2_emit_insn (0); -+#endif -+ -+ gas_assert(reloc_type <= BFD_RELOC_UNUSED); -+ -+ if (address_expr != NULL) -+ { -+ if (address_expr->X_op == O_constant) -+ { -+ switch (reloc_type) -+ { -+ case BFD_RELOC_32: -+ ip->insn_opcode |= address_expr->X_add_number; -+ break; -+ -+ case BFD_RELOC_RISCV_HI20: -+ ip->insn_opcode |= ENCODE_UTYPE_IMM ( -+ RISCV_CONST_HIGH_PART (address_expr->X_add_number)); -+ break; -+ -+ case BFD_RELOC_RISCV_LO12_S: -+ ip->insn_opcode |= ENCODE_STYPE_IMM (address_expr->X_add_number); -+ break; -+ -+ case BFD_RELOC_UNUSED: -+ case BFD_RELOC_RISCV_LO12_I: -+ ip->insn_opcode |= ENCODE_ITYPE_IMM (address_expr->X_add_number); -+ break; -+ -+ default: -+ internalError (); -+ } -+ reloc_type = BFD_RELOC_UNUSED; -+ } -+ else if (reloc_type == BFD_RELOC_12_PCREL) -+ { -+ add_relaxed_insn (ip, relaxed_branch_length (NULL, NULL, 0), 4, -+ RELAX_BRANCH_ENCODE (0, 0), -+ address_expr->X_add_symbol, -+ address_expr->X_add_number); -+ return; -+ } -+ else if (reloc_type < BFD_RELOC_UNUSED) -+ { -+ reloc_howto_type *howto; -+ -+ howto = bfd_reloc_type_lookup (stdoutput, reloc_type); -+ if (howto == NULL) -+ as_bad (_("Unsupported RISC-V relocation number %d"), reloc_type); -+ -+ ip->fixp = fix_new_exp (ip->frag, ip->where, -+ bfd_get_reloc_size (howto), -+ address_expr, -+ reloc_type == BFD_RELOC_12_PCREL || -+ reloc_type == BFD_RELOC_RISCV_CALL || -+ reloc_type == BFD_RELOC_RISCV_JMP, -+ reloc_type); -+ -+ /* These relocations can have an addend that won't fit in -+ 4 octets for 64bit assembly. */ -+ if (rv64 -+ && ! howto->partial_inplace -+ && (reloc_type == BFD_RELOC_32 -+ || reloc_type == BFD_RELOC_64 -+ || reloc_type == BFD_RELOC_CTOR -+ || reloc_type == BFD_RELOC_RISCV_HI20 -+ || reloc_type == BFD_RELOC_RISCV_LO12_I -+ || reloc_type == BFD_RELOC_RISCV_LO12_S)) -+ ip->fixp->fx_no_overflow = 1; -+ } -+ } -+ -+ add_fixed_insn (ip); -+ -+ install_insn (ip); -+} -+ -+/* Build an instruction created by a macro expansion. This is passed -+ a pointer to the count of instructions created so far, an -+ expression, the name of the instruction to build, an operand format -+ string, and corresponding arguments. */ -+ -+static void -+macro_build (expressionS *ep, const char *name, const char *fmt, ...) -+{ -+ const struct riscv_opcode *mo; -+ struct riscv_cl_insn insn; -+ bfd_reloc_code_real_type r; -+ va_list args; -+ -+ va_start (args, fmt); -+ -+ r = BFD_RELOC_UNUSED; -+ mo = (struct riscv_opcode *) hash_find (op_hash, name); -+ gas_assert (mo); -+ gas_assert (strcmp (name, mo->name) == 0); -+ -+ create_insn (&insn, mo); -+ for (;;) -+ { -+ switch (*fmt++) -+ { -+ case 'd': -+ INSERT_OPERAND (RD, insn, va_arg (args, int)); -+ continue; -+ -+ case 's': -+ INSERT_OPERAND (RS1, insn, va_arg (args, int)); -+ continue; -+ -+ case 't': -+ INSERT_OPERAND (RS2, insn, va_arg (args, int)); -+ continue; -+ -+ case '>': -+ INSERT_OPERAND (SHAMT, insn, va_arg (args, int)); -+ continue; -+ -+ case 'j': -+ case 'u': -+ case 'q': -+ gas_assert (ep != NULL); -+ r = va_arg (args, int); -+ continue; -+ -+ case '\0': -+ break; -+ case ',': -+ continue; -+ default: -+ internalError (); -+ } -+ break; -+ } -+ va_end (args); -+ gas_assert (r == BFD_RELOC_UNUSED ? ep == NULL : ep != NULL); -+ -+ append_insn (&insn, ep, r); -+} -+ -+/* -+ * Sign-extend 32-bit mode constants that have bit 31 set and all -+ * higher bits unset. -+ */ -+static void -+normalize_constant_expr (expressionS *ex) -+{ -+ if (rv64) -+ return; -+ if ((ex->X_op == O_constant || ex->X_op == O_symbol) -+ && IS_ZEXT_32BIT_NUM (ex->X_add_number)) -+ ex->X_add_number = (((ex->X_add_number & 0xffffffff) ^ 0x80000000) -+ - 0x80000000); -+} -+ -+static symbolS * -+make_internal_label (void) -+{ -+ return (symbolS *) local_symbol_make (FAKE_LABEL_NAME, now_seg, -+ (valueT) frag_now_fix(), frag_now); -+} -+ -+/* Load an entry from the GOT. */ -+static void -+pcrel_access (int destreg, int tempreg, expressionS *ep, -+ const char* lo_insn, const char* lo_pattern, -+ bfd_reloc_code_real_type hi_reloc, -+ bfd_reloc_code_real_type lo_reloc) -+{ -+ expressionS ep2; -+ ep2.X_op = O_symbol; -+ ep2.X_add_symbol = make_internal_label (); -+ ep2.X_add_number = 0; -+ -+ macro_build (ep, "auipc", "d,u", tempreg, hi_reloc); -+ macro_build (&ep2, lo_insn, lo_pattern, destreg, tempreg, lo_reloc); -+} -+ -+static void -+pcrel_load (int destreg, int tempreg, expressionS *ep, const char* lo_insn, -+ bfd_reloc_code_real_type hi_reloc, -+ bfd_reloc_code_real_type lo_reloc) -+{ -+ pcrel_access (destreg, tempreg, ep, lo_insn, "d,s,j", hi_reloc, lo_reloc); -+} -+ -+static void -+pcrel_store (int srcreg, int tempreg, expressionS *ep, const char* lo_insn, -+ bfd_reloc_code_real_type hi_reloc, -+ bfd_reloc_code_real_type lo_reloc) -+{ -+ pcrel_access (srcreg, tempreg, ep, lo_insn, "t,s,q", hi_reloc, lo_reloc); -+} -+ -+/* PC-relative function call using AUIPC/JALR, relaxed to JAL. */ -+static void -+riscv_call (int destreg, int tempreg, expressionS *ep, -+ bfd_reloc_code_real_type reloc) -+{ -+ macro_build (ep, "auipc", "d,u", tempreg, reloc); -+ macro_build (NULL, "jalr", "d,s", destreg, tempreg); -+} -+ -+/* Warn if an expression is not a constant. */ -+ -+static void -+check_absolute_expr (struct riscv_cl_insn *ip, expressionS *ex) -+{ -+ if (ex->X_op == O_big) -+ as_bad (_("unsupported large constant")); -+ else if (ex->X_op != O_constant) -+ as_bad (_("Instruction %s requires absolute expression"), -+ ip->insn_mo->name); -+ normalize_constant_expr (ex); -+} -+ -+/* Load an integer constant into a register. */ -+ -+static void -+load_const (int reg, expressionS *ep) -+{ -+ int shift = RISCV_IMM_BITS; -+ expressionS upper = *ep, lower = *ep; -+ lower.X_add_number = (int32_t) ep->X_add_number << (32-shift) >> (32-shift); -+ upper.X_add_number -= lower.X_add_number; -+ -+ gas_assert (ep->X_op == O_constant); -+ -+ if (rv64 && !IS_SEXT_32BIT_NUM(ep->X_add_number)) -+ { -+ /* Reduce to a signed 32-bit constant using SLLI and ADDI, which -+ is not optimal but also not so bad. */ -+ while (((upper.X_add_number >> shift) & 1) == 0) -+ shift++; -+ -+ upper.X_add_number = (int64_t) upper.X_add_number >> shift; -+ load_const(reg, &upper); -+ -+ macro_build (NULL, "slli", "d,s,>", reg, reg, shift); -+ if (lower.X_add_number != 0) -+ macro_build (&lower, "addi", "d,s,j", reg, reg, BFD_RELOC_RISCV_LO12_I); -+ } -+ else -+ { -+ int hi_reg = 0; -+ -+ if (upper.X_add_number != 0) -+ { -+ macro_build (ep, "lui", "d,u", reg, BFD_RELOC_RISCV_HI20); -+ hi_reg = reg; -+ } -+ -+ if (lower.X_add_number != 0 || hi_reg == 0) -+ macro_build (ep, ADD32_INSN, "d,s,j", reg, hi_reg, -+ BFD_RELOC_RISCV_LO12_I); -+ } -+} -+ -+/* Expand RISC-V assembly macros into one or more instructions. */ -+static void -+macro (struct riscv_cl_insn *ip) -+{ -+ int rd = (ip->insn_opcode >> OP_SH_RD) & OP_MASK_RD; -+ int rs1 = (ip->insn_opcode >> OP_SH_RS1) & OP_MASK_RS1; -+ int rs2 = (ip->insn_opcode >> OP_SH_RS2) & OP_MASK_RS2; -+ int mask = ip->insn_mo->mask; -+ -+ switch (mask) -+ { -+ case M_LI: -+ load_const (rd, &imm_expr); -+ break; -+ -+ case M_LA: -+ case M_LLA: -+ /* Load the address of a symbol into a register. */ -+ if (!IS_SEXT_32BIT_NUM (offset_expr.X_add_number)) -+ as_bad(_("offset too large")); -+ -+ if (offset_expr.X_op == O_constant) -+ load_const (rd, &offset_expr); -+ else if (riscv_opts.pic && mask == M_LA) /* Global PIC symbol */ -+ pcrel_load (rd, rd, &offset_expr, LOAD_ADDRESS_INSN, -+ BFD_RELOC_RISCV_GOT_HI20, BFD_RELOC_RISCV_PCREL_LO12_I); -+ else /* Local PIC symbol, or any non-PIC symbol */ -+ pcrel_load (rd, rd, &offset_expr, "addi", -+ BFD_RELOC_RISCV_PCREL_HI20, BFD_RELOC_RISCV_PCREL_LO12_I); -+ break; -+ -+ case M_LA_TLS_GD: -+ pcrel_load (rd, rd, &offset_expr, "addi", -+ BFD_RELOC_RISCV_TLS_GD_HI20, BFD_RELOC_RISCV_PCREL_LO12_I); -+ break; -+ -+ case M_LA_TLS_IE: -+ pcrel_load (rd, rd, &offset_expr, LOAD_ADDRESS_INSN, -+ BFD_RELOC_RISCV_TLS_GOT_HI20, BFD_RELOC_RISCV_PCREL_LO12_I); -+ break; -+ -+ case M_LB: -+ pcrel_load (rd, rd, &offset_expr, "lb", -+ BFD_RELOC_RISCV_PCREL_HI20, BFD_RELOC_RISCV_PCREL_LO12_I); -+ break; -+ -+ case M_LBU: -+ pcrel_load (rd, rd, &offset_expr, "lbu", -+ BFD_RELOC_RISCV_PCREL_HI20, BFD_RELOC_RISCV_PCREL_LO12_I); -+ break; -+ -+ case M_LH: -+ pcrel_load (rd, rd, &offset_expr, "lh", -+ BFD_RELOC_RISCV_PCREL_HI20, BFD_RELOC_RISCV_PCREL_LO12_I); -+ break; -+ -+ case M_LHU: -+ pcrel_load (rd, rd, &offset_expr, "lhu", -+ BFD_RELOC_RISCV_PCREL_HI20, BFD_RELOC_RISCV_PCREL_LO12_I); -+ break; -+ -+ case M_LW: -+ pcrel_load (rd, rd, &offset_expr, "lw", -+ BFD_RELOC_RISCV_PCREL_HI20, BFD_RELOC_RISCV_PCREL_LO12_I); -+ break; -+ -+ case M_LWU: -+ pcrel_load (rd, rd, &offset_expr, "lwu", -+ BFD_RELOC_RISCV_PCREL_HI20, BFD_RELOC_RISCV_PCREL_LO12_I); -+ break; -+ -+ case M_LD: -+ pcrel_load (rd, rd, &offset_expr, "ld", -+ BFD_RELOC_RISCV_PCREL_HI20, BFD_RELOC_RISCV_PCREL_LO12_I); -+ break; -+ -+ case M_FLW: -+ pcrel_load (rd, rs1, &offset_expr, "flw", -+ BFD_RELOC_RISCV_PCREL_HI20, BFD_RELOC_RISCV_PCREL_LO12_I); -+ break; -+ -+ case M_FLD: -+ pcrel_load (rd, rs1, &offset_expr, "fld", -+ BFD_RELOC_RISCV_PCREL_HI20, BFD_RELOC_RISCV_PCREL_LO12_I); -+ break; -+ -+ case M_SB: -+ pcrel_store (rs2, rs1, &offset_expr, "sb", -+ BFD_RELOC_RISCV_PCREL_HI20, BFD_RELOC_RISCV_PCREL_LO12_S); -+ break; -+ -+ case M_SH: -+ pcrel_store (rs2, rs1, &offset_expr, "sh", -+ BFD_RELOC_RISCV_PCREL_HI20, BFD_RELOC_RISCV_PCREL_LO12_S); -+ break; -+ -+ case M_SW: -+ pcrel_store (rs2, rs1, &offset_expr, "sw", -+ BFD_RELOC_RISCV_PCREL_HI20, BFD_RELOC_RISCV_PCREL_LO12_S); -+ break; -+ -+ case M_SD: -+ pcrel_store (rs2, rs1, &offset_expr, "sd", -+ BFD_RELOC_RISCV_PCREL_HI20, BFD_RELOC_RISCV_PCREL_LO12_S); -+ break; -+ -+ case M_FSW: -+ pcrel_store (rs2, rs1, &offset_expr, "fsw", -+ BFD_RELOC_RISCV_PCREL_HI20, BFD_RELOC_RISCV_PCREL_LO12_S); -+ break; -+ -+ case M_FSD: -+ pcrel_store (rs2, rs1, &offset_expr, "fsd", -+ BFD_RELOC_RISCV_PCREL_HI20, BFD_RELOC_RISCV_PCREL_LO12_S); -+ break; -+ -+ case M_VF: -+ pcrel_access (0, rs1, &offset_expr, "vf", "s,s,q", -+ BFD_RELOC_RISCV_PCREL_HI20, BFD_RELOC_RISCV_PCREL_LO12_S); -+ break; -+ -+ case M_CALL: -+ riscv_call (rd, rs1, &offset_expr, offset_reloc); -+ break; -+ -+ default: -+ as_bad (_("Macro %s not implemented"), ip->insn_mo->name); -+ break; -+ } -+} -+ -+static const struct percent_op_match percent_op_utype[] = -+{ -+ {"%tprel_hi", BFD_RELOC_RISCV_TPREL_HI20}, -+ {"%pcrel_hi", BFD_RELOC_RISCV_PCREL_HI20}, -+ {"%tls_ie_pcrel_hi", BFD_RELOC_RISCV_TLS_GOT_HI20}, -+ {"%tls_gd_pcrel_hi", BFD_RELOC_RISCV_TLS_GD_HI20}, -+ {"%hi", BFD_RELOC_RISCV_HI20}, -+ {0, 0} -+}; -+ -+static const struct percent_op_match percent_op_itype[] = -+{ -+ {"%lo", BFD_RELOC_RISCV_LO12_I}, -+ {"%tprel_lo", BFD_RELOC_RISCV_TPREL_LO12_I}, -+ {"%pcrel_lo", BFD_RELOC_RISCV_PCREL_LO12_I}, -+ {0, 0} -+}; -+ -+static const struct percent_op_match percent_op_stype[] = -+{ -+ {"%lo", BFD_RELOC_RISCV_LO12_S}, -+ {"%tprel_lo", BFD_RELOC_RISCV_TPREL_LO12_S}, -+ {"%pcrel_lo", BFD_RELOC_RISCV_PCREL_LO12_S}, -+ {0, 0} -+}; -+ -+static const struct percent_op_match percent_op_rtype[] = -+{ -+ {"%tprel_add", BFD_RELOC_RISCV_TPREL_ADD}, -+ {0, 0} -+}; -+ -+/* Return true if *STR points to a relocation operator. When returning true, -+ move *STR over the operator and store its relocation code in *RELOC. -+ Leave both *STR and *RELOC alone when returning false. */ -+ -+static bfd_boolean -+parse_relocation (char **str, bfd_reloc_code_real_type *reloc, -+ const struct percent_op_match *percent_op) -+{ -+ for ( ; percent_op->str; percent_op++) -+ if (strncasecmp (*str, percent_op->str, strlen (percent_op->str)) == 0) -+ { -+ int len = strlen (percent_op->str); -+ -+ if (!ISSPACE ((*str)[len]) && (*str)[len] != '(') -+ continue; -+ -+ *str += strlen (percent_op->str); -+ *reloc = percent_op->reloc; -+ -+ /* Check whether the output BFD supports this relocation. -+ If not, issue an error and fall back on something safe. */ -+ if (!bfd_reloc_type_lookup (stdoutput, percent_op->reloc)) -+ { -+ as_bad ("relocation %s isn't supported by the current ABI", -+ percent_op->str); -+ *reloc = BFD_RELOC_UNUSED; -+ } -+ return TRUE; -+ } -+ return FALSE; -+} -+ -+static void -+my_getExpression (expressionS *ep, char *str) -+{ -+ char *save_in; -+ -+ save_in = input_line_pointer; -+ input_line_pointer = str; -+ expression (ep); -+ expr_end = input_line_pointer; -+ input_line_pointer = save_in; -+} -+ -+/* Parse string STR as a 16-bit relocatable operand. Store the -+ expression in *EP and the relocation, if any, in RELOC. -+ Return the number of relocation operators used (0 or 1). -+ -+ On exit, EXPR_END points to the first character after the expression. */ -+ -+static size_t -+my_getSmallExpression (expressionS *ep, bfd_reloc_code_real_type *reloc, -+ char *str, const struct percent_op_match *percent_op) -+{ -+ size_t reloc_index; -+ int crux_depth, str_depth; -+ char *crux; -+ -+ /* Search for the start of the main expression. -+ End the loop with CRUX pointing to the start -+ of the main expression and with CRUX_DEPTH containing the number -+ of open brackets at that point. */ -+ reloc_index = -1; -+ str_depth = 0; -+ do -+ { -+ reloc_index++; -+ crux = str; -+ crux_depth = str_depth; -+ -+ /* Skip over whitespace and brackets, keeping count of the number -+ of brackets. */ -+ while (*str == ' ' || *str == '\t' || *str == '(') -+ if (*str++ == '(') -+ str_depth++; -+ } -+ while (*str == '%' -+ && reloc_index < 1 -+ && parse_relocation (&str, reloc, percent_op)); -+ -+ my_getExpression (ep, crux); -+ str = expr_end; -+ -+ /* Match every open bracket. */ -+ while (crux_depth > 0 && (*str == ')' || *str == ' ' || *str == '\t')) -+ if (*str++ == ')') -+ crux_depth--; -+ -+ if (crux_depth > 0) -+ as_bad ("unclosed '('"); -+ -+ expr_end = str; -+ -+ return reloc_index; -+} -+ -+/* This routine assembles an instruction into its binary format. As a -+ side effect, it sets one of the global variables imm_reloc or -+ offset_reloc to the type of relocation to do if one of the operands -+ is an address expression. */ -+ -+static void -+riscv_ip (char *str, struct riscv_cl_insn *ip) -+{ -+ char *s; -+ const char *args; -+ char c = 0; -+ struct riscv_opcode *insn; -+ char *argsStart; -+ unsigned int regno; -+ char save_c = 0; -+ int argnum; -+ const struct percent_op_match *p; -+ -+ insn_error = NULL; -+ -+ /* If the instruction contains a '.', we first try to match an instruction -+ including the '.'. Then we try again without the '.'. */ -+ insn = NULL; -+ for (s = str; *s != '\0' && !ISSPACE (*s); ++s) -+ continue; -+ -+ /* If we stopped on whitespace, then replace the whitespace with null for -+ the call to hash_find. Save the character we replaced just in case we -+ have to re-parse the instruction. */ -+ if (ISSPACE (*s)) -+ { -+ save_c = *s; -+ *s++ = '\0'; -+ } -+ -+ insn = (struct riscv_opcode *) hash_find (op_hash, str); -+ -+ /* If we didn't find the instruction in the opcode table, try again, but -+ this time with just the instruction up to, but not including the -+ first '.'. */ -+ if (insn == NULL) -+ { -+ /* Restore the character we overwrite above (if any). */ -+ if (save_c) -+ *(--s) = save_c; -+ -+ /* Scan up to the first '.' or whitespace. */ -+ for (s = str; -+ *s != '\0' && *s != '.' && !ISSPACE (*s); -+ ++s) -+ continue; -+ -+ /* If we did not find a '.', then we can quit now. */ -+ if (*s != '.') -+ { -+ insn_error = "unrecognized opcode"; -+ return; -+ } -+ -+ /* Lookup the instruction in the hash table. */ -+ *s++ = '\0'; -+ if ((insn = (struct riscv_opcode *) hash_find (op_hash, str)) == NULL) -+ { -+ insn_error = "unrecognized opcode"; -+ return; -+ } -+ } -+ -+ argsStart = s; -+ for (;;) -+ { -+ bfd_boolean ok = TRUE; -+ gas_assert (strcmp (insn->name, str) == 0); -+ -+ create_insn (ip, insn); -+ insn_error = NULL; -+ argnum = 1; -+ for (args = insn->args;; ++args) -+ { -+ s += strspn (s, " \t"); -+ switch (*args) -+ { -+ case '\0': /* end of args */ -+ if (*s == '\0') -+ return; -+ break; -+ /* Xcustom */ -+ case '^': -+ { -+ unsigned long max = OP_MASK_RD; -+ my_getExpression (&imm_expr, s); -+ check_absolute_expr (ip, &imm_expr); -+ switch (*++args) -+ { -+ case 'j': -+ max = OP_MASK_CUSTOM_IMM; -+ INSERT_OPERAND (CUSTOM_IMM, *ip, imm_expr.X_add_number); -+ break; -+ case 'd': -+ INSERT_OPERAND (RD, *ip, imm_expr.X_add_number); -+ break; -+ case 's': -+ INSERT_OPERAND (RS1, *ip, imm_expr.X_add_number); -+ break; -+ case 't': -+ INSERT_OPERAND (RS2, *ip, imm_expr.X_add_number); -+ break; -+ } -+ imm_expr.X_op = O_absent; -+ s = expr_end; -+ if ((unsigned long) imm_expr.X_add_number > max) -+ as_warn ("Bad custom immediate (%lu), must be at most %lu", -+ (unsigned long)imm_expr.X_add_number, max); -+ continue; -+ } -+ -+ /* Xhwacha */ -+ case '#': -+ switch ( *++args ) -+ { -+ case 'g': -+ my_getExpression( &imm_expr, s ); -+ /* check_absolute_expr( ip, &imm_expr ); */ -+ if ((unsigned long) imm_expr.X_add_number > 32 ) -+ as_warn( _( "Improper ngpr amount (%lu)" ), -+ (unsigned long) imm_expr.X_add_number ); -+ INSERT_OPERAND( IMMNGPR, *ip, imm_expr.X_add_number ); -+ imm_expr.X_op = O_absent; -+ s = expr_end; -+ continue; -+ case 'f': -+ my_getExpression( &imm_expr, s ); -+ /* check_absolute_expr( ip, &imm_expr ); */ -+ if ((unsigned long) imm_expr.X_add_number > 32 ) -+ as_warn( _( "Improper nfpr amount (%lu)" ), -+ (unsigned long) imm_expr.X_add_number ); -+ INSERT_OPERAND( IMMNFPR, *ip, imm_expr.X_add_number ); -+ imm_expr.X_op = O_absent; -+ s = expr_end; -+ continue; -+ case 'n': -+ my_getExpression( &imm_expr, s ); -+ /* check_absolute_expr( ip, &imm_expr ); */ -+ if ((unsigned long) imm_expr.X_add_number > 8 ) -+ as_warn( _( "Improper nelm amount (%lu)" ), -+ (unsigned long) imm_expr.X_add_number ); -+ INSERT_OPERAND( IMMSEGNELM, *ip, imm_expr.X_add_number - 1 ); -+ imm_expr.X_op = O_absent; -+ s = expr_end; -+ continue; -+ case 'd': -+ ok = reg_lookup( &s, RCLASS_VEC_GPR, ®no ); -+ if ( !ok ) -+ as_bad( _( "Invalid vector register" ) ); -+ INSERT_OPERAND( VRD, *ip, regno ); -+ continue; -+ case 's': -+ ok = reg_lookup( &s, RCLASS_VEC_GPR, ®no ); -+ if ( !ok ) -+ as_bad( _( "Invalid vector register" ) ); -+ INSERT_OPERAND( VRS, *ip, regno ); -+ continue; -+ case 't': -+ ok = reg_lookup( &s, RCLASS_VEC_GPR, ®no ); -+ if ( !ok ) -+ as_bad( _( "Invalid vector register" ) ); -+ INSERT_OPERAND( VRT, *ip, regno ); -+ continue; -+ case 'r': -+ ok = reg_lookup( &s, RCLASS_VEC_GPR, ®no ); -+ if ( !ok ) -+ as_bad( _( "Invalid vector register" ) ); -+ INSERT_OPERAND( VRR, *ip, regno ); -+ continue; -+ case 'D': -+ ok = reg_lookup( &s, RCLASS_VEC_FPR, ®no ); -+ if ( !ok ) -+ as_bad( _( "Invalid vector register" ) ); -+ INSERT_OPERAND( VFD, *ip, regno ); -+ continue; -+ case 'S': -+ ok = reg_lookup( &s, RCLASS_VEC_FPR, ®no ); -+ if ( !ok ) -+ as_bad( _( "Invalid vector register" ) ); -+ INSERT_OPERAND( VFS, *ip, regno ); -+ continue; -+ case 'T': -+ ok = reg_lookup( &s, RCLASS_VEC_FPR, ®no ); -+ if ( !ok ) -+ as_bad( _( "Invalid vector register" ) ); -+ INSERT_OPERAND( VFT, *ip, regno ); -+ continue; -+ case 'R': -+ ok = reg_lookup( &s, RCLASS_VEC_FPR, ®no ); -+ if ( !ok ) -+ as_bad( _( "Invalid vector register" ) ); -+ INSERT_OPERAND( VFR, *ip, regno ); -+ continue; -+ } -+ break; -+ -+ case ',': -+ ++argnum; -+ if (*s++ == *args) -+ continue; -+ s--; -+ break; -+ -+ case '(': -+ case ')': -+ case '[': -+ case ']': -+ if (*s++ == *args) -+ continue; -+ break; -+ -+ case '<': /* shift amount, 0 - 31 */ -+ my_getExpression (&imm_expr, s); -+ check_absolute_expr (ip, &imm_expr); -+ if ((unsigned long) imm_expr.X_add_number > 31) -+ as_warn (_("Improper shift amount (%lu)"), -+ (unsigned long) imm_expr.X_add_number); -+ INSERT_OPERAND (SHAMTW, *ip, imm_expr.X_add_number); -+ imm_expr.X_op = O_absent; -+ s = expr_end; -+ continue; -+ -+ case '>': /* shift amount, 0 - (XLEN-1) */ -+ my_getExpression (&imm_expr, s); -+ check_absolute_expr (ip, &imm_expr); -+ if ((unsigned long) imm_expr.X_add_number > (rv64 ? 63 : 31)) -+ as_warn (_("Improper shift amount (%lu)"), -+ (unsigned long) imm_expr.X_add_number); -+ INSERT_OPERAND (SHAMT, *ip, imm_expr.X_add_number); -+ imm_expr.X_op = O_absent; -+ s = expr_end; -+ continue; -+ -+ case 'Z': /* CSRRxI immediate */ -+ my_getExpression (&imm_expr, s); -+ check_absolute_expr (ip, &imm_expr); -+ if ((unsigned long) imm_expr.X_add_number > 31) -+ as_warn (_("Improper CSRxI immediate (%lu)"), -+ (unsigned long) imm_expr.X_add_number); -+ INSERT_OPERAND (RS1, *ip, imm_expr.X_add_number); -+ imm_expr.X_op = O_absent; -+ s = expr_end; -+ continue; -+ -+ case 'E': /* Control register. */ -+ ok = reg_lookup (&s, RCLASS_CSR, ®no); -+ if (ok) -+ INSERT_OPERAND (CSR, *ip, regno); -+ else -+ { -+ my_getExpression (&imm_expr, s); -+ check_absolute_expr (ip, &imm_expr); -+ if ((unsigned long) imm_expr.X_add_number > 0xfff) -+ as_warn(_("Improper CSR address (%lu)"), -+ (unsigned long) imm_expr.X_add_number); -+ INSERT_OPERAND (CSR, *ip, imm_expr.X_add_number); -+ imm_expr.X_op = O_absent; -+ s = expr_end; -+ } -+ continue; -+ -+ case 'm': /* rounding mode */ -+ if (arg_lookup (&s, riscv_rm, ARRAY_SIZE(riscv_rm), ®no)) -+ { -+ INSERT_OPERAND (RM, *ip, regno); -+ continue; -+ } -+ break; -+ -+ case 'P': -+ case 'Q': /* fence predecessor/successor */ -+ if (arg_lookup (&s, riscv_pred_succ, ARRAY_SIZE(riscv_pred_succ), ®no)) -+ { -+ if (*args == 'P') -+ INSERT_OPERAND(PRED, *ip, regno); -+ else -+ INSERT_OPERAND(SUCC, *ip, regno); -+ continue; -+ } -+ break; -+ -+ case 'd': /* destination register */ -+ case 's': /* source register */ -+ case 't': /* target register */ -+ ok = reg_lookup (&s, RCLASS_GPR, ®no); -+ if (ok) -+ { -+ c = *args; -+ if (*s == ' ') -+ ++s; -+ -+ /* Now that we have assembled one operand, we use the args string -+ * to figure out where it goes in the instruction. */ -+ switch (c) -+ { -+ case 's': -+ INSERT_OPERAND (RS1, *ip, regno); -+ break; -+ case 'd': -+ INSERT_OPERAND (RD, *ip, regno); -+ break; -+ case 't': -+ INSERT_OPERAND (RS2, *ip, regno); -+ break; -+ } -+ continue; -+ } -+ break; -+ -+ case 'D': /* floating point rd */ -+ case 'S': /* floating point rs1 */ -+ case 'T': /* floating point rs2 */ -+ case 'U': /* floating point rs1 and rs2 */ -+ case 'R': /* floating point rs3 */ -+ if (reg_lookup (&s, RCLASS_FPR, ®no)) -+ { -+ c = *args; -+ if (*s == ' ') -+ ++s; -+ switch (c) -+ { -+ case 'D': -+ INSERT_OPERAND (RD, *ip, regno); -+ break; -+ case 'S': -+ INSERT_OPERAND (RS1, *ip, regno); -+ break; -+ case 'U': -+ INSERT_OPERAND (RS1, *ip, regno); -+ /* fallthru */ -+ case 'T': -+ INSERT_OPERAND (RS2, *ip, regno); -+ break; -+ case 'R': -+ INSERT_OPERAND (RS3, *ip, regno); -+ break; -+ } -+ continue; -+ } -+ -+ break; -+ -+ case 'I': -+ my_getExpression (&imm_expr, s); -+ if (imm_expr.X_op != O_big -+ && imm_expr.X_op != O_constant) -+ insn_error = _("absolute expression required"); -+ normalize_constant_expr (&imm_expr); -+ s = expr_end; -+ continue; -+ -+ case 'A': -+ my_getExpression (&offset_expr, s); -+ normalize_constant_expr (&offset_expr); -+ imm_reloc = BFD_RELOC_32; -+ s = expr_end; -+ continue; -+ -+ case 'j': /* sign-extended immediate */ -+ imm_reloc = BFD_RELOC_RISCV_LO12_I; -+ p = percent_op_itype; -+ goto alu_op; -+ case 'q': /* store displacement */ -+ p = percent_op_stype; -+ offset_reloc = BFD_RELOC_RISCV_LO12_S; -+ goto load_store; -+ case 'o': /* load displacement */ -+ p = percent_op_itype; -+ offset_reloc = BFD_RELOC_RISCV_LO12_I; -+ goto load_store; -+ case '0': /* AMO "displacement," which must be zero */ -+ p = percent_op_rtype; -+ offset_reloc = BFD_RELOC_UNUSED; -+load_store: -+ /* Check whether there is only a single bracketed expression -+ left. If so, it must be the base register and the -+ constant must be zero. */ -+ offset_expr.X_op = O_constant; -+ offset_expr.X_add_number = 0; -+ if (*s == '(' && strchr (s + 1, '(') == 0) -+ continue; -+alu_op: -+ /* If this value won't fit into a 16 bit offset, then go -+ find a macro that will generate the 32 bit offset -+ code pattern. */ -+ if (!my_getSmallExpression (&offset_expr, &offset_reloc, s, p)) -+ { -+ normalize_constant_expr (&offset_expr); -+ if (offset_expr.X_op != O_constant -+ || (*args == '0' && offset_expr.X_add_number != 0) -+ || offset_expr.X_add_number >= (signed)RISCV_IMM_REACH/2 -+ || offset_expr.X_add_number < -(signed)RISCV_IMM_REACH/2) -+ break; -+ } -+ -+ s = expr_end; -+ continue; -+ -+ case 'p': /* pc relative offset */ -+ offset_reloc = BFD_RELOC_12_PCREL; -+ my_getExpression (&offset_expr, s); -+ s = expr_end; -+ continue; -+ -+ case 'u': /* upper 20 bits */ -+ p = percent_op_utype; -+ if (!my_getSmallExpression (&imm_expr, &imm_reloc, s, p) -+ && imm_expr.X_op == O_constant) -+ { -+ if (imm_expr.X_add_number < 0 -+ || imm_expr.X_add_number >= (signed)RISCV_BIGIMM_REACH) -+ as_bad (_("lui expression not in range 0..1048575")); -+ -+ imm_reloc = BFD_RELOC_RISCV_HI20; -+ imm_expr.X_add_number <<= RISCV_IMM_BITS; -+ } -+ s = expr_end; -+ continue; -+ -+ case 'a': /* 26 bit address */ -+ my_getExpression (&offset_expr, s); -+ s = expr_end; -+ offset_reloc = BFD_RELOC_RISCV_JMP; -+ continue; -+ -+ case 'c': -+ my_getExpression (&offset_expr, s); -+ s = expr_end; -+ offset_reloc = BFD_RELOC_RISCV_CALL; -+ if (*s == '@') -+ offset_reloc = BFD_RELOC_RISCV_CALL_PLT, s++; -+ continue; -+ -+ default: -+ as_bad (_("bad char = '%c'\n"), *args); -+ internalError (); -+ } -+ break; -+ } -+ /* Args don't match. */ -+ if (insn + 1 < &riscv_opcodes[NUMOPCODES] && -+ !strcmp (insn->name, insn[1].name)) -+ { -+ ++insn; -+ s = argsStart; -+ insn_error = _("illegal operands"); -+ continue; -+ } -+ if (save_c) -+ *(--argsStart) = save_c; -+ insn_error = _("illegal operands"); -+ return; -+ } -+} -+ -+void -+md_assemble (char *str) -+{ -+ struct riscv_cl_insn insn; -+ -+ imm_expr.X_op = O_absent; -+ offset_expr.X_op = O_absent; -+ imm_reloc = BFD_RELOC_UNUSED; -+ offset_reloc = BFD_RELOC_UNUSED; -+ -+ riscv_ip (str, &insn); -+ -+ if (insn_error) -+ { -+ as_bad ("%s `%s'", insn_error, str); -+ return; -+ } -+ -+ if (insn.insn_mo->pinfo == INSN_MACRO) -+ macro (&insn); -+ else -+ { -+ if (imm_expr.X_op != O_absent) -+ append_insn (&insn, &imm_expr, imm_reloc); -+ else if (offset_expr.X_op != O_absent) -+ append_insn (&insn, &offset_expr, offset_reloc); -+ else -+ append_insn (&insn, NULL, BFD_RELOC_UNUSED); -+ } -+} -+ -+char * -+md_atof (int type, char *litP, int *sizeP) -+{ -+ return ieee_md_atof (type, litP, sizeP, TARGET_BYTES_BIG_ENDIAN); -+} -+ -+void -+md_number_to_chars (char *buf, valueT val, int n) -+{ -+ number_to_chars_littleendian (buf, val, n); -+} -+ -+const char *md_shortopts = "O::g::G:"; -+ -+enum options -+ { -+ OPTION_M32 = OPTION_MD_BASE, -+ OPTION_M64, -+ OPTION_MARCH, -+ OPTION_PIC, -+ OPTION_NO_PIC, -+ OPTION_MRVC, -+ OPTION_MNO_RVC, -+ OPTION_END_OF_ENUM -+ }; -+ -+struct option md_longopts[] = -+{ -+ {"m32", no_argument, NULL, OPTION_M32}, -+ {"m64", no_argument, NULL, OPTION_M64}, -+ {"march", required_argument, NULL, OPTION_MARCH}, -+ {"fPIC", no_argument, NULL, OPTION_PIC}, -+ {"fpic", no_argument, NULL, OPTION_PIC}, -+ {"fno-pic", no_argument, NULL, OPTION_NO_PIC}, -+ {"mrvc", no_argument, NULL, OPTION_MRVC}, -+ {"mno-rvc", no_argument, NULL, OPTION_MNO_RVC}, -+ -+ {NULL, no_argument, NULL, 0} -+}; -+size_t md_longopts_size = sizeof (md_longopts); -+ -+int -+md_parse_option (int c, char *arg) -+{ -+ switch (c) -+ { -+ case OPTION_MRVC: -+ riscv_opts.rvc = 1; -+ break; -+ -+ case OPTION_MNO_RVC: -+ riscv_opts.rvc = 0; -+ break; -+ -+ case OPTION_M32: -+ rv64 = FALSE; -+ break; -+ -+ case OPTION_M64: -+ rv64 = TRUE; -+ break; -+ -+ case OPTION_MARCH: -+ riscv_set_arch(arg); -+ -+ case OPTION_NO_PIC: -+ riscv_opts.pic = FALSE; -+ break; -+ -+ case OPTION_PIC: -+ riscv_opts.pic = TRUE; -+ break; -+ -+ default: -+ return 0; -+ } -+ -+ return 1; -+} -+ -+void -+riscv_after_parse_args (void) -+{ -+ if (riscv_subsets == NULL) -+ riscv_set_arch("RVIMAFDXcustom"); -+} -+ -+void -+riscv_init_after_args (void) -+{ -+ /* initialize opcodes */ -+ bfd_riscv_num_opcodes = bfd_riscv_num_builtin_opcodes; -+ riscv_opcodes = (struct riscv_opcode *) riscv_builtin_opcodes; -+} -+ -+long -+md_pcrel_from (fixS *fixP) -+{ -+ return fixP->fx_where + fixP->fx_frag->fr_address; -+} -+ -+/* Apply a fixup to the object file. */ -+ -+void -+md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED) -+{ -+ bfd_byte *buf = (bfd_byte *) (fixP->fx_frag->fr_literal + fixP->fx_where); -+ -+ /* Remember value for tc_gen_reloc. */ -+ fixP->fx_addnumber = *valP; -+ -+ switch (fixP->fx_r_type) -+ { -+ case BFD_RELOC_RISCV_TLS_GOT_HI20: -+ case BFD_RELOC_RISCV_TLS_GD_HI20: -+ case BFD_RELOC_RISCV_TLS_DTPREL32: -+ case BFD_RELOC_RISCV_TLS_DTPREL64: -+ case BFD_RELOC_RISCV_TPREL_HI20: -+ case BFD_RELOC_RISCV_TPREL_LO12_I: -+ case BFD_RELOC_RISCV_TPREL_LO12_S: -+ case BFD_RELOC_RISCV_TPREL_ADD: -+ S_SET_THREAD_LOCAL (fixP->fx_addsy); -+ /* fall through */ -+ -+ case BFD_RELOC_RISCV_GOT_HI20: -+ case BFD_RELOC_RISCV_PCREL_HI20: -+ case BFD_RELOC_RISCV_HI20: -+ case BFD_RELOC_RISCV_LO12_I: -+ case BFD_RELOC_RISCV_LO12_S: -+ case BFD_RELOC_RISCV_ADD8: -+ case BFD_RELOC_RISCV_ADD16: -+ case BFD_RELOC_RISCV_ADD32: -+ case BFD_RELOC_RISCV_ADD64: -+ case BFD_RELOC_RISCV_SUB8: -+ case BFD_RELOC_RISCV_SUB16: -+ case BFD_RELOC_RISCV_SUB32: -+ case BFD_RELOC_RISCV_SUB64: -+ gas_assert (fixP->fx_addsy != NULL); -+ /* Nothing needed to do. The value comes from the reloc entry. */ -+ break; -+ -+ case BFD_RELOC_64: -+ case BFD_RELOC_32: -+ case BFD_RELOC_16: -+ case BFD_RELOC_8: -+ if (fixP->fx_addsy && fixP->fx_subsy) -+ { -+ fixP->fx_next = xmemdup (fixP, sizeof (*fixP), sizeof (*fixP)); -+ fixP->fx_next->fx_addsy = fixP->fx_subsy; -+ fixP->fx_next->fx_subsy = NULL; -+ fixP->fx_next->fx_offset = 0; -+ fixP->fx_subsy = NULL; -+ -+ if (fixP->fx_r_type == BFD_RELOC_64) -+ fixP->fx_r_type = BFD_RELOC_RISCV_ADD64, -+ fixP->fx_next->fx_r_type = BFD_RELOC_RISCV_SUB64; -+ else if (fixP->fx_r_type == BFD_RELOC_32) -+ fixP->fx_r_type = BFD_RELOC_RISCV_ADD32, -+ fixP->fx_next->fx_r_type = BFD_RELOC_RISCV_SUB32; -+ else if (fixP->fx_r_type == BFD_RELOC_16) -+ fixP->fx_r_type = BFD_RELOC_RISCV_ADD16, -+ fixP->fx_next->fx_r_type = BFD_RELOC_RISCV_SUB16; -+ else -+ fixP->fx_r_type = BFD_RELOC_RISCV_ADD8, -+ fixP->fx_next->fx_r_type = BFD_RELOC_RISCV_SUB8; -+ } -+ /* fall through */ -+ -+ case BFD_RELOC_RVA: -+ /* If we are deleting this reloc entry, we must fill in the -+ value now. This can happen if we have a .word which is not -+ resolved when it appears but is later defined. */ -+ if (fixP->fx_addsy == NULL) -+ { -+ gas_assert (fixP->fx_size <= sizeof (valueT)); -+ md_number_to_chars ((char *) buf, *valP, fixP->fx_size); -+ fixP->fx_done = 1; -+ } -+ break; -+ -+ case BFD_RELOC_RISCV_JMP: -+ if (fixP->fx_addsy) -+ { -+ /* Fill in a tentative value to improve objdump readability. */ -+ bfd_vma delta = ENCODE_UJTYPE_IMM (S_GET_VALUE (fixP->fx_addsy) + *valP); -+ bfd_putl32 (bfd_getl32 (buf) | delta, buf); -+ } -+ break; -+ -+ case BFD_RELOC_12_PCREL: -+ if (fixP->fx_addsy) -+ { -+ /* Fill in a tentative value to improve objdump readability. */ -+ bfd_vma delta = ENCODE_SBTYPE_IMM (S_GET_VALUE (fixP->fx_addsy) + *valP); -+ bfd_putl32 (bfd_getl32 (buf) | delta, buf); -+ } -+ break; -+ -+ case BFD_RELOC_RISCV_PCREL_LO12_S: -+ case BFD_RELOC_RISCV_PCREL_LO12_I: -+ case BFD_RELOC_RISCV_CALL: -+ case BFD_RELOC_RISCV_CALL_PLT: -+ case BFD_RELOC_RISCV_ALIGN: -+ break; -+ -+ default: -+ /* We ignore generic BFD relocations we don't know about. */ -+ if (bfd_reloc_type_lookup (stdoutput, fixP->fx_r_type) != NULL) -+ internalError (); -+ } -+} -+ -+/* This structure is used to hold a stack of .set values. */ -+ -+struct riscv_option_stack -+{ -+ struct riscv_option_stack *next; -+ struct riscv_set_options options; -+}; -+ -+static struct riscv_option_stack *riscv_opts_stack; -+ -+/* Handle the .set pseudo-op. */ -+ -+static void -+s_riscv_option (int x ATTRIBUTE_UNUSED) -+{ -+ char *name = input_line_pointer, ch; -+ -+ while (!is_end_of_line[(unsigned char) *input_line_pointer]) -+ ++input_line_pointer; -+ ch = *input_line_pointer; -+ *input_line_pointer = '\0'; -+ -+ if (strcmp (name, "rvc") == 0) -+ riscv_opts.rvc = 1; -+ else if (strcmp (name, "norvc") == 0) -+ riscv_opts.rvc = 0; -+ else if (strcmp (name, "push") == 0) -+ { -+ struct riscv_option_stack *s; -+ -+ s = (struct riscv_option_stack *) xmalloc (sizeof *s); -+ s->next = riscv_opts_stack; -+ s->options = riscv_opts; -+ riscv_opts_stack = s; -+ } -+ else if (strcmp (name, "pop") == 0) -+ { -+ struct riscv_option_stack *s; -+ -+ s = riscv_opts_stack; -+ if (s == NULL) -+ as_bad (_(".option pop with no .option push")); -+ else -+ { -+ riscv_opts = s->options; -+ riscv_opts_stack = s->next; -+ free (s); -+ } -+ } -+ else -+ { -+ as_warn (_("Unrecognized .option directive: %s\n"), name); -+ } -+ *input_line_pointer = ch; -+ demand_empty_rest_of_line (); -+} -+ -+/* Handle the .dtprelword and .dtpreldword pseudo-ops. They generate -+ a 32-bit or 64-bit DTP-relative relocation (BYTES says which) for -+ use in DWARF debug information. */ -+ -+static void -+s_dtprel (int bytes) -+{ -+ expressionS ex; -+ char *p; -+ -+ expression (&ex); -+ -+ if (ex.X_op != O_symbol) -+ { -+ as_bad (_("Unsupported use of %s"), (bytes == 8 -+ ? ".dtpreldword" -+ : ".dtprelword")); -+ ignore_rest_of_line (); -+ } -+ -+ p = frag_more (bytes); -+ md_number_to_chars (p, 0, bytes); -+ fix_new_exp (frag_now, p - frag_now->fr_literal, bytes, &ex, FALSE, -+ (bytes == 8 -+ ? BFD_RELOC_RISCV_TLS_DTPREL64 -+ : BFD_RELOC_RISCV_TLS_DTPREL32)); -+ -+ demand_empty_rest_of_line (); -+} -+ -+/* Handle the .bss pseudo-op. */ -+ -+static void -+s_bss (int ignore ATTRIBUTE_UNUSED) -+{ -+ subseg_set (bss_section, 0); -+ demand_empty_rest_of_line (); -+} -+ -+/* Align to a given power of two. */ -+ -+static void -+s_align (int x ATTRIBUTE_UNUSED) -+{ -+ int alignment, fill_value = 0, fill_value_specified = 0; -+ -+ alignment = get_absolute_expression (); -+ if (alignment < 0 || alignment > 31) -+ as_bad (_("unsatisfiable alignment: %d"), alignment); -+ -+ if (*input_line_pointer == ',') -+ { -+ ++input_line_pointer; -+ fill_value = get_absolute_expression (); -+ fill_value_specified = 1; -+ } -+ -+ if (!fill_value_specified && subseg_text_p (now_seg) && alignment > 2) -+ { -+ /* Emit the worst-case NOP string. The linker will delete any -+ unnecessary NOPs. This allows us to support code alignment -+ in spite of linker relaxations. */ -+ bfd_vma i, worst_case_nop_bytes = (1L << alignment) - 4; -+ char *nops = frag_more (worst_case_nop_bytes); -+ for (i = 0; i < worst_case_nop_bytes; i += 4) -+ md_number_to_chars (nops + i, RISCV_NOP, 4); -+ -+ expressionS ex; -+ ex.X_op = O_constant; -+ ex.X_add_number = worst_case_nop_bytes; -+ -+ fix_new_exp (frag_now, nops - frag_now->fr_literal, 0, -+ &ex, TRUE, BFD_RELOC_RISCV_ALIGN); -+ } -+ else if (alignment) -+ frag_align (alignment, fill_value, 0); -+ -+ record_alignment (now_seg, alignment); -+ -+ demand_empty_rest_of_line (); -+} -+ -+int -+md_estimate_size_before_relax (fragS *fragp, asection *segtype) -+{ -+ return (fragp->fr_var = relaxed_branch_length (fragp, segtype, FALSE)); -+} -+ -+/* Translate internal representation of relocation info to BFD target -+ format. */ -+ -+arelent * -+tc_gen_reloc (asection *section ATTRIBUTE_UNUSED, fixS *fixp) -+{ -+ arelent *reloc = (arelent *) xmalloc (sizeof (arelent)); -+ -+ reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *)); -+ *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy); -+ reloc->address = fixp->fx_frag->fr_address + fixp->fx_where; -+ -+ if (fixp->fx_pcrel) -+ /* At this point, fx_addnumber is "symbol offset - pcrel address". -+ Relocations want only the symbol offset. */ -+ reloc->addend = fixp->fx_addnumber + reloc->address; -+ else -+ reloc->addend = fixp->fx_addnumber; -+ -+ reloc->howto = bfd_reloc_type_lookup (stdoutput, fixp->fx_r_type); -+ if (reloc->howto == NULL) -+ { -+ if ((fixp->fx_r_type == BFD_RELOC_16 || fixp->fx_r_type == BFD_RELOC_8) -+ && fixp->fx_addsy != NULL && fixp->fx_subsy != NULL) -+ { -+ /* We don't have R_RISCV_8/16, but for this special case, -+ we can use R_RISCV_ADD8/16 with R_RISCV_SUB8/16. */ -+ return reloc; -+ } -+ -+ as_bad_where (fixp->fx_file, fixp->fx_line, -+ _("cannot represent %s relocation in object file"), -+ bfd_get_reloc_code_name (fixp->fx_r_type)); -+ return NULL; -+ } -+ -+ return reloc; -+} -+ -+int -+riscv_relax_frag (asection *sec, fragS *fragp, long stretch ATTRIBUTE_UNUSED) -+{ -+ if (RELAX_BRANCH_P (fragp->fr_subtype)) -+ { -+ offsetT old_var = fragp->fr_var; -+ fragp->fr_var = relaxed_branch_length (fragp, sec, TRUE); -+ return fragp->fr_var - old_var; -+ } -+ -+ return 0; -+} -+ -+/* Convert a machine dependent frag. */ -+ -+static void -+md_convert_frag_branch (fragS *fragp) -+{ -+ bfd_byte *buf; -+ insn_t insn; -+ expressionS exp; -+ fixS *fixp; -+ -+ buf = (bfd_byte *)fragp->fr_literal + fragp->fr_fix; -+ -+ exp.X_op = O_symbol; -+ exp.X_add_symbol = fragp->fr_symbol; -+ exp.X_add_number = fragp->fr_offset; -+ -+ if (RELAX_BRANCH_TOOFAR (fragp->fr_subtype)) -+ { -+ gas_assert (fragp->fr_var == 8); -+ /* We could relax JAL to AUIPC/JALR, but we don't do this yet. */ -+ gas_assert (!RELAX_BRANCH_UNCOND (fragp->fr_subtype)); -+ -+ /* Invert the branch condition. Branch over the jump. */ -+ insn = bfd_getl32 (buf); -+ insn ^= MATCH_BEQ ^ MATCH_BNE; -+ insn |= ENCODE_SBTYPE_IMM (8); -+ md_number_to_chars ((char *) buf, insn, 4); -+ buf += 4; -+ -+ /* Jump to the target. */ -+ fixp = fix_new_exp (fragp, buf - (bfd_byte *)fragp->fr_literal, -+ 4, &exp, FALSE, BFD_RELOC_RISCV_JMP); -+ md_number_to_chars ((char *) buf, MATCH_JAL, 4); -+ buf += 4; -+ } -+ else -+ { -+ fixp = fix_new_exp (fragp, buf - (bfd_byte *)fragp->fr_literal, -+ 4, &exp, FALSE, BFD_RELOC_12_PCREL); -+ buf += 4; -+ } -+ -+ fixp->fx_file = fragp->fr_file; -+ fixp->fx_line = fragp->fr_line; -+ fixp->fx_pcrel = 1; -+ -+ gas_assert (buf == (bfd_byte *)fragp->fr_literal -+ + fragp->fr_fix + fragp->fr_var); -+ -+ fragp->fr_fix += fragp->fr_var; -+} -+ -+/* Relax a machine dependent frag. This returns the amount by which -+ the current size of the frag should change. */ -+ -+void -+md_convert_frag (bfd *abfd ATTRIBUTE_UNUSED, segT asec ATTRIBUTE_UNUSED, -+ fragS *fragp) -+{ -+ gas_assert (RELAX_BRANCH_P (fragp->fr_subtype)); -+ md_convert_frag_branch (fragp); -+} -+ -+void -+md_show_usage (FILE *stream) -+{ -+ fprintf (stream, _("\ -+RISC-V options:\n\ -+ -m32 assemble RV32 code\n\ -+ -m64 assemble RV64 code (default)\n\ -+ -fpic generate position-independent code\n\ -+ -fno-pic don't generate position-independent code (default)\n\ -+")); -+} -+ -+/* Standard calling conventions leave the CFA at SP on entry. */ -+void -+riscv_cfi_frame_initial_instructions (void) -+{ -+ cfi_add_CFA_def_cfa_register (X_SP); -+} -+ -+int -+tc_riscv_regname_to_dw2regnum (char *regname) -+{ -+ int reg; -+ -+ if ((reg = reg_lookup_internal (regname, RCLASS_GPR)) >= 0) -+ return reg; -+ -+ if ((reg = reg_lookup_internal (regname, RCLASS_FPR)) >= 0) -+ return reg + 32; -+ -+ as_bad (_("unknown register `%s'"), regname); -+ return -1; -+} -+ -+void -+riscv_elf_final_processing (void) -+{ -+ struct riscv_subset* s; -+ -+ unsigned int Xlen = 0; -+ for (s = riscv_subsets; s != NULL; s = s->next) -+ if (s->name[0] == 'X') -+ Xlen += strlen(s->name); -+ -+ char extension[Xlen]; -+ extension[0] = 0; -+ for (s = riscv_subsets; s != NULL; s = s->next) -+ if (s->name[0] == 'X') -+ strcat(extension, s->name); -+ -+ EF_SET_RISCV_EXT(elf_elfheader (stdoutput)->e_flags, -+ riscv_elf_name_to_flag (extension)); -+} -+ -+/* Pseudo-op table. */ -+ -+static const pseudo_typeS riscv_pseudo_table[] = -+{ -+ /* RISC-V-specific pseudo-ops. */ -+ {"option", s_riscv_option, 0}, -+ {"half", cons, 2}, -+ {"word", cons, 4}, -+ {"dword", cons, 8}, -+ {"dtprelword", s_dtprel, 4}, -+ {"dtpreldword", s_dtprel, 8}, -+ {"bss", s_bss, 0}, -+ {"align", s_align, 0}, -+ -+ /* leb128 doesn't work with relaxation; disallow it */ -+ {"uleb128", s_err, 0}, -+ {"sleb128", s_err, 0}, -+ -+ { NULL, NULL, 0 }, -+}; -+ -+void -+riscv_pop_insert (void) -+{ -+ extern void pop_insert (const pseudo_typeS *); -+ -+ pop_insert (riscv_pseudo_table); -+} -diff -rNU3 dist.orig/gas/config/tc-riscv.h dist/gas/config/tc-riscv.h ---- dist.orig/gas/config/tc-riscv.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gas/config/tc-riscv.h 2015-10-18 13:11:13.000000000 +0200 -@@ -0,0 +1,102 @@ -+/* tc-riscv.h -- header file for tc-riscv.c. -+ Copyright 2011-2014 Free Software Foundation, Inc. -+ -+ Contributed by Andrew Waterman (waterman@cs.berkeley.edu) at UC Berkeley. -+ Based on MIPS target. -+ -+ This file is part of GAS. -+ -+ GAS is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3, or (at your option) -+ any later version. -+ -+ GAS is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with GAS; see the file COPYING. If not, write to the Free -+ Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA -+ 02110-1301, USA. */ -+ -+#ifndef TC_RISCV -+#define TC_RISCV -+ -+#include "opcode/riscv.h" -+ -+struct frag; -+struct expressionS; -+ -+#define TARGET_BYTES_BIG_ENDIAN 0 -+ -+#define TARGET_ARCH bfd_arch_riscv -+ -+#define WORKING_DOT_WORD 1 -+#define OLD_FLOAT_READS -+#define REPEAT_CONS_EXPRESSIONS -+#define LOCAL_LABELS_FB 1 -+#define FAKE_LABEL_NAME ".L0 " -+ -+#define md_relax_frag(segment, fragp, stretch) \ -+ riscv_relax_frag(segment, fragp, stretch) -+extern int riscv_relax_frag (asection *, struct frag *, long); -+ -+#define md_section_align(seg,size) (size) -+#define md_undefined_symbol(name) (0) -+#define md_operand(x) -+ -+#define MAX_MEM_FOR_RS_ALIGN_CODE (1 + 2) -+ -+#define TC_SYMFIELD_TYPE int -+ -+/* The ISA of the target may change based on command-line arguments. */ -+#define TARGET_FORMAT riscv_target_format() -+extern const char *riscv_target_format (void); -+ -+#define md_after_parse_args() riscv_after_parse_args() -+extern void riscv_after_parse_args (void); -+ -+#define tc_init_after_args() riscv_init_after_args() -+extern void riscv_init_after_args (void); -+ -+#define md_parse_long_option(arg) riscv_parse_long_option (arg) -+extern int riscv_parse_long_option (const char *); -+ -+/* Let the linker resolve all the relocs due to relaxation. */ -+#define tc_fix_adjustable(fixp) 0 -+#define md_allow_local_subtract(l,r,s) 0 -+ -+/* Values passed to md_apply_fix don't include symbol values. */ -+#define MD_APPLY_SYM_VALUE(FIX) 0 -+ -+/* Global syms must not be resolved, to support ELF shared libraries. */ -+#define EXTERN_FORCE_RELOC \ -+ (OUTPUT_FLAVOR == bfd_target_elf_flavour) -+ -+#define TC_FORCE_RELOCATION_SUB_SAME(FIX, SEG) ((SEG)->flags & SEC_CODE) -+#define TC_FORCE_RELOCATION_SUB_LOCAL(FIX, SEG) 1 -+#define TC_VALIDATE_FIX_SUB(FIX, SEG) 1 -+#define TC_FORCE_RELOCATION_LOCAL(FIX) 1 -+#define DIFF_EXPR_OK 1 -+ -+extern void riscv_pop_insert (void); -+#define md_pop_insert() riscv_pop_insert() -+ -+#define TARGET_USE_CFIPOP 1 -+ -+#define tc_cfi_frame_initial_instructions riscv_cfi_frame_initial_instructions -+extern void riscv_cfi_frame_initial_instructions (void); -+ -+#define tc_regname_to_dw2regnum tc_riscv_regname_to_dw2regnum -+extern int tc_riscv_regname_to_dw2regnum (char *regname); -+ -+extern bfd_boolean rv64; -+#define DWARF2_DEFAULT_RETURN_COLUMN X_RA -+#define DWARF2_CIE_DATA_ALIGNMENT (rv64 ? 8 : 4) -+ -+#define elf_tc_final_processing riscv_elf_final_processing -+extern void riscv_elf_final_processing (void); -+ -+#endif /* TC_RISCV */ -diff -rNU3 dist.orig/gas/config/tc-vax.c dist/gas/config/tc-vax.c ---- dist.orig/gas/config/tc-vax.c 2010-06-28 16:06:57.000000000 +0200 -+++ dist/gas/config/tc-vax.c 2015-10-18 13:11:13.000000000 +0200 -@@ -24,6 +24,7 @@ - - #include "vax-inst.h" - #include "obstack.h" /* For FRAG_APPEND_1_CHAR macro in "frags.h" */ -+#include "dw2gencfi.h" - #include "subsegs.h" - #include "safe-ctype.h" - -@@ -392,6 +393,9 @@ - && (PLT_symbol == NULL || fragP->fr_symbol != PLT_symbol) - && fragP->fr_symbol != NULL - && flag_want_pic -+#ifdef OBJ_ELF -+ && ELF_ST_VISIBILITY (S_GET_OTHER (fragP->fr_symbol)) != STV_HIDDEN -+#endif - && (!S_IS_DEFINED (fragP->fr_symbol) - || S_IS_WEAK (fragP->fr_symbol) - || S_IS_EXTERNAL (fragP->fr_symbol))) -@@ -1073,6 +1077,154 @@ - return retval; - } - -+#ifdef OBJ_AOUT -+#ifndef BFD_ASSEMBLER -+void -+tc_aout_fix_to_chars (where, fixP, segment_address_in_file) -+ char *where; -+ fixS *fixP; -+ relax_addressT segment_address_in_file; -+{ -+ /* -+ * In: length of relocation (or of address) in chars: 1, 2 or 4. -+ * Out: GNU LD relocation length code: 0, 1, or 2. -+ */ -+ -+ static const unsigned char nbytes_r_length[] = {42, 0, 1, 42, 2}; -+ int r_symbolnum; -+ int r_flags; -+ -+ know (fixP->fx_addsy != NULL); -+ -+ md_number_to_chars (where, -+ fixP->fx_frag->fr_address + fixP->fx_where - segment_address_in_file, -+ 4); -+ -+ r_symbolnum = (S_IS_DEFINED (fixP->fx_addsy) -+ ? S_GET_TYPE (fixP->fx_addsy) -+ : fixP->fx_addsy->sy_number); -+ r_flags = (fixP->fx_pcrel ? 1 : 0) -+ | (!S_IS_DEFINED (fixP->fx_addsy) ? 8 : 0) /* extern */ -+ | ((nbytes_r_length[fixP->fx_size] & 3) << 1); -+ -+#if 0 -+ r_flags |= ((!S_IS_DEFINED(fixP->fx_addsy) -+ && fixP->fx_pcrel -+ && fixP->fx_addsy != GOT_symbol -+ && fixP->fx_addsy != PLT_symbol -+ && flags_want_pic) ? 0x10 : 0); -+#endif -+ -+ switch (fixP->fx_r_type) { -+ case NO_RELOC: -+ break; -+ case NO_RELOC2: -+ if (r_flags & 8) -+ r_flags |= 0x80; /* setting the copy bit */ -+ /* says we can convert */ -+ /* to gotslot if needed */ -+ break; -+ case RELOC_32: -+ if (flag_want_pic && S_IS_EXTERNAL(fixP->fx_addsy)) { -+ r_symbolnum = fixP->fx_addsy->sy_number; -+ r_flags |= 8; /* set extern bit */ -+ } -+ break; -+ case RELOC_JMP_SLOT: -+ if (flag_want_pic) { -+ r_flags |= 0x20; /* set jmptable */ -+ r_flags &= ~0x08; /* clear extern bit */ -+ } -+ break; -+ case RELOC_JMP_TBL: -+ if (flag_want_pic) { -+ r_flags |= 0x20; /* set jmptable */ -+ r_flags |= 0x08; /* set extern bit */ -+ } -+ break; -+ case RELOC_GLOB_DAT: -+ if (flag_want_pic) { -+ r_flags |= 0x10; /* set baserel bit */ -+ r_symbolnum = fixP->fx_addsy->sy_number; -+ if (S_IS_EXTERNAL(fixP->fx_addsy)) -+ r_flags |= 8; /* set extern bit */ -+ } -+ break; -+ } -+ -+ where[4] = (r_symbolnum >> 0) & 0xff; -+ where[5] = (r_symbolnum >> 8) & 0xff; -+ where[6] = (r_symbolnum >> 16) & 0xff; -+ where[7] = r_flags; -+} -+#endif /* !BFD_ASSEMBLER */ -+#endif /* OBJ_AOUT */ -+ -+/* -+ * BUGS, GRIPES, APOLOGIA, etc. -+ * -+ * The opcode table 'votstrs' needs to be sorted on opcode frequency. -+ * That is, AFTER we hash it with hash_...(), we want most-used opcodes -+ * to come out of the hash table faster. -+ * -+ * I am sorry to inflict yet another VAX assembler on the world, but -+ * RMS says we must do everything from scratch, to prevent pin-heads -+ * restricting this software. -+ */ -+ -+/* -+ * This is a vaguely modular set of routines in C to parse VAX -+ * assembly code using DEC mnemonics. It is NOT un*x specific. -+ * -+ * The idea here is that the assembler has taken care of all: -+ * labels -+ * macros -+ * listing -+ * pseudo-ops -+ * line continuation -+ * comments -+ * condensing any whitespace down to exactly one space -+ * and all we have to do is parse 1 line into a vax instruction -+ * partially formed. We will accept a line, and deliver: -+ * an error message (hopefully empty) -+ * a skeleton VAX instruction (tree structure) -+ * textual pointers to all the operand expressions -+ * a warning message that notes a silly operand (hopefully empty) -+ */ -+ -+/* -+ * E D I T H I S T O R Y -+ * -+ * 17may86 Dean Elsner. Bug if line ends immediately after opcode. -+ * 30apr86 Dean Elsner. New vip_op() uses arg block so change call. -+ * 6jan86 Dean Elsner. Crock vip_begin() to call vip_op_defaults(). -+ * 2jan86 Dean Elsner. Invent synthetic opcodes. -+ * Widen vax_opcodeT to 32 bits. Use a bit for VIT_OPCODE_SYNTHETIC, -+ * which means this is not a real opcode, it is like a macro; it will -+ * be relax()ed into 1 or more instructions. -+ * Use another bit for VIT_OPCODE_SPECIAL if the op-code is not optimised -+ * like a regular branch instruction. Option added to vip_begin(): -+ * exclude synthetic opcodes. Invent synthetic_votstrs[]. -+ * 31dec85 Dean Elsner. Invent vit_opcode_nbytes. -+ * Also make vit_opcode into a char[]. We now have n-byte vax opcodes, -+ * so caller's don't have to know the difference between a 1-byte & a -+ * 2-byte op-code. Still need vax_opcodeT concept, so we know how -+ * big an object must be to hold an op.code. -+ * 30dec85 Dean Elsner. Widen typedef vax_opcodeT in "vax-inst.h" -+ * because vax opcodes may be 16 bits. Our crufty C compiler was -+ * happily initialising 8-bit vot_codes with 16-bit numbers! -+ * (Wouldn't the 'phone company like to compress data so easily!) -+ * 29dec85 Dean Elsner. New static table vax_operand_width_size[]. -+ * Invented so we know hw many bytes a "I^#42" needs in its immediate -+ * operand. Revised struct vop in "vax-inst.h": explicitly include -+ * byte length of each operand, and it's letter-code datum type. -+ * 17nov85 Dean Elsner. Name Change. -+ * Due to ar(1) truncating names, we learned the hard way that -+ * "vax-inst-parse.c" -> "vax-inst-parse." dropping the "o" off -+ * the archived object name. SO... we shortened the name of this -+ * source file, and changed the makefile. -+ */ -+ - /* Parse a vax operand in DEC assembler notation. - For speed, expect a string of whitespace to be reduced to a single ' '. - This is the case for GNU AS, and is easy for other DEC-compatible -@@ -3150,7 +3302,7 @@ - if (flag_want_pic && operandP->vop_mode == 8 - && this_add_symbol != NULL) - { -- as_warn (_("Symbol %s used as immediate operand in PIC mode."), -+ as_warn (_("Symbol '%s' used as immediate operand in PIC mode."), - S_GET_NAME (this_add_symbol)); - } - #endif -@@ -3226,7 +3378,15 @@ - length = 4; - } - } -+#ifdef OBJ_ELF -+ if (flag_want_pic && this_add_symbol != NULL) -+ { -+ as_warn (_("Symbol '%s' used as displacement in PIC mode."), -+ S_GET_NAME (this_add_symbol)); -+ } -+#endif - p = frag_more (1 + length); -+ know (operandP->vop_reg != 0xf); - know (operandP->vop_reg >= 0); - p[0] = operandP->vop_reg - | ((at | "?\12\14?\16"[length]) << 4); -@@ -3411,3 +3571,38 @@ - { - return vax_md_atof (type, litP, sizeP); - } -+ -+void -+vax_cfi_frame_initial_instructions (void) -+{ -+ cfi_add_CFA_def_cfa (14, 0); -+} -+ -+int -+tc_vax_regname_to_dw2regnum (char *regname) -+{ -+ unsigned int i; -+ static const struct { char *name; int dw2regnum; } regnames[] = -+ { -+ { "r0", 0 }, { "r1", 1 }, { "r2", 2 }, { "r3", 3 }, -+ { "r4", 4 }, { "r5", 5 }, { "r6", 6 }, { "r7", 7 }, -+ { "r8", 8 }, { "r9", 9 }, { "r10", 10 }, { "r11", 11 }, -+ { "ap", 12 }, { "fp", 13 }, { "sp", 14 }, { "pc", 15 }, -+ { "psw", 16 }, -+ }; -+ -+ for (i = 0; i < ARRAY_SIZE (regnames); ++i) -+ if (strcmp (regnames[i].name, regname) == 0) -+ return regnames[i].dw2regnum; -+ -+ return -1; -+} -+ -+void -+vax_cfi_emit_pcrel_expr (expressionS *expP, unsigned int nbytes) -+{ -+ vax_cons_special_reloc = "pcrel"; -+ expP->X_add_number += nbytes; -+ emit_expr (expP, nbytes); -+ vax_cons_special_reloc = NULL; -+} -diff -rNU3 dist.orig/gas/config/tc-vax.h dist/gas/config/tc-vax.h ---- dist.orig/gas/config/tc-vax.h 2007-07-03 13:01:05.000000000 +0200 -+++ dist/gas/config/tc-vax.h 2015-10-18 13:11:13.000000000 +0200 -@@ -71,9 +71,17 @@ - == S_GET_SEGMENT ((FIX)->fx_addsy))) \ - || S_IS_LOCAL ((FIX)->fx_addsy))) - --/* -- * Local Variables: -- * comment-column: 0 -- * fill-column: 131 -- * End: -- */ -+#define TARGET_USE_CFIPOP 1 -+ -+#define tc_cfi_frame_initial_instructions vax_cfi_frame_initial_instructions -+extern void vax_cfi_frame_initial_instructions (void); -+ -+#define tc_regname_to_dw2regnum tc_vax_regname_to_dw2regnum -+extern int tc_vax_regname_to_dw2regnum (char *); -+ -+#define tc_cfi_emit_pcrel_expr vax_cfi_emit_pcrel_expr -+extern void vax_cfi_emit_pcrel_expr (expressionS *, unsigned int); -+ -+#define DWARF2_LINE_MIN_INSN_LENGTH 1 -+#define DWARF2_DEFAULT_RETURN_COLUMN 15 -+#define DWARF2_CIE_DATA_ALIGNMENT -4 -diff -rNU3 dist.orig/gas/config/te-armnbsd.h dist/gas/config/te-armnbsd.h ---- dist.orig/gas/config/te-armnbsd.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gas/config/te-armnbsd.h 2015-10-18 13:11:13.000000000 +0200 -@@ -0,0 +1,22 @@ -+/* Copyright 2004, 2005, 2007, 2009 Free Software Foundation, Inc. -+ -+ This file is part of GAS, the GNU Assembler. -+ -+ GAS is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as -+ published by the Free Software Foundation; either version 3, -+ or (at your option) any later version. -+ -+ GAS is distributed in the hope that it will be useful, but -+ WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -+ the GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with GAS; see the file COPYING. If not, write to the Free -+ Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA -+ 02110-1301, USA. */ -+ -+#include "te-nbsd.h" -+ -+#define CPU_DEFAULT ARM_ARCH_V4 -diff -rNU3 dist.orig/gas/config/te-armnbsdeabi.h dist/gas/config/te-armnbsdeabi.h ---- dist.orig/gas/config/te-armnbsdeabi.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gas/config/te-armnbsdeabi.h 2015-10-18 13:11:13.000000000 +0200 -@@ -0,0 +1,25 @@ -+/* Copyright 2004, 2005, 2007, 2009 Free Software Foundation, Inc. -+ -+ This file is part of GAS, the GNU Assembler. -+ -+ GAS is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as -+ published by the Free Software Foundation; either version 3, -+ or (at your option) any later version. -+ -+ GAS is distributed in the hope that it will be useful, but -+ WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -+ the GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with GAS; see the file COPYING. If not, write to the Free -+ Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA -+ 02110-1301, USA. */ -+ -+#include "te-nbsd.h" -+ -+/* The EABI requires the use of VFP. */ -+#define CPU_DEFAULT ARM_ARCH_V5TEJ -+#define FPU_DEFAULT FPU_ARCH_VFP -+#define EABI_DEFAULT EF_ARM_EABI_VER5 -diff -rNU3 dist.orig/gas/config/te-armnbsdeabihf.h dist/gas/config/te-armnbsdeabihf.h ---- dist.orig/gas/config/te-armnbsdeabihf.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gas/config/te-armnbsdeabihf.h 2015-10-18 13:11:13.000000000 +0200 -@@ -0,0 +1,25 @@ -+/* Copyright 2004, 2005, 2007, 2009 Free Software Foundation, Inc. -+ -+ This file is part of GAS, the GNU Assembler. -+ -+ GAS is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as -+ published by the Free Software Foundation; either version 3, -+ or (at your option) any later version. -+ -+ GAS is distributed in the hope that it will be useful, but -+ WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -+ the GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with GAS; see the file COPYING. If not, write to the Free -+ Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA -+ 02110-1301, USA. */ -+ -+#include "te-nbsd.h" -+ -+/* The EABI requires the use of VFP. */ -+#define CPU_DEFAULT ARM_ARCH_V5TEJ -+#define FPU_DEFAULT FPU_ARCH_VFP_V2 -+#define EABI_DEFAULT EF_ARM_EABI_VER5 -diff -rNU3 dist.orig/gas/config/vax-inst.h dist/gas/config/vax-inst.h ---- dist.orig/gas/config/vax-inst.h 2009-09-02 09:24:21.000000000 +0200 -+++ dist/gas/config/vax-inst.h 2015-10-18 13:11:13.000000000 +0200 -@@ -66,6 +66,8 @@ - #define VAX_WIDEN_WORD (0x20) /* Add this to byte branch to get word br. */ - #define VAX_WIDEN_LONG (0x6) /* Add this to byte branch to get long jmp.*/ - /* Needs VAX_PC_RELATIVE_MODE byte after it*/ -+#define VAX_CALLS (0xFB) /* Call with arg list on stack */ -+#define VAX_CALLG (0xFA) /* Call with arg list in memory */ - - struct vit /* vax instruction tree */ - { -diff -rNU3 dist.orig/gas/configure dist/gas/configure ---- dist.orig/gas/configure 2012-06-18 06:43:06.000000000 +0200 -+++ dist/gas/configure 2015-10-18 13:11:13.000000000 +0200 -@@ -12146,7 +12146,7 @@ - fi - ;; - -- epiphany | fr30 | ip2k | iq2000 | lm32 | m32r | openrisc) -+ epiphany | fr30 | ip2k | iq2000 | lm32 | m32r | or1k | or1knd) - using_cgen=yes - ;; - -@@ -12340,6 +12340,8 @@ - cgen_cpu_prefix="" - if test $using_cgen = yes ; then - case ${target_cpu} in -+ or1knd) -+ cgen_cpu_prefix=or1k ;; - *) cgen_cpu_prefix=${target_cpu} ;; - esac - -diff -rNU3 dist.orig/gas/configure.in dist/gas/configure.in ---- dist.orig/gas/configure.in 2012-11-05 17:27:44.000000000 +0100 -+++ dist/gas/configure.in 2015-10-18 13:11:13.000000000 +0200 -@@ -314,7 +314,7 @@ - fi - ;; - -- epiphany | fr30 | ip2k | iq2000 | lm32 | m32r | openrisc) -+ epiphany | fr30 | ip2k | iq2000 | lm32 | m32r | or1k | or1knd) - using_cgen=yes - ;; - -@@ -504,6 +504,8 @@ - cgen_cpu_prefix="" - if test $using_cgen = yes ; then - case ${target_cpu} in -+ or1knd) -+ cgen_cpu_prefix=or1k ;; - *) cgen_cpu_prefix=${target_cpu} ;; - esac - AC_SUBST(cgen_cpu_prefix) -diff -rNU3 dist.orig/gas/configure.tgt dist/gas/configure.tgt ---- dist.orig/gas/configure.tgt 2012-09-04 14:53:45.000000000 +0200 -+++ dist/gas/configure.tgt 2015-10-18 13:11:13.000000000 +0200 -@@ -51,7 +51,7 @@ - m32c) cpu_type=m32c endian=little ;; - m32r) cpu_type=m32r endian=big ;; - m32rle) cpu_type=m32r endian=little ;; -- m5200) cpu_type=m68k ;; -+ m5200|m5407) cpu_type=m68k ;; - m68008) cpu_type=m68k ;; - m680[012346]0) cpu_type=m68k ;; - m6811|m6812|m68hc12) cpu_type=m68hc11 ;; -@@ -61,11 +61,13 @@ - mips*el) cpu_type=mips endian=little ;; - mips*) cpu_type=mips endian=big ;; - mt) cpu_type=mt endian=big ;; -- or32*) cpu_type=or32 endian=big ;; -+ or1k*) cpu_type=or1k endian=big ;; - pjl*) cpu_type=pj endian=little ;; - pj*) cpu_type=pj endian=big ;; - powerpc*le*) cpu_type=ppc endian=little ;; - powerpc*) cpu_type=ppc endian=big ;; -+ riscv*eb) cpu_type=riscv endian=big ;; -+ riscv*) cpu_type=riscv endian=little ;; - rs6000*) cpu_type=ppc ;; - rl78*) cpu_type=rl78 ;; - rx) cpu_type=rx ;; -@@ -100,6 +102,7 @@ - case ${generic_target} in - aarch64*-*-elf) fmt=elf;; - aarch64*-*-linux*) fmt=elf em=linux ;; -+ aarch64*-*-netbsd*) fmt=elf em=nbsd ;; - - alpha-*-*vms*) fmt=evax ;; - alpha-*-osf*) fmt=ecoff ;; -@@ -111,9 +114,11 @@ - arc-*-elf*) fmt=elf ;; - - arm-*-aout) fmt=aout ;; -- arm-*-coff) fmt=coff ;; -- arm-*-rtems*) fmt=elf ;; -- arm-*-elf) fmt=elf ;; -+ arm-*-coff | thumb-*-coff) fmt=coff ;; -+ arm-*-rtems* | thumb-*-rtems*) fmt=elf ;; -+ arm-*-elf | thumb-*-elf) fmt=elf ;; -+ arm-*-netbsdelf*-*eabihf*) fmt=elf em=armnbsdeabihf ;; -+ arm-*-netbsdelf*-*eabi*) fmt=elf em=armnbsdeabi ;; - arm-*-eabi*) fmt=elf em=armeabi ;; - arm-*-symbianelf*) fmt=elf em=symbian ;; - arm-*-kaos*) fmt=elf ;; -@@ -124,8 +129,8 @@ - arm-*-uclinux*eabi*) fmt=elf em=armlinuxeabi ;; - arm-*-uclinux*) fmt=elf em=linux ;; - arm-*-nacl*) fmt=elf em=nacl ;; -- arm-*-netbsdelf*) fmt=elf em=nbsd ;; -- arm-*-*n*bsd*) fmt=aout em=nbsd ;; -+ arm-*-netbsdelf*) fmt=elf em=armnbsd ;; -+ arm-*-*n*bsd*) fmt=aout em=armnbsd ;; - arm-*-nto*) fmt=elf ;; - arm-epoc-pe) fmt=coff em=epoc-pe ;; - arm-wince-pe | arm-*-wince | arm*-*-mingw32ce* | arm*-*-cegcc*) -@@ -334,10 +339,9 @@ - ns32k-pc532-lites*) fmt=aout em=nbsd532 ;; - ns32k-*-*n*bsd*) fmt=aout em=nbsd532 ;; - -- openrisc-*-*) fmt=elf ;; -- -- or32-*-rtems*) fmt=elf ;; -- or32-*-elf) fmt=elf ;; -+ or1k-*-elf) fmt=elf ;; -+ or1k-*-linux*) fmt=elf em=linux ;; -+ or1k-*-netbsd*) fmt=elf em=nbsd ;; - - pj*) fmt=elf ;; - -@@ -357,6 +361,11 @@ - ppc-*-kaos*) fmt=elf ;; - ppc-*-lynxos*) fmt=elf em=lynx ;; - -+ riscv*eb-*-linux*) fmt=elf endian=big em=linux ;; -+ riscv*eb-*-netbsd*) fmt=elf endian=big em=nbsd ;; -+ riscv*-*-linux*) fmt=elf endian=little em=linux ;; -+ riscv*-*-netbsd*) fmt=elf endian=little em=nbsd ;; -+ - s390-*-linux-*) fmt=elf em=linux ;; - s390-*-tpf*) fmt=elf ;; - -@@ -451,7 +460,7 @@ - esac - - case ${cpu_type} in -- aarch64 | alpha | arm | i386 | ia64 | microblaze | mips | ns32k | pdp11 | ppc | sparc | z80 | z8k) -+ aarch64 | alpha | arm | i386 | ia64 | microblaze | mips | ns32k | or1k | or1knd | pdp11 | ppc | riscv | sparc | z80 | z8k) - bfd_gas=yes - ;; - esac -diff -rNU3 dist.orig/gas/doc/Makefile.am dist/gas/doc/Makefile.am ---- dist.orig/gas/doc/Makefile.am 2012-09-04 14:53:45.000000000 +0200 -+++ dist/gas/doc/Makefile.am 2015-10-18 13:11:13.000000000 +0200 -@@ -24,6 +24,8 @@ - -I "$(top_srcdir)/../bfd/doc" -I ../../bfd/doc - - asconfig.texi: $(CONFIG).texi -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_asconfig.text: - rm -f asconfig.texi - cp $(srcdir)/$(CONFIG).texi ./asconfig.texi - chmod u+w ./asconfig.texi -@@ -103,6 +105,8 @@ - # The sed command removes the no-adjust Nroff command so that - # the man output looks standard. - as.1: $(srcdir)/as.texinfo asconfig.texi $(CPU_DOCS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_as.1: - touch $@ - -$(TEXI2POD) $(MANCONF) < $(srcdir)/as.texinfo > as.pod - -($(POD2MAN) as.pod | \ -diff -rNU3 dist.orig/gas/doc/Makefile.in dist/gas/doc/Makefile.in ---- dist.orig/gas/doc/Makefile.in 2012-09-04 14:53:45.000000000 +0200 -+++ dist/gas/doc/Makefile.in 2015-10-18 13:11:13.000000000 +0200 -@@ -374,6 +374,8 @@ - -rm -rf .libs _libs - - as.info: as.texinfo $(as_TEXINFOS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_as.info: as.texinfo $(as_TEXINFOS) - restore=: && backupdir="$(am__leading_dot)am$$$$" && \ - rm -rf $$backupdir && mkdir $$backupdir && \ - if ($(MAKEINFO) --version) >/dev/null 2>&1; then \ -@@ -756,6 +758,8 @@ - - - asconfig.texi: $(CONFIG).texi -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_asconfig.texi: - rm -f asconfig.texi - cp $(srcdir)/$(CONFIG).texi ./asconfig.texi - chmod u+w ./asconfig.texi -@@ -773,6 +777,8 @@ - # The sed command removes the no-adjust Nroff command so that - # the man output looks standard. - as.1: $(srcdir)/as.texinfo asconfig.texi $(CPU_DOCS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_as.1: - touch $@ - -$(TEXI2POD) $(MANCONF) < $(srcdir)/as.texinfo > as.pod - -($(POD2MAN) as.pod | \ -diff -rNU3 dist.orig/gas/doc/as.info dist/gas/doc/as.info ---- dist.orig/gas/doc/as.info 2013-03-25 10:10:23.000000000 +0100 -+++ dist/gas/doc/as.info 2015-10-18 13:11:13.000000000 +0200 -@@ -22275,8 +22275,8 @@ - * -g command line option, Alpha: Alpha Options. (line 47) - * -G command line option, Alpha: Alpha Options. (line 53) - * -G option (MIPS): MIPS Opts. (line 8) --* -H option, VAX/VMS: VAX-Opts. (line 81) - * -h option, VAX/VMS: VAX-Opts. (line 45) -+* -H option, VAX/VMS: VAX-Opts. (line 81) - * -I PATH: I. (line 6) - * -ignore-parallel-conflicts option, M32RX: M32R-Opts. (line 87) - * -Ip option, M32RX: M32R-Opts. (line 97) -@@ -22876,8 +22876,8 @@ - * BSD syntax: PDP-11-Syntax. (line 6) - * bss directive, i960: Directives-i960. (line 6) - * bss directive, TIC54X: TIC54X-Directives. (line 29) --* bss section <1>: bss. (line 6) --* bss section: Ld Sections. (line 20) -+* bss section <1>: Ld Sections. (line 20) -+* bss section: bss. (line 6) - * bug criteria: Bug Criteria. (line 6) - * bug reports: Bug Reporting. (line 6) - * bugs in assembler: Reporting Bugs. (line 6) -diff -rNU3 dist.orig/gas/doc/c-mips.texi dist/gas/doc/c-mips.texi ---- dist.orig/gas/doc/c-mips.texi 2012-09-04 16:16:07.000000000 +0200 -+++ dist/gas/doc/c-mips.texi 2015-10-18 13:11:13.000000000 +0200 -@@ -210,6 +210,14 @@ - @itemx -mno-fix-vr4130 - Insert nops to work around the VR4130 @samp{mflo}/@samp{mfhi} errata. - -+@item -mfix-loongson2f-btb -+@itemx -mno-fix-loongson2f-btb -+Clear the Branch Target Buffer before any jump through a register. This -+option is intended to be used on kernel code for the Loongson 2F processor -+only; userland code compiled with this option will fault, and kernel code -+compiled with this option run on another processor than Loongson 2F will -+yield unpredictable results. -+ - @item -mfix-24k - @itemx -mno-fix-24k - Insert nops to work around the 24K @samp{eret}/@samp{deret} errata. -diff -rNU3 dist.orig/gas/remap.c dist/gas/remap.c ---- dist.orig/gas/remap.c 2011-03-11 15:18:24.000000000 +0100 -+++ dist/gas/remap.c 2015-10-18 13:11:13.000000000 +0200 -@@ -84,8 +84,8 @@ - return xstrdup (filename); - name = filename + map->old_len; - name_len = strlen (name) + 1; -- s = (char *) alloca (name_len + map->new_len); -+ s = (char *) xmalloc (name_len + map->new_len); - memcpy (s, map->new_prefix, map->new_len); - memcpy (s + map->new_len, name, name_len); -- return xstrdup (s); -+ return s; - } -diff -rNU3 dist.orig/gprof/corefile.c dist/gprof/corefile.c ---- dist.orig/gprof/corefile.c 2012-03-06 14:54:59.000000000 +0100 -+++ dist/gprof/corefile.c 2015-10-18 13:11:17.000000000 +0200 -@@ -30,6 +30,8 @@ - #include "corefile.h" - #include "safe-ctype.h" - -+#include -+ - bfd *core_bfd; - static int core_num_syms; - static asymbol **core_syms; -diff -rNU3 dist.orig/gprof/gprof.c dist/gprof/gprof.c ---- dist.orig/gprof/gprof.c 2009-06-12 17:33:30.000000000 +0200 -+++ dist/gprof/gprof.c 2015-10-18 13:11:17.000000000 +0200 -@@ -47,6 +47,8 @@ - - static void usage (FILE *, int) ATTRIBUTE_NORETURN; - -+#include -+ - const char * whoami; - const char * function_mapping_file; - static const char * external_symbol_table; -diff -rNU3 dist.orig/gprof/gprof.info dist/gprof/gprof.info ---- dist.orig/gprof/gprof.info 2012-11-13 15:19:35.000000000 +0100 -+++ dist/gprof/gprof.info 2015-10-18 13:11:17.000000000 +0200 -@@ -2441,34 +2441,34 @@ -  - Tag Table: - Node: Top777 --Node: Introduction2102 --Node: Compiling4594 --Node: Executing8650 --Node: Invoking11438 --Node: Output Options12853 --Node: Analysis Options19942 --Node: Miscellaneous Options23640 --Node: Deprecated Options24895 --Node: Symspecs26964 --Node: Output28790 --Node: Flat Profile29830 --Node: Call Graph34783 --Node: Primary38015 --Node: Callers40603 --Node: Subroutines42720 --Node: Cycles44561 --Node: Line-by-line51338 --Node: Annotated Source55411 --Node: Inaccuracy58410 --Node: Sampling Error58668 --Node: Assumptions61572 --Node: How do I?63042 --Node: Incompatibilities64596 --Node: Details66090 --Node: Implementation66483 --Node: File Format72380 --Node: Internals76670 --Node: Debugging85165 --Node: GNU Free Documentation License86766 -+Node: Introduction2103 -+Node: Compiling4595 -+Node: Executing8651 -+Node: Invoking11439 -+Node: Output Options12854 -+Node: Analysis Options19943 -+Node: Miscellaneous Options23641 -+Node: Deprecated Options24896 -+Node: Symspecs26965 -+Node: Output28791 -+Node: Flat Profile29831 -+Node: Call Graph34784 -+Node: Primary38016 -+Node: Callers40604 -+Node: Subroutines42721 -+Node: Cycles44562 -+Node: Line-by-line51339 -+Node: Annotated Source55412 -+Node: Inaccuracy58411 -+Node: Sampling Error58669 -+Node: Assumptions61573 -+Node: How do I?63043 -+Node: Incompatibilities64597 -+Node: Details66091 -+Node: Implementation66484 -+Node: File Format72381 -+Node: Internals76671 -+Node: Debugging85166 -+Node: GNU Free Documentation License86767 -  - End Tag Table -diff -rNU3 dist.orig/include/bfdlink.h dist/include/bfdlink.h ---- dist.orig/include/bfdlink.h 2012-04-09 18:27:18.000000000 +0200 -+++ dist/include/bfdlink.h 2015-10-18 13:11:17.000000000 +0200 -@@ -435,6 +435,10 @@ - option). If this is NULL, no symbols are being wrapped. */ - struct bfd_hash_table *wrap_hash; - -+ /* Hash table of symbols which may be left unresolved during -+ a link. If this is NULL, no symbols can be left unresolved. */ -+ struct bfd_hash_table *ignore_hash; -+ - /* The output BFD. */ - bfd *output_bfd; - -diff -rNU3 dist.orig/include/dis-asm.h dist/include/dis-asm.h ---- dist.orig/include/dis-asm.h 2012-09-04 14:53:46.000000000 +0200 -+++ dist/include/dis-asm.h 2015-10-18 13:11:17.000000000 +0200 -@@ -226,7 +226,6 @@ - extern int print_insn_bfin (bfd_vma, disassemble_info *); - extern int print_insn_big_arm (bfd_vma, disassemble_info *); - extern int print_insn_big_mips (bfd_vma, disassemble_info *); --extern int print_insn_big_or32 (bfd_vma, disassemble_info *); - extern int print_insn_big_powerpc (bfd_vma, disassemble_info *); - extern int print_insn_big_score (bfd_vma, disassemble_info *); - extern int print_insn_cr16 (bfd_vma, disassemble_info *); -@@ -253,7 +252,6 @@ - extern int print_insn_iq2000 (bfd_vma, disassemble_info *); - extern int print_insn_little_arm (bfd_vma, disassemble_info *); - extern int print_insn_little_mips (bfd_vma, disassemble_info *); --extern int print_insn_little_or32 (bfd_vma, disassemble_info *); - extern int print_insn_little_powerpc (bfd_vma, disassemble_info *); - extern int print_insn_little_score (bfd_vma, disassemble_info *); - extern int print_insn_lm32 (bfd_vma, disassemble_info *); -@@ -275,9 +273,10 @@ - extern int print_insn_msp430 (bfd_vma, disassemble_info *); - extern int print_insn_mt (bfd_vma, disassemble_info *); - extern int print_insn_ns32k (bfd_vma, disassemble_info *); --extern int print_insn_openrisc (bfd_vma, disassemble_info *); -+extern int print_insn_or1k (bfd_vma, disassemble_info *); - extern int print_insn_pdp11 (bfd_vma, disassemble_info *); - extern int print_insn_pj (bfd_vma, disassemble_info *); -+extern int print_insn_riscv (bfd_vma, disassemble_info *); - extern int print_insn_rs6000 (bfd_vma, disassemble_info *); - extern int print_insn_s390 (bfd_vma, disassemble_info *); - extern int print_insn_sh (bfd_vma, disassemble_info *); -diff -rNU3 dist.orig/include/elf/common.h dist/include/elf/common.h ---- dist.orig/include/elf/common.h 2012-09-04 14:53:47.000000000 +0200 -+++ dist/include/elf/common.h 2015-10-18 13:11:17.000000000 +0200 -@@ -194,7 +194,7 @@ - #define EM_MN10300 89 /* Matsushita MN10300 */ - #define EM_MN10200 90 /* Matsushita MN10200 */ - #define EM_PJ 91 /* picoJava */ --#define EM_OPENRISC 92 /* OpenRISC 32-bit embedded processor */ -+#define EM_OR1K 92 /* OpenRISC 1000 32-bit embedded processor */ - #define EM_ARC_A5 93 /* ARC Cores Tangent-A5 */ - #define EM_XTENSA 94 /* Tensilica Xtensa Architecture */ - #define EM_VIDEOCORE 95 /* Alphamosaic VideoCore processor */ -@@ -298,6 +298,7 @@ - #define EM_TILEGX 191 /* Tilera TILE-Gx multicore architecture family */ - #define EM_RL78 197 /* Renesas RL78 family. */ - #define EM_78K0R 199 /* Renesas 78K0R. */ -+#define EM_RISCV 243 /* RISC-V */ - - /* If it is necessary to assign new unofficial EM_* values, please pick large - random numbers (0x8523, 0xa7f2, etc.) to minimize the chances of collision -@@ -357,9 +358,6 @@ - /* Ubicom IP2xxx; Written in the absense of an ABI. */ - #define EM_IP2K_OLD 0x8217 - --/* (Deprecated) Temporary number for the OpenRISC processor. */ --#define EM_OR32 0x8472 -- - /* Cygnus PowerPC ELF backend. Written in the absence of an ABI. */ - #define EM_CYGNUS_POWERPC 0x9025 - -@@ -607,6 +605,16 @@ - /* Values for NetBSD .note.netbsd.ident notes. Note name is "NetBSD". */ - - #define NT_NETBSD_IDENT 1 -+#define NT_NETBSD_MARCH 5 -+ -+/* Values for NetBSD .note.netbsd.ident notes. Note name is "PaX". */ -+#define NT_NETBSD_PAX 3 -+#define NT_NETBSD_PAX_MPROTECT 0x01 /* Force enable Mprotect */ -+#define NT_NETBSD_PAX_NOMPROTECT 0x02 /* Force disable Mprotect */ -+#define NT_NETBSD_PAX_GUARD 0x04 /* Force enable Segvguard */ -+#define NT_NETBSD_PAX_NOGUARD 0x08 /* Force disable Servguard */ -+#define NT_NETBSD_PAX_ASLR 0x10 /* Force enable ASLR */ -+#define NT_NETBSD_PAX_NOASLR 0x20 /* Force disable ASLR */ - - /* Values for OpenBSD .note.openbsd.ident notes. Note name is "OpenBSD". */ - -diff -rNU3 dist.orig/include/elf/openrisc.h dist/include/elf/openrisc.h ---- dist.orig/include/elf/openrisc.h 2010-04-15 12:26:08.000000000 +0200 -+++ dist/include/elf/openrisc.h 1970-01-01 01:00:00.000000000 +0100 -@@ -1,39 +0,0 @@ --/* OpenRISC ELF support for BFD. -- Copyright 2001, 2010 Free Software Foundation, Inc. -- -- This file is part of BFD, the Binary File Descriptor library. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software Foundation, -- Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -- --#ifndef _ELF_OPENRISC_H --#define _ELF_OPENRISC_H -- --#include "elf/reloc-macros.h" -- --/* Relocations. */ --START_RELOC_NUMBERS (elf_openrisc_reloc_type) -- RELOC_NUMBER (R_OPENRISC_NONE, 0) -- RELOC_NUMBER (R_OPENRISC_INSN_REL_26, 1) -- RELOC_NUMBER (R_OPENRISC_INSN_ABS_26, 2) -- RELOC_NUMBER (R_OPENRISC_LO_16_IN_INSN, 3) -- RELOC_NUMBER (R_OPENRISC_HI_16_IN_INSN, 4) -- RELOC_NUMBER (R_OPENRISC_8, 5) -- RELOC_NUMBER (R_OPENRISC_16, 6) -- RELOC_NUMBER (R_OPENRISC_32, 7) -- RELOC_NUMBER (R_OPENRISC_GNU_VTINHERIT, 8) -- RELOC_NUMBER (R_OPENRISC_GNU_VTENTRY, 9) --END_RELOC_NUMBERS (R_OPENRISC_max) -- --#endif /* _ELF_OPENRISC_H */ -diff -rNU3 dist.orig/include/elf/or1k.h dist/include/elf/or1k.h ---- dist.orig/include/elf/or1k.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/include/elf/or1k.h 2015-10-18 13:11:17.000000000 +0200 -@@ -0,0 +1,65 @@ -+/* Or1k ELF support for BFD. -+ Copyright 2001-2014 Free Software Foundation, Inc. -+ -+ This file is part of BFD, the Binary File Descriptor library. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, see */ -+ -+#ifndef _ELF_OR1K_H -+#define _ELF_OR1K_H -+ -+#include "elf/reloc-macros.h" -+ -+/* Relocations. */ -+START_RELOC_NUMBERS (elf_or1k_reloc_type) -+ RELOC_NUMBER (R_OR1K_NONE, 0) -+ RELOC_NUMBER (R_OR1K_32, 1) -+ RELOC_NUMBER (R_OR1K_16, 2) -+ RELOC_NUMBER (R_OR1K_8, 3) -+ RELOC_NUMBER (R_OR1K_LO_16_IN_INSN, 4) -+ RELOC_NUMBER (R_OR1K_HI_16_IN_INSN, 5) -+ RELOC_NUMBER (R_OR1K_INSN_REL_26, 6) -+ RELOC_NUMBER (R_OR1K_GNU_VTENTRY, 7) -+ RELOC_NUMBER (R_OR1K_GNU_VTINHERIT, 8) -+ RELOC_NUMBER (R_OR1K_32_PCREL, 9) -+ RELOC_NUMBER (R_OR1K_16_PCREL, 10) -+ RELOC_NUMBER (R_OR1K_8_PCREL, 11) -+ RELOC_NUMBER (R_OR1K_GOTPC_HI16, 12) -+ RELOC_NUMBER (R_OR1K_GOTPC_LO16, 13) -+ RELOC_NUMBER (R_OR1K_GOT16, 14) -+ RELOC_NUMBER (R_OR1K_PLT26, 15) -+ RELOC_NUMBER (R_OR1K_GOTOFF_HI16, 16) -+ RELOC_NUMBER (R_OR1K_GOTOFF_LO16, 17) -+ RELOC_NUMBER (R_OR1K_COPY, 18) -+ RELOC_NUMBER (R_OR1K_GLOB_DAT, 19) -+ RELOC_NUMBER (R_OR1K_JMP_SLOT, 20) -+ RELOC_NUMBER (R_OR1K_RELATIVE, 21) -+ RELOC_NUMBER (R_OR1K_TLS_GD_HI16, 22) -+ RELOC_NUMBER (R_OR1K_TLS_GD_LO16, 23) -+ RELOC_NUMBER (R_OR1K_TLS_LDM_HI16, 24) -+ RELOC_NUMBER (R_OR1K_TLS_LDM_LO16, 25) -+ RELOC_NUMBER (R_OR1K_TLS_LDO_HI16, 26) -+ RELOC_NUMBER (R_OR1K_TLS_LDO_LO16, 27) -+ RELOC_NUMBER (R_OR1K_TLS_IE_HI16, 28) -+ RELOC_NUMBER (R_OR1K_TLS_IE_LO16, 29) -+ RELOC_NUMBER (R_OR1K_TLS_LE_HI16, 30) -+ RELOC_NUMBER (R_OR1K_TLS_LE_LO16, 31) -+ RELOC_NUMBER (R_OR1K_TLS_TPOFF, 32) -+ RELOC_NUMBER (R_OR1K_TLS_DTPOFF, 33) -+ RELOC_NUMBER (R_OR1K_TLS_DTPMOD, 34) -+END_RELOC_NUMBERS (R_OR1K_max) -+ -+#define EF_OR1K_NODELAY (1UL << 0) -+ -+#endif /* _ELF_OR1K_H */ -diff -rNU3 dist.orig/include/elf/or32.h dist/include/elf/or32.h ---- dist.orig/include/elf/or32.h 2010-05-18 05:31:06.000000000 +0200 -+++ dist/include/elf/or32.h 1970-01-01 01:00:00.000000000 +0100 -@@ -1,56 +0,0 @@ --/* OR1K ELF support for BFD. Derived from ppc.h. -- Copyright (C) 2002, 2010 Free Software Foundation, Inc. -- Contributed by Ivan Guzvinec -- -- This file is part of BFD, the Binary File Descriptor library. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, -- MA 02110-1301, USA. */ -- --#ifndef _ELF_OR1K_H --#define _ELF_OR1K_H -- --#include "elf/reloc-macros.h" -- --/* Relocations. */ --START_RELOC_NUMBERS (elf_or32_reloc_type) -- RELOC_NUMBER (R_OR32_NONE, 0) -- RELOC_NUMBER (R_OR32_32, 1) -- RELOC_NUMBER (R_OR32_16, 2) -- RELOC_NUMBER (R_OR32_8, 3) -- RELOC_NUMBER (R_OR32_CONST, 4) -- RELOC_NUMBER (R_OR32_CONSTH, 5) -- RELOC_NUMBER (R_OR32_JUMPTARG, 6) -- RELOC_NUMBER (R_OR32_GNU_VTENTRY, 7) -- RELOC_NUMBER (R_OR32_GNU_VTINHERIT, 8) --END_RELOC_NUMBERS (R_OR32_max) -- --/* Four bit OR32 machine type field. */ --#define EF_OR32_MACH 0x0000000f -- --/* Various CPU types. */ --#define E_OR32_MACH_BASE 0x00000000 --#define E_OR32_MACH_UNUSED1 0x00000001 --#define E_OR32_MACH_UNUSED2 0x00000002 --#define E_OR32_MACH_UNUSED4 0x00000003 -- --/* Processor specific section headers, sh_type field */ --#define SHT_ORDERED SHT_HIPROC /* Link editor is to sort the \ -- entries in this section \ -- based on the address \ -- specified in the associated \ -- symbol table entry. */ -- --#endif /* _ELF_OR1K_H */ -diff -rNU3 dist.orig/include/elf/riscv.h dist/include/elf/riscv.h ---- dist.orig/include/elf/riscv.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/include/elf/riscv.h 2015-10-18 13:11:17.000000000 +0200 -@@ -0,0 +1,138 @@ -+/* RISC-V ELF support for BFD. -+ Copyright 2011-2014 Free Software Foundation, Inc. -+ -+ Contributed by Andrw Waterman at UC Berkeley. -+ Based on MIPS ELF support for BFD, by Ian Lance Taylor. -+ -+ This file is part of BFD, the Binary File Descriptor library. -+ -+ This program is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3 of the License, or -+ (at your option) any later version. -+ -+ This program is distributed in the hope that it will be useful, -+ but WITHOUT ANY WARRANTY; without even the implied warranty of -+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+ GNU General Public License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, write to the Free Software -+ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, -+ MA 02110-1301, USA. */ -+ -+/* This file holds definitions specific to the RISCV ELF ABI. Note -+ that most of this is not actually implemented by BFD. */ -+ -+#ifndef _ELF_RISCV_H -+#define _ELF_RISCV_H -+ -+#include "elf/reloc-macros.h" -+ -+/* Relocation types. */ -+START_RELOC_NUMBERS (elf_riscv_reloc_type) -+ /* Relocation types used by the dynamic linker. */ -+ RELOC_NUMBER (R_RISCV_NONE, 0) -+ RELOC_NUMBER (R_RISCV_32, 1) -+ RELOC_NUMBER (R_RISCV_64, 2) -+ RELOC_NUMBER (R_RISCV_RELATIVE, 3) -+ RELOC_NUMBER (R_RISCV_COPY, 4) -+ RELOC_NUMBER (R_RISCV_JUMP_SLOT, 5) -+ RELOC_NUMBER (R_RISCV_TLS_DTPMOD32, 6) -+ RELOC_NUMBER (R_RISCV_TLS_DTPMOD64, 7) -+ RELOC_NUMBER (R_RISCV_TLS_DTPREL32, 8) -+ RELOC_NUMBER (R_RISCV_TLS_DTPREL64, 9) -+ RELOC_NUMBER (R_RISCV_TLS_TPREL32, 10) -+ RELOC_NUMBER (R_RISCV_TLS_TPREL64, 11) -+ -+ /* Relocation types not used by the dynamic linker. */ -+ RELOC_NUMBER (R_RISCV_BRANCH, 16) -+ RELOC_NUMBER (R_RISCV_JAL, 17) -+ RELOC_NUMBER (R_RISCV_CALL, 18) -+ RELOC_NUMBER (R_RISCV_CALL_PLT, 19) -+ RELOC_NUMBER (R_RISCV_GOT_HI20, 20) -+ RELOC_NUMBER (R_RISCV_TLS_GOT_HI20, 21) -+ RELOC_NUMBER (R_RISCV_TLS_GD_HI20, 22) -+ RELOC_NUMBER (R_RISCV_PCREL_HI20, 23) -+ RELOC_NUMBER (R_RISCV_PCREL_LO12_I, 24) -+ RELOC_NUMBER (R_RISCV_PCREL_LO12_S, 25) -+ RELOC_NUMBER (R_RISCV_HI20, 26) -+ RELOC_NUMBER (R_RISCV_LO12_I, 27) -+ RELOC_NUMBER (R_RISCV_LO12_S, 28) -+ RELOC_NUMBER (R_RISCV_TPREL_HI20, 29) -+ RELOC_NUMBER (R_RISCV_TPREL_LO12_I, 30) -+ RELOC_NUMBER (R_RISCV_TPREL_LO12_S, 31) -+ RELOC_NUMBER (R_RISCV_TPREL_ADD, 32) -+ RELOC_NUMBER (R_RISCV_ADD8, 33) -+ RELOC_NUMBER (R_RISCV_ADD16, 34) -+ RELOC_NUMBER (R_RISCV_ADD32, 35) -+ RELOC_NUMBER (R_RISCV_ADD64, 36) -+ RELOC_NUMBER (R_RISCV_SUB8, 37) -+ RELOC_NUMBER (R_RISCV_SUB16, 38) -+ RELOC_NUMBER (R_RISCV_SUB32, 39) -+ RELOC_NUMBER (R_RISCV_SUB64, 40) -+ RELOC_NUMBER (R_RISCV_GNU_VTINHERIT, 41) -+ RELOC_NUMBER (R_RISCV_GNU_VTENTRY, 42) -+ RELOC_NUMBER (R_RISCV_ALIGN, 43) -+END_RELOC_NUMBERS (R_RISCV_max) -+ -+/* Processor specific flags for the ELF header e_flags field. */ -+ -+/* Custom flag definitions. */ -+ -+#define EF_RISCV_EXT_MASK 0xffff -+#define EF_RISCV_EXT_SH 16 -+#define E_RISCV_EXT_Xcustom 0x0000 -+#define E_RISCV_EXT_Xhwacha 0x0001 -+#define E_RISCV_EXT_RESERVED 0xffff -+ -+#define EF_GET_RISCV_EXT(x) \ -+ ((x >> EF_RISCV_EXT_SH) & EF_RISCV_EXT_MASK) -+ -+#define EF_SET_RISCV_EXT(x, ext) \ -+ do { x |= ((ext & EF_RISCV_EXT_MASK) << EF_RISCV_EXT_SH); } while (0) -+ -+#define EF_IS_RISCV_EXT_Xcustom(x) \ -+ (EF_GET_RISCV_EXT(x) == E_RISCV_EXT_Xcustom) -+ -+/* A mapping from extension names to elf flags */ -+ -+struct riscv_extension_entry -+{ -+ const char* name; -+ unsigned int flag; -+}; -+ -+static const struct riscv_extension_entry riscv_extension_map[] = -+{ -+ {"Xcustom", E_RISCV_EXT_Xcustom}, -+ {"Xhwacha", E_RISCV_EXT_Xhwacha}, -+}; -+ -+/* Given an extension name, return an elf flag. */ -+ -+static inline const char* riscv_elf_flag_to_name(unsigned int flag) -+{ -+ unsigned int i; -+ -+ for (i=0; icurrent_space \ -+ (__len != 0 && __len <= __o->current_space \ - ? (__o->current_ptr += __len, \ - __o->current_space -= __len, \ - (void *) (__o->current_ptr - __len)) \ -diff -rNU3 dist.orig/include/opcode/mips.h dist/include/opcode/mips.h ---- dist.orig/include/opcode/mips.h 2012-09-04 16:21:05.000000000 +0200 -+++ dist/include/opcode/mips.h 2015-10-18 13:11:17.000000000 +0200 -@@ -1035,7 +1035,11 @@ - M_DSUB_I, - M_DSUBU_I, - M_DSUBU_I_2, -+ M_JR_S, -+ M_J_S, - M_J_A, -+ M_JALR_S, -+ M_JALR_DS, - M_JAL_1, - M_JAL_2, - M_JAL_A, -diff -rNU3 dist.orig/include/opcode/riscv-opc.h dist/include/opcode/riscv-opc.h ---- dist.orig/include/opcode/riscv-opc.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/include/opcode/riscv-opc.h 2015-10-18 13:11:17.000000000 +0200 -@@ -0,0 +1,1234 @@ -+/* Automatically generated by parse-opcodes */ -+#ifndef RISCV_ENCODING_H -+#define RISCV_ENCODING_H -+#define MATCH_CUSTOM3_RD_RS1_RS2 0x707b -+#define MASK_CUSTOM3_RD_RS1_RS2 0x707f -+#define MATCH_VLSEGSTWU 0xc00305b -+#define MASK_VLSEGSTWU 0x1e00707f -+#define MATCH_C_LW0 0x12 -+#define MASK_C_LW0 0x801f -+#define MATCH_FMV_D_X 0xf2000053 -+#define MASK_FMV_D_X 0xfff0707f -+#define MATCH_VLH 0x200205b -+#define MASK_VLH 0xfff0707f -+#define MATCH_C_LI 0x0 -+#define MASK_C_LI 0x1f -+#define MATCH_FADD_D 0x2000053 -+#define MASK_FADD_D 0xfe00007f -+#define MATCH_C_LD 0x9 -+#define MASK_C_LD 0x1f -+#define MATCH_VLD 0x600205b -+#define MASK_VLD 0xfff0707f -+#define MATCH_FADD_S 0x53 -+#define MASK_FADD_S 0xfe00007f -+#define MATCH_C_LW 0xa -+#define MASK_C_LW 0x1f -+#define MATCH_VLW 0x400205b -+#define MASK_VLW 0xfff0707f -+#define MATCH_VSSEGSTW 0x400307b -+#define MASK_VSSEGSTW 0x1e00707f -+#define MATCH_UTIDX 0x6077 -+#define MASK_UTIDX 0xfffff07f -+#define MATCH_C_FLW 0x14 -+#define MASK_C_FLW 0x1f -+#define MATCH_FSUB_D 0xa000053 -+#define MASK_FSUB_D 0xfe00007f -+#define MATCH_VSSEGSTD 0x600307b -+#define MASK_VSSEGSTD 0x1e00707f -+#define MATCH_VSSEGSTB 0x307b -+#define MASK_VSSEGSTB 0x1e00707f -+#define MATCH_DIV 0x2004033 -+#define MASK_DIV 0xfe00707f -+#define MATCH_FMV_H_X 0xf4000053 -+#define MASK_FMV_H_X 0xfff0707f -+#define MATCH_C_FLD 0x15 -+#define MASK_C_FLD 0x1f -+#define MATCH_FRRM 0x202073 -+#define MASK_FRRM 0xfffff07f -+#define MATCH_VFMSV_S 0x1000202b -+#define MASK_VFMSV_S 0xfff0707f -+#define MATCH_C_LWSP 0x5 -+#define MASK_C_LWSP 0x1f -+#define MATCH_FENCE 0xf -+#define MASK_FENCE 0x707f -+#define MATCH_FNMSUB_S 0x4b -+#define MASK_FNMSUB_S 0x600007f -+#define MATCH_FLE_S 0xa0000053 -+#define MASK_FLE_S 0xfe00707f -+#define MATCH_FNMSUB_H 0x400004b -+#define MASK_FNMSUB_H 0x600007f -+#define MATCH_FLE_H 0xbc000053 -+#define MASK_FLE_H 0xfe00707f -+#define MATCH_FLW 0x2007 -+#define MASK_FLW 0x707f -+#define MATCH_VSETVL 0x600b -+#define MASK_VSETVL 0xfff0707f -+#define MATCH_VFMSV_D 0x1200202b -+#define MASK_VFMSV_D 0xfff0707f -+#define MATCH_FLE_D 0xa2000053 -+#define MASK_FLE_D 0xfe00707f -+#define MATCH_FENCE_I 0x100f -+#define MASK_FENCE_I 0x707f -+#define MATCH_FNMSUB_D 0x200004b -+#define MASK_FNMSUB_D 0x600007f -+#define MATCH_ADDW 0x3b -+#define MASK_ADDW 0xfe00707f -+#define MATCH_XOR 0x4033 -+#define MASK_XOR 0xfe00707f -+#define MATCH_SUB 0x40000033 -+#define MASK_SUB 0xfe00707f -+#define MATCH_VSSTW 0x400307b -+#define MASK_VSSTW 0xfe00707f -+#define MATCH_VSSTH 0x200307b -+#define MASK_VSSTH 0xfe00707f -+#define MATCH_SC_W 0x1800202f -+#define MASK_SC_W 0xf800707f -+#define MATCH_VSSTB 0x307b -+#define MASK_VSSTB 0xfe00707f -+#define MATCH_VSSTD 0x600307b -+#define MASK_VSSTD 0xfe00707f -+#define MATCH_ADDI 0x13 -+#define MASK_ADDI 0x707f -+#define MATCH_RDTIMEH 0xc8102073 -+#define MASK_RDTIMEH 0xfffff07f -+#define MATCH_MULH 0x2001033 -+#define MASK_MULH 0xfe00707f -+#define MATCH_CSRRSI 0x6073 -+#define MASK_CSRRSI 0x707f -+#define MATCH_FCVT_D_WU 0xd2100053 -+#define MASK_FCVT_D_WU 0xfff0007f -+#define MATCH_MULW 0x200003b -+#define MASK_MULW 0xfe00707f -+#define MATCH_CUSTOM1_RD_RS1_RS2 0x702b -+#define MASK_CUSTOM1_RD_RS1_RS2 0x707f -+#define MATCH_VENQIMM1 0xc00302b -+#define MASK_VENQIMM1 0xfe007fff -+#define MATCH_VENQIMM2 0xe00302b -+#define MASK_VENQIMM2 0xfe007fff -+#define MATCH_RDINSTRET 0xc0202073 -+#define MASK_RDINSTRET 0xfffff07f -+#define MATCH_C_SWSP 0x8 -+#define MASK_C_SWSP 0x1f -+#define MATCH_VLSTW 0x400305b -+#define MASK_VLSTW 0xfe00707f -+#define MATCH_VLSTH 0x200305b -+#define MASK_VLSTH 0xfe00707f -+#define MATCH_VLSTB 0x305b -+#define MASK_VLSTB 0xfe00707f -+#define MATCH_VLSTD 0x600305b -+#define MASK_VLSTD 0xfe00707f -+#define MATCH_ANDI 0x7013 -+#define MASK_ANDI 0x707f -+#define MATCH_FMV_X_S 0xe0000053 -+#define MASK_FMV_X_S 0xfff0707f -+#define MATCH_CUSTOM0_RD_RS1_RS2 0x700b -+#define MASK_CUSTOM0_RD_RS1_RS2 0x707f -+#define MATCH_FNMADD_S 0x4f -+#define MASK_FNMADD_S 0x600007f -+#define MATCH_LWU 0x6003 -+#define MASK_LWU 0x707f -+#define MATCH_CUSTOM0_RS1 0x200b -+#define MASK_CUSTOM0_RS1 0x707f -+#define MATCH_VLSEGSTBU 0x800305b -+#define MASK_VLSEGSTBU 0x1e00707f -+#define MATCH_FNMADD_D 0x200004f -+#define MASK_FNMADD_D 0x600007f -+#define MATCH_FCVT_W_S 0xc0000053 -+#define MASK_FCVT_W_S 0xfff0007f -+#define MATCH_C_SRAI 0x1019 -+#define MASK_C_SRAI 0x1c1f -+#define MATCH_MULHSU 0x2002033 -+#define MASK_MULHSU 0xfe00707f -+#define MATCH_FCVT_D_LU 0xd2300053 -+#define MASK_FCVT_D_LU 0xfff0007f -+#define MATCH_FCVT_W_D 0xc2000053 -+#define MASK_FCVT_W_D 0xfff0007f -+#define MATCH_FSUB_H 0xc000053 -+#define MASK_FSUB_H 0xfe00007f -+#define MATCH_DIVUW 0x200503b -+#define MASK_DIVUW 0xfe00707f -+#define MATCH_SLTI 0x2013 -+#define MASK_SLTI 0x707f -+#define MATCH_VLSTBU 0x800305b -+#define MASK_VLSTBU 0xfe00707f -+#define MATCH_SLTU 0x3033 -+#define MASK_SLTU 0xfe00707f -+#define MATCH_FLH 0x1007 -+#define MASK_FLH 0x707f -+#define MATCH_CUSTOM2_RD_RS1_RS2 0x705b -+#define MASK_CUSTOM2_RD_RS1_RS2 0x707f -+#define MATCH_FLD 0x3007 -+#define MASK_FLD 0x707f -+#define MATCH_FSUB_S 0x8000053 -+#define MASK_FSUB_S 0xfe00007f -+#define MATCH_FCVT_H_LU 0x6c000053 -+#define MASK_FCVT_H_LU 0xfff0007f -+#define MATCH_CUSTOM0 0xb -+#define MASK_CUSTOM0 0x707f -+#define MATCH_CUSTOM1 0x2b -+#define MASK_CUSTOM1 0x707f -+#define MATCH_CUSTOM2 0x5b -+#define MASK_CUSTOM2 0x707f -+#define MATCH_CUSTOM3 0x7b -+#define MASK_CUSTOM3 0x707f -+#define MATCH_VXCPTSAVE 0x302b -+#define MASK_VXCPTSAVE 0xfff07fff -+#define MATCH_VMSV 0x200202b -+#define MASK_VMSV 0xfff0707f -+#define MATCH_FCVT_LU_S 0xc0300053 -+#define MASK_FCVT_LU_S 0xfff0007f -+#define MATCH_AUIPC 0x17 -+#define MASK_AUIPC 0x7f -+#define MATCH_FRFLAGS 0x102073 -+#define MASK_FRFLAGS 0xfffff07f -+#define MATCH_FCVT_LU_D 0xc2300053 -+#define MASK_FCVT_LU_D 0xfff0007f -+#define MATCH_CSRRWI 0x5073 -+#define MASK_CSRRWI 0x707f -+#define MATCH_FADD_H 0x4000053 -+#define MASK_FADD_H 0xfe00007f -+#define MATCH_FSQRT_S 0x58000053 -+#define MASK_FSQRT_S 0xfff0007f -+#define MATCH_VXCPTKILL 0x400302b -+#define MASK_VXCPTKILL 0xffffffff -+#define MATCH_STOP 0x5077 -+#define MASK_STOP 0xffffffff -+#define MATCH_FSGNJN_S 0x20001053 -+#define MASK_FSGNJN_S 0xfe00707f -+#define MATCH_FSGNJN_H 0x34000053 -+#define MASK_FSGNJN_H 0xfe00707f -+#define MATCH_FSQRT_D 0x5a000053 -+#define MASK_FSQRT_D 0xfff0007f -+#define MATCH_XORI 0x4013 -+#define MASK_XORI 0x707f -+#define MATCH_DIVU 0x2005033 -+#define MASK_DIVU 0xfe00707f -+#define MATCH_FSGNJN_D 0x22001053 -+#define MASK_FSGNJN_D 0xfe00707f -+#define MATCH_FSQRT_H 0x24000053 -+#define MASK_FSQRT_H 0xfff0007f -+#define MATCH_VSSEGSTH 0x200307b -+#define MASK_VSSEGSTH 0x1e00707f -+#define MATCH_SW 0x2023 -+#define MASK_SW 0x707f -+#define MATCH_VLSTWU 0xc00305b -+#define MASK_VLSTWU 0xfe00707f -+#define MATCH_VFSSEGW 0x1400207b -+#define MASK_VFSSEGW 0x1ff0707f -+#define MATCH_LHU 0x5003 -+#define MASK_LHU 0x707f -+#define MATCH_SH 0x1023 -+#define MASK_SH 0x707f -+#define MATCH_FMSUB_H 0x4000047 -+#define MASK_FMSUB_H 0x600007f -+#define MATCH_VXCPTAUX 0x200402b -+#define MASK_VXCPTAUX 0xfffff07f -+#define MATCH_FMSUB_D 0x2000047 -+#define MASK_FMSUB_D 0x600007f -+#define MATCH_VFSSEGD 0x1600207b -+#define MASK_VFSSEGD 0x1ff0707f -+#define MATCH_VLSEGHU 0xa00205b -+#define MASK_VLSEGHU 0x1ff0707f -+#define MATCH_MOVN 0x2007077 -+#define MASK_MOVN 0xfe00707f -+#define MATCH_CUSTOM1_RS1 0x202b -+#define MASK_CUSTOM1_RS1 0x707f -+#define MATCH_VLSTHU 0xa00305b -+#define MASK_VLSTHU 0xfe00707f -+#define MATCH_MOVZ 0x7077 -+#define MASK_MOVZ 0xfe00707f -+#define MATCH_CSRRW 0x1073 -+#define MASK_CSRRW 0x707f -+#define MATCH_LD 0x3003 -+#define MASK_LD 0x707f -+#define MATCH_LB 0x3 -+#define MASK_LB 0x707f -+#define MATCH_VLWU 0xc00205b -+#define MASK_VLWU 0xfff0707f -+#define MATCH_LH 0x1003 -+#define MASK_LH 0x707f -+#define MATCH_LW 0x2003 -+#define MASK_LW 0x707f -+#define MATCH_CSRRC 0x3073 -+#define MASK_CSRRC 0x707f -+#define MATCH_FCVT_LU_H 0x4c000053 -+#define MASK_FCVT_LU_H 0xfff0007f -+#define MATCH_FCVT_S_D 0x40100053 -+#define MASK_FCVT_S_D 0xfff0007f -+#define MATCH_BGEU 0x7063 -+#define MASK_BGEU 0x707f -+#define MATCH_VFLSTD 0x1600305b -+#define MASK_VFLSTD 0xfe00707f -+#define MATCH_FCVT_S_L 0xd0200053 -+#define MASK_FCVT_S_L 0xfff0007f -+#define MATCH_FCVT_S_H 0x84000053 -+#define MASK_FCVT_S_H 0xfff0007f -+#define MATCH_FSCSR 0x301073 -+#define MASK_FSCSR 0xfff0707f -+#define MATCH_FCVT_S_W 0xd0000053 -+#define MASK_FCVT_S_W 0xfff0007f -+#define MATCH_VFLSTW 0x1400305b -+#define MASK_VFLSTW 0xfe00707f -+#define MATCH_VXCPTEVAC 0x600302b -+#define MASK_VXCPTEVAC 0xfff07fff -+#define MATCH_AMOMINU_D 0xc000302f -+#define MASK_AMOMINU_D 0xf800707f -+#define MATCH_FSFLAGS 0x101073 -+#define MASK_FSFLAGS 0xfff0707f -+#define MATCH_SRLI 0x5013 -+#define MASK_SRLI 0xfc00707f -+#define MATCH_C_SRLI 0x819 -+#define MASK_C_SRLI 0x1c1f -+#define MATCH_AMOMINU_W 0xc000202f -+#define MASK_AMOMINU_W 0xf800707f -+#define MATCH_SRLW 0x503b -+#define MASK_SRLW 0xfe00707f -+#define MATCH_VFLSEGW 0x1400205b -+#define MASK_VFLSEGW 0x1ff0707f -+#define MATCH_C_LD0 0x8012 -+#define MASK_C_LD0 0x801f -+#define MATCH_VLSEGBU 0x800205b -+#define MASK_VLSEGBU 0x1ff0707f -+#define MATCH_JALR 0x67 -+#define MASK_JALR 0x707f -+#define MATCH_BLT 0x4063 -+#define MASK_BLT 0x707f -+#define MATCH_CUSTOM2_RD_RS1 0x605b -+#define MASK_CUSTOM2_RD_RS1 0x707f -+#define MATCH_FCLASS_S 0xe0001053 -+#define MASK_FCLASS_S 0xfff0707f -+#define MATCH_SFENCE_VM 0x10100073 -+#define MASK_SFENCE_VM 0xfff07fff -+#define MATCH_REM 0x2006033 -+#define MASK_REM 0xfe00707f -+#define MATCH_FCLASS_D 0xe2001053 -+#define MASK_FCLASS_D 0xfff0707f -+#define MATCH_FMUL_S 0x10000053 -+#define MASK_FMUL_S 0xfe00007f -+#define MATCH_RDCYCLEH 0xc8002073 -+#define MASK_RDCYCLEH 0xfffff07f -+#define MATCH_VLSEGSTHU 0xa00305b -+#define MASK_VLSEGSTHU 0x1e00707f -+#define MATCH_FMUL_D 0x12000053 -+#define MASK_FMUL_D 0xfe00007f -+#define MATCH_ORI 0x6013 -+#define MASK_ORI 0x707f -+#define MATCH_FMUL_H 0x14000053 -+#define MASK_FMUL_H 0xfe00007f -+#define MATCH_VFLSEGD 0x1600205b -+#define MASK_VFLSEGD 0x1ff0707f -+#define MATCH_FEQ_S 0xa0002053 -+#define MASK_FEQ_S 0xfe00707f -+#define MATCH_FSGNJX_D 0x22002053 -+#define MASK_FSGNJX_D 0xfe00707f -+#define MATCH_SRAIW 0x4000501b -+#define MASK_SRAIW 0xfe00707f -+#define MATCH_FSGNJX_H 0x3c000053 -+#define MASK_FSGNJX_H 0xfe00707f -+#define MATCH_FSGNJX_S 0x20002053 -+#define MASK_FSGNJX_S 0xfe00707f -+#define MATCH_FEQ_D 0xa2002053 -+#define MASK_FEQ_D 0xfe00707f -+#define MATCH_CUSTOM1_RD_RS1 0x602b -+#define MASK_CUSTOM1_RD_RS1 0x707f -+#define MATCH_FEQ_H 0xac000053 -+#define MASK_FEQ_H 0xfe00707f -+#define MATCH_AMOMAXU_D 0xe000302f -+#define MASK_AMOMAXU_D 0xf800707f -+#define MATCH_DIVW 0x200403b -+#define MASK_DIVW 0xfe00707f -+#define MATCH_AMOMAXU_W 0xe000202f -+#define MASK_AMOMAXU_W 0xf800707f -+#define MATCH_SRAI_RV32 0x40005013 -+#define MASK_SRAI_RV32 0xfe00707f -+#define MATCH_C_SRLI32 0xc19 -+#define MASK_C_SRLI32 0x1c1f -+#define MATCH_VFSSTW 0x1400307b -+#define MASK_VFSSTW 0xfe00707f -+#define MATCH_CUSTOM0_RD 0x400b -+#define MASK_CUSTOM0_RD 0x707f -+#define MATCH_C_BEQ 0x10 -+#define MASK_C_BEQ 0x1f -+#define MATCH_VFSSTD 0x1600307b -+#define MASK_VFSSTD 0xfe00707f -+#define MATCH_CUSTOM3_RD_RS1 0x607b -+#define MASK_CUSTOM3_RD_RS1 0x707f -+#define MATCH_LR_D 0x1000302f -+#define MASK_LR_D 0xf9f0707f -+#define MATCH_LR_W 0x1000202f -+#define MASK_LR_W 0xf9f0707f -+#define MATCH_FCVT_H_WU 0x7c000053 -+#define MASK_FCVT_H_WU 0xfff0007f -+#define MATCH_VMVV 0x200002b -+#define MASK_VMVV 0xfff0707f -+#define MATCH_SLLW 0x103b -+#define MASK_SLLW 0xfe00707f -+#define MATCH_SLLI 0x1013 -+#define MASK_SLLI 0xfc00707f -+#define MATCH_BEQ 0x63 -+#define MASK_BEQ 0x707f -+#define MATCH_AND 0x7033 -+#define MASK_AND 0xfe00707f -+#define MATCH_LBU 0x4003 -+#define MASK_LBU 0x707f -+#define MATCH_FSGNJ_S 0x20000053 -+#define MASK_FSGNJ_S 0xfe00707f -+#define MATCH_FMSUB_S 0x47 -+#define MASK_FMSUB_S 0x600007f -+#define MATCH_C_SUB3 0x11c -+#define MASK_C_SUB3 0x31f -+#define MATCH_FSGNJ_H 0x2c000053 -+#define MASK_FSGNJ_H 0xfe00707f -+#define MATCH_VLB 0x205b -+#define MASK_VLB 0xfff0707f -+#define MATCH_C_ADDIW 0x1d -+#define MASK_C_ADDIW 0x1f -+#define MATCH_CUSTOM3_RS1_RS2 0x307b -+#define MASK_CUSTOM3_RS1_RS2 0x707f -+#define MATCH_FSGNJ_D 0x22000053 -+#define MASK_FSGNJ_D 0xfe00707f -+#define MATCH_VLSEGWU 0xc00205b -+#define MASK_VLSEGWU 0x1ff0707f -+#define MATCH_FCVT_S_WU 0xd0100053 -+#define MASK_FCVT_S_WU 0xfff0007f -+#define MATCH_CUSTOM3_RS1 0x207b -+#define MASK_CUSTOM3_RS1 0x707f -+#define MATCH_SC_D 0x1800302f -+#define MASK_SC_D 0xf800707f -+#define MATCH_VFSW 0x1400207b -+#define MASK_VFSW 0xfff0707f -+#define MATCH_AMOSWAP_D 0x800302f -+#define MASK_AMOSWAP_D 0xf800707f -+#define MATCH_SB 0x23 -+#define MASK_SB 0x707f -+#define MATCH_AMOSWAP_W 0x800202f -+#define MASK_AMOSWAP_W 0xf800707f -+#define MATCH_VFSD 0x1600207b -+#define MASK_VFSD 0xfff0707f -+#define MATCH_CUSTOM2_RS1 0x205b -+#define MASK_CUSTOM2_RS1 0x707f -+#define MATCH_SD 0x3023 -+#define MASK_SD 0x707f -+#define MATCH_FMV_S_X 0xf0000053 -+#define MASK_FMV_S_X 0xfff0707f -+#define MATCH_REMUW 0x200703b -+#define MASK_REMUW 0xfe00707f -+#define MATCH_JAL 0x6f -+#define MASK_JAL 0x7f -+#define MATCH_C_FSD 0x18 -+#define MASK_C_FSD 0x1f -+#define MATCH_RDCYCLE 0xc0002073 -+#define MASK_RDCYCLE 0xfffff07f -+#define MATCH_C_BNE 0x11 -+#define MASK_C_BNE 0x1f -+#define MATCH_C_ADD 0x1a -+#define MASK_C_ADD 0x801f -+#define MATCH_VXCPTCAUSE 0x402b -+#define MASK_VXCPTCAUSE 0xfffff07f -+#define MATCH_VGETCFG 0x400b -+#define MASK_VGETCFG 0xfffff07f -+#define MATCH_LUI 0x37 -+#define MASK_LUI 0x7f -+#define MATCH_VSETCFG 0x200b -+#define MASK_VSETCFG 0x7fff -+#define MATCH_C_SDSP 0x6 -+#define MASK_C_SDSP 0x1f -+#define MATCH_C_LDSP 0x4 -+#define MASK_C_LDSP 0x1f -+#define MATCH_FNMADD_H 0x400004f -+#define MASK_FNMADD_H 0x600007f -+#define MATCH_CUSTOM0_RS1_RS2 0x300b -+#define MASK_CUSTOM0_RS1_RS2 0x707f -+#define MATCH_SLLI_RV32 0x1013 -+#define MASK_SLLI_RV32 0xfe00707f -+#define MATCH_MUL 0x2000033 -+#define MASK_MUL 0xfe00707f -+#define MATCH_CSRRCI 0x7073 -+#define MASK_CSRRCI 0x707f -+#define MATCH_C_SRAI32 0x1419 -+#define MASK_C_SRAI32 0x1c1f -+#define MATCH_FLT_H 0xb4000053 -+#define MASK_FLT_H 0xfe00707f -+#define MATCH_SRAI 0x40005013 -+#define MASK_SRAI 0xfc00707f -+#define MATCH_AMOAND_D 0x6000302f -+#define MASK_AMOAND_D 0xf800707f -+#define MATCH_FLT_D 0xa2001053 -+#define MASK_FLT_D 0xfe00707f -+#define MATCH_SRAW 0x4000503b -+#define MASK_SRAW 0xfe00707f -+#define MATCH_CSRRS 0x2073 -+#define MASK_CSRRS 0x707f -+#define MATCH_FLT_S 0xa0001053 -+#define MASK_FLT_S 0xfe00707f -+#define MATCH_ADDIW 0x1b -+#define MASK_ADDIW 0x707f -+#define MATCH_AMOAND_W 0x6000202f -+#define MASK_AMOAND_W 0xf800707f -+#define MATCH_CUSTOM2_RD 0x405b -+#define MASK_CUSTOM2_RD 0x707f -+#define MATCH_MRTS 0x30500073 -+#define MASK_MRTS 0xffffffff -+#define MATCH_FCVT_WU_D 0xc2100053 -+#define MASK_FCVT_WU_D 0xfff0007f -+#define MATCH_AMOXOR_W 0x2000202f -+#define MASK_AMOXOR_W 0xf800707f -+#define MATCH_FCVT_D_L 0xd2200053 -+#define MASK_FCVT_D_L 0xfff0007f -+#define MATCH_FCVT_WU_H 0x5c000053 -+#define MASK_FCVT_WU_H 0xfff0007f -+#define MATCH_C_SLLI 0x19 -+#define MASK_C_SLLI 0x1c1f -+#define MATCH_AMOXOR_D 0x2000302f -+#define MASK_AMOXOR_D 0xf800707f -+#define MATCH_FCVT_WU_S 0xc0100053 -+#define MASK_FCVT_WU_S 0xfff0007f -+#define MATCH_CUSTOM3_RD 0x407b -+#define MASK_CUSTOM3_RD 0x707f -+#define MATCH_FMAX_H 0xcc000053 -+#define MASK_FMAX_H 0xfe00707f -+#define MATCH_VENQCNT 0x1000302b -+#define MASK_VENQCNT 0xfe007fff -+#define MATCH_VLBU 0x800205b -+#define MASK_VLBU 0xfff0707f -+#define MATCH_VLHU 0xa00205b -+#define MASK_VLHU 0xfff0707f -+#define MATCH_C_SW 0xd -+#define MASK_C_SW 0x1f -+#define MATCH_C_SD 0xc -+#define MASK_C_SD 0x1f -+#define MATCH_C_OR3 0x21c -+#define MASK_C_OR3 0x31f -+#define MATCH_C_AND3 0x31c -+#define MASK_C_AND3 0x31f -+#define MATCH_VFSSEGSTW 0x1400307b -+#define MASK_VFSSEGSTW 0x1e00707f -+#define MATCH_SLT 0x2033 -+#define MASK_SLT 0xfe00707f -+#define MATCH_AMOOR_D 0x4000302f -+#define MASK_AMOOR_D 0xf800707f -+#define MATCH_REMU 0x2007033 -+#define MASK_REMU 0xfe00707f -+#define MATCH_REMW 0x200603b -+#define MASK_REMW 0xfe00707f -+#define MATCH_SLL 0x1033 -+#define MASK_SLL 0xfe00707f -+#define MATCH_VFSSEGSTD 0x1600307b -+#define MASK_VFSSEGSTD 0x1e00707f -+#define MATCH_AMOOR_W 0x4000202f -+#define MASK_AMOOR_W 0xf800707f -+#define MATCH_CUSTOM2_RS1_RS2 0x305b -+#define MASK_CUSTOM2_RS1_RS2 0x707f -+#define MATCH_VF 0x10202b -+#define MASK_VF 0x1f0707f -+#define MATCH_VFMVV 0x1000002b -+#define MASK_VFMVV 0xfff0707f -+#define MATCH_VFLSEGSTW 0x1400305b -+#define MASK_VFLSEGSTW 0x1e00707f -+#define MATCH_VXCPTRESTORE 0x200302b -+#define MASK_VXCPTRESTORE 0xfff07fff -+#define MATCH_VXCPTHOLD 0x800302b -+#define MASK_VXCPTHOLD 0xfff07fff -+#define MATCH_SLTIU 0x3013 -+#define MASK_SLTIU 0x707f -+#define MATCH_VFLSEGSTD 0x1600305b -+#define MASK_VFLSEGSTD 0x1e00707f -+#define MATCH_VFLD 0x1600205b -+#define MASK_VFLD 0xfff0707f -+#define MATCH_FMADD_S 0x43 -+#define MASK_FMADD_S 0x600007f -+#define MATCH_VFLW 0x1400205b -+#define MASK_VFLW 0xfff0707f -+#define MATCH_FMADD_D 0x2000043 -+#define MASK_FMADD_D 0x600007f -+#define MATCH_FMADD_H 0x4000043 -+#define MASK_FMADD_H 0x600007f -+#define MATCH_SRET 0x10000073 -+#define MASK_SRET 0xffffffff -+#define MATCH_VSSEGW 0x400207b -+#define MASK_VSSEGW 0x1ff0707f -+#define MATCH_CUSTOM0_RD_RS1 0x600b -+#define MASK_CUSTOM0_RD_RS1 0x707f -+#define MATCH_VSSEGH 0x200207b -+#define MASK_VSSEGH 0x1ff0707f -+#define MATCH_FRCSR 0x302073 -+#define MASK_FRCSR 0xfffff07f -+#define MATCH_VSSEGD 0x600207b -+#define MASK_VSSEGD 0x1ff0707f -+#define MATCH_VSSEGB 0x207b -+#define MASK_VSSEGB 0x1ff0707f -+#define MATCH_FMIN_H 0xc4000053 -+#define MASK_FMIN_H 0xfe00707f -+#define MATCH_FMIN_D 0x2a000053 -+#define MASK_FMIN_D 0xfe00707f -+#define MATCH_BLTU 0x6063 -+#define MASK_BLTU 0x707f -+#define MATCH_FMIN_S 0x28000053 -+#define MASK_FMIN_S 0xfe00707f -+#define MATCH_SRLI_RV32 0x5013 -+#define MASK_SRLI_RV32 0xfe00707f -+#define MATCH_SLLIW 0x101b -+#define MASK_SLLIW 0xfe00707f -+#define MATCH_FMAX_S 0x28001053 -+#define MASK_FMAX_S 0xfe00707f -+#define MATCH_FCVT_D_H 0x8c000053 -+#define MASK_FCVT_D_H 0xfff0007f -+#define MATCH_FCVT_D_W 0xd2000053 -+#define MASK_FCVT_D_W 0xfff0007f -+#define MATCH_ADD 0x33 -+#define MASK_ADD 0xfe00707f -+#define MATCH_FCVT_D_S 0x42000053 -+#define MASK_FCVT_D_S 0xfff0007f -+#define MATCH_FMAX_D 0x2a001053 -+#define MASK_FMAX_D 0xfe00707f -+#define MATCH_BNE 0x1063 -+#define MASK_BNE 0x707f -+#define MATCH_CUSTOM1_RD 0x402b -+#define MASK_CUSTOM1_RD 0x707f -+#define MATCH_FSRM 0x201073 -+#define MASK_FSRM 0xfff0707f -+#define MATCH_FDIV_D 0x1a000053 -+#define MASK_FDIV_D 0xfe00007f -+#define MATCH_VSW 0x400207b -+#define MASK_VSW 0xfff0707f -+#define MATCH_FCVT_L_S 0xc0200053 -+#define MASK_FCVT_L_S 0xfff0007f -+#define MATCH_FDIV_H 0x1c000053 -+#define MASK_FDIV_H 0xfe00007f -+#define MATCH_VSB 0x207b -+#define MASK_VSB 0xfff0707f -+#define MATCH_FDIV_S 0x18000053 -+#define MASK_FDIV_S 0xfe00007f -+#define MATCH_FSRMI 0x205073 -+#define MASK_FSRMI 0xfff0707f -+#define MATCH_FCVT_L_H 0x44000053 -+#define MASK_FCVT_L_H 0xfff0007f -+#define MATCH_VSH 0x200207b -+#define MASK_VSH 0xfff0707f -+#define MATCH_FCVT_L_D 0xc2200053 -+#define MASK_FCVT_L_D 0xfff0007f -+#define MATCH_FCVT_H_S 0x90000053 -+#define MASK_FCVT_H_S 0xfff0007f -+#define MATCH_SCALL 0x73 -+#define MASK_SCALL 0xffffffff -+#define MATCH_FSFLAGSI 0x105073 -+#define MASK_FSFLAGSI 0xfff0707f -+#define MATCH_FCVT_H_W 0x74000053 -+#define MASK_FCVT_H_W 0xfff0007f -+#define MATCH_FCVT_H_L 0x64000053 -+#define MASK_FCVT_H_L 0xfff0007f -+#define MATCH_SRLIW 0x501b -+#define MASK_SRLIW 0xfe00707f -+#define MATCH_FCVT_S_LU 0xd0300053 -+#define MASK_FCVT_S_LU 0xfff0007f -+#define MATCH_FCVT_H_D 0x92000053 -+#define MASK_FCVT_H_D 0xfff0007f -+#define MATCH_SBREAK 0x100073 -+#define MASK_SBREAK 0xffffffff -+#define MATCH_RDINSTRETH 0xc8202073 -+#define MASK_RDINSTRETH 0xfffff07f -+#define MATCH_SRA 0x40005033 -+#define MASK_SRA 0xfe00707f -+#define MATCH_BGE 0x5063 -+#define MASK_BGE 0x707f -+#define MATCH_SRL 0x5033 -+#define MASK_SRL 0xfe00707f -+#define MATCH_VENQCMD 0xa00302b -+#define MASK_VENQCMD 0xfe007fff -+#define MATCH_OR 0x6033 -+#define MASK_OR 0xfe00707f -+#define MATCH_SUBW 0x4000003b -+#define MASK_SUBW 0xfe00707f -+#define MATCH_FMV_X_D 0xe2000053 -+#define MASK_FMV_X_D 0xfff0707f -+#define MATCH_RDTIME 0xc0102073 -+#define MASK_RDTIME 0xfffff07f -+#define MATCH_AMOADD_D 0x302f -+#define MASK_AMOADD_D 0xf800707f -+#define MATCH_AMOMAX_W 0xa000202f -+#define MASK_AMOMAX_W 0xf800707f -+#define MATCH_C_MOVE 0x2 -+#define MASK_C_MOVE 0x801f -+#define MATCH_FMOVN 0x6007077 -+#define MASK_FMOVN 0xfe00707f -+#define MATCH_C_FSW 0x16 -+#define MASK_C_FSW 0x1f -+#define MATCH_AMOADD_W 0x202f -+#define MASK_AMOADD_W 0xf800707f -+#define MATCH_AMOMAX_D 0xa000302f -+#define MASK_AMOMAX_D 0xf800707f -+#define MATCH_FMOVZ 0x4007077 -+#define MASK_FMOVZ 0xfe00707f -+#define MATCH_CUSTOM1_RS1_RS2 0x302b -+#define MASK_CUSTOM1_RS1_RS2 0x707f -+#define MATCH_FMV_X_H 0xe4000053 -+#define MASK_FMV_X_H 0xfff0707f -+#define MATCH_VSD 0x600207b -+#define MASK_VSD 0xfff0707f -+#define MATCH_VLSEGSTW 0x400305b -+#define MASK_VLSEGSTW 0x1e00707f -+#define MATCH_C_ADDI 0x1 -+#define MASK_C_ADDI 0x1f -+#define MATCH_C_SLLIW 0x1819 -+#define MASK_C_SLLIW 0x1c1f -+#define MATCH_VLSEGSTB 0x305b -+#define MASK_VLSEGSTB 0x1e00707f -+#define MATCH_VLSEGSTD 0x600305b -+#define MASK_VLSEGSTD 0x1e00707f -+#define MATCH_VLSEGSTH 0x200305b -+#define MASK_VLSEGSTH 0x1e00707f -+#define MATCH_MULHU 0x2003033 -+#define MASK_MULHU 0xfe00707f -+#define MATCH_AMOMIN_W 0x8000202f -+#define MASK_AMOMIN_W 0xf800707f -+#define MATCH_C_SLLI32 0x419 -+#define MASK_C_SLLI32 0x1c1f -+#define MATCH_C_ADD3 0x1c -+#define MASK_C_ADD3 0x31f -+#define MATCH_VGETVL 0x200400b -+#define MASK_VGETVL 0xfffff07f -+#define MATCH_AMOMIN_D 0x8000302f -+#define MASK_AMOMIN_D 0xf800707f -+#define MATCH_FCVT_W_H 0x54000053 -+#define MASK_FCVT_W_H 0xfff0007f -+#define MATCH_VLSEGB 0x205b -+#define MASK_VLSEGB 0x1ff0707f -+#define MATCH_FSD 0x3027 -+#define MASK_FSD 0x707f -+#define MATCH_VLSEGD 0x600205b -+#define MASK_VLSEGD 0x1ff0707f -+#define MATCH_FSH 0x1027 -+#define MASK_FSH 0x707f -+#define MATCH_VLSEGH 0x200205b -+#define MASK_VLSEGH 0x1ff0707f -+#define MATCH_C_SUB 0x801a -+#define MASK_C_SUB 0x801f -+#define MATCH_VLSEGW 0x400205b -+#define MASK_VLSEGW 0x1ff0707f -+#define MATCH_FSW 0x2027 -+#define MASK_FSW 0x707f -+#define MATCH_C_J 0x8002 -+#define MASK_C_J 0x801f -+#define CSR_FFLAGS 0x1 -+#define CSR_FRM 0x2 -+#define CSR_FCSR 0x3 -+#define CSR_CYCLE 0xc00 -+#define CSR_TIME 0xc01 -+#define CSR_INSTRET 0xc02 -+#define CSR_STATS 0xc0 -+#define CSR_UARCH0 0xcc0 -+#define CSR_UARCH1 0xcc1 -+#define CSR_UARCH2 0xcc2 -+#define CSR_UARCH3 0xcc3 -+#define CSR_UARCH4 0xcc4 -+#define CSR_UARCH5 0xcc5 -+#define CSR_UARCH6 0xcc6 -+#define CSR_UARCH7 0xcc7 -+#define CSR_UARCH8 0xcc8 -+#define CSR_UARCH9 0xcc9 -+#define CSR_UARCH10 0xcca -+#define CSR_UARCH11 0xccb -+#define CSR_UARCH12 0xccc -+#define CSR_UARCH13 0xccd -+#define CSR_UARCH14 0xcce -+#define CSR_UARCH15 0xccf -+#define CSR_SSTATUS 0x100 -+#define CSR_STVEC 0x101 -+#define CSR_STIMECMP 0x121 -+#define CSR_SSCRATCH 0x140 -+#define CSR_SEPC 0x141 -+#define CSR_SPTBR 0x188 -+#define CSR_SASID 0x189 -+#define CSR_SCYCLE 0x900 -+#define CSR_STIME 0x901 -+#define CSR_SINSTRET 0x902 -+#define CSR_SCAUSE 0xd40 -+#define CSR_SBADADDR 0xd41 -+#define CSR_MSTATUS 0x300 -+#define CSR_MSCRATCH 0x340 -+#define CSR_MEPC 0x341 -+#define CSR_MCAUSE 0x342 -+#define CSR_MBADADDR 0x343 -+#define CSR_RESET 0x780 -+#define CSR_TOHOST 0x781 -+#define CSR_FROMHOST 0x782 -+#define CSR_SEND_IPI 0x783 -+#define CSR_HARTID 0xfc0 -+#define CSR_CYCLEH 0xc80 -+#define CSR_TIMEH 0xc81 -+#define CSR_INSTRETH 0xc82 -+#define CSR_SCYCLEH 0x980 -+#define CSR_STIMEH 0x981 -+#define CSR_SINSTRETH 0x982 -+#define CAUSE_MISALIGNED_FETCH 0x0 -+#define CAUSE_FAULT_FETCH 0x1 -+#define CAUSE_ILLEGAL_INSTRUCTION 0x2 -+#define CAUSE_MISALIGNED_LOAD 0x4 -+#define CAUSE_FAULT_LOAD 0x5 -+#define CAUSE_MISALIGNED_STORE 0x6 -+#define CAUSE_FAULT_STORE 0x7 -+#define CAUSE_ECALL 0x8 -+#define CAUSE_BREAKPOINT 0x9 -+#endif -+#ifdef DECLARE_INSN -+DECLARE_INSN(custom3_rd_rs1_rs2, MATCH_CUSTOM3_RD_RS1_RS2, MASK_CUSTOM3_RD_RS1_RS2) -+DECLARE_INSN(vlsegstwu, MATCH_VLSEGSTWU, MASK_VLSEGSTWU) -+DECLARE_INSN(c_lw0, MATCH_C_LW0, MASK_C_LW0) -+DECLARE_INSN(fmv_d_x, MATCH_FMV_D_X, MASK_FMV_D_X) -+DECLARE_INSN(vlh, MATCH_VLH, MASK_VLH) -+DECLARE_INSN(c_li, MATCH_C_LI, MASK_C_LI) -+DECLARE_INSN(fadd_d, MATCH_FADD_D, MASK_FADD_D) -+DECLARE_INSN(c_ld, MATCH_C_LD, MASK_C_LD) -+DECLARE_INSN(vld, MATCH_VLD, MASK_VLD) -+DECLARE_INSN(fadd_s, MATCH_FADD_S, MASK_FADD_S) -+DECLARE_INSN(c_lw, MATCH_C_LW, MASK_C_LW) -+DECLARE_INSN(vlw, MATCH_VLW, MASK_VLW) -+DECLARE_INSN(vssegstw, MATCH_VSSEGSTW, MASK_VSSEGSTW) -+DECLARE_INSN(utidx, MATCH_UTIDX, MASK_UTIDX) -+DECLARE_INSN(c_flw, MATCH_C_FLW, MASK_C_FLW) -+DECLARE_INSN(fsub_d, MATCH_FSUB_D, MASK_FSUB_D) -+DECLARE_INSN(vssegstd, MATCH_VSSEGSTD, MASK_VSSEGSTD) -+DECLARE_INSN(vssegstb, MATCH_VSSEGSTB, MASK_VSSEGSTB) -+DECLARE_INSN(div, MATCH_DIV, MASK_DIV) -+DECLARE_INSN(fmv_h_x, MATCH_FMV_H_X, MASK_FMV_H_X) -+DECLARE_INSN(c_fld, MATCH_C_FLD, MASK_C_FLD) -+DECLARE_INSN(frrm, MATCH_FRRM, MASK_FRRM) -+DECLARE_INSN(vfmsv_s, MATCH_VFMSV_S, MASK_VFMSV_S) -+DECLARE_INSN(c_lwsp, MATCH_C_LWSP, MASK_C_LWSP) -+DECLARE_INSN(fence, MATCH_FENCE, MASK_FENCE) -+DECLARE_INSN(fnmsub_s, MATCH_FNMSUB_S, MASK_FNMSUB_S) -+DECLARE_INSN(fle_s, MATCH_FLE_S, MASK_FLE_S) -+DECLARE_INSN(fnmsub_h, MATCH_FNMSUB_H, MASK_FNMSUB_H) -+DECLARE_INSN(fle_h, MATCH_FLE_H, MASK_FLE_H) -+DECLARE_INSN(flw, MATCH_FLW, MASK_FLW) -+DECLARE_INSN(vsetvl, MATCH_VSETVL, MASK_VSETVL) -+DECLARE_INSN(vfmsv_d, MATCH_VFMSV_D, MASK_VFMSV_D) -+DECLARE_INSN(fle_d, MATCH_FLE_D, MASK_FLE_D) -+DECLARE_INSN(fence_i, MATCH_FENCE_I, MASK_FENCE_I) -+DECLARE_INSN(fnmsub_d, MATCH_FNMSUB_D, MASK_FNMSUB_D) -+DECLARE_INSN(addw, MATCH_ADDW, MASK_ADDW) -+DECLARE_INSN(xor, MATCH_XOR, MASK_XOR) -+DECLARE_INSN(sub, MATCH_SUB, MASK_SUB) -+DECLARE_INSN(vsstw, MATCH_VSSTW, MASK_VSSTW) -+DECLARE_INSN(vssth, MATCH_VSSTH, MASK_VSSTH) -+DECLARE_INSN(sc_w, MATCH_SC_W, MASK_SC_W) -+DECLARE_INSN(vsstb, MATCH_VSSTB, MASK_VSSTB) -+DECLARE_INSN(vsstd, MATCH_VSSTD, MASK_VSSTD) -+DECLARE_INSN(addi, MATCH_ADDI, MASK_ADDI) -+DECLARE_INSN(rdtimeh, MATCH_RDTIMEH, MASK_RDTIMEH) -+DECLARE_INSN(mulh, MATCH_MULH, MASK_MULH) -+DECLARE_INSN(csrrsi, MATCH_CSRRSI, MASK_CSRRSI) -+DECLARE_INSN(fcvt_d_wu, MATCH_FCVT_D_WU, MASK_FCVT_D_WU) -+DECLARE_INSN(mulw, MATCH_MULW, MASK_MULW) -+DECLARE_INSN(custom1_rd_rs1_rs2, MATCH_CUSTOM1_RD_RS1_RS2, MASK_CUSTOM1_RD_RS1_RS2) -+DECLARE_INSN(venqimm1, MATCH_VENQIMM1, MASK_VENQIMM1) -+DECLARE_INSN(venqimm2, MATCH_VENQIMM2, MASK_VENQIMM2) -+DECLARE_INSN(rdinstret, MATCH_RDINSTRET, MASK_RDINSTRET) -+DECLARE_INSN(c_swsp, MATCH_C_SWSP, MASK_C_SWSP) -+DECLARE_INSN(vlstw, MATCH_VLSTW, MASK_VLSTW) -+DECLARE_INSN(vlsth, MATCH_VLSTH, MASK_VLSTH) -+DECLARE_INSN(vlstb, MATCH_VLSTB, MASK_VLSTB) -+DECLARE_INSN(vlstd, MATCH_VLSTD, MASK_VLSTD) -+DECLARE_INSN(andi, MATCH_ANDI, MASK_ANDI) -+DECLARE_INSN(fmv_x_s, MATCH_FMV_X_S, MASK_FMV_X_S) -+DECLARE_INSN(custom0_rd_rs1_rs2, MATCH_CUSTOM0_RD_RS1_RS2, MASK_CUSTOM0_RD_RS1_RS2) -+DECLARE_INSN(fnmadd_s, MATCH_FNMADD_S, MASK_FNMADD_S) -+DECLARE_INSN(lwu, MATCH_LWU, MASK_LWU) -+DECLARE_INSN(custom0_rs1, MATCH_CUSTOM0_RS1, MASK_CUSTOM0_RS1) -+DECLARE_INSN(vlsegstbu, MATCH_VLSEGSTBU, MASK_VLSEGSTBU) -+DECLARE_INSN(fnmadd_d, MATCH_FNMADD_D, MASK_FNMADD_D) -+DECLARE_INSN(fcvt_w_s, MATCH_FCVT_W_S, MASK_FCVT_W_S) -+DECLARE_INSN(c_srai, MATCH_C_SRAI, MASK_C_SRAI) -+DECLARE_INSN(mulhsu, MATCH_MULHSU, MASK_MULHSU) -+DECLARE_INSN(fcvt_d_lu, MATCH_FCVT_D_LU, MASK_FCVT_D_LU) -+DECLARE_INSN(fcvt_w_d, MATCH_FCVT_W_D, MASK_FCVT_W_D) -+DECLARE_INSN(fsub_h, MATCH_FSUB_H, MASK_FSUB_H) -+DECLARE_INSN(divuw, MATCH_DIVUW, MASK_DIVUW) -+DECLARE_INSN(slti, MATCH_SLTI, MASK_SLTI) -+DECLARE_INSN(vlstbu, MATCH_VLSTBU, MASK_VLSTBU) -+DECLARE_INSN(sltu, MATCH_SLTU, MASK_SLTU) -+DECLARE_INSN(flh, MATCH_FLH, MASK_FLH) -+DECLARE_INSN(custom2_rd_rs1_rs2, MATCH_CUSTOM2_RD_RS1_RS2, MASK_CUSTOM2_RD_RS1_RS2) -+DECLARE_INSN(fld, MATCH_FLD, MASK_FLD) -+DECLARE_INSN(fsub_s, MATCH_FSUB_S, MASK_FSUB_S) -+DECLARE_INSN(fcvt_h_lu, MATCH_FCVT_H_LU, MASK_FCVT_H_LU) -+DECLARE_INSN(custom0, MATCH_CUSTOM0, MASK_CUSTOM0) -+DECLARE_INSN(custom1, MATCH_CUSTOM1, MASK_CUSTOM1) -+DECLARE_INSN(custom2, MATCH_CUSTOM2, MASK_CUSTOM2) -+DECLARE_INSN(custom3, MATCH_CUSTOM3, MASK_CUSTOM3) -+DECLARE_INSN(vxcptsave, MATCH_VXCPTSAVE, MASK_VXCPTSAVE) -+DECLARE_INSN(vmsv, MATCH_VMSV, MASK_VMSV) -+DECLARE_INSN(fcvt_lu_s, MATCH_FCVT_LU_S, MASK_FCVT_LU_S) -+DECLARE_INSN(auipc, MATCH_AUIPC, MASK_AUIPC) -+DECLARE_INSN(frflags, MATCH_FRFLAGS, MASK_FRFLAGS) -+DECLARE_INSN(fcvt_lu_d, MATCH_FCVT_LU_D, MASK_FCVT_LU_D) -+DECLARE_INSN(csrrwi, MATCH_CSRRWI, MASK_CSRRWI) -+DECLARE_INSN(fadd_h, MATCH_FADD_H, MASK_FADD_H) -+DECLARE_INSN(fsqrt_s, MATCH_FSQRT_S, MASK_FSQRT_S) -+DECLARE_INSN(vxcptkill, MATCH_VXCPTKILL, MASK_VXCPTKILL) -+DECLARE_INSN(stop, MATCH_STOP, MASK_STOP) -+DECLARE_INSN(fsgnjn_s, MATCH_FSGNJN_S, MASK_FSGNJN_S) -+DECLARE_INSN(fsgnjn_h, MATCH_FSGNJN_H, MASK_FSGNJN_H) -+DECLARE_INSN(fsqrt_d, MATCH_FSQRT_D, MASK_FSQRT_D) -+DECLARE_INSN(xori, MATCH_XORI, MASK_XORI) -+DECLARE_INSN(divu, MATCH_DIVU, MASK_DIVU) -+DECLARE_INSN(fsgnjn_d, MATCH_FSGNJN_D, MASK_FSGNJN_D) -+DECLARE_INSN(fsqrt_h, MATCH_FSQRT_H, MASK_FSQRT_H) -+DECLARE_INSN(vssegsth, MATCH_VSSEGSTH, MASK_VSSEGSTH) -+DECLARE_INSN(sw, MATCH_SW, MASK_SW) -+DECLARE_INSN(vlstwu, MATCH_VLSTWU, MASK_VLSTWU) -+DECLARE_INSN(vfssegw, MATCH_VFSSEGW, MASK_VFSSEGW) -+DECLARE_INSN(lhu, MATCH_LHU, MASK_LHU) -+DECLARE_INSN(sh, MATCH_SH, MASK_SH) -+DECLARE_INSN(fmsub_h, MATCH_FMSUB_H, MASK_FMSUB_H) -+DECLARE_INSN(vxcptaux, MATCH_VXCPTAUX, MASK_VXCPTAUX) -+DECLARE_INSN(fmsub_d, MATCH_FMSUB_D, MASK_FMSUB_D) -+DECLARE_INSN(vfssegd, MATCH_VFSSEGD, MASK_VFSSEGD) -+DECLARE_INSN(vlseghu, MATCH_VLSEGHU, MASK_VLSEGHU) -+DECLARE_INSN(movn, MATCH_MOVN, MASK_MOVN) -+DECLARE_INSN(custom1_rs1, MATCH_CUSTOM1_RS1, MASK_CUSTOM1_RS1) -+DECLARE_INSN(vlsthu, MATCH_VLSTHU, MASK_VLSTHU) -+DECLARE_INSN(movz, MATCH_MOVZ, MASK_MOVZ) -+DECLARE_INSN(csrrw, MATCH_CSRRW, MASK_CSRRW) -+DECLARE_INSN(ld, MATCH_LD, MASK_LD) -+DECLARE_INSN(lb, MATCH_LB, MASK_LB) -+DECLARE_INSN(vlwu, MATCH_VLWU, MASK_VLWU) -+DECLARE_INSN(lh, MATCH_LH, MASK_LH) -+DECLARE_INSN(lw, MATCH_LW, MASK_LW) -+DECLARE_INSN(csrrc, MATCH_CSRRC, MASK_CSRRC) -+DECLARE_INSN(fcvt_lu_h, MATCH_FCVT_LU_H, MASK_FCVT_LU_H) -+DECLARE_INSN(fcvt_s_d, MATCH_FCVT_S_D, MASK_FCVT_S_D) -+DECLARE_INSN(bgeu, MATCH_BGEU, MASK_BGEU) -+DECLARE_INSN(vflstd, MATCH_VFLSTD, MASK_VFLSTD) -+DECLARE_INSN(fcvt_s_l, MATCH_FCVT_S_L, MASK_FCVT_S_L) -+DECLARE_INSN(fcvt_s_h, MATCH_FCVT_S_H, MASK_FCVT_S_H) -+DECLARE_INSN(fscsr, MATCH_FSCSR, MASK_FSCSR) -+DECLARE_INSN(fcvt_s_w, MATCH_FCVT_S_W, MASK_FCVT_S_W) -+DECLARE_INSN(vflstw, MATCH_VFLSTW, MASK_VFLSTW) -+DECLARE_INSN(vxcptevac, MATCH_VXCPTEVAC, MASK_VXCPTEVAC) -+DECLARE_INSN(amominu_d, MATCH_AMOMINU_D, MASK_AMOMINU_D) -+DECLARE_INSN(fsflags, MATCH_FSFLAGS, MASK_FSFLAGS) -+DECLARE_INSN(srli, MATCH_SRLI, MASK_SRLI) -+DECLARE_INSN(c_srli, MATCH_C_SRLI, MASK_C_SRLI) -+DECLARE_INSN(amominu_w, MATCH_AMOMINU_W, MASK_AMOMINU_W) -+DECLARE_INSN(srlw, MATCH_SRLW, MASK_SRLW) -+DECLARE_INSN(vflsegw, MATCH_VFLSEGW, MASK_VFLSEGW) -+DECLARE_INSN(c_ld0, MATCH_C_LD0, MASK_C_LD0) -+DECLARE_INSN(vlsegbu, MATCH_VLSEGBU, MASK_VLSEGBU) -+DECLARE_INSN(jalr, MATCH_JALR, MASK_JALR) -+DECLARE_INSN(blt, MATCH_BLT, MASK_BLT) -+DECLARE_INSN(custom2_rd_rs1, MATCH_CUSTOM2_RD_RS1, MASK_CUSTOM2_RD_RS1) -+DECLARE_INSN(fclass_s, MATCH_FCLASS_S, MASK_FCLASS_S) -+DECLARE_INSN(sfence_vm, MATCH_SFENCE_VM, MASK_SFENCE_VM) -+DECLARE_INSN(rem, MATCH_REM, MASK_REM) -+DECLARE_INSN(fclass_d, MATCH_FCLASS_D, MASK_FCLASS_D) -+DECLARE_INSN(fmul_s, MATCH_FMUL_S, MASK_FMUL_S) -+DECLARE_INSN(rdcycleh, MATCH_RDCYCLEH, MASK_RDCYCLEH) -+DECLARE_INSN(vlsegsthu, MATCH_VLSEGSTHU, MASK_VLSEGSTHU) -+DECLARE_INSN(fmul_d, MATCH_FMUL_D, MASK_FMUL_D) -+DECLARE_INSN(ori, MATCH_ORI, MASK_ORI) -+DECLARE_INSN(fmul_h, MATCH_FMUL_H, MASK_FMUL_H) -+DECLARE_INSN(vflsegd, MATCH_VFLSEGD, MASK_VFLSEGD) -+DECLARE_INSN(feq_s, MATCH_FEQ_S, MASK_FEQ_S) -+DECLARE_INSN(fsgnjx_d, MATCH_FSGNJX_D, MASK_FSGNJX_D) -+DECLARE_INSN(sraiw, MATCH_SRAIW, MASK_SRAIW) -+DECLARE_INSN(fsgnjx_h, MATCH_FSGNJX_H, MASK_FSGNJX_H) -+DECLARE_INSN(fsgnjx_s, MATCH_FSGNJX_S, MASK_FSGNJX_S) -+DECLARE_INSN(feq_d, MATCH_FEQ_D, MASK_FEQ_D) -+DECLARE_INSN(custom1_rd_rs1, MATCH_CUSTOM1_RD_RS1, MASK_CUSTOM1_RD_RS1) -+DECLARE_INSN(feq_h, MATCH_FEQ_H, MASK_FEQ_H) -+DECLARE_INSN(amomaxu_d, MATCH_AMOMAXU_D, MASK_AMOMAXU_D) -+DECLARE_INSN(divw, MATCH_DIVW, MASK_DIVW) -+DECLARE_INSN(amomaxu_w, MATCH_AMOMAXU_W, MASK_AMOMAXU_W) -+DECLARE_INSN(srai_rv32, MATCH_SRAI_RV32, MASK_SRAI_RV32) -+DECLARE_INSN(c_srli32, MATCH_C_SRLI32, MASK_C_SRLI32) -+DECLARE_INSN(vfsstw, MATCH_VFSSTW, MASK_VFSSTW) -+DECLARE_INSN(custom0_rd, MATCH_CUSTOM0_RD, MASK_CUSTOM0_RD) -+DECLARE_INSN(c_beq, MATCH_C_BEQ, MASK_C_BEQ) -+DECLARE_INSN(vfsstd, MATCH_VFSSTD, MASK_VFSSTD) -+DECLARE_INSN(custom3_rd_rs1, MATCH_CUSTOM3_RD_RS1, MASK_CUSTOM3_RD_RS1) -+DECLARE_INSN(lr_d, MATCH_LR_D, MASK_LR_D) -+DECLARE_INSN(lr_w, MATCH_LR_W, MASK_LR_W) -+DECLARE_INSN(fcvt_h_wu, MATCH_FCVT_H_WU, MASK_FCVT_H_WU) -+DECLARE_INSN(vmvv, MATCH_VMVV, MASK_VMVV) -+DECLARE_INSN(sllw, MATCH_SLLW, MASK_SLLW) -+DECLARE_INSN(slli, MATCH_SLLI, MASK_SLLI) -+DECLARE_INSN(beq, MATCH_BEQ, MASK_BEQ) -+DECLARE_INSN(and, MATCH_AND, MASK_AND) -+DECLARE_INSN(lbu, MATCH_LBU, MASK_LBU) -+DECLARE_INSN(fsgnj_s, MATCH_FSGNJ_S, MASK_FSGNJ_S) -+DECLARE_INSN(fmsub_s, MATCH_FMSUB_S, MASK_FMSUB_S) -+DECLARE_INSN(c_sub3, MATCH_C_SUB3, MASK_C_SUB3) -+DECLARE_INSN(fsgnj_h, MATCH_FSGNJ_H, MASK_FSGNJ_H) -+DECLARE_INSN(vlb, MATCH_VLB, MASK_VLB) -+DECLARE_INSN(c_addiw, MATCH_C_ADDIW, MASK_C_ADDIW) -+DECLARE_INSN(custom3_rs1_rs2, MATCH_CUSTOM3_RS1_RS2, MASK_CUSTOM3_RS1_RS2) -+DECLARE_INSN(fsgnj_d, MATCH_FSGNJ_D, MASK_FSGNJ_D) -+DECLARE_INSN(vlsegwu, MATCH_VLSEGWU, MASK_VLSEGWU) -+DECLARE_INSN(fcvt_s_wu, MATCH_FCVT_S_WU, MASK_FCVT_S_WU) -+DECLARE_INSN(custom3_rs1, MATCH_CUSTOM3_RS1, MASK_CUSTOM3_RS1) -+DECLARE_INSN(sc_d, MATCH_SC_D, MASK_SC_D) -+DECLARE_INSN(vfsw, MATCH_VFSW, MASK_VFSW) -+DECLARE_INSN(amoswap_d, MATCH_AMOSWAP_D, MASK_AMOSWAP_D) -+DECLARE_INSN(sb, MATCH_SB, MASK_SB) -+DECLARE_INSN(amoswap_w, MATCH_AMOSWAP_W, MASK_AMOSWAP_W) -+DECLARE_INSN(vfsd, MATCH_VFSD, MASK_VFSD) -+DECLARE_INSN(custom2_rs1, MATCH_CUSTOM2_RS1, MASK_CUSTOM2_RS1) -+DECLARE_INSN(sd, MATCH_SD, MASK_SD) -+DECLARE_INSN(fmv_s_x, MATCH_FMV_S_X, MASK_FMV_S_X) -+DECLARE_INSN(remuw, MATCH_REMUW, MASK_REMUW) -+DECLARE_INSN(jal, MATCH_JAL, MASK_JAL) -+DECLARE_INSN(c_fsd, MATCH_C_FSD, MASK_C_FSD) -+DECLARE_INSN(rdcycle, MATCH_RDCYCLE, MASK_RDCYCLE) -+DECLARE_INSN(c_bne, MATCH_C_BNE, MASK_C_BNE) -+DECLARE_INSN(c_add, MATCH_C_ADD, MASK_C_ADD) -+DECLARE_INSN(vxcptcause, MATCH_VXCPTCAUSE, MASK_VXCPTCAUSE) -+DECLARE_INSN(vgetcfg, MATCH_VGETCFG, MASK_VGETCFG) -+DECLARE_INSN(lui, MATCH_LUI, MASK_LUI) -+DECLARE_INSN(vsetcfg, MATCH_VSETCFG, MASK_VSETCFG) -+DECLARE_INSN(c_sdsp, MATCH_C_SDSP, MASK_C_SDSP) -+DECLARE_INSN(c_ldsp, MATCH_C_LDSP, MASK_C_LDSP) -+DECLARE_INSN(fnmadd_h, MATCH_FNMADD_H, MASK_FNMADD_H) -+DECLARE_INSN(custom0_rs1_rs2, MATCH_CUSTOM0_RS1_RS2, MASK_CUSTOM0_RS1_RS2) -+DECLARE_INSN(slli_rv32, MATCH_SLLI_RV32, MASK_SLLI_RV32) -+DECLARE_INSN(mul, MATCH_MUL, MASK_MUL) -+DECLARE_INSN(csrrci, MATCH_CSRRCI, MASK_CSRRCI) -+DECLARE_INSN(c_srai32, MATCH_C_SRAI32, MASK_C_SRAI32) -+DECLARE_INSN(flt_h, MATCH_FLT_H, MASK_FLT_H) -+DECLARE_INSN(srai, MATCH_SRAI, MASK_SRAI) -+DECLARE_INSN(amoand_d, MATCH_AMOAND_D, MASK_AMOAND_D) -+DECLARE_INSN(flt_d, MATCH_FLT_D, MASK_FLT_D) -+DECLARE_INSN(sraw, MATCH_SRAW, MASK_SRAW) -+DECLARE_INSN(csrrs, MATCH_CSRRS, MASK_CSRRS) -+DECLARE_INSN(flt_s, MATCH_FLT_S, MASK_FLT_S) -+DECLARE_INSN(addiw, MATCH_ADDIW, MASK_ADDIW) -+DECLARE_INSN(amoand_w, MATCH_AMOAND_W, MASK_AMOAND_W) -+DECLARE_INSN(custom2_rd, MATCH_CUSTOM2_RD, MASK_CUSTOM2_RD) -+DECLARE_INSN(mrts, MATCH_MRTS, MASK_MRTS) -+DECLARE_INSN(fcvt_wu_d, MATCH_FCVT_WU_D, MASK_FCVT_WU_D) -+DECLARE_INSN(amoxor_w, MATCH_AMOXOR_W, MASK_AMOXOR_W) -+DECLARE_INSN(fcvt_d_l, MATCH_FCVT_D_L, MASK_FCVT_D_L) -+DECLARE_INSN(fcvt_wu_h, MATCH_FCVT_WU_H, MASK_FCVT_WU_H) -+DECLARE_INSN(c_slli, MATCH_C_SLLI, MASK_C_SLLI) -+DECLARE_INSN(amoxor_d, MATCH_AMOXOR_D, MASK_AMOXOR_D) -+DECLARE_INSN(fcvt_wu_s, MATCH_FCVT_WU_S, MASK_FCVT_WU_S) -+DECLARE_INSN(custom3_rd, MATCH_CUSTOM3_RD, MASK_CUSTOM3_RD) -+DECLARE_INSN(fmax_h, MATCH_FMAX_H, MASK_FMAX_H) -+DECLARE_INSN(venqcnt, MATCH_VENQCNT, MASK_VENQCNT) -+DECLARE_INSN(vlbu, MATCH_VLBU, MASK_VLBU) -+DECLARE_INSN(vlhu, MATCH_VLHU, MASK_VLHU) -+DECLARE_INSN(c_sw, MATCH_C_SW, MASK_C_SW) -+DECLARE_INSN(c_sd, MATCH_C_SD, MASK_C_SD) -+DECLARE_INSN(c_or3, MATCH_C_OR3, MASK_C_OR3) -+DECLARE_INSN(c_and3, MATCH_C_AND3, MASK_C_AND3) -+DECLARE_INSN(vfssegstw, MATCH_VFSSEGSTW, MASK_VFSSEGSTW) -+DECLARE_INSN(slt, MATCH_SLT, MASK_SLT) -+DECLARE_INSN(amoor_d, MATCH_AMOOR_D, MASK_AMOOR_D) -+DECLARE_INSN(remu, MATCH_REMU, MASK_REMU) -+DECLARE_INSN(remw, MATCH_REMW, MASK_REMW) -+DECLARE_INSN(sll, MATCH_SLL, MASK_SLL) -+DECLARE_INSN(vfssegstd, MATCH_VFSSEGSTD, MASK_VFSSEGSTD) -+DECLARE_INSN(amoor_w, MATCH_AMOOR_W, MASK_AMOOR_W) -+DECLARE_INSN(custom2_rs1_rs2, MATCH_CUSTOM2_RS1_RS2, MASK_CUSTOM2_RS1_RS2) -+DECLARE_INSN(vf, MATCH_VF, MASK_VF) -+DECLARE_INSN(vfmvv, MATCH_VFMVV, MASK_VFMVV) -+DECLARE_INSN(vflsegstw, MATCH_VFLSEGSTW, MASK_VFLSEGSTW) -+DECLARE_INSN(vxcptrestore, MATCH_VXCPTRESTORE, MASK_VXCPTRESTORE) -+DECLARE_INSN(vxcpthold, MATCH_VXCPTHOLD, MASK_VXCPTHOLD) -+DECLARE_INSN(sltiu, MATCH_SLTIU, MASK_SLTIU) -+DECLARE_INSN(vflsegstd, MATCH_VFLSEGSTD, MASK_VFLSEGSTD) -+DECLARE_INSN(vfld, MATCH_VFLD, MASK_VFLD) -+DECLARE_INSN(fmadd_s, MATCH_FMADD_S, MASK_FMADD_S) -+DECLARE_INSN(vflw, MATCH_VFLW, MASK_VFLW) -+DECLARE_INSN(fmadd_d, MATCH_FMADD_D, MASK_FMADD_D) -+DECLARE_INSN(fmadd_h, MATCH_FMADD_H, MASK_FMADD_H) -+DECLARE_INSN(sret, MATCH_SRET, MASK_SRET) -+DECLARE_INSN(vssegw, MATCH_VSSEGW, MASK_VSSEGW) -+DECLARE_INSN(custom0_rd_rs1, MATCH_CUSTOM0_RD_RS1, MASK_CUSTOM0_RD_RS1) -+DECLARE_INSN(vssegh, MATCH_VSSEGH, MASK_VSSEGH) -+DECLARE_INSN(frcsr, MATCH_FRCSR, MASK_FRCSR) -+DECLARE_INSN(vssegd, MATCH_VSSEGD, MASK_VSSEGD) -+DECLARE_INSN(vssegb, MATCH_VSSEGB, MASK_VSSEGB) -+DECLARE_INSN(fmin_h, MATCH_FMIN_H, MASK_FMIN_H) -+DECLARE_INSN(fmin_d, MATCH_FMIN_D, MASK_FMIN_D) -+DECLARE_INSN(bltu, MATCH_BLTU, MASK_BLTU) -+DECLARE_INSN(fmin_s, MATCH_FMIN_S, MASK_FMIN_S) -+DECLARE_INSN(srli_rv32, MATCH_SRLI_RV32, MASK_SRLI_RV32) -+DECLARE_INSN(slliw, MATCH_SLLIW, MASK_SLLIW) -+DECLARE_INSN(fmax_s, MATCH_FMAX_S, MASK_FMAX_S) -+DECLARE_INSN(fcvt_d_h, MATCH_FCVT_D_H, MASK_FCVT_D_H) -+DECLARE_INSN(fcvt_d_w, MATCH_FCVT_D_W, MASK_FCVT_D_W) -+DECLARE_INSN(add, MATCH_ADD, MASK_ADD) -+DECLARE_INSN(fcvt_d_s, MATCH_FCVT_D_S, MASK_FCVT_D_S) -+DECLARE_INSN(fmax_d, MATCH_FMAX_D, MASK_FMAX_D) -+DECLARE_INSN(bne, MATCH_BNE, MASK_BNE) -+DECLARE_INSN(custom1_rd, MATCH_CUSTOM1_RD, MASK_CUSTOM1_RD) -+DECLARE_INSN(fsrm, MATCH_FSRM, MASK_FSRM) -+DECLARE_INSN(fdiv_d, MATCH_FDIV_D, MASK_FDIV_D) -+DECLARE_INSN(vsw, MATCH_VSW, MASK_VSW) -+DECLARE_INSN(fcvt_l_s, MATCH_FCVT_L_S, MASK_FCVT_L_S) -+DECLARE_INSN(fdiv_h, MATCH_FDIV_H, MASK_FDIV_H) -+DECLARE_INSN(vsb, MATCH_VSB, MASK_VSB) -+DECLARE_INSN(fdiv_s, MATCH_FDIV_S, MASK_FDIV_S) -+DECLARE_INSN(fsrmi, MATCH_FSRMI, MASK_FSRMI) -+DECLARE_INSN(fcvt_l_h, MATCH_FCVT_L_H, MASK_FCVT_L_H) -+DECLARE_INSN(vsh, MATCH_VSH, MASK_VSH) -+DECLARE_INSN(fcvt_l_d, MATCH_FCVT_L_D, MASK_FCVT_L_D) -+DECLARE_INSN(fcvt_h_s, MATCH_FCVT_H_S, MASK_FCVT_H_S) -+DECLARE_INSN(scall, MATCH_SCALL, MASK_SCALL) -+DECLARE_INSN(fsflagsi, MATCH_FSFLAGSI, MASK_FSFLAGSI) -+DECLARE_INSN(fcvt_h_w, MATCH_FCVT_H_W, MASK_FCVT_H_W) -+DECLARE_INSN(fcvt_h_l, MATCH_FCVT_H_L, MASK_FCVT_H_L) -+DECLARE_INSN(srliw, MATCH_SRLIW, MASK_SRLIW) -+DECLARE_INSN(fcvt_s_lu, MATCH_FCVT_S_LU, MASK_FCVT_S_LU) -+DECLARE_INSN(fcvt_h_d, MATCH_FCVT_H_D, MASK_FCVT_H_D) -+DECLARE_INSN(sbreak, MATCH_SBREAK, MASK_SBREAK) -+DECLARE_INSN(rdinstreth, MATCH_RDINSTRETH, MASK_RDINSTRETH) -+DECLARE_INSN(sra, MATCH_SRA, MASK_SRA) -+DECLARE_INSN(bge, MATCH_BGE, MASK_BGE) -+DECLARE_INSN(srl, MATCH_SRL, MASK_SRL) -+DECLARE_INSN(venqcmd, MATCH_VENQCMD, MASK_VENQCMD) -+DECLARE_INSN(or, MATCH_OR, MASK_OR) -+DECLARE_INSN(subw, MATCH_SUBW, MASK_SUBW) -+DECLARE_INSN(fmv_x_d, MATCH_FMV_X_D, MASK_FMV_X_D) -+DECLARE_INSN(rdtime, MATCH_RDTIME, MASK_RDTIME) -+DECLARE_INSN(amoadd_d, MATCH_AMOADD_D, MASK_AMOADD_D) -+DECLARE_INSN(amomax_w, MATCH_AMOMAX_W, MASK_AMOMAX_W) -+DECLARE_INSN(c_move, MATCH_C_MOVE, MASK_C_MOVE) -+DECLARE_INSN(fmovn, MATCH_FMOVN, MASK_FMOVN) -+DECLARE_INSN(c_fsw, MATCH_C_FSW, MASK_C_FSW) -+DECLARE_INSN(amoadd_w, MATCH_AMOADD_W, MASK_AMOADD_W) -+DECLARE_INSN(amomax_d, MATCH_AMOMAX_D, MASK_AMOMAX_D) -+DECLARE_INSN(fmovz, MATCH_FMOVZ, MASK_FMOVZ) -+DECLARE_INSN(custom1_rs1_rs2, MATCH_CUSTOM1_RS1_RS2, MASK_CUSTOM1_RS1_RS2) -+DECLARE_INSN(fmv_x_h, MATCH_FMV_X_H, MASK_FMV_X_H) -+DECLARE_INSN(vsd, MATCH_VSD, MASK_VSD) -+DECLARE_INSN(vlsegstw, MATCH_VLSEGSTW, MASK_VLSEGSTW) -+DECLARE_INSN(c_addi, MATCH_C_ADDI, MASK_C_ADDI) -+DECLARE_INSN(c_slliw, MATCH_C_SLLIW, MASK_C_SLLIW) -+DECLARE_INSN(vlsegstb, MATCH_VLSEGSTB, MASK_VLSEGSTB) -+DECLARE_INSN(vlsegstd, MATCH_VLSEGSTD, MASK_VLSEGSTD) -+DECLARE_INSN(vlsegsth, MATCH_VLSEGSTH, MASK_VLSEGSTH) -+DECLARE_INSN(mulhu, MATCH_MULHU, MASK_MULHU) -+DECLARE_INSN(amomin_w, MATCH_AMOMIN_W, MASK_AMOMIN_W) -+DECLARE_INSN(c_slli32, MATCH_C_SLLI32, MASK_C_SLLI32) -+DECLARE_INSN(c_add3, MATCH_C_ADD3, MASK_C_ADD3) -+DECLARE_INSN(vgetvl, MATCH_VGETVL, MASK_VGETVL) -+DECLARE_INSN(amomin_d, MATCH_AMOMIN_D, MASK_AMOMIN_D) -+DECLARE_INSN(fcvt_w_h, MATCH_FCVT_W_H, MASK_FCVT_W_H) -+DECLARE_INSN(vlsegb, MATCH_VLSEGB, MASK_VLSEGB) -+DECLARE_INSN(fsd, MATCH_FSD, MASK_FSD) -+DECLARE_INSN(vlsegd, MATCH_VLSEGD, MASK_VLSEGD) -+DECLARE_INSN(fsh, MATCH_FSH, MASK_FSH) -+DECLARE_INSN(vlsegh, MATCH_VLSEGH, MASK_VLSEGH) -+DECLARE_INSN(c_sub, MATCH_C_SUB, MASK_C_SUB) -+DECLARE_INSN(vlsegw, MATCH_VLSEGW, MASK_VLSEGW) -+DECLARE_INSN(fsw, MATCH_FSW, MASK_FSW) -+DECLARE_INSN(c_j, MATCH_C_J, MASK_C_J) -+#endif -+#ifdef DECLARE_CSR -+DECLARE_CSR(fflags, CSR_FFLAGS) -+DECLARE_CSR(frm, CSR_FRM) -+DECLARE_CSR(fcsr, CSR_FCSR) -+DECLARE_CSR(cycle, CSR_CYCLE) -+DECLARE_CSR(time, CSR_TIME) -+DECLARE_CSR(instret, CSR_INSTRET) -+DECLARE_CSR(stats, CSR_STATS) -+DECLARE_CSR(uarch0, CSR_UARCH0) -+DECLARE_CSR(uarch1, CSR_UARCH1) -+DECLARE_CSR(uarch2, CSR_UARCH2) -+DECLARE_CSR(uarch3, CSR_UARCH3) -+DECLARE_CSR(uarch4, CSR_UARCH4) -+DECLARE_CSR(uarch5, CSR_UARCH5) -+DECLARE_CSR(uarch6, CSR_UARCH6) -+DECLARE_CSR(uarch7, CSR_UARCH7) -+DECLARE_CSR(uarch8, CSR_UARCH8) -+DECLARE_CSR(uarch9, CSR_UARCH9) -+DECLARE_CSR(uarch10, CSR_UARCH10) -+DECLARE_CSR(uarch11, CSR_UARCH11) -+DECLARE_CSR(uarch12, CSR_UARCH12) -+DECLARE_CSR(uarch13, CSR_UARCH13) -+DECLARE_CSR(uarch14, CSR_UARCH14) -+DECLARE_CSR(uarch15, CSR_UARCH15) -+DECLARE_CSR(sstatus, CSR_SSTATUS) -+DECLARE_CSR(stvec, CSR_STVEC) -+DECLARE_CSR(stimecmp, CSR_STIMECMP) -+DECLARE_CSR(sscratch, CSR_SSCRATCH) -+DECLARE_CSR(sepc, CSR_SEPC) -+DECLARE_CSR(sptbr, CSR_SPTBR) -+DECLARE_CSR(sasid, CSR_SASID) -+DECLARE_CSR(scycle, CSR_SCYCLE) -+DECLARE_CSR(stime, CSR_STIME) -+DECLARE_CSR(sinstret, CSR_SINSTRET) -+DECLARE_CSR(scause, CSR_SCAUSE) -+DECLARE_CSR(sbadaddr, CSR_SBADADDR) -+DECLARE_CSR(mstatus, CSR_MSTATUS) -+DECLARE_CSR(mscratch, CSR_MSCRATCH) -+DECLARE_CSR(mepc, CSR_MEPC) -+DECLARE_CSR(mcause, CSR_MCAUSE) -+DECLARE_CSR(mbadaddr, CSR_MBADADDR) -+DECLARE_CSR(reset, CSR_RESET) -+DECLARE_CSR(tohost, CSR_TOHOST) -+DECLARE_CSR(fromhost, CSR_FROMHOST) -+DECLARE_CSR(send_ipi, CSR_SEND_IPI) -+DECLARE_CSR(hartid, CSR_HARTID) -+DECLARE_CSR(cycleh, CSR_CYCLEH) -+DECLARE_CSR(timeh, CSR_TIMEH) -+DECLARE_CSR(instreth, CSR_INSTRETH) -+DECLARE_CSR(scycleh, CSR_SCYCLEH) -+DECLARE_CSR(stimeh, CSR_STIMEH) -+DECLARE_CSR(sinstreth, CSR_SINSTRETH) -+#endif -+#ifdef DECLARE_CAUSE -+DECLARE_CAUSE("fflags", CAUSE_FFLAGS) -+DECLARE_CAUSE("frm", CAUSE_FRM) -+DECLARE_CAUSE("fcsr", CAUSE_FCSR) -+DECLARE_CAUSE("cycle", CAUSE_CYCLE) -+DECLARE_CAUSE("time", CAUSE_TIME) -+DECLARE_CAUSE("instret", CAUSE_INSTRET) -+DECLARE_CAUSE("stats", CAUSE_STATS) -+DECLARE_CAUSE("uarch0", CAUSE_UARCH0) -+DECLARE_CAUSE("uarch1", CAUSE_UARCH1) -+DECLARE_CAUSE("uarch2", CAUSE_UARCH2) -+DECLARE_CAUSE("uarch3", CAUSE_UARCH3) -+DECLARE_CAUSE("uarch4", CAUSE_UARCH4) -+DECLARE_CAUSE("uarch5", CAUSE_UARCH5) -+DECLARE_CAUSE("uarch6", CAUSE_UARCH6) -+DECLARE_CAUSE("uarch7", CAUSE_UARCH7) -+DECLARE_CAUSE("uarch8", CAUSE_UARCH8) -+DECLARE_CAUSE("uarch9", CAUSE_UARCH9) -+DECLARE_CAUSE("uarch10", CAUSE_UARCH10) -+DECLARE_CAUSE("uarch11", CAUSE_UARCH11) -+DECLARE_CAUSE("uarch12", CAUSE_UARCH12) -+DECLARE_CAUSE("uarch13", CAUSE_UARCH13) -+DECLARE_CAUSE("uarch14", CAUSE_UARCH14) -+DECLARE_CAUSE("uarch15", CAUSE_UARCH15) -+DECLARE_CAUSE("sstatus", CAUSE_SSTATUS) -+DECLARE_CAUSE("stvec", CAUSE_STVEC) -+DECLARE_CAUSE("stimecmp", CAUSE_STIMECMP) -+DECLARE_CAUSE("sscratch", CAUSE_SSCRATCH) -+DECLARE_CAUSE("sepc", CAUSE_SEPC) -+DECLARE_CAUSE("sptbr", CAUSE_SPTBR) -+DECLARE_CAUSE("sasid", CAUSE_SASID) -+DECLARE_CAUSE("scycle", CAUSE_SCYCLE) -+DECLARE_CAUSE("stime", CAUSE_STIME) -+DECLARE_CAUSE("sinstret", CAUSE_SINSTRET) -+DECLARE_CAUSE("scause", CAUSE_SCAUSE) -+DECLARE_CAUSE("sbadaddr", CAUSE_SBADADDR) -+DECLARE_CAUSE("mstatus", CAUSE_MSTATUS) -+DECLARE_CAUSE("mscratch", CAUSE_MSCRATCH) -+DECLARE_CAUSE("mepc", CAUSE_MEPC) -+DECLARE_CAUSE("mcause", CAUSE_MCAUSE) -+DECLARE_CAUSE("mbadaddr", CAUSE_MBADADDR) -+DECLARE_CAUSE("reset", CAUSE_RESET) -+DECLARE_CAUSE("tohost", CAUSE_TOHOST) -+DECLARE_CAUSE("fromhost", CAUSE_FROMHOST) -+DECLARE_CAUSE("send_ipi", CAUSE_SEND_IPI) -+DECLARE_CAUSE("hartid", CAUSE_HARTID) -+DECLARE_CAUSE("cycleh", CAUSE_CYCLEH) -+DECLARE_CAUSE("timeh", CAUSE_TIMEH) -+DECLARE_CAUSE("instreth", CAUSE_INSTRETH) -+DECLARE_CAUSE("scycleh", CAUSE_SCYCLEH) -+DECLARE_CAUSE("stimeh", CAUSE_STIMEH) -+DECLARE_CAUSE("sinstreth", CAUSE_SINSTRETH) -+#endif -diff -rNU3 dist.orig/include/opcode/riscv.h dist/include/opcode/riscv.h ---- dist.orig/include/opcode/riscv.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/include/opcode/riscv.h 2015-10-18 13:11:17.000000000 +0200 -@@ -0,0 +1,320 @@ -+/* riscv.h. RISC-V opcode list for GDB, the GNU debugger. -+ Copyright 2011 -+ Free Software Foundation, Inc. -+ Contributed by Andrew Waterman -+ -+This file is part of GDB, GAS, and the GNU binutils. -+ -+GDB, GAS, and the GNU binutils are free software; you can redistribute -+them and/or modify them under the terms of the GNU General Public -+License as published by the Free Software Foundation; either version -+1, or (at your option) any later version. -+ -+GDB, GAS, and the GNU binutils are distributed in the hope that they -+will be useful, but WITHOUT ANY WARRANTY; without even the implied -+warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -+the GNU General Public License for more details. -+ -+You should have received a copy of the GNU General Public License -+along with this file; see the file COPYING. If not, write to the Free -+Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -+ -+#ifndef _RISCV_H_ -+#define _RISCV_H_ -+ -+#include "riscv-opc.h" -+#include -+#include -+ -+/* RVC fields */ -+ -+#define OP_MASK_CRD 0x1f -+#define OP_SH_CRD 5 -+#define OP_MASK_CRS2 0x1f -+#define OP_SH_CRS2 5 -+#define OP_MASK_CRS1 0x1f -+#define OP_SH_CRS1 10 -+#define OP_MASK_CRDS 0x7 -+#define OP_SH_CRDS 13 -+#define OP_MASK_CRS2S 0x7 -+#define OP_SH_CRS2S 13 -+#define OP_MASK_CRS2BS 0x7 -+#define OP_SH_CRS2BS 5 -+#define OP_MASK_CRS1S 0x7 -+#define OP_SH_CRS1S 10 -+#define OP_MASK_CIMM6 0x3f -+#define OP_SH_CIMM6 10 -+#define OP_MASK_CIMM5 0x1f -+#define OP_SH_CIMM5 5 -+#define OP_MASK_CIMM10 0x3ff -+#define OP_SH_CIMM10 5 -+ -+static const char rvc_rs1_regmap[8] = { 20, 21, 2, 3, 4, 5, 6, 7 }; -+#define rvc_rd_regmap rvc_rs1_regmap -+#define rvc_rs2b_regmap rvc_rs1_regmap -+static const char rvc_rs2_regmap[8] = { 20, 21, 2, 3, 4, 5, 6, 0 }; -+ -+typedef uint64_t insn_t; -+ -+static inline unsigned int riscv_insn_length (insn_t insn) -+{ -+ if ((insn & 0x3) != 3) /* RVC */ -+ return 2; -+ if ((insn & 0x1f) != 0x1f) /* base ISA and extensions in 32-bit space */ -+ return 4; -+ if ((insn & 0x3f) == 0x1f) /* 48-bit extensions */ -+ return 6; -+ if ((insn & 0x7f) == 0x3f) /* 64-bit extensions */ -+ return 8; -+ /* longer instructions not supported at the moment */ -+ return 2; -+} -+ -+static const char * const riscv_rm[8] = { -+ "rne", "rtz", "rdn", "rup", "rmm", 0, 0, "dyn" -+}; -+static const char* const riscv_pred_succ[16] = { -+ 0, "w", "r", "rw", "o", "ow", "or", "orw", -+ "i", "iw", "ir", "irw", "io", "iow", "ior", "iorw", -+}; -+ -+#define RVC_JUMP_BITS 10 -+#define RVC_JUMP_ALIGN_BITS 1 -+#define RVC_JUMP_ALIGN (1 << RVC_JUMP_ALIGN_BITS) -+#define RVC_JUMP_REACH ((1ULL<> (s)) & ((1<<(n))-1)) -+#define RV_IMM_SIGN(x) (-(((x) >> 31) & 1)) -+ -+#define EXTRACT_ITYPE_IMM(x) \ -+ (RV_X(x, 20, 12) | (RV_IMM_SIGN(x) << 12)) -+#define EXTRACT_STYPE_IMM(x) \ -+ (RV_X(x, 7, 5) | (RV_X(x, 25, 7) << 5) | (RV_IMM_SIGN(x) << 12)) -+#define EXTRACT_SBTYPE_IMM(x) \ -+ ((RV_X(x, 8, 4) << 1) | (RV_X(x, 25, 6) << 5) | (RV_X(x, 7, 1) << 11) | (RV_IMM_SIGN(x) << 12)) -+#define EXTRACT_UTYPE_IMM(x) \ -+ ((RV_X(x, 12, 20) << 12) | (RV_IMM_SIGN(x) << 32)) -+#define EXTRACT_UJTYPE_IMM(x) \ -+ ((RV_X(x, 21, 10) << 1) | (RV_X(x, 20, 1) << 11) | (RV_X(x, 12, 8) << 12) | (RV_IMM_SIGN(x) << 20)) -+ -+#define ENCODE_ITYPE_IMM(x) \ -+ (RV_X(x, 0, 12) << 20) -+#define ENCODE_STYPE_IMM(x) \ -+ ((RV_X(x, 0, 5) << 7) | (RV_X(x, 5, 7) << 25)) -+#define ENCODE_SBTYPE_IMM(x) \ -+ ((RV_X(x, 1, 4) << 8) | (RV_X(x, 5, 6) << 25) | (RV_X(x, 11, 1) << 7) | (RV_X(x, 12, 1) << 31)) -+#define ENCODE_UTYPE_IMM(x) \ -+ (RV_X(x, 12, 20) << 12) -+#define ENCODE_UJTYPE_IMM(x) \ -+ ((RV_X(x, 1, 10) << 21) | (RV_X(x, 11, 1) << 20) | (RV_X(x, 12, 8) << 12) | (RV_X(x, 20, 1) << 31)) -+ -+#define VALID_ITYPE_IMM(x) (EXTRACT_ITYPE_IMM(ENCODE_ITYPE_IMM(x)) == (x)) -+#define VALID_STYPE_IMM(x) (EXTRACT_STYPE_IMM(ENCODE_STYPE_IMM(x)) == (x)) -+#define VALID_SBTYPE_IMM(x) (EXTRACT_SBTYPE_IMM(ENCODE_SBTYPE_IMM(x)) == (x)) -+#define VALID_UTYPE_IMM(x) (EXTRACT_UTYPE_IMM(ENCODE_UTYPE_IMM(x)) == (x)) -+#define VALID_UJTYPE_IMM(x) (EXTRACT_UJTYPE_IMM(ENCODE_UJTYPE_IMM(x)) == (x)) -+ -+#define RISCV_RTYPE(insn, rd, rs1, rs2) \ -+ ((MATCH_ ## insn) | ((rd) << OP_SH_RD) | ((rs1) << OP_SH_RS1) | ((rs2) << OP_SH_RS2)) -+#define RISCV_ITYPE(insn, rd, rs1, imm) \ -+ ((MATCH_ ## insn) | ((rd) << OP_SH_RD) | ((rs1) << OP_SH_RS1) | ENCODE_ITYPE_IMM(imm)) -+#define RISCV_STYPE(insn, rs1, rs2, imm) \ -+ ((MATCH_ ## insn) | ((rs1) << OP_SH_RS1) | ((rs2) << OP_SH_RS2) | ENCODE_STYPE_IMM(imm)) -+#define RISCV_SBTYPE(insn, rs1, rs2, target) \ -+ ((MATCH_ ## insn) | ((rs1) << OP_SH_RS1) | ((rs2) << OP_SH_RS2) | ENCODE_SBTYPE_IMM(target)) -+#define RISCV_UTYPE(insn, rd, bigimm) \ -+ ((MATCH_ ## insn) | ((rd) << OP_SH_RD) | ENCODE_UTYPE_IMM(bigimm)) -+#define RISCV_UJTYPE(insn, rd, target) \ -+ ((MATCH_ ## insn) | ((rd) << OP_SH_RD) | ENCODE_UJTYPE_IMM(target)) -+ -+#define RISCV_NOP RISCV_ITYPE(ADDI, 0, 0, 0) -+ -+#define RISCV_CONST_HIGH_PART(VALUE) \ -+ (((VALUE) + (RISCV_IMM_REACH/2)) & ~(RISCV_IMM_REACH-1)) -+#define RISCV_CONST_LOW_PART(VALUE) ((VALUE) - RISCV_CONST_HIGH_PART (VALUE)) -+#define RISCV_PCREL_HIGH_PART(VALUE, PC) RISCV_CONST_HIGH_PART((VALUE) - (PC)) -+#define RISCV_PCREL_LOW_PART(VALUE, PC) RISCV_CONST_LOW_PART((VALUE) - (PC)) -+ -+/* RV fields */ -+ -+#define OP_MASK_OP 0x7f -+#define OP_SH_OP 0 -+#define OP_MASK_RS2 0x1f -+#define OP_SH_RS2 20 -+#define OP_MASK_RS1 0x1f -+#define OP_SH_RS1 15 -+#define OP_MASK_RS3 0x1f -+#define OP_SH_RS3 27 -+#define OP_MASK_RD 0x1f -+#define OP_SH_RD 7 -+#define OP_MASK_SHAMT 0x3f -+#define OP_SH_SHAMT 20 -+#define OP_MASK_SHAMTW 0x1f -+#define OP_SH_SHAMTW 20 -+#define OP_MASK_RM 0x7 -+#define OP_SH_RM 12 -+#define OP_MASK_PRED 0xf -+#define OP_SH_PRED 24 -+#define OP_MASK_SUCC 0xf -+#define OP_SH_SUCC 20 -+#define OP_MASK_AQ 0x1 -+#define OP_SH_AQ 26 -+#define OP_MASK_RL 0x1 -+#define OP_SH_RL 25 -+ -+#define OP_MASK_VRD 0x1f -+#define OP_SH_VRD 7 -+#define OP_MASK_VRS 0x1f -+#define OP_SH_VRS 15 -+#define OP_MASK_VRT 0x1f -+#define OP_SH_VRT 20 -+#define OP_MASK_VRR 0x1f -+#define OP_SH_VRR 27 -+ -+#define OP_MASK_VFD 0x1f -+#define OP_SH_VFD 7 -+#define OP_MASK_VFS 0x1f -+#define OP_SH_VFS 15 -+#define OP_MASK_VFT 0x1f -+#define OP_SH_VFT 20 -+#define OP_MASK_VFR 0x1f -+#define OP_SH_VFR 27 -+ -+#define OP_MASK_IMMNGPR 0x3f -+#define OP_SH_IMMNGPR 20 -+#define OP_MASK_IMMNFPR 0x3f -+#define OP_SH_IMMNFPR 26 -+#define OP_MASK_IMMSEGNELM 0x7 -+#define OP_SH_IMMSEGNELM 29 -+#define OP_MASK_CUSTOM_IMM 0x7f -+#define OP_SH_CUSTOM_IMM 25 -+#define OP_MASK_CSR 0xfff -+#define OP_SH_CSR 20 -+ -+#define X_RA 1 -+#define X_SP 2 -+#define X_GP 3 -+#define X_TP 4 -+#define X_T0 5 -+#define X_T1 6 -+#define X_T2 7 -+#define X_T3 28 -+ -+#define NGPR 32 -+#define NFPR 32 -+#define NVGPR 32 -+#define NVFPR 32 -+ -+#define RISCV_JUMP_BITS RISCV_BIGIMM_BITS -+#define RISCV_JUMP_ALIGN_BITS 1 -+#define RISCV_JUMP_ALIGN (1 << RISCV_JUMP_ALIGN_BITS) -+#define RISCV_JUMP_REACH ((1ULL< ld.pod - -($(POD2MAN) ld.pod | \ -diff -rNU3 dist.orig/ld/Makefile.in dist/ld/Makefile.in ---- dist.orig/ld/Makefile.in 2013-03-25 09:06:23.000000000 +0100 -+++ dist/ld/Makefile.in 2015-10-18 13:11:17.000000000 +0200 -@@ -452,12 +452,16 @@ - earmelf_linux_eabi.c \ - earmelf_nacl.c \ - earmelf_nbsd.c \ -+ earmelf_nbsd_eabi.c \ -+ earmelf_nbsd_eabihf.c \ - earmelf_vxworks.c \ - earmelfb.c \ - earmelfb_linux.c \ - earmelfb_linux_eabi.c \ - earmelfb_nacl.c \ - earmelfb_nbsd.c \ -+ earmelfb_nbsd_eabi.c \ -+ earmelfb_nbsd_eabihf.c \ - earmnbsd.c \ - earmnto.c \ - earmpe.c \ -@@ -535,6 +539,7 @@ - eelf32lppc.c \ - eelf32lppcnto.c \ - eelf32lppcsim.c \ -+ eelf32lriscv.c \ - eelf32lsmip.c \ - eelf32ltsmip.c \ - eelf32ltsmip_fbsd.c \ -@@ -548,9 +553,12 @@ - eelf32mipswindiss.c \ - eelf32moxie.c \ - eelf32mt.c \ -- eelf32openrisc.c \ -+ eelf32or1k.c \ -+ eelf32or1k_linux.c \ -+ eelf32or1k_nbsd.c \ - eelf32ppc.c \ - eelf32ppc_fbsd.c \ -+ eelf32ppc_nbsd.c \ - eelf32ppclinux.c \ - eelf32ppcnto.c \ - eelf32ppcsim.c \ -@@ -709,8 +717,6 @@ - emsp430xW427.c \ - enews.c \ - ens32knbsd.c \ -- eor32.c \ -- eor32elf.c \ - epc532macha.c \ - epdp11.c \ - epjelf.c \ -@@ -775,6 +781,8 @@ - eaarch64elfb.c \ - eaarch64linux.c \ - eaarch64linuxb.c \ -+ eaarch64nbsd.c \ -+ eaarch64nbsdb.c \ - eelf32_x86_64.c \ - eelf32_x86_64_nacl.c \ - eelf64_aix.c \ -@@ -793,6 +801,7 @@ - eelf64btsmip_fbsd.c \ - eelf64hppa.c \ - eelf64lppc.c \ -+ eelf64lriscv.c \ - eelf64ltsmip.c \ - eelf64ltsmip_fbsd.c \ - eelf64mmix.c \ -@@ -1060,6 +1069,8 @@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64elfb.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64linux.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64linuxb.Po@am__quote@ -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64nbsd.Po@am__quote@ -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaarch64nbsdb.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaix5ppc.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaix5rs6.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eaixppc.Po@am__quote@ -@@ -1078,12 +1089,16 @@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf_linux_eabi.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf_nacl.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf_nbsd.Po@am__quote@ -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf_nbsd_eabi.Po@am__quote@ -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf_nbsd_eabihf.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelf_vxworks.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelfb.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelfb_linux.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelfb_linux_eabi.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelfb_nacl.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelfb_nbsd.Po@am__quote@ -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelfb_nbsd_eabi.Po@am__quote@ -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmelfb_nbsd_eabihf.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmnbsd.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmnto.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earmpe.Po@am__quote@ -@@ -1156,6 +1171,7 @@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32lppc.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32lppcnto.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32lppcsim.Po@am__quote@ -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32lriscv.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32lsmip.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32ltsmip.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32ltsmip_fbsd.Po@am__quote@ -@@ -1169,9 +1185,12 @@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32mipswindiss.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32moxie.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32mt.Po@am__quote@ --@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32openrisc.Po@am__quote@ -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32or1k.Po@am__quote@ -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32or1k_linux.Po@am__quote@ -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32or1k_nbsd.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32ppc.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32ppc_fbsd.Po@am__quote@ -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32ppc_nbsd.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32ppclinux.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32ppcnto.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf32ppcsim.Po@am__quote@ -@@ -1204,6 +1223,7 @@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64btsmip_fbsd.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64hppa.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64lppc.Po@am__quote@ -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64lriscv.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64ltsmip.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64ltsmip_fbsd.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eelf64mmix.Po@am__quote@ -@@ -1363,8 +1383,6 @@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/emsp430xW427.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/enews.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ens32knbsd.Po@am__quote@ --@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eor32.Po@am__quote@ --@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eor32elf.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/epc532macha.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/epdp11.Po@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/epjelf.Po@am__quote@ -@@ -1490,6 +1508,8 @@ - -rm -f libtool config.lt - - ld.info: ld.texinfo $(ld_TEXINFOS) -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_ld.info: ld.texinfo $(ld_TEXINFOS) - restore=: && backupdir="$(am__leading_dot)am$$$$" && \ - rm -rf $$backupdir && mkdir $$backupdir && \ - if ($(MAKEINFO) --version) >/dev/null 2>&1; then \ -@@ -2201,6 +2221,18 @@ - $(ELF_DEPS) $(srcdir)/emultempl/armelf.em \ - $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} - ${GENSCRIPTS} armelf_nbsd "$(tdir_armelf_nbsd)" -+earmelf_nbsd_eabi.c: $(srcdir)/emulparams/armelf_nbsd_eabi.sh \ -+ $(srcdir)/emulparams/armelf_nbsd.sh \ -+ $(srcdir)/emulparams/armelf.sh \ -+ $(ELF_DEPS) $(srcdir)/emultempl/armelf.em \ -+ $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} -+ ${GENSCRIPTS} armelf_nbsd_eabi "$(tdir_armelf_nbsd_eabi)" -+earmelf_nbsd_eabihf.c: $(srcdir)/emulparams/armelf_nbsd_eabihf.sh \ -+ $(srcdir)/emulparams/armelf_nbsd.sh \ -+ $(srcdir)/emulparams/armelf.sh \ -+ $(ELF_DEPS) $(srcdir)/emultempl/armelf.em \ -+ $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} -+ ${GENSCRIPTS} armelf_nbsd_eabihf "$(tdir_armelf_nbsd_eabihf)" - earmelf_vxworks.c: $(srcdir)/emulparams/armelf_vxworks.sh \ - $(srcdir)/emulparams/vxworks.sh $(srcdir)/emulparams/armelf.sh \ - $(ELF_DEPS) $(srcdir)/emultempl/vxworks.em \ -@@ -2236,6 +2268,20 @@ - $(ELF_DEPS) $(srcdir)/emultempl/armelf.em \ - $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} - ${GENSCRIPTS} armelfb_nbsd "$(tdir_armelfb_nbsd)" -+earmelfb_nbsd_eabi.c: $(srcdir)/emulparams/armelfb_nbsd_eabi.sh \ -+ $(srcdir)/emulparams/armelf_nbsd_eabi.sh \ -+ $(srcdir)/emulparams/armelf_nbsd.sh \ -+ $(srcdir)/emulparams/armelf.sh \ -+ $(ELF_DEPS) $(srcdir)/emultempl/armelf.em \ -+ $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} -+ ${GENSCRIPTS} armelfb_nbsd_eabi "$(tdir_armelfb_nbsd_eabi)" -+earmelfb_nbsd_eabihf.c: $(srcdir)/emulparams/armelfb_nbsd_eabihf.sh \ -+ $(srcdir)/emulparams/armelf_nbsd_eabihf.sh \ -+ $(srcdir)/emulparams/armelf_nbsd.sh \ -+ $(srcdir)/emulparams/armelf.sh \ -+ $(ELF_DEPS) $(srcdir)/emultempl/armelf.em \ -+ $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} -+ ${GENSCRIPTS} armelfb_nbsd_eabihf "$(tdir_armelfb_nbsd_eabihf)" - earmnbsd.c: $(srcdir)/emulparams/armnbsd.sh \ - $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS} - ${GENSCRIPTS} armnbsd "$(tdir_armnbsd)" -@@ -2550,6 +2596,10 @@ - ldemul-list.h \ - $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} - ${GENSCRIPTS} elf32lppcsim "$(tdir_elf32lppcsim)" -+eelf32lriscv.c: $(srcdir)/emulparams/elf32lriscv.sh \ -+ $(srcdir)/emulparams/elf32lriscv-defs.sh $(ELF_DEPS) \ -+ $(srcdir)/emultempl/riscvelf.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} -+ ${GENSCRIPTS} elf32lriscv "$(tdir_elf32lriscv)" - eelf32lsmip.c: $(srcdir)/emulparams/elf32lsmip.sh \ - $(srcdir)/emulparams/elf32lmip.sh $(srcdir)/emulparams/elf32bmip.sh \ - $(ELF_DEPS) $(srcdir)/emultempl/mipself.em $(srcdir)/scripttempl/elf.sc \ -@@ -2600,9 +2650,17 @@ - eelf32mt.c: $(srcdir)/emulparams/elf32mt.sh \ - $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} - ${GENSCRIPTS} elf32mt "$(tdir_mt)" --eelf32openrisc.c: $(srcdir)/emulparams/elf32openrisc.sh \ -+eelf32or1k.c: $(srcdir)/emulparams/elf32or1k.sh \ -+ $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} -+ ${GENSCRIPTS} elf32or1k "$(tdir_or1k)" -+eelf32or1k_linux.c: $(srcdir)/emulparams/elf32or1k_linux.sh \ -+ $(srcdir)/emulparams/elf32or1k.sh \ -+ $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} -+ ${GENSCRIPTS} elf32or1k_linux "$(tdir_or1k_linux)" -+eelf32or1k_nbsd.c: $(srcdir)/emulparams/elf32or1k_nbsd.sh \ -+ $(srcdir)/emulparams/elf32or1k.sh \ - $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} -- ${GENSCRIPTS} elf32openrisc "$(tdir_openrisc)" -+ ${GENSCRIPTS} elf32or1k_nbsd "$(tdir_or1k_nbsd)" - eelf32ppc.c: $(srcdir)/emulparams/elf32ppc.sh \ - $(srcdir)/emulparams/elf32ppccommon.sh $(srcdir)/emultempl/ppc32elf.em \ - ldemul-list.h \ -@@ -2614,6 +2672,12 @@ - ldemul-list.h \ - $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} - ${GENSCRIPTS} elf32ppc_fbsd "$(tdir_elf32ppc_fbsd)" -+eelf32ppc_nbsd.c: $(srcdir)/emulparams/elf32ppc_nbsd.sh \ -+ $(srcdir)/emulparams/elf32ppc.sh $(srcdir)/emulparams/elf32ppccommon.sh \ -+ $(srcdir)/emultempl/ppc32elf.em $(ELF_DEPS) \ -+ ldemul-list.h \ -+ $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} -+ ${GENSCRIPTS} elf32ppc_nbsd "$(tdir_elf32ppc_nbsd)" - eelf32ppclinux.c: $(srcdir)/emulparams/elf32ppclinux.sh \ - $(srcdir)/emulparams/elf32ppc.sh $(srcdir)/emulparams/elf32ppccommon.sh \ - $(srcdir)/emultempl/ppc32elf.em $(ELF_DEPS) \ -@@ -3211,12 +3275,14 @@ - $(ELF_DEPS) $(srcdir)/emultempl/aarch64elf.em \ - $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} - ${GENSCRIPTS} aarch64linuxb "$(tdir_aarch64linuxb)" --eor32.c: $(srcdir)/emulparams/or32.sh \ -- $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/or32.sc ${GEN_DEPENDS} -- ${GENSCRIPTS} or32 "$(tdir_or32)" --eor32elf.c: $(srcdir)/emulparams/or32elf.sh \ -- $(ELF_GEN_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} -- ${GENSCRIPTS} or32elf "$(tdir_or32elf)" -+eaarch64nbsd.c: $(srcdir)/emulparams/aarch64nbsd.sh \ -+ $(ELF_DEPS) $(srcdir)/emultempl/aarch64elf.em \ -+ $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} -+ ${GENSCRIPTS} aarch64nbsd "$(tdir_aarch64nbsd)" -+eaarch64nbsdb.c: $(srcdir)/emulparams/aarch64nbsdb.sh $(srcdir)/emulparams/aarch64nbsd.sh \ -+ $(ELF_DEPS) $(srcdir)/emultempl/aarch64elf.em \ -+ $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} -+ ${GENSCRIPTS} aarch64nbsdb "$(tdir_aarch64nbsdb)" - epc532macha.c: $(srcdir)/emulparams/pc532macha.sh \ - $(srcdir)/emultempl/generic.em $(srcdir)/scripttempl/aout.sc ${GEN_DEPENDS} - ${GENSCRIPTS} pc532macha "$(tdir_pc532macha)" -@@ -3499,6 +3565,11 @@ - ldemul-list.h \ - $(ELF_DEPS) $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} - ${GENSCRIPTS} elf64lppc "$(tdir_elf64lppc)" -+eelf64lriscv.c: $(srcdir)/emulparams/elf64lriscv.sh \ -+ $(srcdir)/emulparams/elf64lriscv-defs.sh \ -+ $(srcdir)/emulparams/elf32lriscv-defs.sh $(ELF_DEPS) \ -+ $(srcdir)/emultempl/riscvelf.em $(srcdir)/scripttempl/elf.sc ${GEN_DEPENDS} -+ ${GENSCRIPTS} elf64lriscv "$(tdir_elf64lriscv)" - eelf64ltsmip.c: $(srcdir)/emulparams/elf64ltsmip.sh \ - $(srcdir)/emulparams/elf64btsmip.sh $(srcdir)/emulparams/elf64bmip-defs.sh \ - $(srcdir)/emulparams/elf32bmipn32-defs.sh $(ELF_DEPS) \ -@@ -3632,6 +3703,8 @@ - # because almost all configs use "gen" version of manual. - # Set DOCVER above to change. - configdoc.texi: ${DOCVER}-doc.texi -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_configdoc.texi: - cp ${srcdir}/${DOCVER}-doc.texi ./configdoc.texi - chmod u+w ./configdoc.texi - -@@ -3639,6 +3712,8 @@ - # The sed command removes the no-adjust Nroff command so that - # the man output looks standard. - ld.1: $(srcdir)/ld.texinfo configdoc.texi -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_ld.1: - touch $@ - -$(TEXI2POD) $(MANCONF) < $(srcdir)/ld.texinfo > ld.pod - -($(POD2MAN) ld.pod | \ -diff -rNU3 dist.orig/ld/configdoc.texi dist/ld/configdoc.texi ---- dist.orig/ld/configdoc.texi 2012-11-13 15:19:33.000000000 +0100 -+++ dist/ld/configdoc.texi 1970-01-01 01:00:00.000000000 +0100 -@@ -1,27 +0,0 @@ --@c ------------------------------ CONFIGURATION VARS: --@c 1. Inclusiveness of this manual --@set GENERIC -- --@c 2. Specific target machines --@set ARM --@set C6X --@set H8300 --@set HPPA --@set I960 --@set M68HC11 --@set M68K --@set MMIX --@set MSP430 --@set POWERPC --@set POWERPC64 --@set Renesas --@set SPU --@set TICOFF --@set WIN32 --@set XTENSA -- --@c 3. Properties of this configuration --@clear SingleFormat --@set UsesEnvVars --@c ------------------------------ end CONFIGURATION VARS -- -diff -rNU3 dist.orig/ld/configure.tgt dist/ld/configure.tgt ---- dist.orig/ld/configure.tgt 2012-09-04 14:53:47.000000000 +0200 -+++ dist/ld/configure.tgt 2015-10-18 13:11:17.000000000 +0200 -@@ -35,6 +35,10 @@ - targ_extra_emuls="aarch64linux aarch64elfb aarch64elf armelfb_linux_eabi armelf_linux_eabi armelfb armelf" ;; - aarch64-*-linux*) targ_emul=aarch64linux - targ_extra_emuls="aarch64linuxb aarch64elf aarch64elfb armelf_linux_eabi armelfb_linux_eabi armelf armelfb" ;; -+aarch64_be-*-netbsd*) targ_emul=aarch64nbsdb -+ targ_extra_emuls="aarch64nbsd aarch64elfb aarch64elf armelfb_nbsd_eabihf armelf_nbsd_eabihf armelfb_nbsd_eabi armelf_nbsd_eabi armelfb_nbsd armelf_nbsd armelf armelfb" ;; -+aarch64-*-netbsd*) targ_emul=aarch64nbsd -+ targ_extra_emuls="aarch64nbsdb aarch64elf aarch64elfb armelf_nbsd_eabihf armelfb_nbsd_eabihf armelf_nbsd_eabi armelfb_nbsd_eabi armelf_nbsd armelfb_nbsd armelf armelfb" ;; - alpha*-*-freebsd* | alpha*-*-kfreebsd*-gnu) - targ_emul=elf64alpha_fbsd - targ_extra_emuls="elf64alpha alpha" -@@ -64,7 +68,19 @@ - arm-*-freebsd* | arm-*-kfreebsd*-gnu) - targ_emul=armelf_fbsd - targ_extra_emuls="armelf" ;; --armeb-*-netbsdelf*) targ_emul=armelfb_nbsd; -+arm*eb-*-netbsdelf*-*eabihf*) -+ targ_emul=armelfb_nbsd_eabihf; -+ targ_extra_emuls="armelf_nbsd_eabihf armelf_nbsd_eabi armelfb_nbsd_eabi armelf_nbsd armelfb_nbsd armelf armnbsd" ;; -+arm*eb-*-netbsdelf*-*eabi*) -+ targ_emul=armelfb_nbsd_eabi; -+ targ_extra_emuls="armelf_nbsd_eabi armelf_nbsd_eabihf armelfb_nbsd_eabihf armelf_nbsd armelfb_nbsd armelf armnbsd" ;; -+arm*-*-netbsdelf*-*eabihf*) -+ targ_emul=armelf_nbsd_eabihf; -+ targ_extra_emuls="armelfb_nbsd_eabihf armelf_nbsd_eabi armelfb_nbsd_eabi armelf_nbsd armelfb_nbsd armelf armnbsd" ;; -+arm*-*-netbsdelf*-*eabi*) -+ targ_emul=armelf_nbsd_eabi; -+ targ_extra_emuls="armelfb_nbsd_eabi armelf_nbsd_eabihf armelfb_nbsd_eabihf armelf_nbsd armelfb_nbsd armelf armnbsd" ;; -+arm*eb-*-netbsdelf*) targ_emul=armelfb_nbsd; - targ_extra_emuls="armelf_nbsd armelf armnbsd" ;; - arm-*-netbsdelf*) targ_emul=armelf_nbsd; - targ_extra_emuls="armelfb_nbsd armelf armnbsd" ;; -@@ -379,7 +395,8 @@ - m68*-*-gnu*) targ_emul=m68kelf ;; - m68*-*-netbsd*4k*) targ_emul=m68k4knbsd - targ_extra_emuls="m68knbsd m68kelfnbsd" ;; --m68*-*-netbsdelf*) targ_emul=m68kelfnbsd -+m68*-*-netbsdelf* | m5407*-*-netbsdelf*) -+ targ_emul=m68kelfnbsd - targ_extra_emuls="m68knbsd m68k4knbsd" ;; - m68*-*-netbsdaout* | m68*-*-netbsd*) - targ_emul=m68knbsd -@@ -409,12 +426,18 @@ - mips*-sgi-irix*) targ_emul=mipsbig ;; - mips*el-*-ecoff*) targ_emul=mipsidtl ;; - mips*-*-ecoff*) targ_emul=mipsidt ;; -+mips64*el-*-netbsd*) targ_emul=elf32ltsmipn32 -+ targ_extra_emuls="elf64btsmip elf64ltsmip elf32ltsmip elf32btsmipn32 elf32btsmip" -+ ;; -+mips64*-*-netbsd*) targ_emul=elf32btsmipn32 -+ targ_extra_emuls="elf64ltsmip elf64btsmip elf32btsmip elf32ltsmipn32 elf32ltsmip" -+ ;; - mips*el-*-netbsd*) targ_emul=elf32ltsmip - targ_extra_emuls="elf32btsmip elf64ltsmip elf64btsmip" - ;; - mips*-*-netbsd*) targ_emul=elf32btsmip - targ_extra_emuls="elf32ltsmip elf64btsmip elf64ltsmip" -- ;; -+ ;; - mips*-*-bsd*) targ_emul=mipsbig ;; - mips*vr4300el-*-elf*) targ_emul=elf32l4300 ;; - mips*vr4300-*-elf*) targ_emul=elf32b4300 ;; -@@ -481,11 +504,11 @@ - ns32k-pc532-mach* | ns32k-pc532-ux*) targ_emul=pc532macha ;; - ns32k-*-netbsd* | ns32k-pc532-lites*) targ_emul=ns32knbsd - ;; --openrisc-*-*) targ_emul=elf32openrisc ;; --or32-*-coff) targ_emul=or32 ;; --or32-*-elf) targ_emul=or32elf ;; --or32-*-rtems*) targ_emul=or32elf -- ;; -+or1k-*-elf | or1knd-*-elf) targ_emul=elf32or1k ;; -+or1k-*-linux* | or1knd-*-linux*) targ_emul=elf32or1k_linux ;; -+or1k-*-netbsd* | or1knd-*-netbsd*) targ_emul=elf32or1k_nbsd ;; -+or1k-*-rtems* | or1knd-*-rtems*) targ_emul=elf32or1k ;; -+ - pdp11-*-*) targ_emul=pdp11 - ;; - pjl*-*-*) targ_emul=pjlelf ; targ_extra_emuls="elf_i386" ;; -@@ -529,8 +552,18 @@ - *) targ_emul=elf32lppc - targ_extra_emuls="elf32ppcsim" ;; - esac ;; -+powerpc64*-*-netbsd*) -+ targ_emul=elf64ppc -+ targ_extra_emuls="elf32ppc elf32ppc_nbsd elf32ppcsim" -+ tdir_elf32ppc=`echo "${targ_alias}" | sed -e 's/64//'` -+ tdir_elf32ppc_nbsd=$tdir_elf32ppc -+ tdir_elf32ppcsim=$tdir_elf32ppc -+ ;; -+powerpc*-*-netbsd*) -+ targ_emul=elf32ppc_nbsd -+ targ_extra_emuls="elf32ppc elf32ppcsim" ;; - powerpc*-*-elf* | powerpc*-*-eabi* | powerpc*-*-sysv* \ -- | powerpc*-*-netbsd* | powerpc-*-openbsd* | powerpc*-*-kaos*) -+ | powerpc-*-openbsd* | powerpc*-*-kaos*) - case "${targ}" in - *64*) targ_emul=elf64ppc - targ_extra_emuls="elf32ppc elf32ppclinux elf32ppcsim" -@@ -557,6 +590,12 @@ - powerpc-*-beos*) targ_emul=aixppc ;; - powerpc-*-windiss*) targ_emul=elf32ppcwindiss ;; - powerpc-*-lynxos*) targ_emul=ppclynx ;; -+riscv32-*-*) targ_emul=elf32lriscv -+ targ_extra_emuls="elf64lriscv" -+ targ_extra_libpath=$targ_extra_emuls ;; -+riscv*-*-*) targ_emul=elf64lriscv -+ targ_extra_emuls="elf32lriscv" -+ targ_extra_libpath=$targ_extra_emuls ;; - rs6000-*-aix[5-9]*) targ_emul=aix5rs6 ;; - rs6000-*-aix*) targ_emul=aixrs6 - ;; -@@ -654,10 +693,15 @@ - tdir_sparclinux=${targ_alias}aout - tdir_elf64_sparc=`echo ${targ_alias} | sed -e 's/32//'` - tdir_sun4=sparc-sun-sunos4 ;; --sparc64-*-netbsd* | sparc64-*-openbsd*) -- targ_emul=elf64_sparc -- targ_extra_emuls="elf32_sparc" ;; --sparc*-*-netbsd*elf*) targ_emul=elf32_sparc ;; -+sparc64-*-netbsd*) targ_emul=elf64_sparc -+ targ_extra_emuls="elf32_sparc sparcnbsd" -+ ;; -+sparc64-*-openbsd*) targ_emul=elf64_sparc -+ targ_extra_emuls="elf32_sparc" -+ ;; -+sparc*-*-netbsd*elf*) targ_emul=elf32_sparc -+ targ_extra_emuls=sparcnbsd -+ ;; - sparc*-*-netbsd*) targ_emul=sparcnbsd ;; - sparc-*-solaris2.[0-6] | sparc-*-solaris2.[0-6].*) - targ_emul=elf32_sparc_sol2 -diff -rNU3 dist.orig/ld/emulparams/aarch64nbsd.sh dist/ld/emulparams/aarch64nbsd.sh ---- dist.orig/ld/emulparams/aarch64nbsd.sh 1970-01-01 01:00:00.000000000 +0100 -+++ dist/ld/emulparams/aarch64nbsd.sh 2015-10-18 13:11:17.000000000 +0200 -@@ -0,0 +1,36 @@ -+ARCH=aarch64 -+MACHINE= -+NOP=0 -+ -+SCRIPT_NAME=elf -+OUTPUT_FORMAT="elf64-littleaarch64" -+BIG_OUTPUT_FORMAT="elf64-bigaarch64" -+LITTLE_OUTPUT_FORMAT="elf64-littleaarch64" -+NO_REL_RELOCS=yes -+ -+TEMPLATE_NAME=elf32 -+EXTRA_EM_FILE=aarch64elf -+ -+GENERATE_SHLIB_SCRIPT=yes -+GENERATE_PIE_SCRIPT=yes -+ -+MAXPAGESIZE="CONSTANT (MAXPAGESIZE)" -+COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)" -+SEPARATE_GOTPLT=24 -+IREL_IN_PLT= -+ -+TEXT_START_ADDR=0x200100000 -+ -+DATA_START_SYMBOLS='PROVIDE (__data_start = .);'; -+ -+# AArch64 does not support .s* sections. -+NO_SMALL_DATA=yes -+ -+OTHER_BSS_SYMBOLS='__bss_start__ = .;' -+OTHER_BSS_END_SYMBOLS='_bss_end__ = . ; __bss_end__ = . ;' -+OTHER_END_SYMBOLS='__end__ = . ;' -+ -+OTHER_SECTIONS='.note.gnu.arm.ident 0 : { KEEP (*(.note.gnu.arm.ident)) }' -+ATTRS_SECTIONS='.ARM.attributes 0 : { KEEP (*(.ARM.attributes)) KEEP (*(.gnu.attributes)) }' -+# Ensure each PLT entry is aligned to a cache line. -+PLT=".plt ${RELOCATING-0} : ALIGN(16) { *(.plt)${IREL_IN_PLT+ *(.iplt)} }" -diff -rNU3 dist.orig/ld/emulparams/aarch64nbsdb.sh dist/ld/emulparams/aarch64nbsdb.sh ---- dist.orig/ld/emulparams/aarch64nbsdb.sh 1970-01-01 01:00:00.000000000 +0100 -+++ dist/ld/emulparams/aarch64nbsdb.sh 2015-10-18 13:11:17.000000000 +0200 -@@ -0,0 +1,2 @@ -+. ${srcdir}/emulparams/aarch64nbsd.sh -+OUTPUT_FORMAT="elf64-bigaarch64" -diff -rNU3 dist.orig/ld/emulparams/armelf_nbsd.sh dist/ld/emulparams/armelf_nbsd.sh ---- dist.orig/ld/emulparams/armelf_nbsd.sh 2006-05-30 18:45:32.000000000 +0200 -+++ dist/ld/emulparams/armelf_nbsd.sh 2015-10-18 13:11:17.000000000 +0200 -@@ -1,7 +1,14 @@ - . ${srcdir}/emulparams/armelf.sh - MAXPAGESIZE="CONSTANT (MAXPAGESIZE)" --TEXT_START_ADDR=0x00008000 -+TEXT_START_ADDR=0x00010000 - TARGET2_TYPE=got-rel - -+unset DATA_START_SYMBOLS - unset STACK_ADDR - unset EMBEDDED -+ -+case "$target" in -+ aarch64*-*-netbsd* | arm*-*-netbsdelf*-*eabi*) -+ LIB_PATH='=/usr/lib/oabi' -+ ;; -+esac -diff -rNU3 dist.orig/ld/emulparams/armelf_nbsd_eabi.sh dist/ld/emulparams/armelf_nbsd_eabi.sh ---- dist.orig/ld/emulparams/armelf_nbsd_eabi.sh 1970-01-01 01:00:00.000000000 +0100 -+++ dist/ld/emulparams/armelf_nbsd_eabi.sh 2015-10-18 13:11:17.000000000 +0200 -@@ -0,0 +1,20 @@ -+. ${srcdir}/emulparams/armelf_nbsd.sh -+ -+# Use the ARM ABI-compliant exception-handling sections. -+OTHER_READONLY_SECTIONS=" -+ .ARM.extab ${RELOCATING-0} : { *(.ARM.extab${RELOCATING+* .gnu.linkonce.armextab.*}) } -+ ${RELOCATING+ PROVIDE_HIDDEN (__exidx_start = .); } -+ .ARM.exidx ${RELOCATING-0} : { *(.ARM.exidx${RELOCATING+* .gnu.linkonce.armexidx.*}) } -+ ${RELOCATING+ PROVIDE_HIDDEN (__exidx_end = .); }" -+ -+case "$target" in -+ arm*-*-netbsdelf*-*eabihf*) -+ LIB_PATH='=/usr/lib/eabi' -+ ;; -+ arm*-*-netbsdelf*-*eabi*) -+ LIB_PATH='=/usr/lib' -+ ;; -+ aarch64*-*-netbsd* | arm*-*-netbsdelf*) -+ LIB_PATH='=/usr/lib/eabi' -+ ;; -+esac -diff -rNU3 dist.orig/ld/emulparams/armelf_nbsd_eabihf.sh dist/ld/emulparams/armelf_nbsd_eabihf.sh ---- dist.orig/ld/emulparams/armelf_nbsd_eabihf.sh 1970-01-01 01:00:00.000000000 +0100 -+++ dist/ld/emulparams/armelf_nbsd_eabihf.sh 2015-10-18 13:11:17.000000000 +0200 -@@ -0,0 +1,17 @@ -+. ${srcdir}/emulparams/armelf_nbsd.sh -+ -+# Use the ARM ABI-compliant exception-handling sections. -+OTHER_READONLY_SECTIONS=" -+ .ARM.extab ${RELOCATING-0} : { *(.ARM.extab${RELOCATING+* .gnu.linkonce.armextab.*}) } -+ ${RELOCATING+ PROVIDE_HIDDEN (__exidx_start = .); } -+ .ARM.exidx ${RELOCATING-0} : { *(.ARM.exidx${RELOCATING+* .gnu.linkonce.armexidx.*}) } -+ ${RELOCATING+ PROVIDE_HIDDEN (__exidx_end = .); }" -+ -+case "$target" in -+ arm*-*-netbsdelf*-*eabihf*) -+ LIB_PATH='=/usr/lib' -+ ;; -+ aarch64*-*-netbsd* | arm*-*-netbsdelf*) -+ LIB_PATH='=/usr/lib/eabihf' -+ ;; -+esac -diff -rNU3 dist.orig/ld/emulparams/armelfb_nbsd_eabi.sh dist/ld/emulparams/armelfb_nbsd_eabi.sh ---- dist.orig/ld/emulparams/armelfb_nbsd_eabi.sh 1970-01-01 01:00:00.000000000 +0100 -+++ dist/ld/emulparams/armelfb_nbsd_eabi.sh 2015-10-18 13:11:17.000000000 +0200 -@@ -0,0 +1,2 @@ -+. ${srcdir}/emulparams/armelf_nbsd_eabi.sh -+OUTPUT_FORMAT="elf32-bigarm" -diff -rNU3 dist.orig/ld/emulparams/armelfb_nbsd_eabihf.sh dist/ld/emulparams/armelfb_nbsd_eabihf.sh ---- dist.orig/ld/emulparams/armelfb_nbsd_eabihf.sh 1970-01-01 01:00:00.000000000 +0100 -+++ dist/ld/emulparams/armelfb_nbsd_eabihf.sh 2015-10-18 13:11:17.000000000 +0200 -@@ -0,0 +1,2 @@ -+. ${srcdir}/emulparams/armelf_nbsd_eabihf.sh -+OUTPUT_FORMAT="elf32-bigarm" -diff -rNU3 dist.orig/ld/emulparams/elf32_sparc.sh dist/ld/emulparams/elf32_sparc.sh ---- dist.orig/ld/emulparams/elf32_sparc.sh 2010-09-20 20:41:15.000000000 +0200 -+++ dist/ld/emulparams/elf32_sparc.sh 2015-10-18 13:11:17.000000000 +0200 -@@ -13,6 +13,13 @@ - TEMPLATE_NAME=elf32 - DATA_PLT= - GENERATE_SHLIB_SCRIPT=yes -+#ELFSIZE=32 - GENERATE_PIE_SCRIPT=yes - NOP=0x01000000 - NO_SMALL_DATA=yes -+ -+case "$target" in -+ sparc64-*-netbsd*) -+ LIB_PATH='=/usr/lib/sparc' -+ ;; -+esac -diff -rNU3 dist.orig/ld/emulparams/elf32bmipn32-defs.sh dist/ld/emulparams/elf32bmipn32-defs.sh ---- dist.orig/ld/emulparams/elf32bmipn32-defs.sh 2012-09-04 16:14:28.000000000 +0200 -+++ dist/ld/emulparams/elf32bmipn32-defs.sh 2015-10-18 13:11:17.000000000 +0200 -@@ -6,6 +6,7 @@ - - # Handle both big- and little-ended 32-bit MIPS objects. - ARCH=mips -+MACHINE= - OUTPUT_FORMAT="elf32-bigmips" - BIG_OUTPUT_FORMAT="elf32-bigmips" - LITTLE_OUTPUT_FORMAT="elf32-littlemips" -diff -rNU3 dist.orig/ld/emulparams/elf32lriscv-defs.sh dist/ld/emulparams/elf32lriscv-defs.sh ---- dist.orig/ld/emulparams/elf32lriscv-defs.sh 1970-01-01 01:00:00.000000000 +0100 -+++ dist/ld/emulparams/elf32lriscv-defs.sh 2015-10-18 13:11:17.000000000 +0200 -@@ -0,0 +1,39 @@ -+# This is an ELF platform. -+SCRIPT_NAME=elf -+ARCH=riscv -+OUTPUT_FORMAT="elf32-littleriscv" -+NO_REL_RELOCS=yes -+ -+TEMPLATE_NAME=elf32 -+EXTRA_EM_FILE=riscvelf -+ -+case "$EMULATION_NAME" in -+elf32*) ELFSIZE=32; LIBPATH_SUFFIX=32 ;; -+elf64*) ELFSIZE=64; LIBPATH_SUFFIX= ;; -+*) echo $0: unhandled emulation $EMULATION_NAME >&2; exit 1 ;; -+esac -+ -+if test `echo "$host" | sed -e s/64//` = `echo "$target" | sed -e s/64//`; then -+ case " $EMULATION_LIBPATH " in -+ *" ${EMULATION_NAME} "*) -+ NATIVE=yes -+ ;; -+ esac -+fi -+ -+GENERATE_SHLIB_SCRIPT=yes -+GENERATE_PIE_SCRIPT=yes -+ -+TEXT_START_ADDR=0x800000 -+MAXPAGESIZE="CONSTANT (MAXPAGESIZE)" -+COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)" -+ -+INITIAL_READONLY_SECTIONS=".interp ${RELOCATING-0} : { *(.interp) }" -+SDATA_START_SYMBOLS="_gp = . + 0x800; -+ *(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4) *(.srodata.cst2) *(.srodata*)" -+if test -n "${CREATE_SHLIB}"; then -+ INITIAL_READONLY_SECTIONS= -+ SDATA_START_SYMBOLS= -+ OTHER_READONLY_SECTIONS=".srodata ${RELOCATING-0} : { *(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4) *(.srodata.cst2) *(.srodata*) }" -+ unset GOT -+fi -diff -rNU3 dist.orig/ld/emulparams/elf32lriscv.sh dist/ld/emulparams/elf32lriscv.sh ---- dist.orig/ld/emulparams/elf32lriscv.sh 1970-01-01 01:00:00.000000000 +0100 -+++ dist/ld/emulparams/elf32lriscv.sh 2015-10-18 13:11:17.000000000 +0200 -@@ -0,0 +1,2 @@ -+. ${srcdir}/emulparams/elf32lriscv-defs.sh -+OUTPUT_FORMAT="elf32-littleriscv" -diff -rNU3 dist.orig/ld/emulparams/elf32openrisc.sh dist/ld/emulparams/elf32openrisc.sh ---- dist.orig/ld/emulparams/elf32openrisc.sh 2008-10-22 07:20:44.000000000 +0200 -+++ dist/ld/emulparams/elf32openrisc.sh 1970-01-01 01:00:00.000000000 +0100 -@@ -1,11 +0,0 @@ --MACHINE= --SCRIPT_NAME=elf --OUTPUT_FORMAT="elf32-openrisc" --NO_RELA_RELOCS=yes --TEXT_START_ADDR=0x10000 --ARCH=openrisc --MAXPAGESIZE="CONSTANT (MAXPAGESIZE)" --ENTRY=_start --EMBEDDED=yes --NOP=0x15000000 -- -diff -rNU3 dist.orig/ld/emulparams/elf32or1k.sh dist/ld/emulparams/elf32or1k.sh ---- dist.orig/ld/emulparams/elf32or1k.sh 1970-01-01 01:00:00.000000000 +0100 -+++ dist/ld/emulparams/elf32or1k.sh 2015-10-18 13:11:17.000000000 +0200 -@@ -0,0 +1,14 @@ -+SCRIPT_NAME=elf -+MACHINE= -+TEMPLATE_NAME=elf32 -+OUTPUT_FORMAT="elf32-or1k" -+NOP=0x15000000 -+TEXT_START_ADDR=0x0000 -+TARGET_PAGE_SIZE=0x2000 -+MAXPAGESIZE="CONSTANT (MAXPAGESIZE)" -+EMBEDDED=yes -+ARCH=or1k -+ELFSIZE=32 -+INITIAL_READONLY_SECTIONS=".vectors ${RELOCATING-0} : { KEEP (*(.vectors)) }" -+NO_REL_RELOCS=yes -+COMMONPAGESIZE="CONSTANT (COMMONPAGESIZE)" -diff -rNU3 dist.orig/ld/emulparams/elf32or1k_linux.sh dist/ld/emulparams/elf32or1k_linux.sh ---- dist.orig/ld/emulparams/elf32or1k_linux.sh 1970-01-01 01:00:00.000000000 +0100 -+++ dist/ld/emulparams/elf32or1k_linux.sh 2015-10-18 13:11:17.000000000 +0200 -@@ -0,0 +1,6 @@ -+. ${srcdir}/emulparams/elf32or1k.sh -+unset EMBEDDED -+GENERATE_SHLIB_SCRIPT=yes -+GENERATE_PIE_SCRIPT=yes -+GENERATE_COMBRELOC_SCRIPT=yes -+TEXT_START_ADDR=0x00002000 -diff -rNU3 dist.orig/ld/emulparams/elf32or1k_nbsd.sh dist/ld/emulparams/elf32or1k_nbsd.sh ---- dist.orig/ld/emulparams/elf32or1k_nbsd.sh 1970-01-01 01:00:00.000000000 +0100 -+++ dist/ld/emulparams/elf32or1k_nbsd.sh 2015-10-18 13:11:17.000000000 +0200 -@@ -0,0 +1,6 @@ -+. ${srcdir}/emulparams/elf32or1k.sh -+unset EMBEDDED -+GENERATE_SHLIB_SCRIPT=yes -+GENERATE_PIE_SCRIPT=yes -+GENERATE_COMBRELOC_SCRIPT=yes -+TEXT_START_ADDR=0x00002000 -diff -rNU3 dist.orig/ld/emulparams/elf32ppc_nbsd.sh dist/ld/emulparams/elf32ppc_nbsd.sh ---- dist.orig/ld/emulparams/elf32ppc_nbsd.sh 1970-01-01 01:00:00.000000000 +0100 -+++ dist/ld/emulparams/elf32ppc_nbsd.sh 2015-10-18 13:11:17.000000000 +0200 -@@ -0,0 +1,7 @@ -+. ${srcdir}/emulparams/elf32ppc.sh -+ -+case "$target" in -+ powerpc64*-*-netbsd*) -+ LIB_PATH='=/usr/lib/powerpc' -+ ;; -+esac -diff -rNU3 dist.orig/ld/emulparams/elf64alpha_nbsd.sh dist/ld/emulparams/elf64alpha_nbsd.sh ---- dist.orig/ld/emulparams/elf64alpha_nbsd.sh 2001-12-18 00:54:58.000000000 +0100 -+++ dist/ld/emulparams/elf64alpha_nbsd.sh 2015-10-18 13:11:17.000000000 +0200 -@@ -1,2 +1,8 @@ - . ${srcdir}/emulparams/elf64alpha.sh - ENTRY=__start -+ -+NOP=0x47ff041f -+# XXX binutils 2.13 -+# Note that the number is always big-endian, thus we have to -+# reverse the digit string. -+#NOP=0x0000fe2f1f04ff47 # unop; nop -diff -rNU3 dist.orig/ld/emulparams/elf64lriscv-defs.sh dist/ld/emulparams/elf64lriscv-defs.sh ---- dist.orig/ld/emulparams/elf64lriscv-defs.sh 1970-01-01 01:00:00.000000000 +0100 -+++ dist/ld/emulparams/elf64lriscv-defs.sh 2015-10-18 13:11:17.000000000 +0200 -@@ -0,0 +1 @@ -+. ${srcdir}/emulparams/elf32lriscv-defs.sh -diff -rNU3 dist.orig/ld/emulparams/elf64lriscv.sh dist/ld/emulparams/elf64lriscv.sh ---- dist.orig/ld/emulparams/elf64lriscv.sh 1970-01-01 01:00:00.000000000 +0100 -+++ dist/ld/emulparams/elf64lriscv.sh 2015-10-18 13:11:17.000000000 +0200 -@@ -0,0 +1,2 @@ -+. ${srcdir}/emulparams/elf64lriscv-defs.sh -+OUTPUT_FORMAT="elf64-littleriscv" -diff -rNU3 dist.orig/ld/emulparams/elf_i386.sh dist/ld/emulparams/elf_i386.sh ---- dist.orig/ld/emulparams/elf_i386.sh 2012-06-11 15:23:50.000000000 +0200 -+++ dist/ld/emulparams/elf_i386.sh 2015-10-18 13:11:17.000000000 +0200 -@@ -9,7 +9,14 @@ - MACHINE= - TEMPLATE_NAME=elf32 - GENERATE_SHLIB_SCRIPT=yes -+#ELFSIZE=32 - GENERATE_PIE_SCRIPT=yes - NO_SMALL_DATA=yes - SEPARATE_GOTPLT="SIZEOF (.got.plt) >= 12 ? 12 : 0" - IREL_IN_PLT= -+ -+case "$target" in -+ x86_64-*-netbsd*) -+ LIB_PATH='=/usr/lib/i386' -+ ;; -+esac -diff -rNU3 dist.orig/ld/emulparams/hppalinux.sh dist/ld/emulparams/hppalinux.sh ---- dist.orig/ld/emulparams/hppalinux.sh 2011-02-18 19:20:29.000000000 +0100 -+++ dist/ld/emulparams/hppalinux.sh 2015-10-18 13:11:17.000000000 +0200 -@@ -1,5 +1,5 @@ - # If you change this file, please also look at files which source this one: --# hppanbsd.sh -+# hppanbsd.sh hppaobsd.sh - - SCRIPT_NAME=elf - ELFSIZE=32 -diff -rNU3 dist.orig/ld/emulparams/hppaobsd.sh dist/ld/emulparams/hppaobsd.sh ---- dist.orig/ld/emulparams/hppaobsd.sh 2006-05-30 18:45:32.000000000 +0200 -+++ dist/ld/emulparams/hppaobsd.sh 2015-10-18 13:11:17.000000000 +0200 -@@ -1,4 +1,4 @@ --. ${srcdir}/emulparams/hppanbsd.sh -+. ${srcdir}/emulparams/hppalinux.sh - - OUTPUT_FORMAT="elf32-hppa" - TEXT_START_ADDR=0x1000 -diff -rNU3 dist.orig/ld/emulparams/m68kelf.sh dist/ld/emulparams/m68kelf.sh ---- dist.orig/ld/emulparams/m68kelf.sh 2009-09-29 18:28:52.000000000 +0200 -+++ dist/ld/emulparams/m68kelf.sh 2015-10-18 13:11:17.000000000 +0200 -@@ -10,5 +10,6 @@ - TEMPLATE_NAME=elf32 - EXTRA_EM_FILE=m68kelf - GENERATE_SHLIB_SCRIPT=yes -+ELFSIZE=32 - GENERATE_PIE_SCRIPT=yes - NO_SMALL_DATA=yes -diff -rNU3 dist.orig/ld/emulparams/m68kelfnbsd.sh dist/ld/emulparams/m68kelfnbsd.sh ---- dist.orig/ld/emulparams/m68kelfnbsd.sh 2001-12-18 14:26:26.000000000 +0100 -+++ dist/ld/emulparams/m68kelfnbsd.sh 2015-10-18 13:11:17.000000000 +0200 -@@ -1,4 +1,4 @@ - . ${srcdir}/emulparams/m68kelf.sh - TEXT_START_ADDR=0x2000 - TARGET_PAGE_SIZE=0x2000 --MACHINE= -+NONPAGED_TEXT_START_ADDR=${TEXT_START_ADDR} -diff -rNU3 dist.orig/ld/emulparams/or32.sh dist/ld/emulparams/or32.sh ---- dist.orig/ld/emulparams/or32.sh 2006-06-20 04:22:14.000000000 +0200 -+++ dist/ld/emulparams/or32.sh 1970-01-01 01:00:00.000000000 +0100 -@@ -1,5 +0,0 @@ --SCRIPT_NAME=or32 --OUTPUT_FORMAT="coff-or32-big" --TEXT_START_ADDR=0x1000000 --TARGET_PAGE_SIZE=0x1000000 --ARCH=or32 -diff -rNU3 dist.orig/ld/emulparams/or32elf.sh dist/ld/emulparams/or32elf.sh ---- dist.orig/ld/emulparams/or32elf.sh 2008-10-22 07:20:44.000000000 +0200 -+++ dist/ld/emulparams/or32elf.sh 1970-01-01 01:00:00.000000000 +0100 -@@ -1,9 +0,0 @@ --SCRIPT_NAME=elf --TEMPLATE_NAME=generic --EXTRA_EM_FILE=genelf --OUTPUT_FORMAT="elf32-or32" --NO_RELA_RELOCS=yes --TEXT_START_ADDR=0x1000000 --TARGET_PAGE_SIZE=0x1000000 --MAXPAGESIZE="CONSTANT (MAXPAGESIZE)" --ARCH=or32 -diff -rNU3 dist.orig/ld/emulparams/sh.sh dist/ld/emulparams/sh.sh ---- dist.orig/ld/emulparams/sh.sh 2001-11-22 10:08:04.000000000 +0100 -+++ dist/ld/emulparams/sh.sh 2015-10-18 13:11:17.000000000 +0200 -@@ -3,6 +3,6 @@ - - SCRIPT_NAME=sh - OUTPUT_FORMAT="coff-sh" --TEXT_START_ADDR=0x8000 --TARGET_PAGE_SIZE=128 -+TEXT_START_ADDR=0x1000 -+TARGET_PAGE_SIZE=0x1000 - ARCH=sh -diff -rNU3 dist.orig/ld/emulparams/shelf_nbsd.sh dist/ld/emulparams/shelf_nbsd.sh ---- dist.orig/ld/emulparams/shelf_nbsd.sh 2008-01-16 00:05:46.000000000 +0100 -+++ dist/ld/emulparams/shelf_nbsd.sh 2015-10-18 13:11:17.000000000 +0200 -@@ -9,7 +9,11 @@ - - DATA_START_SYMBOLS='PROVIDE (__data_start = .);'; - --ENTRY=_start -+ENTRY=__start - - unset EMBEDDED - unset OTHER_SECTIONS -+ -+OTHER_READWRITE_SECTIONS=' -+ .note.ABI-tag : { *(.note.ABI-tag) } -+' -diff -rNU3 dist.orig/ld/emultempl/aarch64elf.em dist/ld/emultempl/aarch64elf.em ---- dist.orig/ld/emultempl/aarch64elf.em 2013-03-25 09:06:23.000000000 +0100 -+++ dist/ld/emultempl/aarch64elf.em 2015-10-18 13:11:17.000000000 +0200 -@@ -38,6 +38,7 @@ - ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown); - #endif /* not TARGET_ */ - input_flags.dynamic = ${DYNAMIC_LINK-TRUE}; -+ input_flags.add_DT_NEEDED_for_dynamic = TRUE; - config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`; - config.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`; - } -diff -rNU3 dist.orig/ld/emultempl/armelf.em dist/ld/emultempl/armelf.em ---- dist.orig/ld/emultempl/armelf.em 2013-03-25 09:06:23.000000000 +0100 -+++ dist/ld/emultempl/armelf.em 2015-10-18 13:11:17.000000000 +0200 -@@ -51,6 +51,7 @@ - ldfile_set_output_arch ("`echo ${ARCH}`", bfd_arch_unknown); - #endif /* not TARGET_ */ - input_flags.dynamic = ${DYNAMIC_LINK-TRUE}; -+ input_flags.add_DT_NEEDED_for_dynamic = TRUE; - config.has_shared = `if test -n "$GENERATE_SHLIB_SCRIPT" ; then echo TRUE ; else echo FALSE ; fi`; - config.separate_code = `if test "x${SEPARATE_CODE}" = xyes ; then echo TRUE ; else echo FALSE ; fi`; - } -diff -rNU3 dist.orig/ld/emultempl/elf32.em dist/ld/emultempl/elf32.em ---- dist.orig/ld/emultempl/elf32.em 2013-03-25 09:06:23.000000000 +0100 -+++ dist/ld/emultempl/elf32.em 2015-10-18 13:11:17.000000000 +0200 -@@ -72,6 +72,9 @@ - - if [ "x${USE_LIBPATH}" = xyes ] ; then - case ${target} in -+ *-*-netbsd*) -+ ;; -+ - *-*-linux-* | *-*-k*bsd*-* | *-*-gnu*) - fragment <name; - size_t len; - struct dt_needed needed; - -- if (name[0] == '/') -+ if (name[0] == '/') { -+ if (prepend_sysroot && ld_sysroot) { -+ bfd_boolean rv; -+ needed.by = n->by; -+ char *filename= concat(ld_sysroot, n->name, (const char *)NULL); -+ needed.name = filename; -+ rv = gld${EMULATION_NAME}_try_needed (&needed, force); -+ free(filename); -+ return rv; -+ } - return gld${EMULATION_NAME}_try_needed (n, force); -+ } - - if (path == NULL || *path == '\0') - return FALSE; -@@ -501,6 +518,13 @@ - } - strcpy (sset, name); - -+ if (prepend_sysroot && filename[0] == '=') -+ abort(); -+ if (filename[0] == '/' && prepend_sysroot && ld_sysroot) { -+ char *filename2 = concat(ld_sysroot, filename, (const char *)NULL); -+ free(filename); -+ filename = filename2; -+ } - needed.name = filename; - if (gld${EMULATION_NAME}_try_needed (&needed, force)) - return TRUE; -@@ -621,6 +645,9 @@ - # FreeBSD - ;; - -+ *-*-netbsd*) -+ ;; -+ - *-*-linux-* | *-*-k*bsd*-* | *-*-gnu*) - fragment <next) - { -- char *tmpname = gld${EMULATION_NAME}_add_sysroot (rp->name); - found = (rp->by == l->by -- && gld${EMULATION_NAME}_search_needed (tmpname, -+ && gld${EMULATION_NAME}_search_needed (rp->name, - &n, -- force)); -- free (tmpname); -+ force, 1)); - } - if (found) - break; -@@ -1315,6 +1340,9 @@ - # FreeBSD - ;; - -+ *-*-netbsd*) -+ ;; -+ - *-*-linux-* | *-*-k*bsd*-* | *-*-gnu*) - # Linux - fragment <ignore_hash != NULL -+ && bfd_hash_lookup (info->ignore_hash, name, FALSE, FALSE) != NULL) -+ return TRUE; -+ - if (config.warn_once) - { -- static struct bfd_hash_table *hash; -- - /* Only warn once about a particular undefined symbol. */ -- if (hash == NULL) -+ if (info->ignore_hash == NULL) - { -- hash = (struct bfd_hash_table *) -- xmalloc (sizeof (struct bfd_hash_table)); -- if (!bfd_hash_table_init (hash, bfd_hash_newfunc, -+ info->ignore_hash = xmalloc (sizeof (struct bfd_hash_table)); -+ if (!bfd_hash_table_init (info->ignore_hash, bfd_hash_newfunc, - sizeof (struct bfd_hash_entry))) - einfo (_("%F%P: bfd_hash_table_init failed: %E\n")); - } - -- if (bfd_hash_lookup (hash, name, FALSE, FALSE) != NULL) -+ if (bfd_hash_lookup (info->ignore_hash, name, FALSE, FALSE) != NULL) - return TRUE; - -- if (bfd_hash_lookup (hash, name, TRUE, TRUE) == NULL) -+ if (bfd_hash_lookup (info->ignore_hash, name, TRUE, TRUE) == NULL) - einfo (_("%F%P: bfd_hash_lookup failed: %E\n")); - } - -diff -rNU3 dist.orig/ld/ldmain.h dist/ld/ldmain.h ---- dist.orig/ld/ldmain.h 2012-07-13 15:20:26.000000000 +0200 -+++ dist/ld/ldmain.h 2015-10-18 13:11:17.000000000 +0200 -@@ -41,6 +41,7 @@ - - extern void add_ysym (const char *); - extern void add_wrap (const char *); -+extern void add_ignoresym (const char *); - extern void add_keepsyms_file (const char *); - - #endif -diff -rNU3 dist.orig/ld/lexsup.c dist/ld/lexsup.c ---- dist.orig/ld/lexsup.c 2013-03-25 09:06:23.000000000 +0100 -+++ dist/ld/lexsup.c 2015-10-18 13:11:17.000000000 +0200 -@@ -398,7 +398,7 @@ - ONE_DASH }, - { {"shared", no_argument, NULL, OPTION_SHARED}, - '\0', NULL, N_("Create a shared library"), ONE_DASH }, -- { {"Bshareable", no_argument, NULL, OPTION_SHARED }, /* FreeBSD. */ -+ { {"Bshareable", no_argument, NULL, OPTION_SHARED }, /* FreeBSD, NetBSD. */ - '\0', NULL, NULL, ONE_DASH }, - { {"pie", no_argument, NULL, OPTION_PIE}, - '\0', NULL, N_("Create a position independent executable"), ONE_DASH }, -@@ -496,8 +496,14 @@ - { {"whole-archive", no_argument, NULL, OPTION_WHOLE_ARCHIVE}, - '\0', NULL, N_("Include all objects from following archives"), - TWO_DASHES }, -+ { {"Bforcearchive", no_argument, NULL, OPTION_WHOLE_ARCHIVE}, -+ '\0', NULL, NULL, TWO_DASHES }, /* NetBSD. */ - { {"wrap", required_argument, NULL, OPTION_WRAP}, - '\0', N_("SYMBOL"), N_("Use wrapper functions for SYMBOL"), TWO_DASHES }, -+ { {"ignore-unresolved-symbol", required_argument, NULL, -+ OPTION_IGNORE_UNRESOLVED_SYMBOL}, -+ '\0', N_("SYMBOL"), -+ N_("Unresolved SYMBOL will not cause an error or warning"), TWO_DASHES }, - }; - - #define OPTION_COUNT ARRAY_SIZE (ld_options) -@@ -1344,6 +1350,9 @@ - case OPTION_WRAP: - add_wrap (optarg); - break; -+ case OPTION_IGNORE_UNRESOLVED_SYMBOL: -+ add_ignoresym (optarg); -+ break; - case OPTION_DISCARD_NONE: - link_info.discard = discard_none; - break; -diff -rNU3 dist.orig/ld/scripttempl/elf.sc dist/ld/scripttempl/elf.sc ---- dist.orig/ld/scripttempl/elf.sc 2013-03-25 09:06:23.000000000 +0100 -+++ dist/ld/scripttempl/elf.sc 2015-10-18 13:11:17.000000000 +0200 -@@ -94,6 +94,8 @@ - # - # Each of these can also have corresponding .rel.* and .rela.* sections. - -+test -z "$TEXT_START_SYMBOLS" && TEXT_START_SYMBOLS="PROVIDE_HIDDEN (__eprol = .);" -+test -z "$ENTRY" && ENTRY=_start - if test -n "$NOP"; then - FILL="=$NOP" - else -@@ -471,11 +473,12 @@ - .text ${RELOCATING-0} : - { - ${RELOCATING+${TEXT_START_SYMBOLS}} -+ *(.text) - ${RELOCATING+*(.text.unlikely .text.*_unlikely)} - ${RELOCATING+*(.text.exit .text.exit.*)} - ${RELOCATING+*(.text.startup .text.startup.*)} - ${RELOCATING+*(.text.hot .text.hot.*)} -- *(.text .stub${RELOCATING+ .text.* .gnu.linkonce.t.*}) -+ *(.stub${RELOCATING+ .text.* .gnu.linkonce.t.*}) - /* .gnu.warning sections are handled specially by elf32.em. */ - *(.gnu.warning) - ${RELOCATING+${OTHER_TEXT_SECTIONS}} -diff -rNU3 dist.orig/ld/scripttempl/sh.sc dist/ld/scripttempl/sh.sc ---- dist.orig/ld/scripttempl/sh.sc 2002-09-25 19:06:09.000000000 +0200 -+++ dist/ld/scripttempl/sh.sc 2015-10-18 13:11:17.000000000 +0200 -@@ -6,16 +6,13 @@ - ___dtors = . ; - *(.dtors) - ___dtors_end = . ; -- } > ram" -+ }" -+ - - cat < ram} -+ } - ${CONSTRUCTING+${TORS}} -- .data : -+ .data ${RELOCATING+ ALIGN(${TARGET_PAGE_SIZE})} : - { - *(.data) - ${RELOCATING+*(.gcc_exc*)} -@@ -35,19 +32,19 @@ - ${RELOCATING+___EH_FRAME_END__ = . ;} - ${RELOCATING+LONG(0);} - ${RELOCATING+ _edata = . ; } -- } ${RELOCATING+ > ram} -- .bss : -+ } -+ .bss ${RELOCATING+ ALIGN(${TARGET_PAGE_SIZE})} : - { - ${RELOCATING+ _bss_start = . ; } - *(.bss) - *(COMMON) - ${RELOCATING+ _end = . ; } -- } ${RELOCATING+ > ram} -- .stack ${RELOCATING+ 0x30000 } : -+ } -+ .stack : - { - ${RELOCATING+ _stack = . ; } - *(.stack) -- } ${RELOCATING+ > ram} -+ } - .stab 0 ${RELOCATING+(NOLOAD)} : - { - *(.stab) -diff -rNU3 dist.orig/libiberty/floatformat.c dist/libiberty/floatformat.c ---- dist.orig/libiberty/floatformat.c 2011-01-03 22:05:58.000000000 +0100 -+++ dist/libiberty/floatformat.c 2015-10-18 13:11:19.000000000 +0200 -@@ -489,7 +489,11 @@ - if (nan) - dto = NAN; - else -+#ifdef __vax__ -+ dto = HUGE_VAL; -+#else - dto = INFINITY; -+#endif - - if (get_field (ufrom, fmt->byteorder, fmt->totalsize, fmt->sign_start, 1)) - dto = -dto; -diff -rNU3 dist.orig/libiberty/make-temp-file.c dist/libiberty/make-temp-file.c ---- dist.orig/libiberty/make-temp-file.c 2011-01-03 22:05:58.000000000 +0100 -+++ dist/libiberty/make-temp-file.c 2015-10-18 13:11:19.000000000 +0200 -@@ -130,10 +130,10 @@ - base = try_dir (P_tmpdir, base); - #endif - -- /* Try /var/tmp, /usr/tmp, then /tmp. */ -+ /* Try /tmp, /var/tmp, then /usr/tmp. */ -+ base = try_dir (tmp, base); - base = try_dir (vartmp, base); - base = try_dir (usrtmp, base); -- base = try_dir (tmp, base); - - /* If all else fails, use the current directory! */ - if (base == 0) -diff -rNU3 dist.orig/libiberty/objalloc.c dist/libiberty/objalloc.c ---- dist.orig/libiberty/objalloc.c 2005-07-22 05:26:05.000000000 +0200 -+++ dist/libiberty/objalloc.c 2015-10-18 13:11:19.000000000 +0200 -@@ -1,5 +1,5 @@ - /* objalloc.c -- routines to allocate memory for objects -- Copyright 1997 Free Software Foundation, Inc. -+ Copyright 1997-2012 Free Software Foundation, Inc. - Written by Ian Lance Taylor, Cygnus Solutions. - - This program is free software; you can redistribute it and/or modify it -@@ -112,8 +112,10 @@ - /* Allocate space from an objalloc structure. */ - - PTR --_objalloc_alloc (struct objalloc *o, unsigned long len) -+_objalloc_alloc (struct objalloc *o, unsigned long original_len) - { -+ unsigned long len = original_len; -+ - /* We avoid confusion from zero sized objects by always allocating - at least 1 byte. */ - if (len == 0) -@@ -121,6 +123,11 @@ - - len = (len + OBJALLOC_ALIGN - 1) &~ (OBJALLOC_ALIGN - 1); - -+ /* Check for overflow in the alignment operation above and the -+ malloc argument below. */ -+ if (len + CHUNK_HEADER_SIZE < original_len) -+ return NULL; -+ - if (len <= o->current_space) - { - o->current_ptr += len; -diff -rNU3 dist.orig/libiberty/strerror.c dist/libiberty/strerror.c ---- dist.orig/libiberty/strerror.c 2005-03-28 04:09:01.000000000 +0200 -+++ dist/libiberty/strerror.c 2015-10-18 13:11:19.000000000 +0200 -@@ -347,7 +347,7 @@ - ENTRY(EPROTOTYPE, "EPROTOTYPE", "Protocol wrong type for socket"), - #endif - #if defined (ENOPROTOOPT) -- ENTRY(ENOPROTOOPT, "ENOPROTOOPT", "Protocol not available"), -+ ENTRY(ENOPROTOOPT, "ENOPROTOOPT", "Protocol option not available"), - #endif - #if defined (EPROTONOSUPPORT) - ENTRY(EPROTONOSUPPORT, "EPROTONOSUPPORT", "Protocol not supported"), -diff -rNU3 dist.orig/opcodes/Makefile.am dist/opcodes/Makefile.am ---- dist.orig/opcodes/Makefile.am 2012-09-04 16:21:06.000000000 +0200 -+++ dist/opcodes/Makefile.am 2015-10-18 13:11:20.000000000 +0200 -@@ -62,7 +62,7 @@ - mep-desc.h mep-opc.h \ - microblaze-opc.h \ - mt-desc.h mt-opc.h \ -- openrisc-desc.h openrisc-opc.h \ -+ or1k-desc.h or1k-opc.h \ - score-opc.h \ - sh-opc.h \ - sh64-opc.h \ -@@ -188,13 +188,11 @@ - mt-ibld.c \ - mt-opc.c \ - ns32k-dis.c \ -- openrisc-asm.c \ -- openrisc-desc.c \ -- openrisc-dis.c \ -- openrisc-ibld.c \ -- openrisc-opc.c \ -- or32-dis.c \ -- or32-opc.c \ -+ or1k-asm.c \ -+ or1k-desc.c \ -+ or1k-dis.c \ -+ or1k-ibld.c \ -+ or1k-opc.c \ - pdp11-dis.c \ - pdp11-opc.c \ - pj-dis.c \ -@@ -332,7 +330,7 @@ - CLEANFILES = \ - stamp-epiphany stamp-fr30 stamp-frv stamp-ip2k stamp-iq2000 stamp-lm32 \ - stamp-m32c stamp-m32r stamp-mep stamp-mt \ -- stamp-openrisc stamp-xc16x stamp-xstormy16 \ -+ stamp-or1k stamp-xc16x stamp-xstormy16 \ - libopcodes.a stamp-lib - - -@@ -348,7 +346,7 @@ - $(CGENDIR)/opc-opinst.scm \ - cgen-asm.in cgen-dis.in cgen-ibld.in - --CGEN_CPUS = epiphany fr30 frv ip2k iq2000 lm32 m32c m32r mep mt openrisc xc16x xstormy16 -+CGEN_CPUS = epiphany fr30 frv ip2k iq2000 lm32 m32c m32r mep mt or1k xc16x xstormy16 - - if CGEN_MAINT - EPIPHANY_DEPS = stamp-epiphany -@@ -361,7 +359,7 @@ - M32R_DEPS = stamp-m32r - MEP_DEPS = stamp-mep - MT_DEPS = stamp-mt --OPENRISC_DEPS = stamp-openrisc -+OR1K_DEPS = stamp-or1k - XC16X_DEPS = stamp-xc16x - XSTORMY16_DEPS = stamp-xstormy16 - else -@@ -375,7 +373,7 @@ - M32R_DEPS = - MEP_DEPS = - MT_DEPS = --OPENRISC_DEPS = -+OR1K_DEPS = - XC16X_DEPS = - XSTORMY16_DEPS = - endif -@@ -469,11 +467,11 @@ - archfile=$(CPUDIR)/mt.cpu \ - opcfile=$(CPUDIR)/mt.opc extrafiles= - --$(srcdir)/openrisc-desc.h $(srcdir)/openrisc-desc.c $(srcdir)/openrisc-opc.h $(srcdir)/openrisc-opc.c $(srcdir)/openrisc-ibld.c $(srcdir)/openrisc-asm.c $(srcdir)/openrisc-dis.c: $(OPENRISC_DEPS) -+$(srcdir)/or1k-desc.h $(srcdir)/or1k-desc.c $(srcdir)/or1k-opc.h $(srcdir)/or1k-opc.c $(srcdir)/or1k-ibld.c $(srcdir)/or1k-opinst.c $(srcdir)/or1k-asm.c $(srcdir)/or1k-dis.c: $(OR1K_DEPS) - @true --stamp-openrisc: $(CGENDEPS) $(CPUDIR)/openrisc.cpu $(CPUDIR)/openrisc.opc -- $(MAKE) run-cgen arch=openrisc prefix=openrisc options= \ -- archfile=$(CPUDIR)/openrisc.cpu opcfile=$(CPUDIR)/openrisc.opc extrafiles= -+stamp-or1k: $(CGENDEPS) $(CPUDIR)/or1k.cpu $(CPUDIR)/or1k.opc $(CPUDIR)/or1kcommon.cpu $(CPUDIR)/or1korbis.cpu $(CPUDIR)/or1korfpx.cpu -+ $(MAKE) run-cgen arch=or1k prefix=or1k options=opinst \ -+ archfile=$(CPUDIR)/or1k.cpu opcfile=$(CPUDIR)/or1k.opc extrafiles=opinst - - $(srcdir)/xc16x-desc.h $(srcdir)/xc16x-desc.c $(srcdir)/xc16x-opc.h $(srcdir)/xc16x-opc.c $(srcdir)/xc16x-ibld.c $(srcdir)/xc16x-asm.c $(srcdir)/xc16x-dis.c: $(XC16X_DEPS) - @true -diff -rNU3 dist.orig/opcodes/Makefile.in dist/opcodes/Makefile.in ---- dist.orig/opcodes/Makefile.in 2012-09-04 16:21:06.000000000 +0200 -+++ dist/opcodes/Makefile.in 2015-10-18 13:11:20.000000000 +0200 -@@ -459,13 +459,11 @@ - mt-ibld.c \ - mt-opc.c \ - ns32k-dis.c \ -- openrisc-asm.c \ -- openrisc-desc.c \ -- openrisc-dis.c \ -- openrisc-ibld.c \ -- openrisc-opc.c \ -- or32-dis.c \ -- or32-opc.c \ -+ or1k-asm.c \ -+ or1k-desc.c \ -+ or1k-dis.c \ -+ or1k-ibld.c \ -+ or1k-opc.c \ - pdp11-dis.c \ - pdp11-opc.c \ - pj-dis.c \ -@@ -572,7 +570,7 @@ - CLEANFILES = \ - stamp-epiphany stamp-fr30 stamp-frv stamp-ip2k stamp-iq2000 stamp-lm32 \ - stamp-m32c stamp-m32r stamp-mep stamp-mt \ -- stamp-openrisc stamp-xc16x stamp-xstormy16 \ -+ stamp-or1k stamp-xc16x stamp-xstormy16 \ - libopcodes.a stamp-lib - - CGENDIR = @cgendir@ -@@ -586,7 +584,7 @@ - $(CGENDIR)/opc-opinst.scm \ - cgen-asm.in cgen-dis.in cgen-ibld.in - --CGEN_CPUS = epiphany fr30 frv ip2k iq2000 lm32 m32c m32r mep mt openrisc xc16x xstormy16 -+CGEN_CPUS = epiphany fr30 frv ip2k iq2000 lm32 m32c m32r mep mt or1k xc16x xstormy16 - @CGEN_MAINT_FALSE@EPIPHANY_DEPS = - @CGEN_MAINT_TRUE@EPIPHANY_DEPS = stamp-epiphany - @CGEN_MAINT_FALSE@FR30_DEPS = -@@ -607,8 +605,8 @@ - @CGEN_MAINT_TRUE@MEP_DEPS = stamp-mep - @CGEN_MAINT_FALSE@MT_DEPS = - @CGEN_MAINT_TRUE@MT_DEPS = stamp-mt --@CGEN_MAINT_FALSE@OPENRISC_DEPS = --@CGEN_MAINT_TRUE@OPENRISC_DEPS = stamp-openrisc -+@CGEN_MAINT_FALSE@OR1K_DEPS = -+@CGEN_MAINT_TRUE@OR1K_DEPS = stamp-or1k - @CGEN_MAINT_FALSE@XC16X_DEPS = - @CGEN_MAINT_TRUE@XC16X_DEPS = stamp-xc16x - @CGEN_MAINT_FALSE@XSTORMY16_DEPS = -@@ -855,13 +853,12 @@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mt-ibld.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mt-opc.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ns32k-dis.Plo@am__quote@ --@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openrisc-asm.Plo@am__quote@ --@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openrisc-desc.Plo@am__quote@ --@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openrisc-dis.Plo@am__quote@ --@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openrisc-ibld.Plo@am__quote@ --@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/openrisc-opc.Plo@am__quote@ --@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/or32-dis.Plo@am__quote@ --@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/or32-opc.Plo@am__quote@ -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/or1k-asm.Plo@am__quote@ -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/or1k-desc.Plo@am__quote@ -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/or1k-dis.Plo@am__quote@ -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/or1k-ibld.Plo@am__quote@ -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/or1k-opc.Plo@am__quote@ -+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/or1k-opinst.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdp11-dis.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pdp11-opc.Plo@am__quote@ - @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pj-dis.Plo@am__quote@ -@@ -1340,11 +1337,11 @@ - archfile=$(CPUDIR)/mt.cpu \ - opcfile=$(CPUDIR)/mt.opc extrafiles= - --$(srcdir)/openrisc-desc.h $(srcdir)/openrisc-desc.c $(srcdir)/openrisc-opc.h $(srcdir)/openrisc-opc.c $(srcdir)/openrisc-ibld.c $(srcdir)/openrisc-asm.c $(srcdir)/openrisc-dis.c: $(OPENRISC_DEPS) -+$(srcdir)/or1k-desc.h $(srcdir)/or1k-desc.c $(srcdir)/or1k-opc.h $(srcdir)/or1k-opc.c $(srcdir)/or1k-ibld.c $(srcdir)/or1k-opinst.c $(srcdir)/or1k-asm.c $(srcdir)/or1k-dis.c: $(OR1K_DEPS) - @true --stamp-openrisc: $(CGENDEPS) $(CPUDIR)/openrisc.cpu $(CPUDIR)/openrisc.opc -- $(MAKE) run-cgen arch=openrisc prefix=openrisc options= \ -- archfile=$(CPUDIR)/openrisc.cpu opcfile=$(CPUDIR)/openrisc.opc extrafiles= -+stamp-or1k: $(CGENDEPS) $(CPUDIR)/or1k.cpu $(CPUDIR)/or1k.opc $(CPUDIR)/or1kcommon.cpu $(CPUDIR)/or1korbis.cpu $(CPUDIR)/or1korfpx.cpu -+ $(MAKE) run-cgen arch=or1k prefix=or1k options=opinst \ -+ archfile=$(CPUDIR)/or1k.cpu opcfile=$(CPUDIR)/or1k.opc extrafiles=opinst - - $(srcdir)/xc16x-desc.h $(srcdir)/xc16x-desc.c $(srcdir)/xc16x-opc.h $(srcdir)/xc16x-opc.c $(srcdir)/xc16x-ibld.c $(srcdir)/xc16x-asm.c $(srcdir)/xc16x-dis.c: $(XC16X_DEPS) - @true -diff -rNU3 dist.orig/opcodes/cgen.sh dist/opcodes/cgen.sh ---- dist.orig/opcodes/cgen.sh 2009-06-14 18:36:56.000000000 +0200 -+++ dist/opcodes/cgen.sh 2015-10-18 13:11:19.000000000 +0200 -@@ -61,6 +61,7 @@ - shift ; extrafiles=$9 - - rootdir=${srcdir}/.. -+move_if_change="${CONFIG_SHELL:-/bin/sh} ${rootdir}/move-if-change" - - # $arch is $6, as passed on the command line. - # $ARCH is the same argument but in all uppercase. -diff -rNU3 dist.orig/opcodes/configure dist/opcodes/configure ---- dist.orig/opcodes/configure 2012-09-04 16:21:07.000000000 +0200 -+++ dist/opcodes/configure 2015-10-18 13:11:19.000000000 +0200 -@@ -12532,13 +12532,13 @@ - bfd_mt_arch) ta="$ta mt-asm.lo mt-desc.lo mt-dis.lo mt-ibld.lo mt-opc.lo" using_cgen=yes ;; - bfd_msp430_arch) ta="$ta msp430-dis.lo" ;; - bfd_ns32k_arch) ta="$ta ns32k-dis.lo" ;; -- bfd_openrisc_arch) ta="$ta openrisc-asm.lo openrisc-desc.lo openrisc-dis.lo openrisc-ibld.lo openrisc-opc.lo" using_cgen=yes ;; -- bfd_or32_arch) ta="$ta or32-dis.lo or32-opc.lo" using_cgen=yes ;; -+ bfd_or1k_arch) ta="$ta or1k-asm.lo or1k-desc.lo or1k-dis.lo or1k-ibld.lo or1k-opc.lo" using_cgen=yes ;; - bfd_pdp11_arch) ta="$ta pdp11-dis.lo pdp11-opc.lo" ;; - bfd_pj_arch) ta="$ta pj-dis.lo pj-opc.lo" ;; - bfd_powerpc_arch) ta="$ta ppc-dis.lo ppc-opc.lo" ;; - bfd_powerpc_64_arch) ta="$ta ppc-dis.lo ppc-opc.lo" ;; - bfd_pyramid_arch) ;; -+ bfd_riscv_arch) ta="$ta riscv-dis.lo riscv-opc.lo" ;; - bfd_romp_arch) ;; - bfd_rs6000_arch) ta="$ta ppc-dis.lo ppc-opc.lo" ;; - bfd_rl78_arch) ta="$ta rl78-dis.lo rl78-decode.lo";; -@@ -12551,6 +12551,14 @@ - # specified, as in sh3-elf, sh3b-linux-gnu, etc. - # Include it just for ELF targets, since the SH5 bfd:s are ELF only. - for t in $target $canon_targets; do -+ # For NetBSD we do NOT want SH5 support unless sh5 or sh64 -+ # is specified -+ case $t in -+ sh5*-* | sh64*-*) # let the case below handle it -+ ;; -+ sh*-*-netbsd* | sh*l*-*-netbsd*) -+ continue ;; -+ esac - case $t in - all | sh5*-* | sh64*-* | sh-*-*elf* | shl*-*-*elf* | \ - sh-*-linux* | shl-*-linux*) -diff -rNU3 dist.orig/opcodes/configure.in dist/opcodes/configure.in ---- dist.orig/opcodes/configure.in 2012-11-05 17:29:08.000000000 +0100 -+++ dist/opcodes/configure.in 2015-10-18 13:11:19.000000000 +0200 -@@ -277,13 +277,13 @@ - bfd_mt_arch) ta="$ta mt-asm.lo mt-desc.lo mt-dis.lo mt-ibld.lo mt-opc.lo" using_cgen=yes ;; - bfd_msp430_arch) ta="$ta msp430-dis.lo" ;; - bfd_ns32k_arch) ta="$ta ns32k-dis.lo" ;; -- bfd_openrisc_arch) ta="$ta openrisc-asm.lo openrisc-desc.lo openrisc-dis.lo openrisc-ibld.lo openrisc-opc.lo" using_cgen=yes ;; -- bfd_or32_arch) ta="$ta or32-dis.lo or32-opc.lo" using_cgen=yes ;; -+ bfd_or1k_arch) ta="$ta or1k-asm.lo or1k-desc.lo or1k-dis.lo or1k-ibld.lo or1k-opc.lo" using_cgen=yes ;; - bfd_pdp11_arch) ta="$ta pdp11-dis.lo pdp11-opc.lo" ;; - bfd_pj_arch) ta="$ta pj-dis.lo pj-opc.lo" ;; - bfd_powerpc_arch) ta="$ta ppc-dis.lo ppc-opc.lo" ;; - bfd_powerpc_64_arch) ta="$ta ppc-dis.lo ppc-opc.lo" ;; - bfd_pyramid_arch) ;; -+ bfd_riscv_arch) ta="$ta riscv-dis.lo riscv-opc.lo" ;; - bfd_romp_arch) ;; - bfd_rs6000_arch) ta="$ta ppc-dis.lo ppc-opc.lo" ;; - bfd_rl78_arch) ta="$ta rl78-dis.lo rl78-decode.lo";; -@@ -296,6 +296,14 @@ - # specified, as in sh3-elf, sh3b-linux-gnu, etc. - # Include it just for ELF targets, since the SH5 bfd:s are ELF only. - for t in $target $canon_targets; do -+ # For NetBSD we do NOT want SH5 support unless sh5 or sh64 -+ # is specified -+ case $t in -+ sh5*-* | sh64*-*) # let the case below handle it -+ ;; -+ sh*-*-netbsd* | sh*l*-*-netbsd*) -+ continue ;; -+ esac - case $t in - all | sh5*-* | sh64*-* | sh-*-*elf* | shl*-*-*elf* | \ - sh-*-linux* | shl-*-linux*) -diff -rNU3 dist.orig/opcodes/disassemble.c dist/opcodes/disassemble.c ---- dist.orig/opcodes/disassemble.c 2012-09-04 14:53:50.000000000 +0200 -+++ dist/opcodes/disassemble.c 2015-10-18 13:11:19.000000000 +0200 -@@ -67,11 +67,11 @@ - #define ARCH_mt - #define ARCH_msp430 - #define ARCH_ns32k --#define ARCH_openrisc --#define ARCH_or32 -+#define ARCH_or1k - #define ARCH_pdp11 - #define ARCH_pj - #define ARCH_powerpc -+#define ARCH_riscv - #define ARCH_rs6000 - #define ARCH_rl78 - #define ARCH_rx -@@ -332,17 +332,9 @@ - disassemble = print_insn_mn10300; - break; - #endif --#ifdef ARCH_openrisc -- case bfd_arch_openrisc: -- disassemble = print_insn_openrisc; -- break; --#endif --#ifdef ARCH_or32 -- case bfd_arch_or32: -- if (bfd_big_endian (abfd)) -- disassemble = print_insn_big_or32; -- else -- disassemble = print_insn_little_or32; -+#ifdef ARCH_or1k -+ case bfd_arch_or1k: -+ disassemble = print_insn_or1k; - break; - #endif - #ifdef ARCH_pdp11 -@@ -363,6 +355,11 @@ - disassemble = print_insn_little_powerpc; - break; - #endif -+#ifdef ARCH_riscv -+ case bfd_arch_riscv: -+ disassemble = print_insn_riscv; -+ break; -+#endif - #ifdef ARCH_rs6000 - case bfd_arch_rs6000: - if (bfd_get_mach (abfd) == bfd_mach_ppc_620) -diff -rNU3 dist.orig/opcodes/mips-opc.c dist/opcodes/mips-opc.c ---- dist.orig/opcodes/mips-opc.c 2012-09-04 16:21:10.000000000 +0200 -+++ dist/opcodes/mips-opc.c 2015-10-18 13:11:20.000000000 +0200 -@@ -791,10 +791,12 @@ - {"hibernate","", 0x42000023, 0xffffffff, 0, 0, V1 }, - {"ins", "t,r,+A,+B", 0x7c000004, 0xfc00003f, WR_t|RD_s, 0, I33 }, - {"iret", "", 0x42000038, 0xffffffff, NODS, 0, MC }, -+{"jr", "s", 0, (int) M_JR_S, INSN_MACRO, 0, I1 }, - {"jr", "s", 0x00000008, 0xfc1fffff, UBD|RD_s, 0, I1 }, - /* jr.hb is officially MIPS{32,64}R2, but it works on R1 as jr with - the same hazard barrier effect. */ - {"jr.hb", "s", 0x00000408, 0xfc1fffff, UBD|RD_s, 0, I32 }, -+{"j", "s", 0, (int) M_J_S, INSN_MACRO, 0, I1 }, - {"j", "s", 0x00000008, 0xfc1fffff, UBD|RD_s, 0, I1 }, /* jr */ - /* SVR4 PIC code requires special handling for j, so it must be a - macro. */ -@@ -803,7 +805,9 @@ - assembler, but will never match user input (because the line above - will match first). */ - {"j", "a", 0x08000000, 0xfc000000, UBD, 0, I1 }, -+{"jalr", "s", 0, (int) M_JALR_S, INSN_MACRO, 0, I1 }, - {"jalr", "s", 0x0000f809, 0xfc1fffff, UBD|RD_s|WR_d, 0, I1 }, -+{"jalr", "d,s", 0, (int) M_JALR_DS, INSN_MACRO, 0, I1 }, - {"jalr", "d,s", 0x00000009, 0xfc1f07ff, UBD|RD_s|WR_d, 0, I1 }, - /* jalr.hb is officially MIPS{32,64}R2, but it works on R1 as jalr - with the same hazard barrier effect. */ -diff -rNU3 dist.orig/opcodes/openrisc-asm.c dist/opcodes/openrisc-asm.c ---- dist.orig/opcodes/openrisc-asm.c 2010-06-27 06:07:55.000000000 +0200 -+++ dist/opcodes/openrisc-asm.c 1970-01-01 01:00:00.000000000 +0100 -@@ -1,649 +0,0 @@ --/* Assembler interface for targets using CGEN. -*- C -*- -- CGEN: Cpu tools GENerator -- -- THIS FILE IS MACHINE GENERATED WITH CGEN. -- - the resultant file is machine generated, cgen-asm.in isn't -- -- Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2005, 2007, 2008, 2010 -- Free Software Foundation, Inc. -- -- This file is part of libopcodes. -- -- This library is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3, or (at your option) -- any later version. -- -- It is distributed in the hope that it will be useful, but WITHOUT -- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software Foundation, Inc., -- 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -- -- --/* ??? Eventually more and more of this stuff can go to cpu-independent files. -- Keep that in mind. */ -- --#include "sysdep.h" --#include --#include "ansidecl.h" --#include "bfd.h" --#include "symcat.h" --#include "openrisc-desc.h" --#include "openrisc-opc.h" --#include "opintl.h" --#include "xregex.h" --#include "libiberty.h" --#include "safe-ctype.h" -- --#undef min --#define min(a,b) ((a) < (b) ? (a) : (b)) --#undef max --#define max(a,b) ((a) > (b) ? (a) : (b)) -- --static const char * parse_insn_normal -- (CGEN_CPU_DESC, const CGEN_INSN *, const char **, CGEN_FIELDS *); -- --/* -- assembler routines inserted here. */ -- --/* -- asm.c */ -- --static const char * MISSING_CLOSING_PARENTHESIS = N_("missing `)'"); -- --#define CGEN_VERBOSE_ASSEMBLER_ERRORS -- --long --openrisc_sign_extend_16bit (long value) --{ -- return ((value & 0xffff) ^ 0x8000) - 0x8000; --} -- --/* Handle hi(). */ -- --static const char * --parse_hi16 (CGEN_CPU_DESC cd, const char ** strp, int opindex, long * valuep) --{ -- const char *errmsg; -- enum cgen_parse_operand_result result_type; -- unsigned long ret; -- -- if (**strp == '#') -- ++*strp; -- -- if (strncasecmp (*strp, "hi(", 3) == 0) -- { -- bfd_vma value; -- -- *strp += 3; -- errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_HI16, -- & result_type, & value); -- if (**strp != ')') -- return MISSING_CLOSING_PARENTHESIS; -- -- ++*strp; -- if (errmsg == NULL -- && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -- value >>= 16; -- ret = value; -- } -- else -- { -- if (**strp == '-') -- { -- long value; -- -- errmsg = cgen_parse_signed_integer (cd, strp, opindex, &value); -- ret = value; -- } -- else -- { -- unsigned long value; -- -- errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, &value); -- ret = value; -- } -- } -- -- *valuep = ((ret & 0xffff) ^ 0x8000) - 0x8000; -- return errmsg; --} -- --/* Handle lo(). */ -- --static const char * --parse_lo16 (CGEN_CPU_DESC cd, const char ** strp, int opindex, long * valuep) --{ -- const char *errmsg; -- enum cgen_parse_operand_result result_type; -- unsigned long ret; -- -- if (**strp == '#') -- ++*strp; -- -- if (strncasecmp (*strp, "lo(", 3) == 0) -- { -- bfd_vma value; -- -- *strp += 3; -- errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_LO16, -- & result_type, & value); -- if (**strp != ')') -- return MISSING_CLOSING_PARENTHESIS; -- -- ++*strp; -- ret = value; -- } -- else -- { -- if (**strp == '-') -- { -- long value; -- -- errmsg = cgen_parse_signed_integer (cd, strp, opindex, &value); -- ret = value; -- } -- else -- { -- unsigned long value; -- -- errmsg = cgen_parse_unsigned_integer (cd, strp, opindex, &value); -- ret = value; -- } -- } -- -- *valuep = ((ret & 0xffff) ^ 0x8000) - 0x8000; -- return errmsg; --} -- --/* -- */ -- --const char * openrisc_cgen_parse_operand -- (CGEN_CPU_DESC, int, const char **, CGEN_FIELDS *); -- --/* Main entry point for operand parsing. -- -- This function is basically just a big switch statement. Earlier versions -- used tables to look up the function to use, but -- - if the table contains both assembler and disassembler functions then -- the disassembler contains much of the assembler and vice-versa, -- - there's a lot of inlining possibilities as things grow, -- - using a switch statement avoids the function call overhead. -- -- This function could be moved into `parse_insn_normal', but keeping it -- separate makes clear the interface between `parse_insn_normal' and each of -- the handlers. */ -- --const char * --openrisc_cgen_parse_operand (CGEN_CPU_DESC cd, -- int opindex, -- const char ** strp, -- CGEN_FIELDS * fields) --{ -- const char * errmsg = NULL; -- /* Used by scalar operands that still need to be parsed. */ -- long junk ATTRIBUTE_UNUSED; -- -- switch (opindex) -- { -- case OPENRISC_OPERAND_ABS_26 : -- { -- bfd_vma value = 0; -- errmsg = cgen_parse_address (cd, strp, OPENRISC_OPERAND_ABS_26, 0, NULL, & value); -- fields->f_abs26 = value; -- } -- break; -- case OPENRISC_OPERAND_DISP_26 : -- { -- bfd_vma value = 0; -- errmsg = cgen_parse_address (cd, strp, OPENRISC_OPERAND_DISP_26, 0, NULL, & value); -- fields->f_disp26 = value; -- } -- break; -- case OPENRISC_OPERAND_HI16 : -- errmsg = parse_hi16 (cd, strp, OPENRISC_OPERAND_HI16, (long *) (& fields->f_simm16)); -- break; -- case OPENRISC_OPERAND_LO16 : -- errmsg = parse_lo16 (cd, strp, OPENRISC_OPERAND_LO16, (long *) (& fields->f_lo16)); -- break; -- case OPENRISC_OPERAND_OP_F_23 : -- errmsg = cgen_parse_unsigned_integer (cd, strp, OPENRISC_OPERAND_OP_F_23, (unsigned long *) (& fields->f_op4)); -- break; -- case OPENRISC_OPERAND_OP_F_3 : -- errmsg = cgen_parse_unsigned_integer (cd, strp, OPENRISC_OPERAND_OP_F_3, (unsigned long *) (& fields->f_op5)); -- break; -- case OPENRISC_OPERAND_RA : -- errmsg = cgen_parse_keyword (cd, strp, & openrisc_cgen_opval_h_gr, & fields->f_r2); -- break; -- case OPENRISC_OPERAND_RB : -- errmsg = cgen_parse_keyword (cd, strp, & openrisc_cgen_opval_h_gr, & fields->f_r3); -- break; -- case OPENRISC_OPERAND_RD : -- errmsg = cgen_parse_keyword (cd, strp, & openrisc_cgen_opval_h_gr, & fields->f_r1); -- break; -- case OPENRISC_OPERAND_SIMM_16 : -- errmsg = cgen_parse_signed_integer (cd, strp, OPENRISC_OPERAND_SIMM_16, (long *) (& fields->f_simm16)); -- break; -- case OPENRISC_OPERAND_UI16NC : -- errmsg = parse_lo16 (cd, strp, OPENRISC_OPERAND_UI16NC, (long *) (& fields->f_i16nc)); -- break; -- case OPENRISC_OPERAND_UIMM_16 : -- errmsg = cgen_parse_unsigned_integer (cd, strp, OPENRISC_OPERAND_UIMM_16, (unsigned long *) (& fields->f_uimm16)); -- break; -- case OPENRISC_OPERAND_UIMM_5 : -- errmsg = cgen_parse_unsigned_integer (cd, strp, OPENRISC_OPERAND_UIMM_5, (unsigned long *) (& fields->f_uimm5)); -- break; -- -- default : -- /* xgettext:c-format */ -- fprintf (stderr, _("Unrecognized field %d while parsing.\n"), opindex); -- abort (); -- } -- -- return errmsg; --} -- --cgen_parse_fn * const openrisc_cgen_parse_handlers[] = --{ -- parse_insn_normal, --}; -- --void --openrisc_cgen_init_asm (CGEN_CPU_DESC cd) --{ -- openrisc_cgen_init_opcode_table (cd); -- openrisc_cgen_init_ibld_table (cd); -- cd->parse_handlers = & openrisc_cgen_parse_handlers[0]; -- cd->parse_operand = openrisc_cgen_parse_operand; --#ifdef CGEN_ASM_INIT_HOOK --CGEN_ASM_INIT_HOOK --#endif --} -- -- -- --/* Regex construction routine. -- -- This translates an opcode syntax string into a regex string, -- by replacing any non-character syntax element (such as an -- opcode) with the pattern '.*' -- -- It then compiles the regex and stores it in the opcode, for -- later use by openrisc_cgen_assemble_insn -- -- Returns NULL for success, an error message for failure. */ -- --char * --openrisc_cgen_build_insn_regex (CGEN_INSN *insn) --{ -- CGEN_OPCODE *opc = (CGEN_OPCODE *) CGEN_INSN_OPCODE (insn); -- const char *mnem = CGEN_INSN_MNEMONIC (insn); -- char rxbuf[CGEN_MAX_RX_ELEMENTS]; -- char *rx = rxbuf; -- const CGEN_SYNTAX_CHAR_TYPE *syn; -- int reg_err; -- -- syn = CGEN_SYNTAX_STRING (CGEN_OPCODE_SYNTAX (opc)); -- -- /* Mnemonics come first in the syntax string. */ -- if (! CGEN_SYNTAX_MNEMONIC_P (* syn)) -- return _("missing mnemonic in syntax string"); -- ++syn; -- -- /* Generate a case sensitive regular expression that emulates case -- insensitive matching in the "C" locale. We cannot generate a case -- insensitive regular expression because in Turkish locales, 'i' and 'I' -- are not equal modulo case conversion. */ -- -- /* Copy the literal mnemonic out of the insn. */ -- for (; *mnem; mnem++) -- { -- char c = *mnem; -- -- if (ISALPHA (c)) -- { -- *rx++ = '['; -- *rx++ = TOLOWER (c); -- *rx++ = TOUPPER (c); -- *rx++ = ']'; -- } -- else -- *rx++ = c; -- } -- -- /* Copy any remaining literals from the syntax string into the rx. */ -- for(; * syn != 0 && rx <= rxbuf + (CGEN_MAX_RX_ELEMENTS - 7 - 4); ++syn) -- { -- if (CGEN_SYNTAX_CHAR_P (* syn)) -- { -- char c = CGEN_SYNTAX_CHAR (* syn); -- -- switch (c) -- { -- /* Escape any regex metacharacters in the syntax. */ -- case '.': case '[': case '\\': -- case '*': case '^': case '$': -- --#ifdef CGEN_ESCAPE_EXTENDED_REGEX -- case '?': case '{': case '}': -- case '(': case ')': case '*': -- case '|': case '+': case ']': --#endif -- *rx++ = '\\'; -- *rx++ = c; -- break; -- -- default: -- if (ISALPHA (c)) -- { -- *rx++ = '['; -- *rx++ = TOLOWER (c); -- *rx++ = TOUPPER (c); -- *rx++ = ']'; -- } -- else -- *rx++ = c; -- break; -- } -- } -- else -- { -- /* Replace non-syntax fields with globs. */ -- *rx++ = '.'; -- *rx++ = '*'; -- } -- } -- -- /* Trailing whitespace ok. */ -- * rx++ = '['; -- * rx++ = ' '; -- * rx++ = '\t'; -- * rx++ = ']'; -- * rx++ = '*'; -- -- /* But anchor it after that. */ -- * rx++ = '$'; -- * rx = '\0'; -- -- CGEN_INSN_RX (insn) = xmalloc (sizeof (regex_t)); -- reg_err = regcomp ((regex_t *) CGEN_INSN_RX (insn), rxbuf, REG_NOSUB); -- -- if (reg_err == 0) -- return NULL; -- else -- { -- static char msg[80]; -- -- regerror (reg_err, (regex_t *) CGEN_INSN_RX (insn), msg, 80); -- regfree ((regex_t *) CGEN_INSN_RX (insn)); -- free (CGEN_INSN_RX (insn)); -- (CGEN_INSN_RX (insn)) = NULL; -- return msg; -- } --} -- -- --/* Default insn parser. -- -- The syntax string is scanned and operands are parsed and stored in FIELDS. -- Relocs are queued as we go via other callbacks. -- -- ??? Note that this is currently an all-or-nothing parser. If we fail to -- parse the instruction, we return 0 and the caller will start over from -- the beginning. Backtracking will be necessary in parsing subexpressions, -- but that can be handled there. Not handling backtracking here may get -- expensive in the case of the m68k. Deal with later. -- -- Returns NULL for success, an error message for failure. */ -- --static const char * --parse_insn_normal (CGEN_CPU_DESC cd, -- const CGEN_INSN *insn, -- const char **strp, -- CGEN_FIELDS *fields) --{ -- /* ??? Runtime added insns not handled yet. */ -- const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn); -- const char *str = *strp; -- const char *errmsg; -- const char *p; -- const CGEN_SYNTAX_CHAR_TYPE * syn; --#ifdef CGEN_MNEMONIC_OPERANDS -- /* FIXME: wip */ -- int past_opcode_p; --#endif -- -- /* For now we assume the mnemonic is first (there are no leading operands). -- We can parse it without needing to set up operand parsing. -- GAS's input scrubber will ensure mnemonics are lowercase, but we may -- not be called from GAS. */ -- p = CGEN_INSN_MNEMONIC (insn); -- while (*p && TOLOWER (*p) == TOLOWER (*str)) -- ++p, ++str; -- -- if (* p) -- return _("unrecognized instruction"); -- --#ifndef CGEN_MNEMONIC_OPERANDS -- if (* str && ! ISSPACE (* str)) -- return _("unrecognized instruction"); --#endif -- -- CGEN_INIT_PARSE (cd); -- cgen_init_parse_operand (cd); --#ifdef CGEN_MNEMONIC_OPERANDS -- past_opcode_p = 0; --#endif -- -- /* We don't check for (*str != '\0') here because we want to parse -- any trailing fake arguments in the syntax string. */ -- syn = CGEN_SYNTAX_STRING (syntax); -- -- /* Mnemonics come first for now, ensure valid string. */ -- if (! CGEN_SYNTAX_MNEMONIC_P (* syn)) -- abort (); -- -- ++syn; -- -- while (* syn != 0) -- { -- /* Non operand chars must match exactly. */ -- if (CGEN_SYNTAX_CHAR_P (* syn)) -- { -- /* FIXME: While we allow for non-GAS callers above, we assume the -- first char after the mnemonic part is a space. */ -- /* FIXME: We also take inappropriate advantage of the fact that -- GAS's input scrubber will remove extraneous blanks. */ -- if (TOLOWER (*str) == TOLOWER (CGEN_SYNTAX_CHAR (* syn))) -- { --#ifdef CGEN_MNEMONIC_OPERANDS -- if (CGEN_SYNTAX_CHAR(* syn) == ' ') -- past_opcode_p = 1; --#endif -- ++ syn; -- ++ str; -- } -- else if (*str) -- { -- /* Syntax char didn't match. Can't be this insn. */ -- static char msg [80]; -- -- /* xgettext:c-format */ -- sprintf (msg, _("syntax error (expected char `%c', found `%c')"), -- CGEN_SYNTAX_CHAR(*syn), *str); -- return msg; -- } -- else -- { -- /* Ran out of input. */ -- static char msg [80]; -- -- /* xgettext:c-format */ -- sprintf (msg, _("syntax error (expected char `%c', found end of instruction)"), -- CGEN_SYNTAX_CHAR(*syn)); -- return msg; -- } -- continue; -- } -- --#ifdef CGEN_MNEMONIC_OPERANDS -- (void) past_opcode_p; --#endif -- /* We have an operand of some sort. */ -- errmsg = cd->parse_operand (cd, CGEN_SYNTAX_FIELD (*syn), &str, fields); -- if (errmsg) -- return errmsg; -- -- /* Done with this operand, continue with next one. */ -- ++ syn; -- } -- -- /* If we're at the end of the syntax string, we're done. */ -- if (* syn == 0) -- { -- /* FIXME: For the moment we assume a valid `str' can only contain -- blanks now. IE: We needn't try again with a longer version of -- the insn and it is assumed that longer versions of insns appear -- before shorter ones (eg: lsr r2,r3,1 vs lsr r2,r3). */ -- while (ISSPACE (* str)) -- ++ str; -- -- if (* str != '\0') -- return _("junk at end of line"); /* FIXME: would like to include `str' */ -- -- return NULL; -- } -- -- /* We couldn't parse it. */ -- return _("unrecognized instruction"); --} -- --/* Main entry point. -- This routine is called for each instruction to be assembled. -- STR points to the insn to be assembled. -- We assume all necessary tables have been initialized. -- The assembled instruction, less any fixups, is stored in BUF. -- Remember that if CGEN_INT_INSN_P then BUF is an int and thus the value -- still needs to be converted to target byte order, otherwise BUF is an array -- of bytes in target byte order. -- The result is a pointer to the insn's entry in the opcode table, -- or NULL if an error occured (an error message will have already been -- printed). -- -- Note that when processing (non-alias) macro-insns, -- this function recurses. -- -- ??? It's possible to make this cpu-independent. -- One would have to deal with a few minor things. -- At this point in time doing so would be more of a curiosity than useful -- [for example this file isn't _that_ big], but keeping the possibility in -- mind helps keep the design clean. */ -- --const CGEN_INSN * --openrisc_cgen_assemble_insn (CGEN_CPU_DESC cd, -- const char *str, -- CGEN_FIELDS *fields, -- CGEN_INSN_BYTES_PTR buf, -- char **errmsg) --{ -- const char *start; -- CGEN_INSN_LIST *ilist; -- const char *parse_errmsg = NULL; -- const char *insert_errmsg = NULL; -- int recognized_mnemonic = 0; -- -- /* Skip leading white space. */ -- while (ISSPACE (* str)) -- ++ str; -- -- /* The instructions are stored in hashed lists. -- Get the first in the list. */ -- ilist = CGEN_ASM_LOOKUP_INSN (cd, str); -- -- /* Keep looking until we find a match. */ -- start = str; -- for ( ; ilist != NULL ; ilist = CGEN_ASM_NEXT_INSN (ilist)) -- { -- const CGEN_INSN *insn = ilist->insn; -- recognized_mnemonic = 1; -- --#ifdef CGEN_VALIDATE_INSN_SUPPORTED -- /* Not usually needed as unsupported opcodes -- shouldn't be in the hash lists. */ -- /* Is this insn supported by the selected cpu? */ -- if (! openrisc_cgen_insn_supported (cd, insn)) -- continue; --#endif -- /* If the RELAXED attribute is set, this is an insn that shouldn't be -- chosen immediately. Instead, it is used during assembler/linker -- relaxation if possible. */ -- if (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_RELAXED) != 0) -- continue; -- -- str = start; -- -- /* Skip this insn if str doesn't look right lexically. */ -- if (CGEN_INSN_RX (insn) != NULL && -- regexec ((regex_t *) CGEN_INSN_RX (insn), str, 0, NULL, 0) == REG_NOMATCH) -- continue; -- -- /* Allow parse/insert handlers to obtain length of insn. */ -- CGEN_FIELDS_BITSIZE (fields) = CGEN_INSN_BITSIZE (insn); -- -- parse_errmsg = CGEN_PARSE_FN (cd, insn) (cd, insn, & str, fields); -- if (parse_errmsg != NULL) -- continue; -- -- /* ??? 0 is passed for `pc'. */ -- insert_errmsg = CGEN_INSERT_FN (cd, insn) (cd, insn, fields, buf, -- (bfd_vma) 0); -- if (insert_errmsg != NULL) -- continue; -- -- /* It is up to the caller to actually output the insn and any -- queued relocs. */ -- return insn; -- } -- -- { -- static char errbuf[150]; -- const char *tmp_errmsg; --#ifdef CGEN_VERBOSE_ASSEMBLER_ERRORS --#define be_verbose 1 --#else --#define be_verbose 0 --#endif -- -- if (be_verbose) -- { -- /* If requesting verbose error messages, use insert_errmsg. -- Failing that, use parse_errmsg. */ -- tmp_errmsg = (insert_errmsg ? insert_errmsg : -- parse_errmsg ? parse_errmsg : -- recognized_mnemonic ? -- _("unrecognized form of instruction") : -- _("unrecognized instruction")); -- -- if (strlen (start) > 50) -- /* xgettext:c-format */ -- sprintf (errbuf, "%s `%.50s...'", tmp_errmsg, start); -- else -- /* xgettext:c-format */ -- sprintf (errbuf, "%s `%.50s'", tmp_errmsg, start); -- } -- else -- { -- if (strlen (start) > 50) -- /* xgettext:c-format */ -- sprintf (errbuf, _("bad instruction `%.50s...'"), start); -- else -- /* xgettext:c-format */ -- sprintf (errbuf, _("bad instruction `%.50s'"), start); -- } -- -- *errmsg = errbuf; -- return NULL; -- } --} -diff -rNU3 dist.orig/opcodes/openrisc-desc.c dist/opcodes/openrisc-desc.c ---- dist.orig/opcodes/openrisc-desc.c 2010-02-12 04:25:49.000000000 +0100 -+++ dist/opcodes/openrisc-desc.c 1970-01-01 01:00:00.000000000 +0100 -@@ -1,1018 +0,0 @@ --/* CPU data for openrisc. -- --THIS FILE IS MACHINE GENERATED WITH CGEN. -- --Copyright 1996-2010 Free Software Foundation, Inc. -- --This file is part of the GNU Binutils and/or GDB, the GNU debugger. -- -- This file is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3, or (at your option) -- any later version. -- -- It is distributed in the hope that it will be useful, but WITHOUT -- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- License for more details. -- -- You should have received a copy of the GNU General Public License along -- with this program; if not, write to the Free Software Foundation, Inc., -- 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. -- --*/ -- --#include "sysdep.h" --#include --#include --#include "ansidecl.h" --#include "bfd.h" --#include "symcat.h" --#include "openrisc-desc.h" --#include "openrisc-opc.h" --#include "opintl.h" --#include "libiberty.h" --#include "xregex.h" -- --/* Attributes. */ -- --static const CGEN_ATTR_ENTRY bool_attr[] = --{ -- { "#f", 0 }, -- { "#t", 1 }, -- { 0, 0 } --}; -- --static const CGEN_ATTR_ENTRY MACH_attr[] ATTRIBUTE_UNUSED = --{ -- { "base", MACH_BASE }, -- { "openrisc", MACH_OPENRISC }, -- { "or1300", MACH_OR1300 }, -- { "max", MACH_MAX }, -- { 0, 0 } --}; -- --static const CGEN_ATTR_ENTRY ISA_attr[] ATTRIBUTE_UNUSED = --{ -- { "or32", ISA_OR32 }, -- { "max", ISA_MAX }, -- { 0, 0 } --}; -- --static const CGEN_ATTR_ENTRY HAS_CACHE_attr[] ATTRIBUTE_UNUSED = --{ -- { "DATA_CACHE", HAS_CACHE_DATA_CACHE }, -- { "INSN_CACHE", HAS_CACHE_INSN_CACHE }, -- { 0, 0 } --}; -- --const CGEN_ATTR_TABLE openrisc_cgen_ifield_attr_table[] = --{ -- { "MACH", & MACH_attr[0], & MACH_attr[0] }, -- { "VIRTUAL", &bool_attr[0], &bool_attr[0] }, -- { "PCREL-ADDR", &bool_attr[0], &bool_attr[0] }, -- { "ABS-ADDR", &bool_attr[0], &bool_attr[0] }, -- { "RESERVED", &bool_attr[0], &bool_attr[0] }, -- { "SIGN-OPT", &bool_attr[0], &bool_attr[0] }, -- { "SIGNED", &bool_attr[0], &bool_attr[0] }, -- { 0, 0, 0 } --}; -- --const CGEN_ATTR_TABLE openrisc_cgen_hardware_attr_table[] = --{ -- { "MACH", & MACH_attr[0], & MACH_attr[0] }, -- { "VIRTUAL", &bool_attr[0], &bool_attr[0] }, -- { "CACHE-ADDR", &bool_attr[0], &bool_attr[0] }, -- { "PC", &bool_attr[0], &bool_attr[0] }, -- { "PROFILE", &bool_attr[0], &bool_attr[0] }, -- { 0, 0, 0 } --}; -- --const CGEN_ATTR_TABLE openrisc_cgen_operand_attr_table[] = --{ -- { "MACH", & MACH_attr[0], & MACH_attr[0] }, -- { "VIRTUAL", &bool_attr[0], &bool_attr[0] }, -- { "PCREL-ADDR", &bool_attr[0], &bool_attr[0] }, -- { "ABS-ADDR", &bool_attr[0], &bool_attr[0] }, -- { "SIGN-OPT", &bool_attr[0], &bool_attr[0] }, -- { "SIGNED", &bool_attr[0], &bool_attr[0] }, -- { "NEGATIVE", &bool_attr[0], &bool_attr[0] }, -- { "RELAX", &bool_attr[0], &bool_attr[0] }, -- { "SEM-ONLY", &bool_attr[0], &bool_attr[0] }, -- { 0, 0, 0 } --}; -- --const CGEN_ATTR_TABLE openrisc_cgen_insn_attr_table[] = --{ -- { "MACH", & MACH_attr[0], & MACH_attr[0] }, -- { "ALIAS", &bool_attr[0], &bool_attr[0] }, -- { "VIRTUAL", &bool_attr[0], &bool_attr[0] }, -- { "UNCOND-CTI", &bool_attr[0], &bool_attr[0] }, -- { "COND-CTI", &bool_attr[0], &bool_attr[0] }, -- { "SKIP-CTI", &bool_attr[0], &bool_attr[0] }, -- { "DELAY-SLOT", &bool_attr[0], &bool_attr[0] }, -- { "RELAXABLE", &bool_attr[0], &bool_attr[0] }, -- { "RELAXED", &bool_attr[0], &bool_attr[0] }, -- { "NO-DIS", &bool_attr[0], &bool_attr[0] }, -- { "PBB", &bool_attr[0], &bool_attr[0] }, -- { "NOT-IN-DELAY-SLOT", &bool_attr[0], &bool_attr[0] }, -- { 0, 0, 0 } --}; -- --/* Instruction set variants. */ -- --static const CGEN_ISA openrisc_cgen_isa_table[] = { -- { "or32", 32, 32, 32, 32 }, -- { 0, 0, 0, 0, 0 } --}; -- --/* Machine variants. */ -- --static const CGEN_MACH openrisc_cgen_mach_table[] = { -- { "openrisc", "openrisc", MACH_OPENRISC, 0 }, -- { "or1300", "openrisc:1300", MACH_OR1300, 0 }, -- { 0, 0, 0, 0 } --}; -- --static CGEN_KEYWORD_ENTRY openrisc_cgen_opval_h_gr_entries[] = --{ -- { "r0", 0, {0, {{{0, 0}}}}, 0, 0 }, -- { "r1", 1, {0, {{{0, 0}}}}, 0, 0 }, -- { "r2", 2, {0, {{{0, 0}}}}, 0, 0 }, -- { "r3", 3, {0, {{{0, 0}}}}, 0, 0 }, -- { "r4", 4, {0, {{{0, 0}}}}, 0, 0 }, -- { "r5", 5, {0, {{{0, 0}}}}, 0, 0 }, -- { "r6", 6, {0, {{{0, 0}}}}, 0, 0 }, -- { "r7", 7, {0, {{{0, 0}}}}, 0, 0 }, -- { "r8", 8, {0, {{{0, 0}}}}, 0, 0 }, -- { "r9", 9, {0, {{{0, 0}}}}, 0, 0 }, -- { "r10", 10, {0, {{{0, 0}}}}, 0, 0 }, -- { "r11", 11, {0, {{{0, 0}}}}, 0, 0 }, -- { "r12", 12, {0, {{{0, 0}}}}, 0, 0 }, -- { "r13", 13, {0, {{{0, 0}}}}, 0, 0 }, -- { "r14", 14, {0, {{{0, 0}}}}, 0, 0 }, -- { "r15", 15, {0, {{{0, 0}}}}, 0, 0 }, -- { "r16", 16, {0, {{{0, 0}}}}, 0, 0 }, -- { "r17", 17, {0, {{{0, 0}}}}, 0, 0 }, -- { "r18", 18, {0, {{{0, 0}}}}, 0, 0 }, -- { "r19", 19, {0, {{{0, 0}}}}, 0, 0 }, -- { "r20", 20, {0, {{{0, 0}}}}, 0, 0 }, -- { "r21", 21, {0, {{{0, 0}}}}, 0, 0 }, -- { "r22", 22, {0, {{{0, 0}}}}, 0, 0 }, -- { "r23", 23, {0, {{{0, 0}}}}, 0, 0 }, -- { "r24", 24, {0, {{{0, 0}}}}, 0, 0 }, -- { "r25", 25, {0, {{{0, 0}}}}, 0, 0 }, -- { "r26", 26, {0, {{{0, 0}}}}, 0, 0 }, -- { "r27", 27, {0, {{{0, 0}}}}, 0, 0 }, -- { "r28", 28, {0, {{{0, 0}}}}, 0, 0 }, -- { "r29", 29, {0, {{{0, 0}}}}, 0, 0 }, -- { "r30", 30, {0, {{{0, 0}}}}, 0, 0 }, -- { "r31", 31, {0, {{{0, 0}}}}, 0, 0 }, -- { "lr", 11, {0, {{{0, 0}}}}, 0, 0 }, -- { "sp", 1, {0, {{{0, 0}}}}, 0, 0 }, -- { "fp", 2, {0, {{{0, 0}}}}, 0, 0 } --}; -- --CGEN_KEYWORD openrisc_cgen_opval_h_gr = --{ -- & openrisc_cgen_opval_h_gr_entries[0], -- 35, -- 0, 0, 0, 0, "" --}; -- -- --/* The hardware table. */ -- --#define A(a) (1 << CGEN_HW_##a) -- --const CGEN_HW_ENTRY openrisc_cgen_hw_table[] = --{ -- { "h-memory", HW_H_MEMORY, CGEN_ASM_NONE, 0, { 0, { { { (1<name) -- { -- if (strcmp (name, table->bfd_name) == 0) -- return table; -- ++table; -- } -- abort (); --} -- --/* Subroutine of openrisc_cgen_cpu_open to build the hardware table. */ -- --static void --build_hw_table (CGEN_CPU_TABLE *cd) --{ -- int i; -- int machs = cd->machs; -- const CGEN_HW_ENTRY *init = & openrisc_cgen_hw_table[0]; -- /* MAX_HW is only an upper bound on the number of selected entries. -- However each entry is indexed by it's enum so there can be holes in -- the table. */ -- const CGEN_HW_ENTRY **selected = -- (const CGEN_HW_ENTRY **) xmalloc (MAX_HW * sizeof (CGEN_HW_ENTRY *)); -- -- cd->hw_table.init_entries = init; -- cd->hw_table.entry_size = sizeof (CGEN_HW_ENTRY); -- memset (selected, 0, MAX_HW * sizeof (CGEN_HW_ENTRY *)); -- /* ??? For now we just use machs to determine which ones we want. */ -- for (i = 0; init[i].name != NULL; ++i) -- if (CGEN_HW_ATTR_VALUE (&init[i], CGEN_HW_MACH) -- & machs) -- selected[init[i].type] = &init[i]; -- cd->hw_table.entries = selected; -- cd->hw_table.num_entries = MAX_HW; --} -- --/* Subroutine of openrisc_cgen_cpu_open to build the hardware table. */ -- --static void --build_ifield_table (CGEN_CPU_TABLE *cd) --{ -- cd->ifld_table = & openrisc_cgen_ifld_table[0]; --} -- --/* Subroutine of openrisc_cgen_cpu_open to build the hardware table. */ -- --static void --build_operand_table (CGEN_CPU_TABLE *cd) --{ -- int i; -- int machs = cd->machs; -- const CGEN_OPERAND *init = & openrisc_cgen_operand_table[0]; -- /* MAX_OPERANDS is only an upper bound on the number of selected entries. -- However each entry is indexed by it's enum so there can be holes in -- the table. */ -- const CGEN_OPERAND **selected = xmalloc (MAX_OPERANDS * sizeof (* selected)); -- -- cd->operand_table.init_entries = init; -- cd->operand_table.entry_size = sizeof (CGEN_OPERAND); -- memset (selected, 0, MAX_OPERANDS * sizeof (CGEN_OPERAND *)); -- /* ??? For now we just use mach to determine which ones we want. */ -- for (i = 0; init[i].name != NULL; ++i) -- if (CGEN_OPERAND_ATTR_VALUE (&init[i], CGEN_OPERAND_MACH) -- & machs) -- selected[init[i].type] = &init[i]; -- cd->operand_table.entries = selected; -- cd->operand_table.num_entries = MAX_OPERANDS; --} -- --/* Subroutine of openrisc_cgen_cpu_open to build the hardware table. -- ??? This could leave out insns not supported by the specified mach/isa, -- but that would cause errors like "foo only supported by bar" to become -- "unknown insn", so for now we include all insns and require the app to -- do the checking later. -- ??? On the other hand, parsing of such insns may require their hardware or -- operand elements to be in the table [which they mightn't be]. */ -- --static void --build_insn_table (CGEN_CPU_TABLE *cd) --{ -- int i; -- const CGEN_IBASE *ib = & openrisc_cgen_insn_table[0]; -- CGEN_INSN *insns = xmalloc (MAX_INSNS * sizeof (CGEN_INSN)); -- -- memset (insns, 0, MAX_INSNS * sizeof (CGEN_INSN)); -- for (i = 0; i < MAX_INSNS; ++i) -- insns[i].base = &ib[i]; -- cd->insn_table.init_entries = insns; -- cd->insn_table.entry_size = sizeof (CGEN_IBASE); -- cd->insn_table.num_init_entries = MAX_INSNS; --} -- --/* Subroutine of openrisc_cgen_cpu_open to rebuild the tables. */ -- --static void --openrisc_cgen_rebuild_tables (CGEN_CPU_TABLE *cd) --{ -- int i; -- CGEN_BITSET *isas = cd->isas; -- unsigned int machs = cd->machs; -- -- cd->int_insn_p = CGEN_INT_INSN_P; -- -- /* Data derived from the isa spec. */ --#define UNSET (CGEN_SIZE_UNKNOWN + 1) -- cd->default_insn_bitsize = UNSET; -- cd->base_insn_bitsize = UNSET; -- cd->min_insn_bitsize = 65535; /* Some ridiculously big number. */ -- cd->max_insn_bitsize = 0; -- for (i = 0; i < MAX_ISAS; ++i) -- if (cgen_bitset_contains (isas, i)) -- { -- const CGEN_ISA *isa = & openrisc_cgen_isa_table[i]; -- -- /* Default insn sizes of all selected isas must be -- equal or we set the result to 0, meaning "unknown". */ -- if (cd->default_insn_bitsize == UNSET) -- cd->default_insn_bitsize = isa->default_insn_bitsize; -- else if (isa->default_insn_bitsize == cd->default_insn_bitsize) -- ; /* This is ok. */ -- else -- cd->default_insn_bitsize = CGEN_SIZE_UNKNOWN; -- -- /* Base insn sizes of all selected isas must be equal -- or we set the result to 0, meaning "unknown". */ -- if (cd->base_insn_bitsize == UNSET) -- cd->base_insn_bitsize = isa->base_insn_bitsize; -- else if (isa->base_insn_bitsize == cd->base_insn_bitsize) -- ; /* This is ok. */ -- else -- cd->base_insn_bitsize = CGEN_SIZE_UNKNOWN; -- -- /* Set min,max insn sizes. */ -- if (isa->min_insn_bitsize < cd->min_insn_bitsize) -- cd->min_insn_bitsize = isa->min_insn_bitsize; -- if (isa->max_insn_bitsize > cd->max_insn_bitsize) -- cd->max_insn_bitsize = isa->max_insn_bitsize; -- } -- -- /* Data derived from the mach spec. */ -- for (i = 0; i < MAX_MACHS; ++i) -- if (((1 << i) & machs) != 0) -- { -- const CGEN_MACH *mach = & openrisc_cgen_mach_table[i]; -- -- if (mach->insn_chunk_bitsize != 0) -- { -- if (cd->insn_chunk_bitsize != 0 && cd->insn_chunk_bitsize != mach->insn_chunk_bitsize) -- { -- fprintf (stderr, "openrisc_cgen_rebuild_tables: conflicting insn-chunk-bitsize values: `%d' vs. `%d'\n", -- cd->insn_chunk_bitsize, mach->insn_chunk_bitsize); -- abort (); -- } -- -- cd->insn_chunk_bitsize = mach->insn_chunk_bitsize; -- } -- } -- -- /* Determine which hw elements are used by MACH. */ -- build_hw_table (cd); -- -- /* Build the ifield table. */ -- build_ifield_table (cd); -- -- /* Determine which operands are used by MACH/ISA. */ -- build_operand_table (cd); -- -- /* Build the instruction table. */ -- build_insn_table (cd); --} -- --/* Initialize a cpu table and return a descriptor. -- It's much like opening a file, and must be the first function called. -- The arguments are a set of (type/value) pairs, terminated with -- CGEN_CPU_OPEN_END. -- -- Currently supported values: -- CGEN_CPU_OPEN_ISAS: bitmap of values in enum isa_attr -- CGEN_CPU_OPEN_MACHS: bitmap of values in enum mach_attr -- CGEN_CPU_OPEN_BFDMACH: specify 1 mach using bfd name -- CGEN_CPU_OPEN_ENDIAN: specify endian choice -- CGEN_CPU_OPEN_END: terminates arguments -- -- ??? Simultaneous multiple isas might not make sense, but it's not (yet) -- precluded. */ -- --CGEN_CPU_DESC --openrisc_cgen_cpu_open (enum cgen_cpu_open_arg arg_type, ...) --{ -- CGEN_CPU_TABLE *cd = (CGEN_CPU_TABLE *) xmalloc (sizeof (CGEN_CPU_TABLE)); -- static int init_p; -- CGEN_BITSET *isas = 0; /* 0 = "unspecified" */ -- unsigned int machs = 0; /* 0 = "unspecified" */ -- enum cgen_endian endian = CGEN_ENDIAN_UNKNOWN; -- va_list ap; -- -- if (! init_p) -- { -- init_tables (); -- init_p = 1; -- } -- -- memset (cd, 0, sizeof (*cd)); -- -- va_start (ap, arg_type); -- while (arg_type != CGEN_CPU_OPEN_END) -- { -- switch (arg_type) -- { -- case CGEN_CPU_OPEN_ISAS : -- isas = va_arg (ap, CGEN_BITSET *); -- break; -- case CGEN_CPU_OPEN_MACHS : -- machs = va_arg (ap, unsigned int); -- break; -- case CGEN_CPU_OPEN_BFDMACH : -- { -- const char *name = va_arg (ap, const char *); -- const CGEN_MACH *mach = -- lookup_mach_via_bfd_name (openrisc_cgen_mach_table, name); -- -- machs |= 1 << mach->num; -- break; -- } -- case CGEN_CPU_OPEN_ENDIAN : -- endian = va_arg (ap, enum cgen_endian); -- break; -- default : -- fprintf (stderr, "openrisc_cgen_cpu_open: unsupported argument `%d'\n", -- arg_type); -- abort (); /* ??? return NULL? */ -- } -- arg_type = va_arg (ap, enum cgen_cpu_open_arg); -- } -- va_end (ap); -- -- /* Mach unspecified means "all". */ -- if (machs == 0) -- machs = (1 << MAX_MACHS) - 1; -- /* Base mach is always selected. */ -- machs |= 1; -- if (endian == CGEN_ENDIAN_UNKNOWN) -- { -- /* ??? If target has only one, could have a default. */ -- fprintf (stderr, "openrisc_cgen_cpu_open: no endianness specified\n"); -- abort (); -- } -- -- cd->isas = cgen_bitset_copy (isas); -- cd->machs = machs; -- cd->endian = endian; -- /* FIXME: for the sparc case we can determine insn-endianness statically. -- The worry here is where both data and insn endian can be independently -- chosen, in which case this function will need another argument. -- Actually, will want to allow for more arguments in the future anyway. */ -- cd->insn_endian = endian; -- -- /* Table (re)builder. */ -- cd->rebuild_tables = openrisc_cgen_rebuild_tables; -- openrisc_cgen_rebuild_tables (cd); -- -- /* Default to not allowing signed overflow. */ -- cd->signed_overflow_ok_p = 0; -- -- return (CGEN_CPU_DESC) cd; --} -- --/* Cover fn to openrisc_cgen_cpu_open to handle the simple case of 1 isa, 1 mach. -- MACH_NAME is the bfd name of the mach. */ -- --CGEN_CPU_DESC --openrisc_cgen_cpu_open_1 (const char *mach_name, enum cgen_endian endian) --{ -- return openrisc_cgen_cpu_open (CGEN_CPU_OPEN_BFDMACH, mach_name, -- CGEN_CPU_OPEN_ENDIAN, endian, -- CGEN_CPU_OPEN_END); --} -- --/* Close a cpu table. -- ??? This can live in a machine independent file, but there's currently -- no place to put this file (there's no libcgen). libopcodes is the wrong -- place as some simulator ports use this but they don't use libopcodes. */ -- --void --openrisc_cgen_cpu_close (CGEN_CPU_DESC cd) --{ -- unsigned int i; -- const CGEN_INSN *insns; -- -- if (cd->macro_insn_table.init_entries) -- { -- insns = cd->macro_insn_table.init_entries; -- for (i = 0; i < cd->macro_insn_table.num_init_entries; ++i, ++insns) -- if (CGEN_INSN_RX ((insns))) -- regfree (CGEN_INSN_RX (insns)); -- } -- -- if (cd->insn_table.init_entries) -- { -- insns = cd->insn_table.init_entries; -- for (i = 0; i < cd->insn_table.num_init_entries; ++i, ++insns) -- if (CGEN_INSN_RX (insns)) -- regfree (CGEN_INSN_RX (insns)); -- } -- -- if (cd->macro_insn_table.init_entries) -- free ((CGEN_INSN *) cd->macro_insn_table.init_entries); -- -- if (cd->insn_table.init_entries) -- free ((CGEN_INSN *) cd->insn_table.init_entries); -- -- if (cd->hw_table.entries) -- free ((CGEN_HW_ENTRY *) cd->hw_table.entries); -- -- if (cd->operand_table.entries) -- free ((CGEN_HW_ENTRY *) cd->operand_table.entries); -- -- free (cd); --} -- -diff -rNU3 dist.orig/opcodes/openrisc-desc.h dist/opcodes/openrisc-desc.h ---- dist.orig/opcodes/openrisc-desc.h 2010-10-09 08:50:23.000000000 +0200 -+++ dist/opcodes/openrisc-desc.h 1970-01-01 01:00:00.000000000 +0100 -@@ -1,288 +0,0 @@ --/* CPU data header for openrisc. -- --THIS FILE IS MACHINE GENERATED WITH CGEN. -- --Copyright 1996-2010 Free Software Foundation, Inc. -- --This file is part of the GNU Binutils and/or GDB, the GNU debugger. -- -- This file is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3, or (at your option) -- any later version. -- -- It is distributed in the hope that it will be useful, but WITHOUT -- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- License for more details. -- -- You should have received a copy of the GNU General Public License along -- with this program; if not, write to the Free Software Foundation, Inc., -- 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. -- --*/ -- --#ifndef OPENRISC_CPU_H --#define OPENRISC_CPU_H -- --#define CGEN_ARCH openrisc -- --/* Given symbol S, return openrisc_cgen_. */ --#define CGEN_SYM(s) openrisc##_cgen_##s -- -- --/* Selected cpu families. */ --#define HAVE_CPU_OPENRISCBF -- --#define CGEN_INSN_LSB0_P 1 -- --/* Minimum size of any insn (in bytes). */ --#define CGEN_MIN_INSN_SIZE 4 -- --/* Maximum size of any insn (in bytes). */ --#define CGEN_MAX_INSN_SIZE 4 -- --#define CGEN_INT_INSN_P 1 -- --/* Maximum number of syntax elements in an instruction. */ --#define CGEN_ACTUAL_MAX_SYNTAX_ELEMENTS 14 -- --/* CGEN_MNEMONIC_OPERANDS is defined if mnemonics have operands. -- e.g. In "b,a foo" the ",a" is an operand. If mnemonics have operands -- we can't hash on everything up to the space. */ --#define CGEN_MNEMONIC_OPERANDS -- --/* Maximum number of fields in an instruction. */ --#define CGEN_ACTUAL_MAX_IFMT_OPERANDS 9 -- --/* Enums. */ -- --/* Enum declaration for exception vectors. */ --typedef enum e_exception { -- E_RESET, E_BUSERR, E_DPF, E_IPF -- , E_EXTINT, E_ALIGN, E_ILLEGAL, E_PEINT -- , E_DTLBMISS, E_ITLBMISS, E_RRANGE, E_SYSCALL -- , E_BREAK, E_RESERVED --} E_EXCEPTION; -- --/* Enum declaration for FIXME. */ --typedef enum insn_class { -- OP1_0, OP1_1, OP1_2, OP1_3 --} INSN_CLASS; -- --/* Enum declaration for FIXME. */ --typedef enum insn_sub { -- OP2_0, OP2_1, OP2_2, OP2_3 -- , OP2_4, OP2_5, OP2_6, OP2_7 -- , OP2_8, OP2_9, OP2_10, OP2_11 -- , OP2_12, OP2_13, OP2_14, OP2_15 --} INSN_SUB; -- --/* Enum declaration for FIXME. */ --typedef enum insn_op3 { -- OP3_0, OP3_1, OP3_2, OP3_3 --} INSN_OP3; -- --/* Enum declaration for FIXME. */ --typedef enum insn_op4 { -- OP4_0, OP4_1, OP4_2, OP4_3 -- , OP4_4, OP4_5, OP4_6, OP4_7 --} INSN_OP4; -- --/* Enum declaration for FIXME. */ --typedef enum insn_op5 { -- OP5_0, OP5_1, OP5_2, OP5_3 -- , OP5_4, OP5_5, OP5_6, OP5_7 -- , OP5_8, OP5_9, OP5_10, OP5_11 -- , OP5_12, OP5_13, OP5_14, OP5_15 -- , OP5_16, OP5_17, OP5_18, OP5_19 -- , OP5_20, OP5_21, OP5_22, OP5_23 -- , OP5_24, OP5_25, OP5_26, OP5_27 -- , OP5_28, OP5_29, OP5_30, OP5_31 --} INSN_OP5; -- --/* Enum declaration for FIXME. */ --typedef enum insn_op6 { -- OP6_0, OP6_1, OP6_2, OP6_3 -- , OP6_4, OP6_5, OP6_6, OP6_7 --} INSN_OP6; -- --/* Enum declaration for FIXME. */ --typedef enum insn_op7 { -- OP7_0, OP7_1, OP7_2, OP7_3 -- , OP7_4, OP7_5, OP7_6, OP7_7 -- , OP7_8, OP7_9, OP7_10, OP7_11 -- , OP7_12, OP7_13, OP7_14, OP7_15 --} INSN_OP7; -- --/* Attributes. */ -- --/* Enum declaration for machine type selection. */ --typedef enum mach_attr { -- MACH_BASE, MACH_OPENRISC, MACH_OR1300, MACH_MAX --} MACH_ATTR; -- --/* Enum declaration for instruction set selection. */ --typedef enum isa_attr { -- ISA_OR32, ISA_MAX --} ISA_ATTR; -- --/* Enum declaration for if this model has caches. */ --typedef enum has_cache_attr { -- HAS_CACHE_DATA_CACHE, HAS_CACHE_INSN_CACHE --} HAS_CACHE_ATTR; -- --/* Number of architecture variants. */ --#define MAX_ISAS 1 --#define MAX_MACHS ((int) MACH_MAX) -- --/* Ifield support. */ -- --/* Ifield attribute indices. */ -- --/* Enum declaration for cgen_ifld attrs. */ --typedef enum cgen_ifld_attr { -- CGEN_IFLD_VIRTUAL, CGEN_IFLD_PCREL_ADDR, CGEN_IFLD_ABS_ADDR, CGEN_IFLD_RESERVED -- , CGEN_IFLD_SIGN_OPT, CGEN_IFLD_SIGNED, CGEN_IFLD_END_BOOLS, CGEN_IFLD_START_NBOOLS = 31 -- , CGEN_IFLD_MACH, CGEN_IFLD_END_NBOOLS --} CGEN_IFLD_ATTR; -- --/* Number of non-boolean elements in cgen_ifld_attr. */ --#define CGEN_IFLD_NBOOL_ATTRS (CGEN_IFLD_END_NBOOLS - CGEN_IFLD_START_NBOOLS - 1) -- --/* cgen_ifld attribute accessor macros. */ --#define CGEN_ATTR_CGEN_IFLD_MACH_VALUE(attrs) ((attrs)->nonbool[CGEN_IFLD_MACH-CGEN_IFLD_START_NBOOLS-1].nonbitset) --#define CGEN_ATTR_CGEN_IFLD_VIRTUAL_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_IFLD_VIRTUAL)) != 0) --#define CGEN_ATTR_CGEN_IFLD_PCREL_ADDR_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_IFLD_PCREL_ADDR)) != 0) --#define CGEN_ATTR_CGEN_IFLD_ABS_ADDR_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_IFLD_ABS_ADDR)) != 0) --#define CGEN_ATTR_CGEN_IFLD_RESERVED_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_IFLD_RESERVED)) != 0) --#define CGEN_ATTR_CGEN_IFLD_SIGN_OPT_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_IFLD_SIGN_OPT)) != 0) --#define CGEN_ATTR_CGEN_IFLD_SIGNED_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_IFLD_SIGNED)) != 0) -- --/* Enum declaration for openrisc ifield types. */ --typedef enum ifield_type { -- OPENRISC_F_NIL, OPENRISC_F_ANYOF, OPENRISC_F_CLASS, OPENRISC_F_SUB -- , OPENRISC_F_R1, OPENRISC_F_R2, OPENRISC_F_R3, OPENRISC_F_SIMM16 -- , OPENRISC_F_UIMM16, OPENRISC_F_UIMM5, OPENRISC_F_HI16, OPENRISC_F_LO16 -- , OPENRISC_F_OP1, OPENRISC_F_OP2, OPENRISC_F_OP3, OPENRISC_F_OP4 -- , OPENRISC_F_OP5, OPENRISC_F_OP6, OPENRISC_F_OP7, OPENRISC_F_I16_1 -- , OPENRISC_F_I16_2, OPENRISC_F_DISP26, OPENRISC_F_ABS26, OPENRISC_F_I16NC -- , OPENRISC_F_F_15_8, OPENRISC_F_F_10_3, OPENRISC_F_F_4_1, OPENRISC_F_F_7_3 -- , OPENRISC_F_F_10_7, OPENRISC_F_F_10_11, OPENRISC_F_MAX --} IFIELD_TYPE; -- --#define MAX_IFLD ((int) OPENRISC_F_MAX) -- --/* Hardware attribute indices. */ -- --/* Enum declaration for cgen_hw attrs. */ --typedef enum cgen_hw_attr { -- CGEN_HW_VIRTUAL, CGEN_HW_CACHE_ADDR, CGEN_HW_PC, CGEN_HW_PROFILE -- , CGEN_HW_END_BOOLS, CGEN_HW_START_NBOOLS = 31, CGEN_HW_MACH, CGEN_HW_END_NBOOLS --} CGEN_HW_ATTR; -- --/* Number of non-boolean elements in cgen_hw_attr. */ --#define CGEN_HW_NBOOL_ATTRS (CGEN_HW_END_NBOOLS - CGEN_HW_START_NBOOLS - 1) -- --/* cgen_hw attribute accessor macros. */ --#define CGEN_ATTR_CGEN_HW_MACH_VALUE(attrs) ((attrs)->nonbool[CGEN_HW_MACH-CGEN_HW_START_NBOOLS-1].nonbitset) --#define CGEN_ATTR_CGEN_HW_VIRTUAL_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_HW_VIRTUAL)) != 0) --#define CGEN_ATTR_CGEN_HW_CACHE_ADDR_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_HW_CACHE_ADDR)) != 0) --#define CGEN_ATTR_CGEN_HW_PC_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_HW_PC)) != 0) --#define CGEN_ATTR_CGEN_HW_PROFILE_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_HW_PROFILE)) != 0) -- --/* Enum declaration for openrisc hardware types. */ --typedef enum cgen_hw_type { -- HW_H_MEMORY, HW_H_SINT, HW_H_UINT, HW_H_ADDR -- , HW_H_IADDR, HW_H_PC, HW_H_GR, HW_H_SR -- , HW_H_HI16, HW_H_LO16, HW_H_CBIT, HW_H_DELAY_INSN -- , HW_MAX --} CGEN_HW_TYPE; -- --#define MAX_HW ((int) HW_MAX) -- --/* Operand attribute indices. */ -- --/* Enum declaration for cgen_operand attrs. */ --typedef enum cgen_operand_attr { -- CGEN_OPERAND_VIRTUAL, CGEN_OPERAND_PCREL_ADDR, CGEN_OPERAND_ABS_ADDR, CGEN_OPERAND_SIGN_OPT -- , CGEN_OPERAND_SIGNED, CGEN_OPERAND_NEGATIVE, CGEN_OPERAND_RELAX, CGEN_OPERAND_SEM_ONLY -- , CGEN_OPERAND_END_BOOLS, CGEN_OPERAND_START_NBOOLS = 31, CGEN_OPERAND_MACH, CGEN_OPERAND_END_NBOOLS --} CGEN_OPERAND_ATTR; -- --/* Number of non-boolean elements in cgen_operand_attr. */ --#define CGEN_OPERAND_NBOOL_ATTRS (CGEN_OPERAND_END_NBOOLS - CGEN_OPERAND_START_NBOOLS - 1) -- --/* cgen_operand attribute accessor macros. */ --#define CGEN_ATTR_CGEN_OPERAND_MACH_VALUE(attrs) ((attrs)->nonbool[CGEN_OPERAND_MACH-CGEN_OPERAND_START_NBOOLS-1].nonbitset) --#define CGEN_ATTR_CGEN_OPERAND_VIRTUAL_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_OPERAND_VIRTUAL)) != 0) --#define CGEN_ATTR_CGEN_OPERAND_PCREL_ADDR_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_OPERAND_PCREL_ADDR)) != 0) --#define CGEN_ATTR_CGEN_OPERAND_ABS_ADDR_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_OPERAND_ABS_ADDR)) != 0) --#define CGEN_ATTR_CGEN_OPERAND_SIGN_OPT_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_OPERAND_SIGN_OPT)) != 0) --#define CGEN_ATTR_CGEN_OPERAND_SIGNED_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_OPERAND_SIGNED)) != 0) --#define CGEN_ATTR_CGEN_OPERAND_NEGATIVE_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_OPERAND_NEGATIVE)) != 0) --#define CGEN_ATTR_CGEN_OPERAND_RELAX_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_OPERAND_RELAX)) != 0) --#define CGEN_ATTR_CGEN_OPERAND_SEM_ONLY_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_OPERAND_SEM_ONLY)) != 0) -- --/* Enum declaration for openrisc operand types. */ --typedef enum cgen_operand_type { -- OPENRISC_OPERAND_PC, OPENRISC_OPERAND_SR, OPENRISC_OPERAND_CBIT, OPENRISC_OPERAND_SIMM_16 -- , OPENRISC_OPERAND_UIMM_16, OPENRISC_OPERAND_DISP_26, OPENRISC_OPERAND_ABS_26, OPENRISC_OPERAND_UIMM_5 -- , OPENRISC_OPERAND_RD, OPENRISC_OPERAND_RA, OPENRISC_OPERAND_RB, OPENRISC_OPERAND_OP_F_23 -- , OPENRISC_OPERAND_OP_F_3, OPENRISC_OPERAND_HI16, OPENRISC_OPERAND_LO16, OPENRISC_OPERAND_UI16NC -- , OPENRISC_OPERAND_MAX --} CGEN_OPERAND_TYPE; -- --/* Number of operands types. */ --#define MAX_OPERANDS 16 -- --/* Maximum number of operands referenced by any insn. */ --#define MAX_OPERAND_INSTANCES 8 -- --/* Insn attribute indices. */ -- --/* Enum declaration for cgen_insn attrs. */ --typedef enum cgen_insn_attr { -- CGEN_INSN_ALIAS, CGEN_INSN_VIRTUAL, CGEN_INSN_UNCOND_CTI, CGEN_INSN_COND_CTI -- , CGEN_INSN_SKIP_CTI, CGEN_INSN_DELAY_SLOT, CGEN_INSN_RELAXABLE, CGEN_INSN_RELAXED -- , CGEN_INSN_NO_DIS, CGEN_INSN_PBB, CGEN_INSN_NOT_IN_DELAY_SLOT, CGEN_INSN_END_BOOLS -- , CGEN_INSN_START_NBOOLS = 31, CGEN_INSN_MACH, CGEN_INSN_END_NBOOLS --} CGEN_INSN_ATTR; -- --/* Number of non-boolean elements in cgen_insn_attr. */ --#define CGEN_INSN_NBOOL_ATTRS (CGEN_INSN_END_NBOOLS - CGEN_INSN_START_NBOOLS - 1) -- --/* cgen_insn attribute accessor macros. */ --#define CGEN_ATTR_CGEN_INSN_MACH_VALUE(attrs) ((attrs)->nonbool[CGEN_INSN_MACH-CGEN_INSN_START_NBOOLS-1].nonbitset) --#define CGEN_ATTR_CGEN_INSN_ALIAS_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_INSN_ALIAS)) != 0) --#define CGEN_ATTR_CGEN_INSN_VIRTUAL_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_INSN_VIRTUAL)) != 0) --#define CGEN_ATTR_CGEN_INSN_UNCOND_CTI_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_INSN_UNCOND_CTI)) != 0) --#define CGEN_ATTR_CGEN_INSN_COND_CTI_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_INSN_COND_CTI)) != 0) --#define CGEN_ATTR_CGEN_INSN_SKIP_CTI_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_INSN_SKIP_CTI)) != 0) --#define CGEN_ATTR_CGEN_INSN_DELAY_SLOT_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_INSN_DELAY_SLOT)) != 0) --#define CGEN_ATTR_CGEN_INSN_RELAXABLE_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_INSN_RELAXABLE)) != 0) --#define CGEN_ATTR_CGEN_INSN_RELAXED_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_INSN_RELAXED)) != 0) --#define CGEN_ATTR_CGEN_INSN_NO_DIS_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_INSN_NO_DIS)) != 0) --#define CGEN_ATTR_CGEN_INSN_PBB_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_INSN_PBB)) != 0) --#define CGEN_ATTR_CGEN_INSN_NOT_IN_DELAY_SLOT_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_INSN_NOT_IN_DELAY_SLOT)) != 0) -- --/* cgen.h uses things we just defined. */ --#include "opcode/cgen.h" -- --extern const struct cgen_ifld openrisc_cgen_ifld_table[]; -- --/* Attributes. */ --extern const CGEN_ATTR_TABLE openrisc_cgen_hardware_attr_table[]; --extern const CGEN_ATTR_TABLE openrisc_cgen_ifield_attr_table[]; --extern const CGEN_ATTR_TABLE openrisc_cgen_operand_attr_table[]; --extern const CGEN_ATTR_TABLE openrisc_cgen_insn_attr_table[]; -- --/* Hardware decls. */ -- --extern CGEN_KEYWORD openrisc_cgen_opval_h_gr; -- --extern const CGEN_HW_ENTRY openrisc_cgen_hw_table[]; -- -- -- --#endif /* OPENRISC_CPU_H */ -diff -rNU3 dist.orig/opcodes/openrisc-dis.c dist/opcodes/openrisc-dis.c ---- dist.orig/opcodes/openrisc-dis.c 2010-02-12 05:42:28.000000000 +0100 -+++ dist/opcodes/openrisc-dis.c 1970-01-01 01:00:00.000000000 +0100 -@@ -1,556 +0,0 @@ --/* Disassembler interface for targets using CGEN. -*- C -*- -- CGEN: Cpu tools GENerator -- -- THIS FILE IS MACHINE GENERATED WITH CGEN. -- - the resultant file is machine generated, cgen-dis.in isn't -- -- Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2007, -- 2008, 2010 Free Software Foundation, Inc. -- -- This file is part of libopcodes. -- -- This library is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3, or (at your option) -- any later version. -- -- It is distributed in the hope that it will be useful, but WITHOUT -- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software Foundation, Inc., -- 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -- --/* ??? Eventually more and more of this stuff can go to cpu-independent files. -- Keep that in mind. */ -- --#include "sysdep.h" --#include --#include "ansidecl.h" --#include "dis-asm.h" --#include "bfd.h" --#include "symcat.h" --#include "libiberty.h" --#include "openrisc-desc.h" --#include "openrisc-opc.h" --#include "opintl.h" -- --/* Default text to print if an instruction isn't recognized. */ --#define UNKNOWN_INSN_MSG _("*unknown*") -- --static void print_normal -- (CGEN_CPU_DESC, void *, long, unsigned int, bfd_vma, int); --static void print_address -- (CGEN_CPU_DESC, void *, bfd_vma, unsigned int, bfd_vma, int) ATTRIBUTE_UNUSED; --static void print_keyword -- (CGEN_CPU_DESC, void *, CGEN_KEYWORD *, long, unsigned int) ATTRIBUTE_UNUSED; --static void print_insn_normal -- (CGEN_CPU_DESC, void *, const CGEN_INSN *, CGEN_FIELDS *, bfd_vma, int); --static int print_insn -- (CGEN_CPU_DESC, bfd_vma, disassemble_info *, bfd_byte *, unsigned); --static int default_print_insn -- (CGEN_CPU_DESC, bfd_vma, disassemble_info *) ATTRIBUTE_UNUSED; --static int read_insn -- (CGEN_CPU_DESC, bfd_vma, disassemble_info *, bfd_byte *, int, CGEN_EXTRACT_INFO *, -- unsigned long *); -- --/* -- disassembler routines inserted here. */ -- -- --void openrisc_cgen_print_operand -- (CGEN_CPU_DESC, int, PTR, CGEN_FIELDS *, void const *, bfd_vma, int); -- --/* Main entry point for printing operands. -- XINFO is a `void *' and not a `disassemble_info *' to not put a requirement -- of dis-asm.h on cgen.h. -- -- This function is basically just a big switch statement. Earlier versions -- used tables to look up the function to use, but -- - if the table contains both assembler and disassembler functions then -- the disassembler contains much of the assembler and vice-versa, -- - there's a lot of inlining possibilities as things grow, -- - using a switch statement avoids the function call overhead. -- -- This function could be moved into `print_insn_normal', but keeping it -- separate makes clear the interface between `print_insn_normal' and each of -- the handlers. */ -- --void --openrisc_cgen_print_operand (CGEN_CPU_DESC cd, -- int opindex, -- void * xinfo, -- CGEN_FIELDS *fields, -- void const *attrs ATTRIBUTE_UNUSED, -- bfd_vma pc, -- int length) --{ -- disassemble_info *info = (disassemble_info *) xinfo; -- -- switch (opindex) -- { -- case OPENRISC_OPERAND_ABS_26 : -- print_address (cd, info, fields->f_abs26, 0|(1<f_disp26, 0|(1<f_simm16, 0|(1<f_lo16, 0|(1<f_op4, 0, pc, length); -- break; -- case OPENRISC_OPERAND_OP_F_3 : -- print_normal (cd, info, fields->f_op5, 0, pc, length); -- break; -- case OPENRISC_OPERAND_RA : -- print_keyword (cd, info, & openrisc_cgen_opval_h_gr, fields->f_r2, 0); -- break; -- case OPENRISC_OPERAND_RB : -- print_keyword (cd, info, & openrisc_cgen_opval_h_gr, fields->f_r3, 0); -- break; -- case OPENRISC_OPERAND_RD : -- print_keyword (cd, info, & openrisc_cgen_opval_h_gr, fields->f_r1, 0); -- break; -- case OPENRISC_OPERAND_SIMM_16 : -- print_normal (cd, info, fields->f_simm16, 0|(1<f_i16nc, 0|(1<f_uimm16, 0, pc, length); -- break; -- case OPENRISC_OPERAND_UIMM_5 : -- print_normal (cd, info, fields->f_uimm5, 0, pc, length); -- break; -- -- default : -- /* xgettext:c-format */ -- fprintf (stderr, _("Unrecognized field %d while printing insn.\n"), -- opindex); -- abort (); -- } --} -- --cgen_print_fn * const openrisc_cgen_print_handlers[] = --{ -- print_insn_normal, --}; -- -- --void --openrisc_cgen_init_dis (CGEN_CPU_DESC cd) --{ -- openrisc_cgen_init_opcode_table (cd); -- openrisc_cgen_init_ibld_table (cd); -- cd->print_handlers = & openrisc_cgen_print_handlers[0]; -- cd->print_operand = openrisc_cgen_print_operand; --} -- -- --/* Default print handler. */ -- --static void --print_normal (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, -- void *dis_info, -- long value, -- unsigned int attrs, -- bfd_vma pc ATTRIBUTE_UNUSED, -- int length ATTRIBUTE_UNUSED) --{ -- disassemble_info *info = (disassemble_info *) dis_info; -- -- /* Print the operand as directed by the attributes. */ -- if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SEM_ONLY)) -- ; /* nothing to do */ -- else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SIGNED)) -- (*info->fprintf_func) (info->stream, "%ld", value); -- else -- (*info->fprintf_func) (info->stream, "0x%lx", value); --} -- --/* Default address handler. */ -- --static void --print_address (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, -- void *dis_info, -- bfd_vma value, -- unsigned int attrs, -- bfd_vma pc ATTRIBUTE_UNUSED, -- int length ATTRIBUTE_UNUSED) --{ -- disassemble_info *info = (disassemble_info *) dis_info; -- -- /* Print the operand as directed by the attributes. */ -- if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SEM_ONLY)) -- ; /* Nothing to do. */ -- else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_PCREL_ADDR)) -- (*info->print_address_func) (value, info); -- else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_ABS_ADDR)) -- (*info->print_address_func) (value, info); -- else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SIGNED)) -- (*info->fprintf_func) (info->stream, "%ld", (long) value); -- else -- (*info->fprintf_func) (info->stream, "0x%lx", (long) value); --} -- --/* Keyword print handler. */ -- --static void --print_keyword (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, -- void *dis_info, -- CGEN_KEYWORD *keyword_table, -- long value, -- unsigned int attrs ATTRIBUTE_UNUSED) --{ -- disassemble_info *info = (disassemble_info *) dis_info; -- const CGEN_KEYWORD_ENTRY *ke; -- -- ke = cgen_keyword_lookup_value (keyword_table, value); -- if (ke != NULL) -- (*info->fprintf_func) (info->stream, "%s", ke->name); -- else -- (*info->fprintf_func) (info->stream, "???"); --} -- --/* Default insn printer. -- -- DIS_INFO is defined as `void *' so the disassembler needn't know anything -- about disassemble_info. */ -- --static void --print_insn_normal (CGEN_CPU_DESC cd, -- void *dis_info, -- const CGEN_INSN *insn, -- CGEN_FIELDS *fields, -- bfd_vma pc, -- int length) --{ -- const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn); -- disassemble_info *info = (disassemble_info *) dis_info; -- const CGEN_SYNTAX_CHAR_TYPE *syn; -- -- CGEN_INIT_PRINT (cd); -- -- for (syn = CGEN_SYNTAX_STRING (syntax); *syn; ++syn) -- { -- if (CGEN_SYNTAX_MNEMONIC_P (*syn)) -- { -- (*info->fprintf_func) (info->stream, "%s", CGEN_INSN_MNEMONIC (insn)); -- continue; -- } -- if (CGEN_SYNTAX_CHAR_P (*syn)) -- { -- (*info->fprintf_func) (info->stream, "%c", CGEN_SYNTAX_CHAR (*syn)); -- continue; -- } -- -- /* We have an operand. */ -- openrisc_cgen_print_operand (cd, CGEN_SYNTAX_FIELD (*syn), info, -- fields, CGEN_INSN_ATTRS (insn), pc, length); -- } --} -- --/* Subroutine of print_insn. Reads an insn into the given buffers and updates -- the extract info. -- Returns 0 if all is well, non-zero otherwise. */ -- --static int --read_insn (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, -- bfd_vma pc, -- disassemble_info *info, -- bfd_byte *buf, -- int buflen, -- CGEN_EXTRACT_INFO *ex_info, -- unsigned long *insn_value) --{ -- int status = (*info->read_memory_func) (pc, buf, buflen, info); -- -- if (status != 0) -- { -- (*info->memory_error_func) (status, pc, info); -- return -1; -- } -- -- ex_info->dis_info = info; -- ex_info->valid = (1 << buflen) - 1; -- ex_info->insn_bytes = buf; -- -- *insn_value = bfd_get_bits (buf, buflen * 8, info->endian == BFD_ENDIAN_BIG); -- return 0; --} -- --/* Utility to print an insn. -- BUF is the base part of the insn, target byte order, BUFLEN bytes long. -- The result is the size of the insn in bytes or zero for an unknown insn -- or -1 if an error occurs fetching data (memory_error_func will have -- been called). */ -- --static int --print_insn (CGEN_CPU_DESC cd, -- bfd_vma pc, -- disassemble_info *info, -- bfd_byte *buf, -- unsigned int buflen) --{ -- CGEN_INSN_INT insn_value; -- const CGEN_INSN_LIST *insn_list; -- CGEN_EXTRACT_INFO ex_info; -- int basesize; -- -- /* Extract base part of instruction, just in case CGEN_DIS_* uses it. */ -- basesize = cd->base_insn_bitsize < buflen * 8 ? -- cd->base_insn_bitsize : buflen * 8; -- insn_value = cgen_get_insn_value (cd, buf, basesize); -- -- -- /* Fill in ex_info fields like read_insn would. Don't actually call -- read_insn, since the incoming buffer is already read (and possibly -- modified a la m32r). */ -- ex_info.valid = (1 << buflen) - 1; -- ex_info.dis_info = info; -- ex_info.insn_bytes = buf; -- -- /* The instructions are stored in hash lists. -- Pick the first one and keep trying until we find the right one. */ -- -- insn_list = CGEN_DIS_LOOKUP_INSN (cd, (char *) buf, insn_value); -- while (insn_list != NULL) -- { -- const CGEN_INSN *insn = insn_list->insn; -- CGEN_FIELDS fields; -- int length; -- unsigned long insn_value_cropped; -- --#ifdef CGEN_VALIDATE_INSN_SUPPORTED -- /* Not needed as insn shouldn't be in hash lists if not supported. */ -- /* Supported by this cpu? */ -- if (! openrisc_cgen_insn_supported (cd, insn)) -- { -- insn_list = CGEN_DIS_NEXT_INSN (insn_list); -- continue; -- } --#endif -- -- /* Basic bit mask must be correct. */ -- /* ??? May wish to allow target to defer this check until the extract -- handler. */ -- -- /* Base size may exceed this instruction's size. Extract the -- relevant part from the buffer. */ -- if ((unsigned) (CGEN_INSN_BITSIZE (insn) / 8) < buflen && -- (unsigned) (CGEN_INSN_BITSIZE (insn) / 8) <= sizeof (unsigned long)) -- insn_value_cropped = bfd_get_bits (buf, CGEN_INSN_BITSIZE (insn), -- info->endian == BFD_ENDIAN_BIG); -- else -- insn_value_cropped = insn_value; -- -- if ((insn_value_cropped & CGEN_INSN_BASE_MASK (insn)) -- == CGEN_INSN_BASE_VALUE (insn)) -- { -- /* Printing is handled in two passes. The first pass parses the -- machine insn and extracts the fields. The second pass prints -- them. */ -- -- /* Make sure the entire insn is loaded into insn_value, if it -- can fit. */ -- if (((unsigned) CGEN_INSN_BITSIZE (insn) > cd->base_insn_bitsize) && -- (unsigned) (CGEN_INSN_BITSIZE (insn) / 8) <= sizeof (unsigned long)) -- { -- unsigned long full_insn_value; -- int rc = read_insn (cd, pc, info, buf, -- CGEN_INSN_BITSIZE (insn) / 8, -- & ex_info, & full_insn_value); -- if (rc != 0) -- return rc; -- length = CGEN_EXTRACT_FN (cd, insn) -- (cd, insn, &ex_info, full_insn_value, &fields, pc); -- } -- else -- length = CGEN_EXTRACT_FN (cd, insn) -- (cd, insn, &ex_info, insn_value_cropped, &fields, pc); -- -- /* Length < 0 -> error. */ -- if (length < 0) -- return length; -- if (length > 0) -- { -- CGEN_PRINT_FN (cd, insn) (cd, info, insn, &fields, pc, length); -- /* Length is in bits, result is in bytes. */ -- return length / 8; -- } -- } -- -- insn_list = CGEN_DIS_NEXT_INSN (insn_list); -- } -- -- return 0; --} -- --/* Default value for CGEN_PRINT_INSN. -- The result is the size of the insn in bytes or zero for an unknown insn -- or -1 if an error occured fetching bytes. */ -- --#ifndef CGEN_PRINT_INSN --#define CGEN_PRINT_INSN default_print_insn --#endif -- --static int --default_print_insn (CGEN_CPU_DESC cd, bfd_vma pc, disassemble_info *info) --{ -- bfd_byte buf[CGEN_MAX_INSN_SIZE]; -- int buflen; -- int status; -- -- /* Attempt to read the base part of the insn. */ -- buflen = cd->base_insn_bitsize / 8; -- status = (*info->read_memory_func) (pc, buf, buflen, info); -- -- /* Try again with the minimum part, if min < base. */ -- if (status != 0 && (cd->min_insn_bitsize < cd->base_insn_bitsize)) -- { -- buflen = cd->min_insn_bitsize / 8; -- status = (*info->read_memory_func) (pc, buf, buflen, info); -- } -- -- if (status != 0) -- { -- (*info->memory_error_func) (status, pc, info); -- return -1; -- } -- -- return print_insn (cd, pc, info, buf, buflen); --} -- --/* Main entry point. -- Print one instruction from PC on INFO->STREAM. -- Return the size of the instruction (in bytes). */ -- --typedef struct cpu_desc_list --{ -- struct cpu_desc_list *next; -- CGEN_BITSET *isa; -- int mach; -- int endian; -- CGEN_CPU_DESC cd; --} cpu_desc_list; -- --int --print_insn_openrisc (bfd_vma pc, disassemble_info *info) --{ -- static cpu_desc_list *cd_list = 0; -- cpu_desc_list *cl = 0; -- static CGEN_CPU_DESC cd = 0; -- static CGEN_BITSET *prev_isa; -- static int prev_mach; -- static int prev_endian; -- int length; -- CGEN_BITSET *isa; -- int mach; -- int endian = (info->endian == BFD_ENDIAN_BIG -- ? CGEN_ENDIAN_BIG -- : CGEN_ENDIAN_LITTLE); -- enum bfd_architecture arch; -- -- /* ??? gdb will set mach but leave the architecture as "unknown" */ --#ifndef CGEN_BFD_ARCH --#define CGEN_BFD_ARCH bfd_arch_openrisc --#endif -- arch = info->arch; -- if (arch == bfd_arch_unknown) -- arch = CGEN_BFD_ARCH; -- -- /* There's no standard way to compute the machine or isa number -- so we leave it to the target. */ --#ifdef CGEN_COMPUTE_MACH -- mach = CGEN_COMPUTE_MACH (info); --#else -- mach = info->mach; --#endif -- --#ifdef CGEN_COMPUTE_ISA -- { -- static CGEN_BITSET *permanent_isa; -- -- if (!permanent_isa) -- permanent_isa = cgen_bitset_create (MAX_ISAS); -- isa = permanent_isa; -- cgen_bitset_clear (isa); -- cgen_bitset_add (isa, CGEN_COMPUTE_ISA (info)); -- } --#else -- isa = info->insn_sets; --#endif -- -- /* If we've switched cpu's, try to find a handle we've used before */ -- if (cd -- && (cgen_bitset_compare (isa, prev_isa) != 0 -- || mach != prev_mach -- || endian != prev_endian)) -- { -- cd = 0; -- for (cl = cd_list; cl; cl = cl->next) -- { -- if (cgen_bitset_compare (cl->isa, isa) == 0 && -- cl->mach == mach && -- cl->endian == endian) -- { -- cd = cl->cd; -- prev_isa = cd->isas; -- break; -- } -- } -- } -- -- /* If we haven't initialized yet, initialize the opcode table. */ -- if (! cd) -- { -- const bfd_arch_info_type *arch_type = bfd_lookup_arch (arch, mach); -- const char *mach_name; -- -- if (!arch_type) -- abort (); -- mach_name = arch_type->printable_name; -- -- prev_isa = cgen_bitset_copy (isa); -- prev_mach = mach; -- prev_endian = endian; -- cd = openrisc_cgen_cpu_open (CGEN_CPU_OPEN_ISAS, prev_isa, -- CGEN_CPU_OPEN_BFDMACH, mach_name, -- CGEN_CPU_OPEN_ENDIAN, prev_endian, -- CGEN_CPU_OPEN_END); -- if (!cd) -- abort (); -- -- /* Save this away for future reference. */ -- cl = xmalloc (sizeof (struct cpu_desc_list)); -- cl->cd = cd; -- cl->isa = prev_isa; -- cl->mach = mach; -- cl->endian = endian; -- cl->next = cd_list; -- cd_list = cl; -- -- openrisc_cgen_init_dis (cd); -- } -- -- /* We try to have as much common code as possible. -- But at this point some targets need to take over. */ -- /* ??? Some targets may need a hook elsewhere. Try to avoid this, -- but if not possible try to move this hook elsewhere rather than -- have two hooks. */ -- length = CGEN_PRINT_INSN (cd, pc, info); -- if (length > 0) -- return length; -- if (length < 0) -- return -1; -- -- (*info->fprintf_func) (info->stream, UNKNOWN_INSN_MSG); -- return cd->default_insn_bitsize / 8; --} -diff -rNU3 dist.orig/opcodes/openrisc-ibld.c dist/opcodes/openrisc-ibld.c ---- dist.orig/opcodes/openrisc-ibld.c 2010-01-07 19:05:45.000000000 +0100 -+++ dist/opcodes/openrisc-ibld.c 1970-01-01 01:00:00.000000000 +0100 -@@ -1,1009 +0,0 @@ --/* Instruction building/extraction support for openrisc. -*- C -*- -- -- THIS FILE IS MACHINE GENERATED WITH CGEN: Cpu tools GENerator. -- - the resultant file is machine generated, cgen-ibld.in isn't -- -- Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2005, 2006, 2007, -- 2008, 2010 Free Software Foundation, Inc. -- -- This file is part of libopcodes. -- -- This library is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3, or (at your option) -- any later version. -- -- It is distributed in the hope that it will be useful, but WITHOUT -- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software Foundation, Inc., -- 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -- --/* ??? Eventually more and more of this stuff can go to cpu-independent files. -- Keep that in mind. */ -- --#include "sysdep.h" --#include --#include "ansidecl.h" --#include "dis-asm.h" --#include "bfd.h" --#include "symcat.h" --#include "openrisc-desc.h" --#include "openrisc-opc.h" --#include "cgen/basic-modes.h" --#include "opintl.h" --#include "safe-ctype.h" -- --#undef min --#define min(a,b) ((a) < (b) ? (a) : (b)) --#undef max --#define max(a,b) ((a) > (b) ? (a) : (b)) -- --/* Used by the ifield rtx function. */ --#define FLD(f) (fields->f) -- --static const char * insert_normal -- (CGEN_CPU_DESC, long, unsigned int, unsigned int, unsigned int, -- unsigned int, unsigned int, unsigned int, CGEN_INSN_BYTES_PTR); --static const char * insert_insn_normal -- (CGEN_CPU_DESC, const CGEN_INSN *, -- CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma); --static int extract_normal -- (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, CGEN_INSN_INT, -- unsigned int, unsigned int, unsigned int, unsigned int, -- unsigned int, unsigned int, bfd_vma, long *); --static int extract_insn_normal -- (CGEN_CPU_DESC, const CGEN_INSN *, CGEN_EXTRACT_INFO *, -- CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma); --#if CGEN_INT_INSN_P --static void put_insn_int_value -- (CGEN_CPU_DESC, CGEN_INSN_BYTES_PTR, int, int, CGEN_INSN_INT); --#endif --#if ! CGEN_INT_INSN_P --static CGEN_INLINE void insert_1 -- (CGEN_CPU_DESC, unsigned long, int, int, int, unsigned char *); --static CGEN_INLINE int fill_cache -- (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, int, int, bfd_vma); --static CGEN_INLINE long extract_1 -- (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, int, int, int, unsigned char *, bfd_vma); --#endif -- --/* Operand insertion. */ -- --#if ! CGEN_INT_INSN_P -- --/* Subroutine of insert_normal. */ -- --static CGEN_INLINE void --insert_1 (CGEN_CPU_DESC cd, -- unsigned long value, -- int start, -- int length, -- int word_length, -- unsigned char *bufp) --{ -- unsigned long x,mask; -- int shift; -- -- x = cgen_get_insn_value (cd, bufp, word_length); -- -- /* Written this way to avoid undefined behaviour. */ -- mask = (((1L << (length - 1)) - 1) << 1) | 1; -- if (CGEN_INSN_LSB0_P) -- shift = (start + 1) - length; -- else -- shift = (word_length - (start + length)); -- x = (x & ~(mask << shift)) | ((value & mask) << shift); -- -- cgen_put_insn_value (cd, bufp, word_length, (bfd_vma) x); --} -- --#endif /* ! CGEN_INT_INSN_P */ -- --/* Default insertion routine. -- -- ATTRS is a mask of the boolean attributes. -- WORD_OFFSET is the offset in bits from the start of the insn of the value. -- WORD_LENGTH is the length of the word in bits in which the value resides. -- START is the starting bit number in the word, architecture origin. -- LENGTH is the length of VALUE in bits. -- TOTAL_LENGTH is the total length of the insn in bits. -- -- The result is an error message or NULL if success. */ -- --/* ??? This duplicates functionality with bfd's howto table and -- bfd_install_relocation. */ --/* ??? This doesn't handle bfd_vma's. Create another function when -- necessary. */ -- --static const char * --insert_normal (CGEN_CPU_DESC cd, -- long value, -- unsigned int attrs, -- unsigned int word_offset, -- unsigned int start, -- unsigned int length, -- unsigned int word_length, -- unsigned int total_length, -- CGEN_INSN_BYTES_PTR buffer) --{ -- static char errbuf[100]; -- /* Written this way to avoid undefined behaviour. */ -- unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1; -- -- /* If LENGTH is zero, this operand doesn't contribute to the value. */ -- if (length == 0) -- return NULL; -- -- if (word_length > 8 * sizeof (CGEN_INSN_INT)) -- abort (); -- -- /* For architectures with insns smaller than the base-insn-bitsize, -- word_length may be too big. */ -- if (cd->min_insn_bitsize < cd->base_insn_bitsize) -- { -- if (word_offset == 0 -- && word_length > total_length) -- word_length = total_length; -- } -- -- /* Ensure VALUE will fit. */ -- if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGN_OPT)) -- { -- long minval = - (1L << (length - 1)); -- unsigned long maxval = mask; -- -- if ((value > 0 && (unsigned long) value > maxval) -- || value < minval) -- { -- /* xgettext:c-format */ -- sprintf (errbuf, -- _("operand out of range (%ld not between %ld and %lu)"), -- value, minval, maxval); -- return errbuf; -- } -- } -- else if (! CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED)) -- { -- unsigned long maxval = mask; -- unsigned long val = (unsigned long) value; -- -- /* For hosts with a word size > 32 check to see if value has been sign -- extended beyond 32 bits. If so then ignore these higher sign bits -- as the user is attempting to store a 32-bit signed value into an -- unsigned 32-bit field which is allowed. */ -- if (sizeof (unsigned long) > 4 && ((value >> 32) == -1)) -- val &= 0xFFFFFFFF; -- -- if (val > maxval) -- { -- /* xgettext:c-format */ -- sprintf (errbuf, -- _("operand out of range (0x%lx not between 0 and 0x%lx)"), -- val, maxval); -- return errbuf; -- } -- } -- else -- { -- if (! cgen_signed_overflow_ok_p (cd)) -- { -- long minval = - (1L << (length - 1)); -- long maxval = (1L << (length - 1)) - 1; -- -- if (value < minval || value > maxval) -- { -- sprintf -- /* xgettext:c-format */ -- (errbuf, _("operand out of range (%ld not between %ld and %ld)"), -- value, minval, maxval); -- return errbuf; -- } -- } -- } -- --#if CGEN_INT_INSN_P -- -- { -- int shift; -- -- if (CGEN_INSN_LSB0_P) -- shift = (word_offset + start + 1) - length; -- else -- shift = total_length - (word_offset + start + length); -- *buffer = (*buffer & ~(mask << shift)) | ((value & mask) << shift); -- } -- --#else /* ! CGEN_INT_INSN_P */ -- -- { -- unsigned char *bufp = (unsigned char *) buffer + word_offset / 8; -- -- insert_1 (cd, value, start, length, word_length, bufp); -- } -- --#endif /* ! CGEN_INT_INSN_P */ -- -- return NULL; --} -- --/* Default insn builder (insert handler). -- The instruction is recorded in CGEN_INT_INSN_P byte order (meaning -- that if CGEN_INSN_BYTES_PTR is an int * and thus, the value is -- recorded in host byte order, otherwise BUFFER is an array of bytes -- and the value is recorded in target byte order). -- The result is an error message or NULL if success. */ -- --static const char * --insert_insn_normal (CGEN_CPU_DESC cd, -- const CGEN_INSN * insn, -- CGEN_FIELDS * fields, -- CGEN_INSN_BYTES_PTR buffer, -- bfd_vma pc) --{ -- const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn); -- unsigned long value; -- const CGEN_SYNTAX_CHAR_TYPE * syn; -- -- CGEN_INIT_INSERT (cd); -- value = CGEN_INSN_BASE_VALUE (insn); -- -- /* If we're recording insns as numbers (rather than a string of bytes), -- target byte order handling is deferred until later. */ -- --#if CGEN_INT_INSN_P -- -- put_insn_int_value (cd, buffer, cd->base_insn_bitsize, -- CGEN_FIELDS_BITSIZE (fields), value); -- --#else -- -- cgen_put_insn_value (cd, buffer, min ((unsigned) cd->base_insn_bitsize, -- (unsigned) CGEN_FIELDS_BITSIZE (fields)), -- value); -- --#endif /* ! CGEN_INT_INSN_P */ -- -- /* ??? It would be better to scan the format's fields. -- Still need to be able to insert a value based on the operand though; -- e.g. storing a branch displacement that got resolved later. -- Needs more thought first. */ -- -- for (syn = CGEN_SYNTAX_STRING (syntax); * syn; ++ syn) -- { -- const char *errmsg; -- -- if (CGEN_SYNTAX_CHAR_P (* syn)) -- continue; -- -- errmsg = (* cd->insert_operand) (cd, CGEN_SYNTAX_FIELD (*syn), -- fields, buffer, pc); -- if (errmsg) -- return errmsg; -- } -- -- return NULL; --} -- --#if CGEN_INT_INSN_P --/* Cover function to store an insn value into an integral insn. Must go here -- because it needs -desc.h for CGEN_INT_INSN_P. */ -- --static void --put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, -- CGEN_INSN_BYTES_PTR buf, -- int length, -- int insn_length, -- CGEN_INSN_INT value) --{ -- /* For architectures with insns smaller than the base-insn-bitsize, -- length may be too big. */ -- if (length > insn_length) -- *buf = value; -- else -- { -- int shift = insn_length - length; -- /* Written this way to avoid undefined behaviour. */ -- CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1; -- -- *buf = (*buf & ~(mask << shift)) | ((value & mask) << shift); -- } --} --#endif -- --/* Operand extraction. */ -- --#if ! CGEN_INT_INSN_P -- --/* Subroutine of extract_normal. -- Ensure sufficient bytes are cached in EX_INFO. -- OFFSET is the offset in bytes from the start of the insn of the value. -- BYTES is the length of the needed value. -- Returns 1 for success, 0 for failure. */ -- --static CGEN_INLINE int --fill_cache (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, -- CGEN_EXTRACT_INFO *ex_info, -- int offset, -- int bytes, -- bfd_vma pc) --{ -- /* It's doubtful that the middle part has already been fetched so -- we don't optimize that case. kiss. */ -- unsigned int mask; -- disassemble_info *info = (disassemble_info *) ex_info->dis_info; -- -- /* First do a quick check. */ -- mask = (1 << bytes) - 1; -- if (((ex_info->valid >> offset) & mask) == mask) -- return 1; -- -- /* Search for the first byte we need to read. */ -- for (mask = 1 << offset; bytes > 0; --bytes, ++offset, mask <<= 1) -- if (! (mask & ex_info->valid)) -- break; -- -- if (bytes) -- { -- int status; -- -- pc += offset; -- status = (*info->read_memory_func) -- (pc, ex_info->insn_bytes + offset, bytes, info); -- -- if (status != 0) -- { -- (*info->memory_error_func) (status, pc, info); -- return 0; -- } -- -- ex_info->valid |= ((1 << bytes) - 1) << offset; -- } -- -- return 1; --} -- --/* Subroutine of extract_normal. */ -- --static CGEN_INLINE long --extract_1 (CGEN_CPU_DESC cd, -- CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED, -- int start, -- int length, -- int word_length, -- unsigned char *bufp, -- bfd_vma pc ATTRIBUTE_UNUSED) --{ -- unsigned long x; -- int shift; -- -- x = cgen_get_insn_value (cd, bufp, word_length); -- -- if (CGEN_INSN_LSB0_P) -- shift = (start + 1) - length; -- else -- shift = (word_length - (start + length)); -- return x >> shift; --} -- --#endif /* ! CGEN_INT_INSN_P */ -- --/* Default extraction routine. -- -- INSN_VALUE is the first base_insn_bitsize bits of the insn in host order, -- or sometimes less for cases like the m32r where the base insn size is 32 -- but some insns are 16 bits. -- ATTRS is a mask of the boolean attributes. We only need `SIGNED', -- but for generality we take a bitmask of all of them. -- WORD_OFFSET is the offset in bits from the start of the insn of the value. -- WORD_LENGTH is the length of the word in bits in which the value resides. -- START is the starting bit number in the word, architecture origin. -- LENGTH is the length of VALUE in bits. -- TOTAL_LENGTH is the total length of the insn in bits. -- -- Returns 1 for success, 0 for failure. */ -- --/* ??? The return code isn't properly used. wip. */ -- --/* ??? This doesn't handle bfd_vma's. Create another function when -- necessary. */ -- --static int --extract_normal (CGEN_CPU_DESC cd, --#if ! CGEN_INT_INSN_P -- CGEN_EXTRACT_INFO *ex_info, --#else -- CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED, --#endif -- CGEN_INSN_INT insn_value, -- unsigned int attrs, -- unsigned int word_offset, -- unsigned int start, -- unsigned int length, -- unsigned int word_length, -- unsigned int total_length, --#if ! CGEN_INT_INSN_P -- bfd_vma pc, --#else -- bfd_vma pc ATTRIBUTE_UNUSED, --#endif -- long *valuep) --{ -- long value, mask; -- -- /* If LENGTH is zero, this operand doesn't contribute to the value -- so give it a standard value of zero. */ -- if (length == 0) -- { -- *valuep = 0; -- return 1; -- } -- -- if (word_length > 8 * sizeof (CGEN_INSN_INT)) -- abort (); -- -- /* For architectures with insns smaller than the insn-base-bitsize, -- word_length may be too big. */ -- if (cd->min_insn_bitsize < cd->base_insn_bitsize) -- { -- if (word_offset + word_length > total_length) -- word_length = total_length - word_offset; -- } -- -- /* Does the value reside in INSN_VALUE, and at the right alignment? */ -- -- if (CGEN_INT_INSN_P || (word_offset == 0 && word_length == total_length)) -- { -- if (CGEN_INSN_LSB0_P) -- value = insn_value >> ((word_offset + start + 1) - length); -- else -- value = insn_value >> (total_length - ( word_offset + start + length)); -- } -- --#if ! CGEN_INT_INSN_P -- -- else -- { -- unsigned char *bufp = ex_info->insn_bytes + word_offset / 8; -- -- if (word_length > 8 * sizeof (CGEN_INSN_INT)) -- abort (); -- -- if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0) -- return 0; -- -- value = extract_1 (cd, ex_info, start, length, word_length, bufp, pc); -- } -- --#endif /* ! CGEN_INT_INSN_P */ -- -- /* Written this way to avoid undefined behaviour. */ -- mask = (((1L << (length - 1)) - 1) << 1) | 1; -- -- value &= mask; -- /* sign extend? */ -- if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED) -- && (value & (1L << (length - 1)))) -- value |= ~mask; -- -- *valuep = value; -- -- return 1; --} -- --/* Default insn extractor. -- -- INSN_VALUE is the first base_insn_bitsize bits, translated to host order. -- The extracted fields are stored in FIELDS. -- EX_INFO is used to handle reading variable length insns. -- Return the length of the insn in bits, or 0 if no match, -- or -1 if an error occurs fetching data (memory_error_func will have -- been called). */ -- --static int --extract_insn_normal (CGEN_CPU_DESC cd, -- const CGEN_INSN *insn, -- CGEN_EXTRACT_INFO *ex_info, -- CGEN_INSN_INT insn_value, -- CGEN_FIELDS *fields, -- bfd_vma pc) --{ -- const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn); -- const CGEN_SYNTAX_CHAR_TYPE *syn; -- -- CGEN_FIELDS_BITSIZE (fields) = CGEN_INSN_BITSIZE (insn); -- -- CGEN_INIT_EXTRACT (cd); -- -- for (syn = CGEN_SYNTAX_STRING (syntax); *syn; ++syn) -- { -- int length; -- -- if (CGEN_SYNTAX_CHAR_P (*syn)) -- continue; -- -- length = (* cd->extract_operand) (cd, CGEN_SYNTAX_FIELD (*syn), -- ex_info, insn_value, fields, pc); -- if (length <= 0) -- return length; -- } -- -- /* We recognized and successfully extracted this insn. */ -- return CGEN_INSN_BITSIZE (insn); --} -- --/* Machine generated code added here. */ -- --const char * openrisc_cgen_insert_operand -- (CGEN_CPU_DESC, int, CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma); -- --/* Main entry point for operand insertion. -- -- This function is basically just a big switch statement. Earlier versions -- used tables to look up the function to use, but -- - if the table contains both assembler and disassembler functions then -- the disassembler contains much of the assembler and vice-versa, -- - there's a lot of inlining possibilities as things grow, -- - using a switch statement avoids the function call overhead. -- -- This function could be moved into `parse_insn_normal', but keeping it -- separate makes clear the interface between `parse_insn_normal' and each of -- the handlers. It's also needed by GAS to insert operands that couldn't be -- resolved during parsing. */ -- --const char * --openrisc_cgen_insert_operand (CGEN_CPU_DESC cd, -- int opindex, -- CGEN_FIELDS * fields, -- CGEN_INSN_BYTES_PTR buffer, -- bfd_vma pc ATTRIBUTE_UNUSED) --{ -- const char * errmsg = NULL; -- unsigned int total_length = CGEN_FIELDS_BITSIZE (fields); -- -- switch (opindex) -- { -- case OPENRISC_OPERAND_ABS_26 : -- { -- long value = fields->f_abs26; -- value = ((SI) (pc) >> (2)); -- errmsg = insert_normal (cd, value, 0|(1<f_disp26; -- value = ((SI) (((value) - (pc))) >> (2)); -- errmsg = insert_normal (cd, value, 0|(1<f_simm16, 0|(1<f_lo16, 0|(1<f_op4, 0, 0, 23, 3, 32, total_length, buffer); -- break; -- case OPENRISC_OPERAND_OP_F_3 : -- errmsg = insert_normal (cd, fields->f_op5, 0, 0, 25, 5, 32, total_length, buffer); -- break; -- case OPENRISC_OPERAND_RA : -- errmsg = insert_normal (cd, fields->f_r2, 0, 0, 20, 5, 32, total_length, buffer); -- break; -- case OPENRISC_OPERAND_RB : -- errmsg = insert_normal (cd, fields->f_r3, 0, 0, 15, 5, 32, total_length, buffer); -- break; -- case OPENRISC_OPERAND_RD : -- errmsg = insert_normal (cd, fields->f_r1, 0, 0, 25, 5, 32, total_length, buffer); -- break; -- case OPENRISC_OPERAND_SIMM_16 : -- errmsg = insert_normal (cd, fields->f_simm16, 0|(1<> (11))) & (31)); -- FLD (f_i16_1) = ((FLD (f_i16nc)) & (2047)); --} -- errmsg = insert_normal (cd, fields->f_i16_1, 0, 0, 10, 11, 32, total_length, buffer); -- if (errmsg) -- break; -- errmsg = insert_normal (cd, fields->f_i16_2, 0, 0, 25, 5, 32, total_length, buffer); -- if (errmsg) -- break; -- } -- break; -- case OPENRISC_OPERAND_UIMM_16 : -- errmsg = insert_normal (cd, fields->f_uimm16, 0, 0, 15, 16, 32, total_length, buffer); -- break; -- case OPENRISC_OPERAND_UIMM_5 : -- errmsg = insert_normal (cd, fields->f_uimm5, 0, 0, 4, 5, 32, total_length, buffer); -- break; -- -- default : -- /* xgettext:c-format */ -- fprintf (stderr, _("Unrecognized field %d while building insn.\n"), -- opindex); -- abort (); -- } -- -- return errmsg; --} -- --int openrisc_cgen_extract_operand -- (CGEN_CPU_DESC, int, CGEN_EXTRACT_INFO *, CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma); -- --/* Main entry point for operand extraction. -- The result is <= 0 for error, >0 for success. -- ??? Actual values aren't well defined right now. -- -- This function is basically just a big switch statement. Earlier versions -- used tables to look up the function to use, but -- - if the table contains both assembler and disassembler functions then -- the disassembler contains much of the assembler and vice-versa, -- - there's a lot of inlining possibilities as things grow, -- - using a switch statement avoids the function call overhead. -- -- This function could be moved into `print_insn_normal', but keeping it -- separate makes clear the interface between `print_insn_normal' and each of -- the handlers. */ -- --int --openrisc_cgen_extract_operand (CGEN_CPU_DESC cd, -- int opindex, -- CGEN_EXTRACT_INFO *ex_info, -- CGEN_INSN_INT insn_value, -- CGEN_FIELDS * fields, -- bfd_vma pc) --{ -- /* Assume success (for those operands that are nops). */ -- int length = 1; -- unsigned int total_length = CGEN_FIELDS_BITSIZE (fields); -- -- switch (opindex) -- { -- case OPENRISC_OPERAND_ABS_26 : -- { -- long value; -- length = extract_normal (cd, ex_info, insn_value, 0|(1<f_abs26 = value; -- } -- break; -- case OPENRISC_OPERAND_DISP_26 : -- { -- long value; -- length = extract_normal (cd, ex_info, insn_value, 0|(1<f_disp26 = value; -- } -- break; -- case OPENRISC_OPERAND_HI16 : -- length = extract_normal (cd, ex_info, insn_value, 0|(1<f_simm16); -- break; -- case OPENRISC_OPERAND_LO16 : -- length = extract_normal (cd, ex_info, insn_value, 0|(1<f_lo16); -- break; -- case OPENRISC_OPERAND_OP_F_23 : -- length = extract_normal (cd, ex_info, insn_value, 0, 0, 23, 3, 32, total_length, pc, & fields->f_op4); -- break; -- case OPENRISC_OPERAND_OP_F_3 : -- length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 5, 32, total_length, pc, & fields->f_op5); -- break; -- case OPENRISC_OPERAND_RA : -- length = extract_normal (cd, ex_info, insn_value, 0, 0, 20, 5, 32, total_length, pc, & fields->f_r2); -- break; -- case OPENRISC_OPERAND_RB : -- length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 5, 32, total_length, pc, & fields->f_r3); -- break; -- case OPENRISC_OPERAND_RD : -- length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 5, 32, total_length, pc, & fields->f_r1); -- break; -- case OPENRISC_OPERAND_SIMM_16 : -- length = extract_normal (cd, ex_info, insn_value, 0|(1<f_simm16); -- break; -- case OPENRISC_OPERAND_UI16NC : -- { -- length = extract_normal (cd, ex_info, insn_value, 0, 0, 10, 11, 32, total_length, pc, & fields->f_i16_1); -- if (length <= 0) break; -- length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 5, 32, total_length, pc, & fields->f_i16_2); -- if (length <= 0) break; --{ -- FLD (f_i16nc) = openrisc_sign_extend_16bit (((((FLD (f_i16_2)) << (11))) | (FLD (f_i16_1)))); --} -- } -- break; -- case OPENRISC_OPERAND_UIMM_16 : -- length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 16, 32, total_length, pc, & fields->f_uimm16); -- break; -- case OPENRISC_OPERAND_UIMM_5 : -- length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 5, 32, total_length, pc, & fields->f_uimm5); -- break; -- -- default : -- /* xgettext:c-format */ -- fprintf (stderr, _("Unrecognized field %d while decoding insn.\n"), -- opindex); -- abort (); -- } -- -- return length; --} -- --cgen_insert_fn * const openrisc_cgen_insert_handlers[] = --{ -- insert_insn_normal, --}; -- --cgen_extract_fn * const openrisc_cgen_extract_handlers[] = --{ -- extract_insn_normal, --}; -- --int openrisc_cgen_get_int_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *); --bfd_vma openrisc_cgen_get_vma_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *); -- --/* Getting values from cgen_fields is handled by a collection of functions. -- They are distinguished by the type of the VALUE argument they return. -- TODO: floating point, inlining support, remove cases where result type -- not appropriate. */ -- --int --openrisc_cgen_get_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, -- int opindex, -- const CGEN_FIELDS * fields) --{ -- int value; -- -- switch (opindex) -- { -- case OPENRISC_OPERAND_ABS_26 : -- value = fields->f_abs26; -- break; -- case OPENRISC_OPERAND_DISP_26 : -- value = fields->f_disp26; -- break; -- case OPENRISC_OPERAND_HI16 : -- value = fields->f_simm16; -- break; -- case OPENRISC_OPERAND_LO16 : -- value = fields->f_lo16; -- break; -- case OPENRISC_OPERAND_OP_F_23 : -- value = fields->f_op4; -- break; -- case OPENRISC_OPERAND_OP_F_3 : -- value = fields->f_op5; -- break; -- case OPENRISC_OPERAND_RA : -- value = fields->f_r2; -- break; -- case OPENRISC_OPERAND_RB : -- value = fields->f_r3; -- break; -- case OPENRISC_OPERAND_RD : -- value = fields->f_r1; -- break; -- case OPENRISC_OPERAND_SIMM_16 : -- value = fields->f_simm16; -- break; -- case OPENRISC_OPERAND_UI16NC : -- value = fields->f_i16nc; -- break; -- case OPENRISC_OPERAND_UIMM_16 : -- value = fields->f_uimm16; -- break; -- case OPENRISC_OPERAND_UIMM_5 : -- value = fields->f_uimm5; -- break; -- -- default : -- /* xgettext:c-format */ -- fprintf (stderr, _("Unrecognized field %d while getting int operand.\n"), -- opindex); -- abort (); -- } -- -- return value; --} -- --bfd_vma --openrisc_cgen_get_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, -- int opindex, -- const CGEN_FIELDS * fields) --{ -- bfd_vma value; -- -- switch (opindex) -- { -- case OPENRISC_OPERAND_ABS_26 : -- value = fields->f_abs26; -- break; -- case OPENRISC_OPERAND_DISP_26 : -- value = fields->f_disp26; -- break; -- case OPENRISC_OPERAND_HI16 : -- value = fields->f_simm16; -- break; -- case OPENRISC_OPERAND_LO16 : -- value = fields->f_lo16; -- break; -- case OPENRISC_OPERAND_OP_F_23 : -- value = fields->f_op4; -- break; -- case OPENRISC_OPERAND_OP_F_3 : -- value = fields->f_op5; -- break; -- case OPENRISC_OPERAND_RA : -- value = fields->f_r2; -- break; -- case OPENRISC_OPERAND_RB : -- value = fields->f_r3; -- break; -- case OPENRISC_OPERAND_RD : -- value = fields->f_r1; -- break; -- case OPENRISC_OPERAND_SIMM_16 : -- value = fields->f_simm16; -- break; -- case OPENRISC_OPERAND_UI16NC : -- value = fields->f_i16nc; -- break; -- case OPENRISC_OPERAND_UIMM_16 : -- value = fields->f_uimm16; -- break; -- case OPENRISC_OPERAND_UIMM_5 : -- value = fields->f_uimm5; -- break; -- -- default : -- /* xgettext:c-format */ -- fprintf (stderr, _("Unrecognized field %d while getting vma operand.\n"), -- opindex); -- abort (); -- } -- -- return value; --} -- --void openrisc_cgen_set_int_operand (CGEN_CPU_DESC, int, CGEN_FIELDS *, int); --void openrisc_cgen_set_vma_operand (CGEN_CPU_DESC, int, CGEN_FIELDS *, bfd_vma); -- --/* Stuffing values in cgen_fields is handled by a collection of functions. -- They are distinguished by the type of the VALUE argument they accept. -- TODO: floating point, inlining support, remove cases where argument type -- not appropriate. */ -- --void --openrisc_cgen_set_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, -- int opindex, -- CGEN_FIELDS * fields, -- int value) --{ -- switch (opindex) -- { -- case OPENRISC_OPERAND_ABS_26 : -- fields->f_abs26 = value; -- break; -- case OPENRISC_OPERAND_DISP_26 : -- fields->f_disp26 = value; -- break; -- case OPENRISC_OPERAND_HI16 : -- fields->f_simm16 = value; -- break; -- case OPENRISC_OPERAND_LO16 : -- fields->f_lo16 = value; -- break; -- case OPENRISC_OPERAND_OP_F_23 : -- fields->f_op4 = value; -- break; -- case OPENRISC_OPERAND_OP_F_3 : -- fields->f_op5 = value; -- break; -- case OPENRISC_OPERAND_RA : -- fields->f_r2 = value; -- break; -- case OPENRISC_OPERAND_RB : -- fields->f_r3 = value; -- break; -- case OPENRISC_OPERAND_RD : -- fields->f_r1 = value; -- break; -- case OPENRISC_OPERAND_SIMM_16 : -- fields->f_simm16 = value; -- break; -- case OPENRISC_OPERAND_UI16NC : -- fields->f_i16nc = value; -- break; -- case OPENRISC_OPERAND_UIMM_16 : -- fields->f_uimm16 = value; -- break; -- case OPENRISC_OPERAND_UIMM_5 : -- fields->f_uimm5 = value; -- break; -- -- default : -- /* xgettext:c-format */ -- fprintf (stderr, _("Unrecognized field %d while setting int operand.\n"), -- opindex); -- abort (); -- } --} -- --void --openrisc_cgen_set_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, -- int opindex, -- CGEN_FIELDS * fields, -- bfd_vma value) --{ -- switch (opindex) -- { -- case OPENRISC_OPERAND_ABS_26 : -- fields->f_abs26 = value; -- break; -- case OPENRISC_OPERAND_DISP_26 : -- fields->f_disp26 = value; -- break; -- case OPENRISC_OPERAND_HI16 : -- fields->f_simm16 = value; -- break; -- case OPENRISC_OPERAND_LO16 : -- fields->f_lo16 = value; -- break; -- case OPENRISC_OPERAND_OP_F_23 : -- fields->f_op4 = value; -- break; -- case OPENRISC_OPERAND_OP_F_3 : -- fields->f_op5 = value; -- break; -- case OPENRISC_OPERAND_RA : -- fields->f_r2 = value; -- break; -- case OPENRISC_OPERAND_RB : -- fields->f_r3 = value; -- break; -- case OPENRISC_OPERAND_RD : -- fields->f_r1 = value; -- break; -- case OPENRISC_OPERAND_SIMM_16 : -- fields->f_simm16 = value; -- break; -- case OPENRISC_OPERAND_UI16NC : -- fields->f_i16nc = value; -- break; -- case OPENRISC_OPERAND_UIMM_16 : -- fields->f_uimm16 = value; -- break; -- case OPENRISC_OPERAND_UIMM_5 : -- fields->f_uimm5 = value; -- break; -- -- default : -- /* xgettext:c-format */ -- fprintf (stderr, _("Unrecognized field %d while setting vma operand.\n"), -- opindex); -- abort (); -- } --} -- --/* Function to call before using the instruction builder tables. */ -- --void --openrisc_cgen_init_ibld_table (CGEN_CPU_DESC cd) --{ -- cd->insert_handlers = & openrisc_cgen_insert_handlers[0]; -- cd->extract_handlers = & openrisc_cgen_extract_handlers[0]; -- -- cd->insert_operand = openrisc_cgen_insert_operand; -- cd->extract_operand = openrisc_cgen_extract_operand; -- -- cd->get_int_operand = openrisc_cgen_get_int_operand; -- cd->set_int_operand = openrisc_cgen_set_int_operand; -- cd->get_vma_operand = openrisc_cgen_get_vma_operand; -- cd->set_vma_operand = openrisc_cgen_set_vma_operand; --} -diff -rNU3 dist.orig/opcodes/openrisc-opc.c dist/opcodes/openrisc-opc.c ---- dist.orig/opcodes/openrisc-opc.c 2010-02-12 04:25:49.000000000 +0100 -+++ dist/opcodes/openrisc-opc.c 1970-01-01 01:00:00.000000000 +0100 -@@ -1,682 +0,0 @@ --/* Instruction opcode table for openrisc. -- --THIS FILE IS MACHINE GENERATED WITH CGEN. -- --Copyright 1996-2010 Free Software Foundation, Inc. -- --This file is part of the GNU Binutils and/or GDB, the GNU debugger. -- -- This file is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3, or (at your option) -- any later version. -- -- It is distributed in the hope that it will be useful, but WITHOUT -- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- License for more details. -- -- You should have received a copy of the GNU General Public License along -- with this program; if not, write to the Free Software Foundation, Inc., -- 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. -- --*/ -- --#include "sysdep.h" --#include "ansidecl.h" --#include "bfd.h" --#include "symcat.h" --#include "openrisc-desc.h" --#include "openrisc-opc.h" --#include "libiberty.h" -- --/* -- opc.c */ --/* -- */ --/* The hash functions are recorded here to help keep assembler code out of -- the disassembler and vice versa. */ -- --static int asm_hash_insn_p (const CGEN_INSN *); --static unsigned int asm_hash_insn (const char *); --static int dis_hash_insn_p (const CGEN_INSN *); --static unsigned int dis_hash_insn (const char *, CGEN_INSN_INT); -- --/* Instruction formats. */ -- --#define F(f) & openrisc_cgen_ifld_table[OPENRISC_##f] --static const CGEN_IFMT ifmt_empty ATTRIBUTE_UNUSED = { -- 0, 0, 0x0, { { 0 } } --}; -- --static const CGEN_IFMT ifmt_l_j ATTRIBUTE_UNUSED = { -- 32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_ABS26) }, { 0 } } --}; -- --static const CGEN_IFMT ifmt_l_jr ATTRIBUTE_UNUSED = { -- 32, 32, 0xffe00000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_OP3) }, { F (F_OP4) }, { F (F_R2) }, { F (F_UIMM16) }, { 0 } } --}; -- --static const CGEN_IFMT ifmt_l_bal ATTRIBUTE_UNUSED = { -- 32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_DISP26) }, { 0 } } --}; -- --static const CGEN_IFMT ifmt_l_movhi ATTRIBUTE_UNUSED = { -- 32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_SIMM16) }, { 0 } } --}; -- --static const CGEN_IFMT ifmt_l_mfsr ATTRIBUTE_UNUSED = { -- 32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_UIMM16) }, { 0 } } --}; -- --static const CGEN_IFMT ifmt_l_mtsr ATTRIBUTE_UNUSED = { -- 32, 32, 0xfc0007ff, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_R3) }, { F (F_I16_1) }, { 0 } } --}; -- --static const CGEN_IFMT ifmt_l_lw ATTRIBUTE_UNUSED = { -- 32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_SIMM16) }, { 0 } } --}; -- --static const CGEN_IFMT ifmt_l_sw ATTRIBUTE_UNUSED = { -- 32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R3) }, { F (F_I16NC) }, { 0 } } --}; -- --static const CGEN_IFMT ifmt_l_sll ATTRIBUTE_UNUSED = { -- 32, 32, 0xfc0007ff, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_R3) }, { F (F_F_10_3) }, { F (F_OP6) }, { F (F_F_4_1) }, { F (F_OP7) }, { 0 } } --}; -- --static const CGEN_IFMT ifmt_l_slli ATTRIBUTE_UNUSED = { -- 32, 32, 0xfc00ffe0, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_F_15_8) }, { F (F_OP6) }, { F (F_UIMM5) }, { 0 } } --}; -- --static const CGEN_IFMT ifmt_l_add ATTRIBUTE_UNUSED = { -- 32, 32, 0xfc0007ff, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_R3) }, { F (F_F_10_7) }, { F (F_OP7) }, { 0 } } --}; -- --static const CGEN_IFMT ifmt_l_addi ATTRIBUTE_UNUSED = { -- 32, 32, 0xfc000000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_R1) }, { F (F_R2) }, { F (F_LO16) }, { 0 } } --}; -- --static const CGEN_IFMT ifmt_l_sfgts ATTRIBUTE_UNUSED = { -- 32, 32, 0xffe007ff, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_OP5) }, { F (F_R2) }, { F (F_R3) }, { F (F_F_10_11) }, { 0 } } --}; -- --static const CGEN_IFMT ifmt_l_sfgtsi ATTRIBUTE_UNUSED = { -- 32, 32, 0xffe00000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_OP5) }, { F (F_R2) }, { F (F_SIMM16) }, { 0 } } --}; -- --static const CGEN_IFMT ifmt_l_sfgtui ATTRIBUTE_UNUSED = { -- 32, 32, 0xffe00000, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_OP5) }, { F (F_R2) }, { F (F_UIMM16) }, { 0 } } --}; -- --#undef F -- --#define A(a) (1 << CGEN_INSN_##a) --#define OPERAND(op) OPENRISC_OPERAND_##op --#define MNEM CGEN_SYNTAX_MNEMONIC /* syntax value for mnemonic */ --#define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field)) -- --/* The instruction table. */ -- --static const CGEN_OPCODE openrisc_cgen_insn_opcode_table[MAX_INSNS] = --{ -- /* Special null first entry. -- A `num' value of zero is thus invalid. -- Also, the special `invalid' insn resides here. */ -- { { 0, 0, 0, 0 }, {{0}}, 0, {0}}, --/* l.j ${abs-26} */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (ABS_26), 0 } }, -- & ifmt_l_j, { 0x0 } -- }, --/* l.jal ${abs-26} */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (ABS_26), 0 } }, -- & ifmt_l_j, { 0x4000000 } -- }, --/* l.jr $rA */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RA), 0 } }, -- & ifmt_l_jr, { 0x14000000 } -- }, --/* l.jalr $rA */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RA), 0 } }, -- & ifmt_l_jr, { 0x14200000 } -- }, --/* l.bal ${disp-26} */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (DISP_26), 0 } }, -- & ifmt_l_bal, { 0x8000000 } -- }, --/* l.bnf ${disp-26} */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (DISP_26), 0 } }, -- & ifmt_l_bal, { 0xc000000 } -- }, --/* l.bf ${disp-26} */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (DISP_26), 0 } }, -- & ifmt_l_bal, { 0x10000000 } -- }, --/* l.brk ${uimm-16} */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (UIMM_16), 0 } }, -- & ifmt_l_jr, { 0x17000000 } -- }, --/* l.rfe $rA */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RA), 0 } }, -- & ifmt_l_jr, { 0x14400000 } -- }, --/* l.sys ${uimm-16} */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (UIMM_16), 0 } }, -- & ifmt_l_jr, { 0x16000000 } -- }, --/* l.nop */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, 0 } }, -- & ifmt_l_jr, { 0x15000000 } -- }, --/* l.movhi $rD,$hi16 */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RD), ',', OP (HI16), 0 } }, -- & ifmt_l_movhi, { 0x18000000 } -- }, --/* l.mfsr $rD,$rA */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RD), ',', OP (RA), 0 } }, -- & ifmt_l_mfsr, { 0x1c000000 } -- }, --/* l.mtsr $rA,$rB */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, -- & ifmt_l_mtsr, { 0x40000000 } -- }, --/* l.lw $rD,${simm-16}($rA) */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RD), ',', OP (SIMM_16), '(', OP (RA), ')', 0 } }, -- & ifmt_l_lw, { 0x80000000 } -- }, --/* l.lbz $rD,${simm-16}($rA) */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RD), ',', OP (SIMM_16), '(', OP (RA), ')', 0 } }, -- & ifmt_l_lw, { 0x84000000 } -- }, --/* l.lbs $rD,${simm-16}($rA) */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RD), ',', OP (SIMM_16), '(', OP (RA), ')', 0 } }, -- & ifmt_l_lw, { 0x88000000 } -- }, --/* l.lhz $rD,${simm-16}($rA) */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RD), ',', OP (SIMM_16), '(', OP (RA), ')', 0 } }, -- & ifmt_l_lw, { 0x8c000000 } -- }, --/* l.lhs $rD,${simm-16}($rA) */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RD), ',', OP (SIMM_16), '(', OP (RA), ')', 0 } }, -- & ifmt_l_lw, { 0x90000000 } -- }, --/* l.sw ${ui16nc}($rA),$rB */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (UI16NC), '(', OP (RA), ')', ',', OP (RB), 0 } }, -- & ifmt_l_sw, { 0xd4000000 } -- }, --/* l.sb ${ui16nc}($rA),$rB */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (UI16NC), '(', OP (RA), ')', ',', OP (RB), 0 } }, -- & ifmt_l_sw, { 0xd8000000 } -- }, --/* l.sh ${ui16nc}($rA),$rB */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (UI16NC), '(', OP (RA), ')', ',', OP (RB), 0 } }, -- & ifmt_l_sw, { 0xdc000000 } -- }, --/* l.sll $rD,$rA,$rB */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, -- & ifmt_l_sll, { 0xe0000008 } -- }, --/* l.slli $rD,$rA,${uimm-5} */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (UIMM_5), 0 } }, -- & ifmt_l_slli, { 0xb4000000 } -- }, --/* l.srl $rD,$rA,$rB */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, -- & ifmt_l_sll, { 0xe0000028 } -- }, --/* l.srli $rD,$rA,${uimm-5} */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (UIMM_5), 0 } }, -- & ifmt_l_slli, { 0xb4000020 } -- }, --/* l.sra $rD,$rA,$rB */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, -- & ifmt_l_sll, { 0xe0000048 } -- }, --/* l.srai $rD,$rA,${uimm-5} */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (UIMM_5), 0 } }, -- & ifmt_l_slli, { 0xb4000040 } -- }, --/* l.ror $rD,$rA,$rB */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, -- & ifmt_l_sll, { 0xe0000088 } -- }, --/* l.rori $rD,$rA,${uimm-5} */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (UIMM_5), 0 } }, -- & ifmt_l_slli, { 0xb4000080 } -- }, --/* l.add $rD,$rA,$rB */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, -- & ifmt_l_add, { 0xe0000000 } -- }, --/* l.addi $rD,$rA,$lo16 */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (LO16), 0 } }, -- & ifmt_l_addi, { 0x94000000 } -- }, --/* l.sub $rD,$rA,$rB */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, -- & ifmt_l_add, { 0xe0000002 } -- }, --/* l.subi $rD,$rA,$lo16 */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (LO16), 0 } }, -- & ifmt_l_addi, { 0x9c000000 } -- }, --/* l.and $rD,$rA,$rB */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, -- & ifmt_l_add, { 0xe0000003 } -- }, --/* l.andi $rD,$rA,$lo16 */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (LO16), 0 } }, -- & ifmt_l_addi, { 0xa0000000 } -- }, --/* l.or $rD,$rA,$rB */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, -- & ifmt_l_add, { 0xe0000004 } -- }, --/* l.ori $rD,$rA,$lo16 */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (LO16), 0 } }, -- & ifmt_l_addi, { 0xa4000000 } -- }, --/* l.xor $rD,$rA,$rB */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, -- & ifmt_l_add, { 0xe0000005 } -- }, --/* l.xori $rD,$rA,$lo16 */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (LO16), 0 } }, -- & ifmt_l_addi, { 0xa8000000 } -- }, --/* l.mul $rD,$rA,$rB */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, -- & ifmt_l_add, { 0xe0000006 } -- }, --/* l.muli $rD,$rA,$lo16 */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (LO16), 0 } }, -- & ifmt_l_addi, { 0xac000000 } -- }, --/* l.div $rD,$rA,$rB */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, -- & ifmt_l_add, { 0xe0000009 } -- }, --/* l.divu $rD,$rA,$rB */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, -- & ifmt_l_add, { 0xe000000a } -- }, --/* l.sfgts $rA,$rB */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, -- & ifmt_l_sfgts, { 0xe4c00000 } -- }, --/* l.sfgtu $rA,$rB */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, -- & ifmt_l_sfgts, { 0xe4400000 } -- }, --/* l.sfges $rA,$rB */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, -- & ifmt_l_sfgts, { 0xe4e00000 } -- }, --/* l.sfgeu $rA,$rB */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, -- & ifmt_l_sfgts, { 0xe4600000 } -- }, --/* l.sflts $rA,$rB */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, -- & ifmt_l_sfgts, { 0xe5000000 } -- }, --/* l.sfltu $rA,$rB */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, -- & ifmt_l_sfgts, { 0xe4800000 } -- }, --/* l.sfles $rA,$rB */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, -- & ifmt_l_sfgts, { 0xe5200000 } -- }, --/* l.sfleu $rA,$rB */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, -- & ifmt_l_sfgts, { 0xe4a00000 } -- }, --/* l.sfgtsi $rA,${simm-16} */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RA), ',', OP (SIMM_16), 0 } }, -- & ifmt_l_sfgtsi, { 0xb8c00000 } -- }, --/* l.sfgtui $rA,${uimm-16} */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RA), ',', OP (UIMM_16), 0 } }, -- & ifmt_l_sfgtui, { 0xb8400000 } -- }, --/* l.sfgesi $rA,${simm-16} */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RA), ',', OP (SIMM_16), 0 } }, -- & ifmt_l_sfgtsi, { 0xb8e00000 } -- }, --/* l.sfgeui $rA,${uimm-16} */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RA), ',', OP (UIMM_16), 0 } }, -- & ifmt_l_sfgtui, { 0xb8600000 } -- }, --/* l.sfltsi $rA,${simm-16} */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RA), ',', OP (SIMM_16), 0 } }, -- & ifmt_l_sfgtsi, { 0xb9000000 } -- }, --/* l.sfltui $rA,${uimm-16} */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RA), ',', OP (UIMM_16), 0 } }, -- & ifmt_l_sfgtui, { 0xb8800000 } -- }, --/* l.sflesi $rA,${simm-16} */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RA), ',', OP (SIMM_16), 0 } }, -- & ifmt_l_sfgtsi, { 0xb9200000 } -- }, --/* l.sfleui $rA,${uimm-16} */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RA), ',', OP (UIMM_16), 0 } }, -- & ifmt_l_sfgtui, { 0xb8a00000 } -- }, --/* l.sfeq $rA,$rB */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, -- & ifmt_l_sfgts, { 0xe4000000 } -- }, --/* l.sfeqi $rA,${simm-16} */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RA), ',', OP (SIMM_16), 0 } }, -- & ifmt_l_sfgtsi, { 0xb8000000 } -- }, --/* l.sfne $rA,$rB */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, -- & ifmt_l_sfgts, { 0xe4200000 } -- }, --/* l.sfnei $rA,${simm-16} */ -- { -- { 0, 0, 0, 0 }, -- { { MNEM, ' ', OP (RA), ',', OP (SIMM_16), 0 } }, -- & ifmt_l_sfgtsi, { 0xb8200000 } -- }, --}; -- --#undef A --#undef OPERAND --#undef MNEM --#undef OP -- --/* Formats for ALIAS macro-insns. */ -- --#define F(f) & openrisc_cgen_ifld_table[OPENRISC_##f] --static const CGEN_IFMT ifmt_l_ret ATTRIBUTE_UNUSED = { -- 32, 32, 0xffffffff, { { F (F_CLASS) }, { F (F_SUB) }, { F (F_OP3) }, { F (F_OP4) }, { F (F_R2) }, { F (F_UIMM16) }, { 0 } } --}; -- --#undef F -- --/* Each non-simple macro entry points to an array of expansion possibilities. */ -- --#define A(a) (1 << CGEN_INSN_##a) --#define OPERAND(op) OPENRISC_OPERAND_##op --#define MNEM CGEN_SYNTAX_MNEMONIC /* syntax value for mnemonic */ --#define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field)) -- --/* The macro instruction table. */ -- --static const CGEN_IBASE openrisc_cgen_macro_insn_table[] = --{ --/* l.ret */ -- { -- -1, "l-ret", "l.ret", 32, -- { 0|A(ALIAS), { { { (1<= 1) -- memset (insns, 0, num_macros * sizeof (CGEN_INSN)); -- for (i = 0; i < num_macros; ++i) -- { -- insns[i].base = &ib[i]; -- insns[i].opcode = &oc[i]; -- openrisc_cgen_build_insn_regex (& insns[i]); -- } -- cd->macro_insn_table.init_entries = insns; -- cd->macro_insn_table.entry_size = sizeof (CGEN_IBASE); -- cd->macro_insn_table.num_init_entries = num_macros; -- -- oc = & openrisc_cgen_insn_opcode_table[0]; -- insns = (CGEN_INSN *) cd->insn_table.init_entries; -- for (i = 0; i < MAX_INSNS; ++i) -- { -- insns[i].opcode = &oc[i]; -- openrisc_cgen_build_insn_regex (& insns[i]); -- } -- -- cd->sizeof_fields = sizeof (CGEN_FIELDS); -- cd->set_fields_bitsize = set_fields_bitsize; -- -- cd->asm_hash_p = asm_hash_insn_p; -- cd->asm_hash = asm_hash_insn; -- cd->asm_hash_size = CGEN_ASM_HASH_SIZE; -- -- cd->dis_hash_p = dis_hash_insn_p; -- cd->dis_hash = dis_hash_insn; -- cd->dis_hash_size = CGEN_DIS_HASH_SIZE; --} -diff -rNU3 dist.orig/opcodes/openrisc-opc.h dist/opcodes/openrisc-opc.h ---- dist.orig/opcodes/openrisc-opc.h 2010-01-02 19:50:59.000000000 +0100 -+++ dist/opcodes/openrisc-opc.h 1970-01-01 01:00:00.000000000 +0100 -@@ -1,113 +0,0 @@ --/* Instruction opcode header for openrisc. -- --THIS FILE IS MACHINE GENERATED WITH CGEN. -- --Copyright 1996-2010 Free Software Foundation, Inc. -- --This file is part of the GNU Binutils and/or GDB, the GNU debugger. -- -- This file is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3, or (at your option) -- any later version. -- -- It is distributed in the hope that it will be useful, but WITHOUT -- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- License for more details. -- -- You should have received a copy of the GNU General Public License along -- with this program; if not, write to the Free Software Foundation, Inc., -- 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. -- --*/ -- --#ifndef OPENRISC_OPC_H --#define OPENRISC_OPC_H -- --/* -- opc.h */ --#undef CGEN_DIS_HASH_SIZE --#define CGEN_DIS_HASH_SIZE 64 --#undef CGEN_DIS_HASH --#define CGEN_DIS_HASH(buffer, value) (((unsigned char *) (buffer))[0] >> 2) -- --extern long openrisc_sign_extend_16bit (long); --/* -- */ --/* Enum declaration for openrisc instruction types. */ --typedef enum cgen_insn_type { -- OPENRISC_INSN_INVALID, OPENRISC_INSN_L_J, OPENRISC_INSN_L_JAL, OPENRISC_INSN_L_JR -- , OPENRISC_INSN_L_JALR, OPENRISC_INSN_L_BAL, OPENRISC_INSN_L_BNF, OPENRISC_INSN_L_BF -- , OPENRISC_INSN_L_BRK, OPENRISC_INSN_L_RFE, OPENRISC_INSN_L_SYS, OPENRISC_INSN_L_NOP -- , OPENRISC_INSN_L_MOVHI, OPENRISC_INSN_L_MFSR, OPENRISC_INSN_L_MTSR, OPENRISC_INSN_L_LW -- , OPENRISC_INSN_L_LBZ, OPENRISC_INSN_L_LBS, OPENRISC_INSN_L_LHZ, OPENRISC_INSN_L_LHS -- , OPENRISC_INSN_L_SW, OPENRISC_INSN_L_SB, OPENRISC_INSN_L_SH, OPENRISC_INSN_L_SLL -- , OPENRISC_INSN_L_SLLI, OPENRISC_INSN_L_SRL, OPENRISC_INSN_L_SRLI, OPENRISC_INSN_L_SRA -- , OPENRISC_INSN_L_SRAI, OPENRISC_INSN_L_ROR, OPENRISC_INSN_L_RORI, OPENRISC_INSN_L_ADD -- , OPENRISC_INSN_L_ADDI, OPENRISC_INSN_L_SUB, OPENRISC_INSN_L_SUBI, OPENRISC_INSN_L_AND -- , OPENRISC_INSN_L_ANDI, OPENRISC_INSN_L_OR, OPENRISC_INSN_L_ORI, OPENRISC_INSN_L_XOR -- , OPENRISC_INSN_L_XORI, OPENRISC_INSN_L_MUL, OPENRISC_INSN_L_MULI, OPENRISC_INSN_L_DIV -- , OPENRISC_INSN_L_DIVU, OPENRISC_INSN_L_SFGTS, OPENRISC_INSN_L_SFGTU, OPENRISC_INSN_L_SFGES -- , OPENRISC_INSN_L_SFGEU, OPENRISC_INSN_L_SFLTS, OPENRISC_INSN_L_SFLTU, OPENRISC_INSN_L_SFLES -- , OPENRISC_INSN_L_SFLEU, OPENRISC_INSN_L_SFGTSI, OPENRISC_INSN_L_SFGTUI, OPENRISC_INSN_L_SFGESI -- , OPENRISC_INSN_L_SFGEUI, OPENRISC_INSN_L_SFLTSI, OPENRISC_INSN_L_SFLTUI, OPENRISC_INSN_L_SFLESI -- , OPENRISC_INSN_L_SFLEUI, OPENRISC_INSN_L_SFEQ, OPENRISC_INSN_L_SFEQI, OPENRISC_INSN_L_SFNE -- , OPENRISC_INSN_L_SFNEI --} CGEN_INSN_TYPE; -- --/* Index of `invalid' insn place holder. */ --#define CGEN_INSN_INVALID OPENRISC_INSN_INVALID -- --/* Total number of insns in table. */ --#define MAX_INSNS ((int) OPENRISC_INSN_L_SFNEI + 1) -- --/* This struct records data prior to insertion or after extraction. */ --struct cgen_fields --{ -- int length; -- long f_nil; -- long f_anyof; -- long f_class; -- long f_sub; -- long f_r1; -- long f_r2; -- long f_r3; -- long f_simm16; -- long f_uimm16; -- long f_uimm5; -- long f_hi16; -- long f_lo16; -- long f_op1; -- long f_op2; -- long f_op3; -- long f_op4; -- long f_op5; -- long f_op6; -- long f_op7; -- long f_i16_1; -- long f_i16_2; -- long f_disp26; -- long f_abs26; -- long f_i16nc; -- long f_f_15_8; -- long f_f_10_3; -- long f_f_4_1; -- long f_f_7_3; -- long f_f_10_7; -- long f_f_10_11; --}; -- --#define CGEN_INIT_PARSE(od) \ --{\ --} --#define CGEN_INIT_INSERT(od) \ --{\ --} --#define CGEN_INIT_EXTRACT(od) \ --{\ --} --#define CGEN_INIT_PRINT(od) \ --{\ --} -- -- --#endif /* OPENRISC_OPC_H */ -diff -rNU3 dist.orig/opcodes/or1k-asm.c dist/opcodes/or1k-asm.c ---- dist.orig/opcodes/or1k-asm.c 1970-01-01 01:00:00.000000000 +0100 -+++ dist/opcodes/or1k-asm.c 2015-10-18 13:11:20.000000000 +0200 -@@ -0,0 +1,910 @@ -+/* Assembler interface for targets using CGEN. -*- C -*- -+ CGEN: Cpu tools GENerator -+ -+ THIS FILE IS MACHINE GENERATED WITH CGEN. -+ - the resultant file is machine generated, cgen-asm.in isn't -+ -+ Copyright (C) 1996-2014 Free Software Foundation, Inc. -+ -+ This file is part of libopcodes. -+ -+ This library is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3, or (at your option) -+ any later version. -+ -+ It is distributed in the hope that it will be useful, but WITHOUT -+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -+ License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, write to the Free Software Foundation, Inc., -+ 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -+ -+ -+/* ??? Eventually more and more of this stuff can go to cpu-independent files. -+ Keep that in mind. */ -+ -+#include "sysdep.h" -+#include -+#include "ansidecl.h" -+#include "bfd.h" -+#include "symcat.h" -+#include "or1k-desc.h" -+#include "or1k-opc.h" -+#include "opintl.h" -+#include "xregex.h" -+#include "libiberty.h" -+#include "safe-ctype.h" -+ -+#undef min -+#define min(a,b) ((a) < (b) ? (a) : (b)) -+#undef max -+#define max(a,b) ((a) > (b) ? (a) : (b)) -+ -+static const char * parse_insn_normal -+ (CGEN_CPU_DESC, const CGEN_INSN *, const char **, CGEN_FIELDS *); -+ -+/* -- assembler routines inserted here. */ -+ -+/* -- asm.c */ -+ -+static const char * MISSING_CLOSING_PARENTHESIS = N_("missing `)'"); -+ -+#define CGEN_VERBOSE_ASSEMBLER_ERRORS -+ -+static const char * -+parse_disp26 (CGEN_CPU_DESC cd, -+ const char ** strp, -+ int opindex, -+ int opinfo, -+ enum cgen_parse_operand_result * resultp, -+ bfd_vma * valuep) -+{ -+ const char *errmsg = NULL; -+ enum cgen_parse_operand_result result_type; -+ -+ if (strncasecmp (*strp, "plt(", 4) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 4; -+ errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_OR1K_PLT26, -+ & result_type, & value); -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ value = (value >> 2) & 0xffff; -+ *valuep = value; -+ return errmsg; -+ } -+ return cgen_parse_address (cd, strp, opindex, opinfo, resultp, valuep); -+} -+ -+static const char * -+parse_simm16 (CGEN_CPU_DESC cd, const char ** strp, int opindex, long * valuep) -+{ -+ const char *errmsg; -+ enum cgen_parse_operand_result result_type; -+ long ret; -+ -+ if (**strp == '#') -+ ++*strp; -+ -+ if (strncasecmp (*strp, "hi(", 3) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 3; -+ errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_HI16, -+ & result_type, & value); -+ if (**strp != ')') -+ errmsg = MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ -+ ret = value; -+ -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ { -+ ret >>= 16; -+ ret &= 0xffff; -+ ret = (ret ^ 0x8000) - 0x8000; -+ } -+ } -+ else if (strncasecmp (*strp, "lo(", 3) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 3; -+ errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_LO16, -+ & result_type, & value); -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ -+ ret = value; -+ -+ if (result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ { -+ ret &= 0xffff; -+ ret = (ret ^ 0x8000) - 0x8000; -+ } -+ } -+ else if (strncasecmp (*strp, "got(", 4) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 4; -+ errmsg = cgen_parse_address (cd, strp, opindex, BFD_RELOC_OR1K_GOT16, -+ & result_type, & value); -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ value &= 0xffff; -+ *valuep = value; -+ return errmsg; -+ } -+ else if (strncasecmp (*strp, "gotpchi(", 8) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 8; -+ errmsg = cgen_parse_address (cd, strp, opindex, -+ BFD_RELOC_OR1K_GOTPC_HI16, -+ & result_type, & value); -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ value = (value >> 16) & 0xffff; -+ *valuep = value; -+ return errmsg; -+ } -+ else if (strncasecmp (*strp, "gotpclo(", 8) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 8; -+ errmsg = cgen_parse_address (cd, strp, opindex, -+ BFD_RELOC_OR1K_GOTPC_LO16, -+ &result_type, &value); -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ value &= 0xffff; -+ *valuep = value; -+ return errmsg; -+ } -+ else if (strncasecmp (*strp, "gotoffhi(", 9) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 9; -+ errmsg = cgen_parse_address (cd, strp, opindex, -+ BFD_RELOC_OR1K_GOTOFF_HI16, -+ & result_type, & value); -+ -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ value = (value >> 16) & 0xffff; -+ *valuep = value; -+ return errmsg; -+ } -+ else if (strncasecmp (*strp, "gotofflo(", 9) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 9; -+ errmsg = cgen_parse_address (cd, strp, opindex, -+ BFD_RELOC_OR1K_GOTOFF_LO16, -+ &result_type, &value); -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ value &= 0xffff; -+ *valuep = value; -+ return errmsg; -+ } -+ else if (strncasecmp (*strp, "tlsgdhi(", 8) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 8; -+ errmsg = cgen_parse_address (cd, strp, opindex, -+ BFD_RELOC_OR1K_TLS_GD_HI16, -+ & result_type, & value); -+ -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ value = (value >> 16) & 0xffff; -+ *valuep = value; -+ return errmsg; -+ } -+ else if (strncasecmp (*strp, "tlsgdlo(", 8) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 8; -+ errmsg = cgen_parse_address (cd, strp, opindex, -+ BFD_RELOC_OR1K_TLS_GD_LO16, -+ &result_type, &value); -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ value &= 0xffff; -+ *valuep = value; -+ return errmsg; -+ } -+ else if (strncasecmp (*strp, "tlsldmhi(", 9) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 9; -+ errmsg = cgen_parse_address (cd, strp, opindex, -+ BFD_RELOC_OR1K_TLS_LDM_HI16, -+ & result_type, & value); -+ -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ value = (value >> 16) & 0xffff; -+ *valuep = value; -+ return errmsg; -+ } -+ else if (strncasecmp (*strp, "tlsldmlo(", 9) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 9; -+ errmsg = cgen_parse_address (cd, strp, opindex, -+ BFD_RELOC_OR1K_TLS_LDM_LO16, -+ &result_type, &value); -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ value &= 0xffff; -+ *valuep = value; -+ return errmsg; -+ } -+ else if (strncasecmp (*strp, "dtpoffhi(", 9) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 9; -+ errmsg = cgen_parse_address (cd, strp, opindex, -+ BFD_RELOC_OR1K_TLS_LDO_HI16, -+ & result_type, & value); -+ -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ value = (value >> 16) & 0xffff; -+ *valuep = value; -+ return errmsg; -+ } -+ else if (strncasecmp (*strp, "dtpofflo(", 9) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 9; -+ errmsg = cgen_parse_address (cd, strp, opindex, -+ BFD_RELOC_OR1K_TLS_LDO_LO16, -+ &result_type, &value); -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ value &= 0xffff; -+ *valuep = value; -+ return errmsg; -+ } -+ else if (strncasecmp (*strp, "gottpoffhi(", 11) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 11; -+ errmsg = cgen_parse_address (cd, strp, opindex, -+ BFD_RELOC_OR1K_TLS_IE_HI16, -+ & result_type, & value); -+ -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ value = (value >> 16) & 0xffff; -+ *valuep = value; -+ return errmsg; -+ } -+ else if (strncasecmp (*strp, "gottpofflo(", 11) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 11; -+ errmsg = cgen_parse_address (cd, strp, opindex, -+ BFD_RELOC_OR1K_TLS_IE_LO16, -+ &result_type, &value); -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ value &= 0xffff; -+ *valuep = value; -+ return errmsg; -+ } -+ else if (strncasecmp (*strp, "tpoffhi(", 8) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 8; -+ errmsg = cgen_parse_address (cd, strp, opindex, -+ BFD_RELOC_OR1K_TLS_LE_HI16, -+ & result_type, & value); -+ -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ value = (value >> 16) & 0xffff; -+ *valuep = value; -+ return errmsg; -+ } -+ else if (strncasecmp (*strp, "tpofflo(", 8) == 0) -+ { -+ bfd_vma value; -+ -+ *strp += 8; -+ errmsg = cgen_parse_address (cd, strp, opindex, -+ BFD_RELOC_OR1K_TLS_LE_LO16, -+ &result_type, &value); -+ if (**strp != ')') -+ return MISSING_CLOSING_PARENTHESIS; -+ ++*strp; -+ if (errmsg == NULL -+ && result_type == CGEN_PARSE_OPERAND_RESULT_NUMBER) -+ value &= 0xffff; -+ *valuep = value; -+ return errmsg; -+ } -+ else -+ { -+ long value; -+ errmsg = cgen_parse_signed_integer (cd, strp, opindex, &value); -+ ret = value; -+ } -+ -+ if (errmsg == NULL) -+ *valuep = ret; -+ -+ return errmsg; -+} -+ -+static const char * -+parse_uimm16 (CGEN_CPU_DESC cd, const char ** strp, int opindex, unsigned long * valuep) -+{ -+ const char *errmsg = parse_simm16(cd, strp, opindex, (long *) valuep); -+ -+ if (errmsg == NULL) -+ *valuep &= 0xffff; -+ return errmsg; -+} -+ -+/* -- */ -+ -+const char * or1k_cgen_parse_operand -+ (CGEN_CPU_DESC, int, const char **, CGEN_FIELDS *); -+ -+/* Main entry point for operand parsing. -+ -+ This function is basically just a big switch statement. Earlier versions -+ used tables to look up the function to use, but -+ - if the table contains both assembler and disassembler functions then -+ the disassembler contains much of the assembler and vice-versa, -+ - there's a lot of inlining possibilities as things grow, -+ - using a switch statement avoids the function call overhead. -+ -+ This function could be moved into `parse_insn_normal', but keeping it -+ separate makes clear the interface between `parse_insn_normal' and each of -+ the handlers. */ -+ -+const char * -+or1k_cgen_parse_operand (CGEN_CPU_DESC cd, -+ int opindex, -+ const char ** strp, -+ CGEN_FIELDS * fields) -+{ -+ const char * errmsg = NULL; -+ /* Used by scalar operands that still need to be parsed. */ -+ long junk ATTRIBUTE_UNUSED; -+ -+ switch (opindex) -+ { -+ case OR1K_OPERAND_DISP26 : -+ { -+ bfd_vma value = 0; -+ errmsg = parse_disp26 (cd, strp, OR1K_OPERAND_DISP26, 0, NULL, & value); -+ fields->f_disp26 = value; -+ } -+ break; -+ case OR1K_OPERAND_RA : -+ errmsg = cgen_parse_keyword (cd, strp, & or1k_cgen_opval_h_gpr, & fields->f_r2); -+ break; -+ case OR1K_OPERAND_RADF : -+ errmsg = cgen_parse_keyword (cd, strp, & or1k_cgen_opval_h_fdr, & fields->f_r1); -+ break; -+ case OR1K_OPERAND_RASF : -+ errmsg = cgen_parse_keyword (cd, strp, & or1k_cgen_opval_h_fsr, & fields->f_r2); -+ break; -+ case OR1K_OPERAND_RB : -+ errmsg = cgen_parse_keyword (cd, strp, & or1k_cgen_opval_h_gpr, & fields->f_r3); -+ break; -+ case OR1K_OPERAND_RBDF : -+ errmsg = cgen_parse_keyword (cd, strp, & or1k_cgen_opval_h_fdr, & fields->f_r1); -+ break; -+ case OR1K_OPERAND_RBSF : -+ errmsg = cgen_parse_keyword (cd, strp, & or1k_cgen_opval_h_fsr, & fields->f_r3); -+ break; -+ case OR1K_OPERAND_RD : -+ errmsg = cgen_parse_keyword (cd, strp, & or1k_cgen_opval_h_gpr, & fields->f_r1); -+ break; -+ case OR1K_OPERAND_RDDF : -+ errmsg = cgen_parse_keyword (cd, strp, & or1k_cgen_opval_h_fdr, & fields->f_r1); -+ break; -+ case OR1K_OPERAND_RDSF : -+ errmsg = cgen_parse_keyword (cd, strp, & or1k_cgen_opval_h_fsr, & fields->f_r1); -+ break; -+ case OR1K_OPERAND_SIMM16 : -+ errmsg = parse_simm16 (cd, strp, OR1K_OPERAND_SIMM16, (long *) (& fields->f_simm16)); -+ break; -+ case OR1K_OPERAND_SIMM16_SPLIT : -+ errmsg = parse_simm16 (cd, strp, OR1K_OPERAND_SIMM16_SPLIT, (long *) (& fields->f_simm16_split)); -+ break; -+ case OR1K_OPERAND_UIMM16 : -+ errmsg = parse_uimm16 (cd, strp, OR1K_OPERAND_UIMM16, (unsigned long *) (& fields->f_uimm16)); -+ break; -+ case OR1K_OPERAND_UIMM16_SPLIT : -+ errmsg = parse_uimm16 (cd, strp, OR1K_OPERAND_UIMM16_SPLIT, (unsigned long *) (& fields->f_uimm16_split)); -+ break; -+ case OR1K_OPERAND_UIMM6 : -+ errmsg = cgen_parse_unsigned_integer (cd, strp, OR1K_OPERAND_UIMM6, (unsigned long *) (& fields->f_uimm6)); -+ break; -+ -+ default : -+ /* xgettext:c-format */ -+ fprintf (stderr, _("Unrecognized field %d while parsing.\n"), opindex); -+ abort (); -+ } -+ -+ return errmsg; -+} -+ -+cgen_parse_fn * const or1k_cgen_parse_handlers[] = -+{ -+ parse_insn_normal, -+}; -+ -+void -+or1k_cgen_init_asm (CGEN_CPU_DESC cd) -+{ -+ or1k_cgen_init_opcode_table (cd); -+ or1k_cgen_init_ibld_table (cd); -+ cd->parse_handlers = & or1k_cgen_parse_handlers[0]; -+ cd->parse_operand = or1k_cgen_parse_operand; -+#ifdef CGEN_ASM_INIT_HOOK -+CGEN_ASM_INIT_HOOK -+#endif -+} -+ -+ -+ -+/* Regex construction routine. -+ -+ This translates an opcode syntax string into a regex string, -+ by replacing any non-character syntax element (such as an -+ opcode) with the pattern '.*' -+ -+ It then compiles the regex and stores it in the opcode, for -+ later use by or1k_cgen_assemble_insn -+ -+ Returns NULL for success, an error message for failure. */ -+ -+char * -+or1k_cgen_build_insn_regex (CGEN_INSN *insn) -+{ -+ CGEN_OPCODE *opc = (CGEN_OPCODE *) CGEN_INSN_OPCODE (insn); -+ const char *mnem = CGEN_INSN_MNEMONIC (insn); -+ char rxbuf[CGEN_MAX_RX_ELEMENTS]; -+ char *rx = rxbuf; -+ const CGEN_SYNTAX_CHAR_TYPE *syn; -+ int reg_err; -+ -+ syn = CGEN_SYNTAX_STRING (CGEN_OPCODE_SYNTAX (opc)); -+ -+ /* Mnemonics come first in the syntax string. */ -+ if (! CGEN_SYNTAX_MNEMONIC_P (* syn)) -+ return _("missing mnemonic in syntax string"); -+ ++syn; -+ -+ /* Generate a case sensitive regular expression that emulates case -+ insensitive matching in the "C" locale. We cannot generate a case -+ insensitive regular expression because in Turkish locales, 'i' and 'I' -+ are not equal modulo case conversion. */ -+ -+ /* Copy the literal mnemonic out of the insn. */ -+ for (; *mnem; mnem++) -+ { -+ char c = *mnem; -+ -+ if (ISALPHA (c)) -+ { -+ *rx++ = '['; -+ *rx++ = TOLOWER (c); -+ *rx++ = TOUPPER (c); -+ *rx++ = ']'; -+ } -+ else -+ *rx++ = c; -+ } -+ -+ /* Copy any remaining literals from the syntax string into the rx. */ -+ for(; * syn != 0 && rx <= rxbuf + (CGEN_MAX_RX_ELEMENTS - 7 - 4); ++syn) -+ { -+ if (CGEN_SYNTAX_CHAR_P (* syn)) -+ { -+ char c = CGEN_SYNTAX_CHAR (* syn); -+ -+ switch (c) -+ { -+ /* Escape any regex metacharacters in the syntax. */ -+ case '.': case '[': case '\\': -+ case '*': case '^': case '$': -+ -+#ifdef CGEN_ESCAPE_EXTENDED_REGEX -+ case '?': case '{': case '}': -+ case '(': case ')': case '*': -+ case '|': case '+': case ']': -+#endif -+ *rx++ = '\\'; -+ *rx++ = c; -+ break; -+ -+ default: -+ if (ISALPHA (c)) -+ { -+ *rx++ = '['; -+ *rx++ = TOLOWER (c); -+ *rx++ = TOUPPER (c); -+ *rx++ = ']'; -+ } -+ else -+ *rx++ = c; -+ break; -+ } -+ } -+ else -+ { -+ /* Replace non-syntax fields with globs. */ -+ *rx++ = '.'; -+ *rx++ = '*'; -+ } -+ } -+ -+ /* Trailing whitespace ok. */ -+ * rx++ = '['; -+ * rx++ = ' '; -+ * rx++ = '\t'; -+ * rx++ = ']'; -+ * rx++ = '*'; -+ -+ /* But anchor it after that. */ -+ * rx++ = '$'; -+ * rx = '\0'; -+ -+ CGEN_INSN_RX (insn) = xmalloc (sizeof (regex_t)); -+ reg_err = regcomp ((regex_t *) CGEN_INSN_RX (insn), rxbuf, REG_NOSUB); -+ -+ if (reg_err == 0) -+ return NULL; -+ else -+ { -+ static char msg[80]; -+ -+ regerror (reg_err, (regex_t *) CGEN_INSN_RX (insn), msg, 80); -+ regfree ((regex_t *) CGEN_INSN_RX (insn)); -+ free (CGEN_INSN_RX (insn)); -+ (CGEN_INSN_RX (insn)) = NULL; -+ return msg; -+ } -+} -+ -+ -+/* Default insn parser. -+ -+ The syntax string is scanned and operands are parsed and stored in FIELDS. -+ Relocs are queued as we go via other callbacks. -+ -+ ??? Note that this is currently an all-or-nothing parser. If we fail to -+ parse the instruction, we return 0 and the caller will start over from -+ the beginning. Backtracking will be necessary in parsing subexpressions, -+ but that can be handled there. Not handling backtracking here may get -+ expensive in the case of the m68k. Deal with later. -+ -+ Returns NULL for success, an error message for failure. */ -+ -+static const char * -+parse_insn_normal (CGEN_CPU_DESC cd, -+ const CGEN_INSN *insn, -+ const char **strp, -+ CGEN_FIELDS *fields) -+{ -+ /* ??? Runtime added insns not handled yet. */ -+ const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn); -+ const char *str = *strp; -+ const char *errmsg; -+ const char *p; -+ const CGEN_SYNTAX_CHAR_TYPE * syn; -+#ifdef CGEN_MNEMONIC_OPERANDS -+ /* FIXME: wip */ -+ int past_opcode_p; -+#endif -+ -+ /* For now we assume the mnemonic is first (there are no leading operands). -+ We can parse it without needing to set up operand parsing. -+ GAS's input scrubber will ensure mnemonics are lowercase, but we may -+ not be called from GAS. */ -+ p = CGEN_INSN_MNEMONIC (insn); -+ while (*p && TOLOWER (*p) == TOLOWER (*str)) -+ ++p, ++str; -+ -+ if (* p) -+ return _("unrecognized instruction"); -+ -+#ifndef CGEN_MNEMONIC_OPERANDS -+ if (* str && ! ISSPACE (* str)) -+ return _("unrecognized instruction"); -+#endif -+ -+ CGEN_INIT_PARSE (cd); -+ cgen_init_parse_operand (cd); -+#ifdef CGEN_MNEMONIC_OPERANDS -+ past_opcode_p = 0; -+#endif -+ -+ /* We don't check for (*str != '\0') here because we want to parse -+ any trailing fake arguments in the syntax string. */ -+ syn = CGEN_SYNTAX_STRING (syntax); -+ -+ /* Mnemonics come first for now, ensure valid string. */ -+ if (! CGEN_SYNTAX_MNEMONIC_P (* syn)) -+ abort (); -+ -+ ++syn; -+ -+ while (* syn != 0) -+ { -+ /* Non operand chars must match exactly. */ -+ if (CGEN_SYNTAX_CHAR_P (* syn)) -+ { -+ /* FIXME: While we allow for non-GAS callers above, we assume the -+ first char after the mnemonic part is a space. */ -+ /* FIXME: We also take inappropriate advantage of the fact that -+ GAS's input scrubber will remove extraneous blanks. */ -+ if (TOLOWER (*str) == TOLOWER (CGEN_SYNTAX_CHAR (* syn))) -+ { -+#ifdef CGEN_MNEMONIC_OPERANDS -+ if (CGEN_SYNTAX_CHAR(* syn) == ' ') -+ past_opcode_p = 1; -+#endif -+ ++ syn; -+ ++ str; -+ } -+ else if (*str) -+ { -+ /* Syntax char didn't match. Can't be this insn. */ -+ static char msg [80]; -+ -+ /* xgettext:c-format */ -+ sprintf (msg, _("syntax error (expected char `%c', found `%c')"), -+ CGEN_SYNTAX_CHAR(*syn), *str); -+ return msg; -+ } -+ else -+ { -+ /* Ran out of input. */ -+ static char msg [80]; -+ -+ /* xgettext:c-format */ -+ sprintf (msg, _("syntax error (expected char `%c', found end of instruction)"), -+ CGEN_SYNTAX_CHAR(*syn)); -+ return msg; -+ } -+ continue; -+ } -+ -+#ifdef CGEN_MNEMONIC_OPERANDS -+ (void) past_opcode_p; -+#endif -+ /* We have an operand of some sort. */ -+ errmsg = cd->parse_operand (cd, CGEN_SYNTAX_FIELD (*syn), &str, fields); -+ if (errmsg) -+ return errmsg; -+ -+ /* Done with this operand, continue with next one. */ -+ ++ syn; -+ } -+ -+ /* If we're at the end of the syntax string, we're done. */ -+ if (* syn == 0) -+ { -+ /* FIXME: For the moment we assume a valid `str' can only contain -+ blanks now. IE: We needn't try again with a longer version of -+ the insn and it is assumed that longer versions of insns appear -+ before shorter ones (eg: lsr r2,r3,1 vs lsr r2,r3). */ -+ while (ISSPACE (* str)) -+ ++ str; -+ -+ if (* str != '\0') -+ return _("junk at end of line"); /* FIXME: would like to include `str' */ -+ -+ return NULL; -+ } -+ -+ /* We couldn't parse it. */ -+ return _("unrecognized instruction"); -+} -+ -+/* Main entry point. -+ This routine is called for each instruction to be assembled. -+ STR points to the insn to be assembled. -+ We assume all necessary tables have been initialized. -+ The assembled instruction, less any fixups, is stored in BUF. -+ Remember that if CGEN_INT_INSN_P then BUF is an int and thus the value -+ still needs to be converted to target byte order, otherwise BUF is an array -+ of bytes in target byte order. -+ The result is a pointer to the insn's entry in the opcode table, -+ or NULL if an error occured (an error message will have already been -+ printed). -+ -+ Note that when processing (non-alias) macro-insns, -+ this function recurses. -+ -+ ??? It's possible to make this cpu-independent. -+ One would have to deal with a few minor things. -+ At this point in time doing so would be more of a curiosity than useful -+ [for example this file isn't _that_ big], but keeping the possibility in -+ mind helps keep the design clean. */ -+ -+const CGEN_INSN * -+or1k_cgen_assemble_insn (CGEN_CPU_DESC cd, -+ const char *str, -+ CGEN_FIELDS *fields, -+ CGEN_INSN_BYTES_PTR buf, -+ char **errmsg) -+{ -+ const char *start; -+ CGEN_INSN_LIST *ilist; -+ const char *parse_errmsg = NULL; -+ const char *insert_errmsg = NULL; -+ int recognized_mnemonic = 0; -+ -+ /* Skip leading white space. */ -+ while (ISSPACE (* str)) -+ ++ str; -+ -+ /* The instructions are stored in hashed lists. -+ Get the first in the list. */ -+ ilist = CGEN_ASM_LOOKUP_INSN (cd, str); -+ -+ /* Keep looking until we find a match. */ -+ start = str; -+ for ( ; ilist != NULL ; ilist = CGEN_ASM_NEXT_INSN (ilist)) -+ { -+ const CGEN_INSN *insn = ilist->insn; -+ recognized_mnemonic = 1; -+ -+#ifdef CGEN_VALIDATE_INSN_SUPPORTED -+ /* Not usually needed as unsupported opcodes -+ shouldn't be in the hash lists. */ -+ /* Is this insn supported by the selected cpu? */ -+ if (! or1k_cgen_insn_supported (cd, insn)) -+ continue; -+#endif -+ /* If the RELAXED attribute is set, this is an insn that shouldn't be -+ chosen immediately. Instead, it is used during assembler/linker -+ relaxation if possible. */ -+ if (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_RELAXED) != 0) -+ continue; -+ -+ str = start; -+ -+ /* Skip this insn if str doesn't look right lexically. */ -+ if (CGEN_INSN_RX (insn) != NULL && -+ regexec ((regex_t *) CGEN_INSN_RX (insn), str, 0, NULL, 0) == REG_NOMATCH) -+ continue; -+ -+ /* Allow parse/insert handlers to obtain length of insn. */ -+ CGEN_FIELDS_BITSIZE (fields) = CGEN_INSN_BITSIZE (insn); -+ -+ parse_errmsg = CGEN_PARSE_FN (cd, insn) (cd, insn, & str, fields); -+ if (parse_errmsg != NULL) -+ continue; -+ -+ /* ??? 0 is passed for `pc'. */ -+ insert_errmsg = CGEN_INSERT_FN (cd, insn) (cd, insn, fields, buf, -+ (bfd_vma) 0); -+ if (insert_errmsg != NULL) -+ continue; -+ -+ /* It is up to the caller to actually output the insn and any -+ queued relocs. */ -+ return insn; -+ } -+ -+ { -+ static char errbuf[150]; -+ const char *tmp_errmsg; -+#ifdef CGEN_VERBOSE_ASSEMBLER_ERRORS -+#define be_verbose 1 -+#else -+#define be_verbose 0 -+#endif -+ -+ if (be_verbose) -+ { -+ /* If requesting verbose error messages, use insert_errmsg. -+ Failing that, use parse_errmsg. */ -+ tmp_errmsg = (insert_errmsg ? insert_errmsg : -+ parse_errmsg ? parse_errmsg : -+ recognized_mnemonic ? -+ _("unrecognized form of instruction") : -+ _("unrecognized instruction")); -+ -+ if (strlen (start) > 50) -+ /* xgettext:c-format */ -+ sprintf (errbuf, "%s `%.50s...'", tmp_errmsg, start); -+ else -+ /* xgettext:c-format */ -+ sprintf (errbuf, "%s `%.50s'", tmp_errmsg, start); -+ } -+ else -+ { -+ if (strlen (start) > 50) -+ /* xgettext:c-format */ -+ sprintf (errbuf, _("bad instruction `%.50s...'"), start); -+ else -+ /* xgettext:c-format */ -+ sprintf (errbuf, _("bad instruction `%.50s'"), start); -+ } -+ -+ *errmsg = errbuf; -+ return NULL; -+ } -+} -diff -rNU3 dist.orig/opcodes/or1k-desc.c dist/opcodes/or1k-desc.c ---- dist.orig/opcodes/or1k-desc.c 1970-01-01 01:00:00.000000000 +0100 -+++ dist/opcodes/or1k-desc.c 2015-10-18 13:11:20.000000000 +0200 -@@ -0,0 +1,2110 @@ -+/* CPU data for or1k. -+ -+THIS FILE IS MACHINE GENERATED WITH CGEN. -+ -+Copyright (C) 1996-2014 Free Software Foundation, Inc. -+ -+This file is part of the GNU Binutils and/or GDB, the GNU debugger. -+ -+ This file is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3, or (at your option) -+ any later version. -+ -+ It is distributed in the hope that it will be useful, but WITHOUT -+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -+ License for more details. -+ -+ You should have received a copy of the GNU General Public License along -+ with this program; if not, write to the Free Software Foundation, Inc., -+ 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. -+ -+*/ -+ -+#include "sysdep.h" -+#include -+#include -+#include "ansidecl.h" -+#include "bfd.h" -+#include "symcat.h" -+#include "or1k-desc.h" -+#include "or1k-opc.h" -+#include "opintl.h" -+#include "libiberty.h" -+#include "xregex.h" -+ -+/* Attributes. */ -+ -+static const CGEN_ATTR_ENTRY bool_attr[] = -+{ -+ { "#f", 0 }, -+ { "#t", 1 }, -+ { 0, 0 } -+}; -+ -+static const CGEN_ATTR_ENTRY MACH_attr[] ATTRIBUTE_UNUSED = -+{ -+ { "base", MACH_BASE }, -+ { "or32", MACH_OR32 }, -+ { "or32nd", MACH_OR32ND }, -+ { "or64", MACH_OR64 }, -+ { "or64nd", MACH_OR64ND }, -+ { "max", MACH_MAX }, -+ { 0, 0 } -+}; -+ -+static const CGEN_ATTR_ENTRY ISA_attr[] ATTRIBUTE_UNUSED = -+{ -+ { "openrisc", ISA_OPENRISC }, -+ { "max", ISA_MAX }, -+ { 0, 0 } -+}; -+ -+const CGEN_ATTR_TABLE or1k_cgen_ifield_attr_table[] = -+{ -+ { "MACH", & MACH_attr[0], & MACH_attr[0] }, -+ { "VIRTUAL", &bool_attr[0], &bool_attr[0] }, -+ { "PCREL-ADDR", &bool_attr[0], &bool_attr[0] }, -+ { "ABS-ADDR", &bool_attr[0], &bool_attr[0] }, -+ { "RESERVED", &bool_attr[0], &bool_attr[0] }, -+ { "SIGN-OPT", &bool_attr[0], &bool_attr[0] }, -+ { "SIGNED", &bool_attr[0], &bool_attr[0] }, -+ { 0, 0, 0 } -+}; -+ -+const CGEN_ATTR_TABLE or1k_cgen_hardware_attr_table[] = -+{ -+ { "MACH", & MACH_attr[0], & MACH_attr[0] }, -+ { "VIRTUAL", &bool_attr[0], &bool_attr[0] }, -+ { "CACHE-ADDR", &bool_attr[0], &bool_attr[0] }, -+ { "PC", &bool_attr[0], &bool_attr[0] }, -+ { "PROFILE", &bool_attr[0], &bool_attr[0] }, -+ { 0, 0, 0 } -+}; -+ -+const CGEN_ATTR_TABLE or1k_cgen_operand_attr_table[] = -+{ -+ { "MACH", & MACH_attr[0], & MACH_attr[0] }, -+ { "VIRTUAL", &bool_attr[0], &bool_attr[0] }, -+ { "PCREL-ADDR", &bool_attr[0], &bool_attr[0] }, -+ { "ABS-ADDR", &bool_attr[0], &bool_attr[0] }, -+ { "SIGN-OPT", &bool_attr[0], &bool_attr[0] }, -+ { "SIGNED", &bool_attr[0], &bool_attr[0] }, -+ { "NEGATIVE", &bool_attr[0], &bool_attr[0] }, -+ { "RELAX", &bool_attr[0], &bool_attr[0] }, -+ { "SEM-ONLY", &bool_attr[0], &bool_attr[0] }, -+ { 0, 0, 0 } -+}; -+ -+const CGEN_ATTR_TABLE or1k_cgen_insn_attr_table[] = -+{ -+ { "MACH", & MACH_attr[0], & MACH_attr[0] }, -+ { "ALIAS", &bool_attr[0], &bool_attr[0] }, -+ { "VIRTUAL", &bool_attr[0], &bool_attr[0] }, -+ { "UNCOND-CTI", &bool_attr[0], &bool_attr[0] }, -+ { "COND-CTI", &bool_attr[0], &bool_attr[0] }, -+ { "SKIP-CTI", &bool_attr[0], &bool_attr[0] }, -+ { "DELAY-SLOT", &bool_attr[0], &bool_attr[0] }, -+ { "RELAXABLE", &bool_attr[0], &bool_attr[0] }, -+ { "RELAXED", &bool_attr[0], &bool_attr[0] }, -+ { "NO-DIS", &bool_attr[0], &bool_attr[0] }, -+ { "PBB", &bool_attr[0], &bool_attr[0] }, -+ { "DELAYED-CTI", &bool_attr[0], &bool_attr[0] }, -+ { "NOT-IN-DELAY-SLOT", &bool_attr[0], &bool_attr[0] }, -+ { "FORCED-CTI", &bool_attr[0], &bool_attr[0] }, -+ { 0, 0, 0 } -+}; -+ -+/* Instruction set variants. */ -+ -+static const CGEN_ISA or1k_cgen_isa_table[] = { -+ { "openrisc", 32, 32, 32, 32 }, -+ { 0, 0, 0, 0, 0 } -+}; -+ -+/* Machine variants. */ -+ -+static const CGEN_MACH or1k_cgen_mach_table[] = { -+ { "or32", "or1k", MACH_OR32, 0 }, -+ { "or32nd", "or1knd", MACH_OR32ND, 0 }, -+ { "or64", "or1k64", MACH_OR64, 0 }, -+ { "or64nd", "or1k64nd", MACH_OR64ND, 0 }, -+ { 0, 0, 0, 0 } -+}; -+ -+static CGEN_KEYWORD_ENTRY or1k_cgen_opval_h_fsr_entries[] = -+{ -+ { "r0", 0, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r1", 1, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r2", 2, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r3", 3, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r4", 4, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r5", 5, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r6", 6, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r7", 7, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r8", 8, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r9", 9, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r10", 10, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r11", 11, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r12", 12, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r13", 13, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r14", 14, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r15", 15, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r16", 16, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r17", 17, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r18", 18, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r19", 19, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r20", 20, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r21", 21, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r22", 22, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r23", 23, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r24", 24, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r25", 25, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r26", 26, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r27", 27, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r28", 28, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r29", 29, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r30", 30, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r31", 31, {0, {{{0, 0}}}}, 0, 0 }, -+ { "lr", 9, {0, {{{0, 0}}}}, 0, 0 }, -+ { "sp", 1, {0, {{{0, 0}}}}, 0, 0 }, -+ { "fp", 2, {0, {{{0, 0}}}}, 0, 0 } -+}; -+ -+CGEN_KEYWORD or1k_cgen_opval_h_fsr = -+{ -+ & or1k_cgen_opval_h_fsr_entries[0], -+ 35, -+ 0, 0, 0, 0, "" -+}; -+ -+static CGEN_KEYWORD_ENTRY or1k_cgen_opval_h_fdr_entries[] = -+{ -+ { "r0", 0, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r1", 1, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r2", 2, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r3", 3, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r4", 4, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r5", 5, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r6", 6, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r7", 7, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r8", 8, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r9", 9, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r10", 10, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r11", 11, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r12", 12, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r13", 13, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r14", 14, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r15", 15, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r16", 16, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r17", 17, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r18", 18, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r19", 19, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r20", 20, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r21", 21, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r22", 22, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r23", 23, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r24", 24, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r25", 25, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r26", 26, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r27", 27, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r28", 28, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r29", 29, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r30", 30, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r31", 31, {0, {{{0, 0}}}}, 0, 0 }, -+ { "lr", 9, {0, {{{0, 0}}}}, 0, 0 }, -+ { "sp", 1, {0, {{{0, 0}}}}, 0, 0 }, -+ { "fp", 2, {0, {{{0, 0}}}}, 0, 0 } -+}; -+ -+CGEN_KEYWORD or1k_cgen_opval_h_fdr = -+{ -+ & or1k_cgen_opval_h_fdr_entries[0], -+ 35, -+ 0, 0, 0, 0, "" -+}; -+ -+static CGEN_KEYWORD_ENTRY or1k_cgen_opval_h_gpr_entries[] = -+{ -+ { "r0", 0, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r1", 1, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r2", 2, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r3", 3, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r4", 4, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r5", 5, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r6", 6, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r7", 7, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r8", 8, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r9", 9, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r10", 10, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r11", 11, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r12", 12, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r13", 13, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r14", 14, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r15", 15, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r16", 16, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r17", 17, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r18", 18, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r19", 19, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r20", 20, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r21", 21, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r22", 22, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r23", 23, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r24", 24, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r25", 25, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r26", 26, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r27", 27, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r28", 28, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r29", 29, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r30", 30, {0, {{{0, 0}}}}, 0, 0 }, -+ { "r31", 31, {0, {{{0, 0}}}}, 0, 0 }, -+ { "lr", 9, {0, {{{0, 0}}}}, 0, 0 }, -+ { "sp", 1, {0, {{{0, 0}}}}, 0, 0 }, -+ { "fp", 2, {0, {{{0, 0}}}}, 0, 0 } -+}; -+ -+CGEN_KEYWORD or1k_cgen_opval_h_gpr = -+{ -+ & or1k_cgen_opval_h_gpr_entries[0], -+ 35, -+ 0, 0, 0, 0, "" -+}; -+ -+ -+/* The hardware table. */ -+ -+#define A(a) (1 << CGEN_HW_##a) -+ -+const CGEN_HW_ENTRY or1k_cgen_hw_table[] = -+{ -+ { "h-memory", HW_H_MEMORY, CGEN_ASM_NONE, 0, { 0, { { { (1<name) -+ { -+ if (strcmp (name, table->bfd_name) == 0) -+ return table; -+ ++table; -+ } -+ abort (); -+} -+ -+/* Subroutine of or1k_cgen_cpu_open to build the hardware table. */ -+ -+static void -+build_hw_table (CGEN_CPU_TABLE *cd) -+{ -+ int i; -+ int machs = cd->machs; -+ const CGEN_HW_ENTRY *init = & or1k_cgen_hw_table[0]; -+ /* MAX_HW is only an upper bound on the number of selected entries. -+ However each entry is indexed by it's enum so there can be holes in -+ the table. */ -+ const CGEN_HW_ENTRY **selected = -+ (const CGEN_HW_ENTRY **) xmalloc (MAX_HW * sizeof (CGEN_HW_ENTRY *)); -+ -+ cd->hw_table.init_entries = init; -+ cd->hw_table.entry_size = sizeof (CGEN_HW_ENTRY); -+ memset (selected, 0, MAX_HW * sizeof (CGEN_HW_ENTRY *)); -+ /* ??? For now we just use machs to determine which ones we want. */ -+ for (i = 0; init[i].name != NULL; ++i) -+ if (CGEN_HW_ATTR_VALUE (&init[i], CGEN_HW_MACH) -+ & machs) -+ selected[init[i].type] = &init[i]; -+ cd->hw_table.entries = selected; -+ cd->hw_table.num_entries = MAX_HW; -+} -+ -+/* Subroutine of or1k_cgen_cpu_open to build the hardware table. */ -+ -+static void -+build_ifield_table (CGEN_CPU_TABLE *cd) -+{ -+ cd->ifld_table = & or1k_cgen_ifld_table[0]; -+} -+ -+/* Subroutine of or1k_cgen_cpu_open to build the hardware table. */ -+ -+static void -+build_operand_table (CGEN_CPU_TABLE *cd) -+{ -+ int i; -+ int machs = cd->machs; -+ const CGEN_OPERAND *init = & or1k_cgen_operand_table[0]; -+ /* MAX_OPERANDS is only an upper bound on the number of selected entries. -+ However each entry is indexed by it's enum so there can be holes in -+ the table. */ -+ const CGEN_OPERAND **selected = xmalloc (MAX_OPERANDS * sizeof (* selected)); -+ -+ cd->operand_table.init_entries = init; -+ cd->operand_table.entry_size = sizeof (CGEN_OPERAND); -+ memset (selected, 0, MAX_OPERANDS * sizeof (CGEN_OPERAND *)); -+ /* ??? For now we just use mach to determine which ones we want. */ -+ for (i = 0; init[i].name != NULL; ++i) -+ if (CGEN_OPERAND_ATTR_VALUE (&init[i], CGEN_OPERAND_MACH) -+ & machs) -+ selected[init[i].type] = &init[i]; -+ cd->operand_table.entries = selected; -+ cd->operand_table.num_entries = MAX_OPERANDS; -+} -+ -+/* Subroutine of or1k_cgen_cpu_open to build the hardware table. -+ ??? This could leave out insns not supported by the specified mach/isa, -+ but that would cause errors like "foo only supported by bar" to become -+ "unknown insn", so for now we include all insns and require the app to -+ do the checking later. -+ ??? On the other hand, parsing of such insns may require their hardware or -+ operand elements to be in the table [which they mightn't be]. */ -+ -+static void -+build_insn_table (CGEN_CPU_TABLE *cd) -+{ -+ int i; -+ const CGEN_IBASE *ib = & or1k_cgen_insn_table[0]; -+ CGEN_INSN *insns = xmalloc (MAX_INSNS * sizeof (CGEN_INSN)); -+ -+ memset (insns, 0, MAX_INSNS * sizeof (CGEN_INSN)); -+ for (i = 0; i < MAX_INSNS; ++i) -+ insns[i].base = &ib[i]; -+ cd->insn_table.init_entries = insns; -+ cd->insn_table.entry_size = sizeof (CGEN_IBASE); -+ cd->insn_table.num_init_entries = MAX_INSNS; -+} -+ -+/* Subroutine of or1k_cgen_cpu_open to rebuild the tables. */ -+ -+static void -+or1k_cgen_rebuild_tables (CGEN_CPU_TABLE *cd) -+{ -+ int i; -+ CGEN_BITSET *isas = cd->isas; -+ unsigned int machs = cd->machs; -+ -+ cd->int_insn_p = CGEN_INT_INSN_P; -+ -+ /* Data derived from the isa spec. */ -+#define UNSET (CGEN_SIZE_UNKNOWN + 1) -+ cd->default_insn_bitsize = UNSET; -+ cd->base_insn_bitsize = UNSET; -+ cd->min_insn_bitsize = 65535; /* Some ridiculously big number. */ -+ cd->max_insn_bitsize = 0; -+ for (i = 0; i < MAX_ISAS; ++i) -+ if (cgen_bitset_contains (isas, i)) -+ { -+ const CGEN_ISA *isa = & or1k_cgen_isa_table[i]; -+ -+ /* Default insn sizes of all selected isas must be -+ equal or we set the result to 0, meaning "unknown". */ -+ if (cd->default_insn_bitsize == UNSET) -+ cd->default_insn_bitsize = isa->default_insn_bitsize; -+ else if (isa->default_insn_bitsize == cd->default_insn_bitsize) -+ ; /* This is ok. */ -+ else -+ cd->default_insn_bitsize = CGEN_SIZE_UNKNOWN; -+ -+ /* Base insn sizes of all selected isas must be equal -+ or we set the result to 0, meaning "unknown". */ -+ if (cd->base_insn_bitsize == UNSET) -+ cd->base_insn_bitsize = isa->base_insn_bitsize; -+ else if (isa->base_insn_bitsize == cd->base_insn_bitsize) -+ ; /* This is ok. */ -+ else -+ cd->base_insn_bitsize = CGEN_SIZE_UNKNOWN; -+ -+ /* Set min,max insn sizes. */ -+ if (isa->min_insn_bitsize < cd->min_insn_bitsize) -+ cd->min_insn_bitsize = isa->min_insn_bitsize; -+ if (isa->max_insn_bitsize > cd->max_insn_bitsize) -+ cd->max_insn_bitsize = isa->max_insn_bitsize; -+ } -+ -+ /* Data derived from the mach spec. */ -+ for (i = 0; i < MAX_MACHS; ++i) -+ if (((1 << i) & machs) != 0) -+ { -+ const CGEN_MACH *mach = & or1k_cgen_mach_table[i]; -+ -+ if (mach->insn_chunk_bitsize != 0) -+ { -+ if (cd->insn_chunk_bitsize != 0 && cd->insn_chunk_bitsize != mach->insn_chunk_bitsize) -+ { -+ fprintf (stderr, "or1k_cgen_rebuild_tables: conflicting insn-chunk-bitsize values: `%d' vs. `%d'\n", -+ cd->insn_chunk_bitsize, mach->insn_chunk_bitsize); -+ abort (); -+ } -+ -+ cd->insn_chunk_bitsize = mach->insn_chunk_bitsize; -+ } -+ } -+ -+ /* Determine which hw elements are used by MACH. */ -+ build_hw_table (cd); -+ -+ /* Build the ifield table. */ -+ build_ifield_table (cd); -+ -+ /* Determine which operands are used by MACH/ISA. */ -+ build_operand_table (cd); -+ -+ /* Build the instruction table. */ -+ build_insn_table (cd); -+} -+ -+/* Initialize a cpu table and return a descriptor. -+ It's much like opening a file, and must be the first function called. -+ The arguments are a set of (type/value) pairs, terminated with -+ CGEN_CPU_OPEN_END. -+ -+ Currently supported values: -+ CGEN_CPU_OPEN_ISAS: bitmap of values in enum isa_attr -+ CGEN_CPU_OPEN_MACHS: bitmap of values in enum mach_attr -+ CGEN_CPU_OPEN_BFDMACH: specify 1 mach using bfd name -+ CGEN_CPU_OPEN_ENDIAN: specify endian choice -+ CGEN_CPU_OPEN_END: terminates arguments -+ -+ ??? Simultaneous multiple isas might not make sense, but it's not (yet) -+ precluded. */ -+ -+CGEN_CPU_DESC -+or1k_cgen_cpu_open (enum cgen_cpu_open_arg arg_type, ...) -+{ -+ CGEN_CPU_TABLE *cd = (CGEN_CPU_TABLE *) xmalloc (sizeof (CGEN_CPU_TABLE)); -+ static int init_p; -+ CGEN_BITSET *isas = 0; /* 0 = "unspecified" */ -+ unsigned int machs = 0; /* 0 = "unspecified" */ -+ enum cgen_endian endian = CGEN_ENDIAN_UNKNOWN; -+ va_list ap; -+ -+ if (! init_p) -+ { -+ init_tables (); -+ init_p = 1; -+ } -+ -+ memset (cd, 0, sizeof (*cd)); -+ -+ va_start (ap, arg_type); -+ while (arg_type != CGEN_CPU_OPEN_END) -+ { -+ switch (arg_type) -+ { -+ case CGEN_CPU_OPEN_ISAS : -+ isas = va_arg (ap, CGEN_BITSET *); -+ break; -+ case CGEN_CPU_OPEN_MACHS : -+ machs = va_arg (ap, unsigned int); -+ break; -+ case CGEN_CPU_OPEN_BFDMACH : -+ { -+ const char *name = va_arg (ap, const char *); -+ const CGEN_MACH *mach = -+ lookup_mach_via_bfd_name (or1k_cgen_mach_table, name); -+ -+ machs |= 1 << mach->num; -+ break; -+ } -+ case CGEN_CPU_OPEN_ENDIAN : -+ endian = va_arg (ap, enum cgen_endian); -+ break; -+ default : -+ fprintf (stderr, "or1k_cgen_cpu_open: unsupported argument `%d'\n", -+ arg_type); -+ abort (); /* ??? return NULL? */ -+ } -+ arg_type = va_arg (ap, enum cgen_cpu_open_arg); -+ } -+ va_end (ap); -+ -+ /* Mach unspecified means "all". */ -+ if (machs == 0) -+ machs = (1 << MAX_MACHS) - 1; -+ /* Base mach is always selected. */ -+ machs |= 1; -+ if (endian == CGEN_ENDIAN_UNKNOWN) -+ { -+ /* ??? If target has only one, could have a default. */ -+ fprintf (stderr, "or1k_cgen_cpu_open: no endianness specified\n"); -+ abort (); -+ } -+ -+ cd->isas = cgen_bitset_copy (isas); -+ cd->machs = machs; -+ cd->endian = endian; -+ /* FIXME: for the sparc case we can determine insn-endianness statically. -+ The worry here is where both data and insn endian can be independently -+ chosen, in which case this function will need another argument. -+ Actually, will want to allow for more arguments in the future anyway. */ -+ cd->insn_endian = endian; -+ -+ /* Table (re)builder. */ -+ cd->rebuild_tables = or1k_cgen_rebuild_tables; -+ or1k_cgen_rebuild_tables (cd); -+ -+ /* Default to not allowing signed overflow. */ -+ cd->signed_overflow_ok_p = 0; -+ -+ return (CGEN_CPU_DESC) cd; -+} -+ -+/* Cover fn to or1k_cgen_cpu_open to handle the simple case of 1 isa, 1 mach. -+ MACH_NAME is the bfd name of the mach. */ -+ -+CGEN_CPU_DESC -+or1k_cgen_cpu_open_1 (const char *mach_name, enum cgen_endian endian) -+{ -+ return or1k_cgen_cpu_open (CGEN_CPU_OPEN_BFDMACH, mach_name, -+ CGEN_CPU_OPEN_ENDIAN, endian, -+ CGEN_CPU_OPEN_END); -+} -+ -+/* Close a cpu table. -+ ??? This can live in a machine independent file, but there's currently -+ no place to put this file (there's no libcgen). libopcodes is the wrong -+ place as some simulator ports use this but they don't use libopcodes. */ -+ -+void -+or1k_cgen_cpu_close (CGEN_CPU_DESC cd) -+{ -+ unsigned int i; -+ const CGEN_INSN *insns; -+ -+ if (cd->macro_insn_table.init_entries) -+ { -+ insns = cd->macro_insn_table.init_entries; -+ for (i = 0; i < cd->macro_insn_table.num_init_entries; ++i, ++insns) -+ if (CGEN_INSN_RX ((insns))) -+ regfree (CGEN_INSN_RX (insns)); -+ } -+ -+ if (cd->insn_table.init_entries) -+ { -+ insns = cd->insn_table.init_entries; -+ for (i = 0; i < cd->insn_table.num_init_entries; ++i, ++insns) -+ if (CGEN_INSN_RX (insns)) -+ regfree (CGEN_INSN_RX (insns)); -+ } -+ -+ if (cd->macro_insn_table.init_entries) -+ free ((CGEN_INSN *) cd->macro_insn_table.init_entries); -+ -+ if (cd->insn_table.init_entries) -+ free ((CGEN_INSN *) cd->insn_table.init_entries); -+ -+ if (cd->hw_table.entries) -+ free ((CGEN_HW_ENTRY *) cd->hw_table.entries); -+ -+ if (cd->operand_table.entries) -+ free ((CGEN_HW_ENTRY *) cd->operand_table.entries); -+ -+ free (cd); -+} -+ -diff -rNU3 dist.orig/opcodes/or1k-desc.h dist/opcodes/or1k-desc.h ---- dist.orig/opcodes/or1k-desc.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/opcodes/or1k-desc.h 2015-10-18 13:11:20.000000000 +0200 -@@ -0,0 +1,682 @@ -+/* CPU data header for or1k. -+ -+THIS FILE IS MACHINE GENERATED WITH CGEN. -+ -+Copyright (C) 1996-2014 Free Software Foundation, Inc. -+ -+This file is part of the GNU Binutils and/or GDB, the GNU debugger. -+ -+ This file is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3, or (at your option) -+ any later version. -+ -+ It is distributed in the hope that it will be useful, but WITHOUT -+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -+ License for more details. -+ -+ You should have received a copy of the GNU General Public License along -+ with this program; if not, write to the Free Software Foundation, Inc., -+ 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. -+ -+*/ -+ -+#ifndef OR1K_CPU_H -+#define OR1K_CPU_H -+ -+#define CGEN_ARCH or1k -+ -+/* Given symbol S, return or1k_cgen_. */ -+#define CGEN_SYM(s) or1k##_cgen_##s -+ -+ -+/* Selected cpu families. */ -+#define HAVE_CPU_OR1K32BF -+#define HAVE_CPU_OR1K64BF -+ -+#define CGEN_INSN_LSB0_P 1 -+ -+/* Minimum size of any insn (in bytes). */ -+#define CGEN_MIN_INSN_SIZE 4 -+ -+/* Maximum size of any insn (in bytes). */ -+#define CGEN_MAX_INSN_SIZE 4 -+ -+#define CGEN_INT_INSN_P 1 -+ -+/* Maximum number of syntax elements in an instruction. */ -+#define CGEN_ACTUAL_MAX_SYNTAX_ELEMENTS 17 -+ -+/* CGEN_MNEMONIC_OPERANDS is defined if mnemonics have operands. -+ e.g. In "b,a foo" the ",a" is an operand. If mnemonics have operands -+ we can't hash on everything up to the space. */ -+#define CGEN_MNEMONIC_OPERANDS -+ -+/* Maximum number of fields in an instruction. */ -+#define CGEN_ACTUAL_MAX_IFMT_OPERANDS 8 -+ -+/* Enums. */ -+ -+/* Enum declaration for Exception numbers. */ -+typedef enum except_number { -+ EXCEPT_NONE, EXCEPT_RESET, EXCEPT_BUSERR, EXCEPT_DPF -+ , EXCEPT_IPF, EXCEPT_TICK, EXCEPT_ALIGN, EXCEPT_ILLEGAL -+ , EXCEPT_INT, EXCEPT_DTLBMISS, EXCEPT_ITLBMISS, EXCEPT_RANGE -+ , EXCEPT_SYSCALL, EXCEPT_FPE, EXCEPT_TRAP -+} EXCEPT_NUMBER; -+ -+/* Enum declaration for special purpose register groups. */ -+typedef enum spr_groups { -+ SPR_GROUP_SYS, SPR_GROUP_DMMU, SPR_GROUP_IMMU, SPR_GROUP_DCACHE -+ , SPR_GROUP_ICACHE, SPR_GROUP_MAC, SPR_GROUP_DEBUG, SPR_GROUP_PERF -+ , SPR_GROUP_POWER, SPR_GROUP_PIC, SPR_GROUP_TICK, SPR_GROUP_FPU -+} SPR_GROUPS; -+ -+/* Enum declaration for special purpose register indicies. */ -+typedef enum spr_reg_indices { -+ SPR_INDEX_SYS_VR = 0, SPR_INDEX_SYS_UPR = 1, SPR_INDEX_SYS_CPUCFGR = 2, SPR_INDEX_SYS_DMMUCFGR = 3 -+ , SPR_INDEX_SYS_IMMUCFGR = 4, SPR_INDEX_SYS_DCCFGR = 5, SPR_INDEX_SYS_ICCFGR = 6, SPR_INDEX_SYS_DCFGR = 7 -+ , SPR_INDEX_SYS_PCCFGR = 8, SPR_INDEX_SYS_NPC = 16, SPR_INDEX_SYS_SR = 17, SPR_INDEX_SYS_PPC = 18 -+ , SPR_INDEX_SYS_FPCSR = 20, SPR_INDEX_SYS_EPCR0 = 32, SPR_INDEX_SYS_EPCR1 = 33, SPR_INDEX_SYS_EPCR2 = 34 -+ , SPR_INDEX_SYS_EPCR3 = 35, SPR_INDEX_SYS_EPCR4 = 36, SPR_INDEX_SYS_EPCR5 = 37, SPR_INDEX_SYS_EPCR6 = 38 -+ , SPR_INDEX_SYS_EPCR7 = 39, SPR_INDEX_SYS_EPCR8 = 40, SPR_INDEX_SYS_EPCR9 = 41, SPR_INDEX_SYS_EPCR10 = 42 -+ , SPR_INDEX_SYS_EPCR11 = 43, SPR_INDEX_SYS_EPCR12 = 44, SPR_INDEX_SYS_EPCR13 = 45, SPR_INDEX_SYS_EPCR14 = 46 -+ , SPR_INDEX_SYS_EPCR15 = 47, SPR_INDEX_SYS_EEAR0 = 48, SPR_INDEX_SYS_EEAR1 = 49, SPR_INDEX_SYS_EEAR2 = 50 -+ , SPR_INDEX_SYS_EEAR3 = 51, SPR_INDEX_SYS_EEAR4 = 52, SPR_INDEX_SYS_EEAR5 = 53, SPR_INDEX_SYS_EEAR6 = 54 -+ , SPR_INDEX_SYS_EEAR7 = 55, SPR_INDEX_SYS_EEAR8 = 56, SPR_INDEX_SYS_EEAR9 = 57, SPR_INDEX_SYS_EEAR10 = 58 -+ , SPR_INDEX_SYS_EEAR11 = 59, SPR_INDEX_SYS_EEAR12 = 60, SPR_INDEX_SYS_EEAR13 = 61, SPR_INDEX_SYS_EEAR14 = 62 -+ , SPR_INDEX_SYS_EEAR15 = 63, SPR_INDEX_SYS_ESR0 = 64, SPR_INDEX_SYS_ESR1 = 65, SPR_INDEX_SYS_ESR2 = 66 -+ , SPR_INDEX_SYS_ESR3 = 67, SPR_INDEX_SYS_ESR4 = 68, SPR_INDEX_SYS_ESR5 = 69, SPR_INDEX_SYS_ESR6 = 70 -+ , SPR_INDEX_SYS_ESR7 = 71, SPR_INDEX_SYS_ESR8 = 72, SPR_INDEX_SYS_ESR9 = 73, SPR_INDEX_SYS_ESR10 = 74 -+ , SPR_INDEX_SYS_ESR11 = 75, SPR_INDEX_SYS_ESR12 = 76, SPR_INDEX_SYS_ESR13 = 77, SPR_INDEX_SYS_ESR14 = 78 -+ , SPR_INDEX_SYS_ESR15 = 79, SPR_INDEX_SYS_GPR0 = 1024, SPR_INDEX_SYS_GPR1 = 1025, SPR_INDEX_SYS_GPR2 = 1026 -+ , SPR_INDEX_SYS_GPR3 = 1027, SPR_INDEX_SYS_GPR4 = 1028, SPR_INDEX_SYS_GPR5 = 1029, SPR_INDEX_SYS_GPR6 = 1030 -+ , SPR_INDEX_SYS_GPR7 = 1031, SPR_INDEX_SYS_GPR8 = 1032, SPR_INDEX_SYS_GPR9 = 1033, SPR_INDEX_SYS_GPR10 = 1034 -+ , SPR_INDEX_SYS_GPR11 = 1035, SPR_INDEX_SYS_GPR12 = 1036, SPR_INDEX_SYS_GPR13 = 1037, SPR_INDEX_SYS_GPR14 = 1038 -+ , SPR_INDEX_SYS_GPR15 = 1039, SPR_INDEX_SYS_GPR16 = 1040, SPR_INDEX_SYS_GPR17 = 1041, SPR_INDEX_SYS_GPR18 = 1042 -+ , SPR_INDEX_SYS_GPR19 = 1043, SPR_INDEX_SYS_GPR20 = 1044, SPR_INDEX_SYS_GPR21 = 1045, SPR_INDEX_SYS_GPR22 = 1046 -+ , SPR_INDEX_SYS_GPR23 = 1047, SPR_INDEX_SYS_GPR24 = 1048, SPR_INDEX_SYS_GPR25 = 1049, SPR_INDEX_SYS_GPR26 = 1050 -+ , SPR_INDEX_SYS_GPR27 = 1051, SPR_INDEX_SYS_GPR28 = 1052, SPR_INDEX_SYS_GPR29 = 1053, SPR_INDEX_SYS_GPR30 = 1054 -+ , SPR_INDEX_SYS_GPR31 = 1055, SPR_INDEX_SYS_GPR32 = 1056, SPR_INDEX_SYS_GPR33 = 1057, SPR_INDEX_SYS_GPR34 = 1058 -+ , SPR_INDEX_SYS_GPR35 = 1059, SPR_INDEX_SYS_GPR36 = 1060, SPR_INDEX_SYS_GPR37 = 1061, SPR_INDEX_SYS_GPR38 = 1062 -+ , SPR_INDEX_SYS_GPR39 = 1063, SPR_INDEX_SYS_GPR40 = 1064, SPR_INDEX_SYS_GPR41 = 1065, SPR_INDEX_SYS_GPR42 = 1066 -+ , SPR_INDEX_SYS_GPR43 = 1067, SPR_INDEX_SYS_GPR44 = 1068, SPR_INDEX_SYS_GPR45 = 1069, SPR_INDEX_SYS_GPR46 = 1070 -+ , SPR_INDEX_SYS_GPR47 = 1071, SPR_INDEX_SYS_GPR48 = 1072, SPR_INDEX_SYS_GPR49 = 1073, SPR_INDEX_SYS_GPR50 = 1074 -+ , SPR_INDEX_SYS_GPR51 = 1075, SPR_INDEX_SYS_GPR52 = 1076, SPR_INDEX_SYS_GPR53 = 1077, SPR_INDEX_SYS_GPR54 = 1078 -+ , SPR_INDEX_SYS_GPR55 = 1079, SPR_INDEX_SYS_GPR56 = 1080, SPR_INDEX_SYS_GPR57 = 1081, SPR_INDEX_SYS_GPR58 = 1082 -+ , SPR_INDEX_SYS_GPR59 = 1083, SPR_INDEX_SYS_GPR60 = 1084, SPR_INDEX_SYS_GPR61 = 1085, SPR_INDEX_SYS_GPR62 = 1086 -+ , SPR_INDEX_SYS_GPR63 = 1087, SPR_INDEX_SYS_GPR64 = 1088, SPR_INDEX_SYS_GPR65 = 1089, SPR_INDEX_SYS_GPR66 = 1090 -+ , SPR_INDEX_SYS_GPR67 = 1091, SPR_INDEX_SYS_GPR68 = 1092, SPR_INDEX_SYS_GPR69 = 1093, SPR_INDEX_SYS_GPR70 = 1094 -+ , SPR_INDEX_SYS_GPR71 = 1095, SPR_INDEX_SYS_GPR72 = 1096, SPR_INDEX_SYS_GPR73 = 1097, SPR_INDEX_SYS_GPR74 = 1098 -+ , SPR_INDEX_SYS_GPR75 = 1099, SPR_INDEX_SYS_GPR76 = 1100, SPR_INDEX_SYS_GPR77 = 1101, SPR_INDEX_SYS_GPR78 = 1102 -+ , SPR_INDEX_SYS_GPR79 = 1103, SPR_INDEX_SYS_GPR80 = 1104, SPR_INDEX_SYS_GPR81 = 1105, SPR_INDEX_SYS_GPR82 = 1106 -+ , SPR_INDEX_SYS_GPR83 = 1107, SPR_INDEX_SYS_GPR84 = 1108, SPR_INDEX_SYS_GPR85 = 1109, SPR_INDEX_SYS_GPR86 = 1110 -+ , SPR_INDEX_SYS_GPR87 = 1111, SPR_INDEX_SYS_GPR88 = 1112, SPR_INDEX_SYS_GPR89 = 1113, SPR_INDEX_SYS_GPR90 = 1114 -+ , SPR_INDEX_SYS_GPR91 = 1115, SPR_INDEX_SYS_GPR92 = 1116, SPR_INDEX_SYS_GPR93 = 1117, SPR_INDEX_SYS_GPR94 = 1118 -+ , SPR_INDEX_SYS_GPR95 = 1119, SPR_INDEX_SYS_GPR96 = 1120, SPR_INDEX_SYS_GPR97 = 1121, SPR_INDEX_SYS_GPR98 = 1122 -+ , SPR_INDEX_SYS_GPR99 = 1123, SPR_INDEX_SYS_GPR100 = 1124, SPR_INDEX_SYS_GPR101 = 1125, SPR_INDEX_SYS_GPR102 = 1126 -+ , SPR_INDEX_SYS_GPR103 = 1127, SPR_INDEX_SYS_GPR104 = 1128, SPR_INDEX_SYS_GPR105 = 1129, SPR_INDEX_SYS_GPR106 = 1130 -+ , SPR_INDEX_SYS_GPR107 = 1131, SPR_INDEX_SYS_GPR108 = 1132, SPR_INDEX_SYS_GPR109 = 1133, SPR_INDEX_SYS_GPR110 = 1134 -+ , SPR_INDEX_SYS_GPR111 = 1135, SPR_INDEX_SYS_GPR112 = 1136, SPR_INDEX_SYS_GPR113 = 1137, SPR_INDEX_SYS_GPR114 = 1138 -+ , SPR_INDEX_SYS_GPR115 = 1139, SPR_INDEX_SYS_GPR116 = 1140, SPR_INDEX_SYS_GPR117 = 1141, SPR_INDEX_SYS_GPR118 = 1142 -+ , SPR_INDEX_SYS_GPR119 = 1143, SPR_INDEX_SYS_GPR120 = 1144, SPR_INDEX_SYS_GPR121 = 1145, SPR_INDEX_SYS_GPR122 = 1146 -+ , SPR_INDEX_SYS_GPR123 = 1147, SPR_INDEX_SYS_GPR124 = 1148, SPR_INDEX_SYS_GPR125 = 1149, SPR_INDEX_SYS_GPR126 = 1150 -+ , SPR_INDEX_SYS_GPR127 = 1151, SPR_INDEX_SYS_GPR128 = 1152, SPR_INDEX_SYS_GPR129 = 1153, SPR_INDEX_SYS_GPR130 = 1154 -+ , SPR_INDEX_SYS_GPR131 = 1155, SPR_INDEX_SYS_GPR132 = 1156, SPR_INDEX_SYS_GPR133 = 1157, SPR_INDEX_SYS_GPR134 = 1158 -+ , SPR_INDEX_SYS_GPR135 = 1159, SPR_INDEX_SYS_GPR136 = 1160, SPR_INDEX_SYS_GPR137 = 1161, SPR_INDEX_SYS_GPR138 = 1162 -+ , SPR_INDEX_SYS_GPR139 = 1163, SPR_INDEX_SYS_GPR140 = 1164, SPR_INDEX_SYS_GPR141 = 1165, SPR_INDEX_SYS_GPR142 = 1166 -+ , SPR_INDEX_SYS_GPR143 = 1167, SPR_INDEX_SYS_GPR144 = 1168, SPR_INDEX_SYS_GPR145 = 1169, SPR_INDEX_SYS_GPR146 = 1170 -+ , SPR_INDEX_SYS_GPR147 = 1171, SPR_INDEX_SYS_GPR148 = 1172, SPR_INDEX_SYS_GPR149 = 1173, SPR_INDEX_SYS_GPR150 = 1174 -+ , SPR_INDEX_SYS_GPR151 = 1175, SPR_INDEX_SYS_GPR152 = 1176, SPR_INDEX_SYS_GPR153 = 1177, SPR_INDEX_SYS_GPR154 = 1178 -+ , SPR_INDEX_SYS_GPR155 = 1179, SPR_INDEX_SYS_GPR156 = 1180, SPR_INDEX_SYS_GPR157 = 1181, SPR_INDEX_SYS_GPR158 = 1182 -+ , SPR_INDEX_SYS_GPR159 = 1183, SPR_INDEX_SYS_GPR160 = 1184, SPR_INDEX_SYS_GPR161 = 1185, SPR_INDEX_SYS_GPR162 = 1186 -+ , SPR_INDEX_SYS_GPR163 = 1187, SPR_INDEX_SYS_GPR164 = 1188, SPR_INDEX_SYS_GPR165 = 1189, SPR_INDEX_SYS_GPR166 = 1190 -+ , SPR_INDEX_SYS_GPR167 = 1191, SPR_INDEX_SYS_GPR168 = 1192, SPR_INDEX_SYS_GPR169 = 1193, SPR_INDEX_SYS_GPR170 = 1194 -+ , SPR_INDEX_SYS_GPR171 = 1195, SPR_INDEX_SYS_GPR172 = 1196, SPR_INDEX_SYS_GPR173 = 1197, SPR_INDEX_SYS_GPR174 = 1198 -+ , SPR_INDEX_SYS_GPR175 = 1199, SPR_INDEX_SYS_GPR176 = 1200, SPR_INDEX_SYS_GPR177 = 1201, SPR_INDEX_SYS_GPR178 = 1202 -+ , SPR_INDEX_SYS_GPR179 = 1203, SPR_INDEX_SYS_GPR180 = 1204, SPR_INDEX_SYS_GPR181 = 1205, SPR_INDEX_SYS_GPR182 = 1206 -+ , SPR_INDEX_SYS_GPR183 = 1207, SPR_INDEX_SYS_GPR184 = 1208, SPR_INDEX_SYS_GPR185 = 1209, SPR_INDEX_SYS_GPR186 = 1210 -+ , SPR_INDEX_SYS_GPR187 = 1211, SPR_INDEX_SYS_GPR188 = 1212, SPR_INDEX_SYS_GPR189 = 1213, SPR_INDEX_SYS_GPR190 = 1214 -+ , SPR_INDEX_SYS_GPR191 = 1215, SPR_INDEX_SYS_GPR192 = 1216, SPR_INDEX_SYS_GPR193 = 1217, SPR_INDEX_SYS_GPR194 = 1218 -+ , SPR_INDEX_SYS_GPR195 = 1219, SPR_INDEX_SYS_GPR196 = 1220, SPR_INDEX_SYS_GPR197 = 1221, SPR_INDEX_SYS_GPR198 = 1222 -+ , SPR_INDEX_SYS_GPR199 = 1223, SPR_INDEX_SYS_GPR200 = 1224, SPR_INDEX_SYS_GPR201 = 1225, SPR_INDEX_SYS_GPR202 = 1226 -+ , SPR_INDEX_SYS_GPR203 = 1227, SPR_INDEX_SYS_GPR204 = 1228, SPR_INDEX_SYS_GPR205 = 1229, SPR_INDEX_SYS_GPR206 = 1230 -+ , SPR_INDEX_SYS_GPR207 = 1231, SPR_INDEX_SYS_GPR208 = 1232, SPR_INDEX_SYS_GPR209 = 1233, SPR_INDEX_SYS_GPR210 = 1234 -+ , SPR_INDEX_SYS_GPR211 = 1235, SPR_INDEX_SYS_GPR212 = 1236, SPR_INDEX_SYS_GPR213 = 1237, SPR_INDEX_SYS_GPR214 = 1238 -+ , SPR_INDEX_SYS_GPR215 = 1239, SPR_INDEX_SYS_GPR216 = 1240, SPR_INDEX_SYS_GPR217 = 1241, SPR_INDEX_SYS_GPR218 = 1242 -+ , SPR_INDEX_SYS_GPR219 = 1243, SPR_INDEX_SYS_GPR220 = 1244, SPR_INDEX_SYS_GPR221 = 1245, SPR_INDEX_SYS_GPR222 = 1246 -+ , SPR_INDEX_SYS_GPR223 = 1247, SPR_INDEX_SYS_GPR224 = 1248, SPR_INDEX_SYS_GPR225 = 1249, SPR_INDEX_SYS_GPR226 = 1250 -+ , SPR_INDEX_SYS_GPR227 = 1251, SPR_INDEX_SYS_GPR228 = 1252, SPR_INDEX_SYS_GPR229 = 1253, SPR_INDEX_SYS_GPR230 = 1254 -+ , SPR_INDEX_SYS_GPR231 = 1255, SPR_INDEX_SYS_GPR232 = 1256, SPR_INDEX_SYS_GPR233 = 1257, SPR_INDEX_SYS_GPR234 = 1258 -+ , SPR_INDEX_SYS_GPR235 = 1259, SPR_INDEX_SYS_GPR236 = 1260, SPR_INDEX_SYS_GPR237 = 1261, SPR_INDEX_SYS_GPR238 = 1262 -+ , SPR_INDEX_SYS_GPR239 = 1263, SPR_INDEX_SYS_GPR240 = 1264, SPR_INDEX_SYS_GPR241 = 1265, SPR_INDEX_SYS_GPR242 = 1266 -+ , SPR_INDEX_SYS_GPR243 = 1267, SPR_INDEX_SYS_GPR244 = 1268, SPR_INDEX_SYS_GPR245 = 1269, SPR_INDEX_SYS_GPR246 = 1270 -+ , SPR_INDEX_SYS_GPR247 = 1271, SPR_INDEX_SYS_GPR248 = 1272, SPR_INDEX_SYS_GPR249 = 1273, SPR_INDEX_SYS_GPR250 = 1274 -+ , SPR_INDEX_SYS_GPR251 = 1275, SPR_INDEX_SYS_GPR252 = 1276, SPR_INDEX_SYS_GPR253 = 1277, SPR_INDEX_SYS_GPR254 = 1278 -+ , SPR_INDEX_SYS_GPR255 = 1279, SPR_INDEX_SYS_GPR256 = 1280, SPR_INDEX_SYS_GPR257 = 1281, SPR_INDEX_SYS_GPR258 = 1282 -+ , SPR_INDEX_SYS_GPR259 = 1283, SPR_INDEX_SYS_GPR260 = 1284, SPR_INDEX_SYS_GPR261 = 1285, SPR_INDEX_SYS_GPR262 = 1286 -+ , SPR_INDEX_SYS_GPR263 = 1287, SPR_INDEX_SYS_GPR264 = 1288, SPR_INDEX_SYS_GPR265 = 1289, SPR_INDEX_SYS_GPR266 = 1290 -+ , SPR_INDEX_SYS_GPR267 = 1291, SPR_INDEX_SYS_GPR268 = 1292, SPR_INDEX_SYS_GPR269 = 1293, SPR_INDEX_SYS_GPR270 = 1294 -+ , SPR_INDEX_SYS_GPR271 = 1295, SPR_INDEX_SYS_GPR272 = 1296, SPR_INDEX_SYS_GPR273 = 1297, SPR_INDEX_SYS_GPR274 = 1298 -+ , SPR_INDEX_SYS_GPR275 = 1299, SPR_INDEX_SYS_GPR276 = 1300, SPR_INDEX_SYS_GPR277 = 1301, SPR_INDEX_SYS_GPR278 = 1302 -+ , SPR_INDEX_SYS_GPR279 = 1303, SPR_INDEX_SYS_GPR280 = 1304, SPR_INDEX_SYS_GPR281 = 1305, SPR_INDEX_SYS_GPR282 = 1306 -+ , SPR_INDEX_SYS_GPR283 = 1307, SPR_INDEX_SYS_GPR284 = 1308, SPR_INDEX_SYS_GPR285 = 1309, SPR_INDEX_SYS_GPR286 = 1310 -+ , SPR_INDEX_SYS_GPR287 = 1311, SPR_INDEX_SYS_GPR288 = 1312, SPR_INDEX_SYS_GPR289 = 1313, SPR_INDEX_SYS_GPR290 = 1314 -+ , SPR_INDEX_SYS_GPR291 = 1315, SPR_INDEX_SYS_GPR292 = 1316, SPR_INDEX_SYS_GPR293 = 1317, SPR_INDEX_SYS_GPR294 = 1318 -+ , SPR_INDEX_SYS_GPR295 = 1319, SPR_INDEX_SYS_GPR296 = 1320, SPR_INDEX_SYS_GPR297 = 1321, SPR_INDEX_SYS_GPR298 = 1322 -+ , SPR_INDEX_SYS_GPR299 = 1323, SPR_INDEX_SYS_GPR300 = 1324, SPR_INDEX_SYS_GPR301 = 1325, SPR_INDEX_SYS_GPR302 = 1326 -+ , SPR_INDEX_SYS_GPR303 = 1327, SPR_INDEX_SYS_GPR304 = 1328, SPR_INDEX_SYS_GPR305 = 1329, SPR_INDEX_SYS_GPR306 = 1330 -+ , SPR_INDEX_SYS_GPR307 = 1331, SPR_INDEX_SYS_GPR308 = 1332, SPR_INDEX_SYS_GPR309 = 1333, SPR_INDEX_SYS_GPR310 = 1334 -+ , SPR_INDEX_SYS_GPR311 = 1335, SPR_INDEX_SYS_GPR312 = 1336, SPR_INDEX_SYS_GPR313 = 1337, SPR_INDEX_SYS_GPR314 = 1338 -+ , SPR_INDEX_SYS_GPR315 = 1339, SPR_INDEX_SYS_GPR316 = 1340, SPR_INDEX_SYS_GPR317 = 1341, SPR_INDEX_SYS_GPR318 = 1342 -+ , SPR_INDEX_SYS_GPR319 = 1343, SPR_INDEX_SYS_GPR320 = 1344, SPR_INDEX_SYS_GPR321 = 1345, SPR_INDEX_SYS_GPR322 = 1346 -+ , SPR_INDEX_SYS_GPR323 = 1347, SPR_INDEX_SYS_GPR324 = 1348, SPR_INDEX_SYS_GPR325 = 1349, SPR_INDEX_SYS_GPR326 = 1350 -+ , SPR_INDEX_SYS_GPR327 = 1351, SPR_INDEX_SYS_GPR328 = 1352, SPR_INDEX_SYS_GPR329 = 1353, SPR_INDEX_SYS_GPR330 = 1354 -+ , SPR_INDEX_SYS_GPR331 = 1355, SPR_INDEX_SYS_GPR332 = 1356, SPR_INDEX_SYS_GPR333 = 1357, SPR_INDEX_SYS_GPR334 = 1358 -+ , SPR_INDEX_SYS_GPR335 = 1359, SPR_INDEX_SYS_GPR336 = 1360, SPR_INDEX_SYS_GPR337 = 1361, SPR_INDEX_SYS_GPR338 = 1362 -+ , SPR_INDEX_SYS_GPR339 = 1363, SPR_INDEX_SYS_GPR340 = 1364, SPR_INDEX_SYS_GPR341 = 1365, SPR_INDEX_SYS_GPR342 = 1366 -+ , SPR_INDEX_SYS_GPR343 = 1367, SPR_INDEX_SYS_GPR344 = 1368, SPR_INDEX_SYS_GPR345 = 1369, SPR_INDEX_SYS_GPR346 = 1370 -+ , SPR_INDEX_SYS_GPR347 = 1371, SPR_INDEX_SYS_GPR348 = 1372, SPR_INDEX_SYS_GPR349 = 1373, SPR_INDEX_SYS_GPR350 = 1374 -+ , SPR_INDEX_SYS_GPR351 = 1375, SPR_INDEX_SYS_GPR352 = 1376, SPR_INDEX_SYS_GPR353 = 1377, SPR_INDEX_SYS_GPR354 = 1378 -+ , SPR_INDEX_SYS_GPR355 = 1379, SPR_INDEX_SYS_GPR356 = 1380, SPR_INDEX_SYS_GPR357 = 1381, SPR_INDEX_SYS_GPR358 = 1382 -+ , SPR_INDEX_SYS_GPR359 = 1383, SPR_INDEX_SYS_GPR360 = 1384, SPR_INDEX_SYS_GPR361 = 1385, SPR_INDEX_SYS_GPR362 = 1386 -+ , SPR_INDEX_SYS_GPR363 = 1387, SPR_INDEX_SYS_GPR364 = 1388, SPR_INDEX_SYS_GPR365 = 1389, SPR_INDEX_SYS_GPR366 = 1390 -+ , SPR_INDEX_SYS_GPR367 = 1391, SPR_INDEX_SYS_GPR368 = 1392, SPR_INDEX_SYS_GPR369 = 1393, SPR_INDEX_SYS_GPR370 = 1394 -+ , SPR_INDEX_SYS_GPR371 = 1395, SPR_INDEX_SYS_GPR372 = 1396, SPR_INDEX_SYS_GPR373 = 1397, SPR_INDEX_SYS_GPR374 = 1398 -+ , SPR_INDEX_SYS_GPR375 = 1399, SPR_INDEX_SYS_GPR376 = 1400, SPR_INDEX_SYS_GPR377 = 1401, SPR_INDEX_SYS_GPR378 = 1402 -+ , SPR_INDEX_SYS_GPR379 = 1403, SPR_INDEX_SYS_GPR380 = 1404, SPR_INDEX_SYS_GPR381 = 1405, SPR_INDEX_SYS_GPR382 = 1406 -+ , SPR_INDEX_SYS_GPR383 = 1407, SPR_INDEX_SYS_GPR384 = 1408, SPR_INDEX_SYS_GPR385 = 1409, SPR_INDEX_SYS_GPR386 = 1410 -+ , SPR_INDEX_SYS_GPR387 = 1411, SPR_INDEX_SYS_GPR388 = 1412, SPR_INDEX_SYS_GPR389 = 1413, SPR_INDEX_SYS_GPR390 = 1414 -+ , SPR_INDEX_SYS_GPR391 = 1415, SPR_INDEX_SYS_GPR392 = 1416, SPR_INDEX_SYS_GPR393 = 1417, SPR_INDEX_SYS_GPR394 = 1418 -+ , SPR_INDEX_SYS_GPR395 = 1419, SPR_INDEX_SYS_GPR396 = 1420, SPR_INDEX_SYS_GPR397 = 1421, SPR_INDEX_SYS_GPR398 = 1422 -+ , SPR_INDEX_SYS_GPR399 = 1423, SPR_INDEX_SYS_GPR400 = 1424, SPR_INDEX_SYS_GPR401 = 1425, SPR_INDEX_SYS_GPR402 = 1426 -+ , SPR_INDEX_SYS_GPR403 = 1427, SPR_INDEX_SYS_GPR404 = 1428, SPR_INDEX_SYS_GPR405 = 1429, SPR_INDEX_SYS_GPR406 = 1430 -+ , SPR_INDEX_SYS_GPR407 = 1431, SPR_INDEX_SYS_GPR408 = 1432, SPR_INDEX_SYS_GPR409 = 1433, SPR_INDEX_SYS_GPR410 = 1434 -+ , SPR_INDEX_SYS_GPR411 = 1435, SPR_INDEX_SYS_GPR412 = 1436, SPR_INDEX_SYS_GPR413 = 1437, SPR_INDEX_SYS_GPR414 = 1438 -+ , SPR_INDEX_SYS_GPR415 = 1439, SPR_INDEX_SYS_GPR416 = 1440, SPR_INDEX_SYS_GPR417 = 1441, SPR_INDEX_SYS_GPR418 = 1442 -+ , SPR_INDEX_SYS_GPR419 = 1443, SPR_INDEX_SYS_GPR420 = 1444, SPR_INDEX_SYS_GPR421 = 1445, SPR_INDEX_SYS_GPR422 = 1446 -+ , SPR_INDEX_SYS_GPR423 = 1447, SPR_INDEX_SYS_GPR424 = 1448, SPR_INDEX_SYS_GPR425 = 1449, SPR_INDEX_SYS_GPR426 = 1450 -+ , SPR_INDEX_SYS_GPR427 = 1451, SPR_INDEX_SYS_GPR428 = 1452, SPR_INDEX_SYS_GPR429 = 1453, SPR_INDEX_SYS_GPR430 = 1454 -+ , SPR_INDEX_SYS_GPR431 = 1455, SPR_INDEX_SYS_GPR432 = 1456, SPR_INDEX_SYS_GPR433 = 1457, SPR_INDEX_SYS_GPR434 = 1458 -+ , SPR_INDEX_SYS_GPR435 = 1459, SPR_INDEX_SYS_GPR436 = 1460, SPR_INDEX_SYS_GPR437 = 1461, SPR_INDEX_SYS_GPR438 = 1462 -+ , SPR_INDEX_SYS_GPR439 = 1463, SPR_INDEX_SYS_GPR440 = 1464, SPR_INDEX_SYS_GPR441 = 1465, SPR_INDEX_SYS_GPR442 = 1466 -+ , SPR_INDEX_SYS_GPR443 = 1467, SPR_INDEX_SYS_GPR444 = 1468, SPR_INDEX_SYS_GPR445 = 1469, SPR_INDEX_SYS_GPR446 = 1470 -+ , SPR_INDEX_SYS_GPR447 = 1471, SPR_INDEX_SYS_GPR448 = 1472, SPR_INDEX_SYS_GPR449 = 1473, SPR_INDEX_SYS_GPR450 = 1474 -+ , SPR_INDEX_SYS_GPR451 = 1475, SPR_INDEX_SYS_GPR452 = 1476, SPR_INDEX_SYS_GPR453 = 1477, SPR_INDEX_SYS_GPR454 = 1478 -+ , SPR_INDEX_SYS_GPR455 = 1479, SPR_INDEX_SYS_GPR456 = 1480, SPR_INDEX_SYS_GPR457 = 1481, SPR_INDEX_SYS_GPR458 = 1482 -+ , SPR_INDEX_SYS_GPR459 = 1483, SPR_INDEX_SYS_GPR460 = 1484, SPR_INDEX_SYS_GPR461 = 1485, SPR_INDEX_SYS_GPR462 = 1486 -+ , SPR_INDEX_SYS_GPR463 = 1487, SPR_INDEX_SYS_GPR464 = 1488, SPR_INDEX_SYS_GPR465 = 1489, SPR_INDEX_SYS_GPR466 = 1490 -+ , SPR_INDEX_SYS_GPR467 = 1491, SPR_INDEX_SYS_GPR468 = 1492, SPR_INDEX_SYS_GPR469 = 1493, SPR_INDEX_SYS_GPR470 = 1494 -+ , SPR_INDEX_SYS_GPR471 = 1495, SPR_INDEX_SYS_GPR472 = 1496, SPR_INDEX_SYS_GPR473 = 1497, SPR_INDEX_SYS_GPR474 = 1498 -+ , SPR_INDEX_SYS_GPR475 = 1499, SPR_INDEX_SYS_GPR476 = 1500, SPR_INDEX_SYS_GPR477 = 1501, SPR_INDEX_SYS_GPR478 = 1502 -+ , SPR_INDEX_SYS_GPR479 = 1503, SPR_INDEX_SYS_GPR480 = 1504, SPR_INDEX_SYS_GPR481 = 1505, SPR_INDEX_SYS_GPR482 = 1506 -+ , SPR_INDEX_SYS_GPR483 = 1507, SPR_INDEX_SYS_GPR484 = 1508, SPR_INDEX_SYS_GPR485 = 1509, SPR_INDEX_SYS_GPR486 = 1510 -+ , SPR_INDEX_SYS_GPR487 = 1511, SPR_INDEX_SYS_GPR488 = 1512, SPR_INDEX_SYS_GPR489 = 1513, SPR_INDEX_SYS_GPR490 = 1514 -+ , SPR_INDEX_SYS_GPR491 = 1515, SPR_INDEX_SYS_GPR492 = 1516, SPR_INDEX_SYS_GPR493 = 1517, SPR_INDEX_SYS_GPR494 = 1518 -+ , SPR_INDEX_SYS_GPR495 = 1519, SPR_INDEX_SYS_GPR496 = 1520, SPR_INDEX_SYS_GPR497 = 1521, SPR_INDEX_SYS_GPR498 = 1522 -+ , SPR_INDEX_SYS_GPR499 = 1523, SPR_INDEX_SYS_GPR500 = 1524, SPR_INDEX_SYS_GPR501 = 1525, SPR_INDEX_SYS_GPR502 = 1526 -+ , SPR_INDEX_SYS_GPR503 = 1527, SPR_INDEX_SYS_GPR504 = 1528, SPR_INDEX_SYS_GPR505 = 1529, SPR_INDEX_SYS_GPR506 = 1530 -+ , SPR_INDEX_SYS_GPR507 = 1531, SPR_INDEX_SYS_GPR508 = 1532, SPR_INDEX_SYS_GPR509 = 1533, SPR_INDEX_SYS_GPR510 = 1534 -+ , SPR_INDEX_SYS_GPR511 = 1535, SPR_INDEX_MAC_MACLO = 1, SPR_INDEX_MAC_MACHI = 2, SPR_INDEX_TICK_TTMR = 0 -+} SPR_REG_INDICES; -+ -+/* Enum declaration for SPR field msb positions. */ -+typedef enum spr_field_msbs { -+ SPR_FIELD_MSB_SYS_VR_REV = 5, SPR_FIELD_MSB_SYS_VR_CFG = 23, SPR_FIELD_MSB_SYS_VR_VER = 31, SPR_FIELD_MSB_SYS_UPR_UP = 0 -+ , SPR_FIELD_MSB_SYS_UPR_DCP = 1, SPR_FIELD_MSB_SYS_UPR_ICP = 2, SPR_FIELD_MSB_SYS_UPR_DMP = 3, SPR_FIELD_MSB_SYS_UPR_MP = 4 -+ , SPR_FIELD_MSB_SYS_UPR_IMP = 5, SPR_FIELD_MSB_SYS_UPR_DUP = 6, SPR_FIELD_MSB_SYS_UPR_PCUP = 7, SPR_FIELD_MSB_SYS_UPR_PICP = 8 -+ , SPR_FIELD_MSB_SYS_UPR_PMP = 9, SPR_FIELD_MSB_SYS_UPR_TTP = 10, SPR_FIELD_MSB_SYS_UPR_CUP = 31, SPR_FIELD_MSB_SYS_CPUCFGR_NSGR = 3 -+ , SPR_FIELD_MSB_SYS_CPUCFGR_CGF = 4, SPR_FIELD_MSB_SYS_CPUCFGR_OB32S = 5, SPR_FIELD_MSB_SYS_CPUCFGR_OB64S = 6, SPR_FIELD_MSB_SYS_CPUCFGR_OF32S = 7 -+ , SPR_FIELD_MSB_SYS_CPUCFGR_OF64S = 8, SPR_FIELD_MSB_SYS_CPUCFGR_OV64S = 9, SPR_FIELD_MSB_SYS_CPUCFGR_ND = 10, SPR_FIELD_MSB_SYS_SR_SM = 0 -+ , SPR_FIELD_MSB_SYS_SR_TEE = 1, SPR_FIELD_MSB_SYS_SR_IEE = 2, SPR_FIELD_MSB_SYS_SR_DCE = 3, SPR_FIELD_MSB_SYS_SR_ICE = 4 -+ , SPR_FIELD_MSB_SYS_SR_DME = 5, SPR_FIELD_MSB_SYS_SR_IME = 6, SPR_FIELD_MSB_SYS_SR_LEE = 7, SPR_FIELD_MSB_SYS_SR_CE = 8 -+ , SPR_FIELD_MSB_SYS_SR_F = 9, SPR_FIELD_MSB_SYS_SR_CY = 10, SPR_FIELD_MSB_SYS_SR_OV = 11, SPR_FIELD_MSB_SYS_SR_OVE = 12 -+ , SPR_FIELD_MSB_SYS_SR_DSX = 13, SPR_FIELD_MSB_SYS_SR_EPH = 14, SPR_FIELD_MSB_SYS_SR_FO = 15, SPR_FIELD_MSB_SYS_SR_SUMRA = 16 -+ , SPR_FIELD_MSB_SYS_SR_CID = 31, SPR_FIELD_MSB_SYS_FPCSR_FPEE = 0, SPR_FIELD_MSB_SYS_FPCSR_RM = 2, SPR_FIELD_MSB_SYS_FPCSR_OVF = 3 -+ , SPR_FIELD_MSB_SYS_FPCSR_UNF = 4, SPR_FIELD_MSB_SYS_FPCSR_SNF = 5, SPR_FIELD_MSB_SYS_FPCSR_QNF = 6, SPR_FIELD_MSB_SYS_FPCSR_ZF = 7 -+ , SPR_FIELD_MSB_SYS_FPCSR_IXF = 8, SPR_FIELD_MSB_SYS_FPCSR_IVF = 9, SPR_FIELD_MSB_SYS_FPCSR_INF = 10, SPR_FIELD_MSB_SYS_FPCSR_DZF = 11 -+} SPR_FIELD_MSBS; -+ -+/* Enum declaration for SPR field lsb positions. */ -+typedef enum spr_field_lsbs { -+ SPR_FIELD_SIZE_SYS_VR_REV = 0, SPR_FIELD_SIZE_SYS_VR_CFG = 16, SPR_FIELD_SIZE_SYS_VR_VER = 24, SPR_FIELD_SIZE_SYS_UPR_UP = 0 -+ , SPR_FIELD_SIZE_SYS_UPR_DCP = 1, SPR_FIELD_SIZE_SYS_UPR_ICP = 2, SPR_FIELD_SIZE_SYS_UPR_DMP = 3, SPR_FIELD_SIZE_SYS_UPR_MP = 4 -+ , SPR_FIELD_SIZE_SYS_UPR_IMP = 5, SPR_FIELD_SIZE_SYS_UPR_DUP = 6, SPR_FIELD_SIZE_SYS_UPR_PCUP = 7, SPR_FIELD_SIZE_SYS_UPR_PICP = 8 -+ , SPR_FIELD_SIZE_SYS_UPR_PMP = 9, SPR_FIELD_SIZE_SYS_UPR_TTP = 10, SPR_FIELD_SIZE_SYS_UPR_CUP = 24, SPR_FIELD_SIZE_SYS_CPUCFGR_NSGR = 0 -+ , SPR_FIELD_SIZE_SYS_CPUCFGR_CGF = 4, SPR_FIELD_SIZE_SYS_CPUCFGR_OB32S = 5, SPR_FIELD_SIZE_SYS_CPUCFGR_OB64S = 6, SPR_FIELD_SIZE_SYS_CPUCFGR_OF32S = 7 -+ , SPR_FIELD_SIZE_SYS_CPUCFGR_OF64S = 8, SPR_FIELD_SIZE_SYS_CPUCFGR_OV64S = 9, SPR_FIELD_SIZE_SYS_CPUCFGR_ND = 10, SPR_FIELD_SIZE_SYS_SR_SM = 0 -+ , SPR_FIELD_SIZE_SYS_SR_TEE = 1, SPR_FIELD_SIZE_SYS_SR_IEE = 2, SPR_FIELD_SIZE_SYS_SR_DCE = 3, SPR_FIELD_SIZE_SYS_SR_ICE = 4 -+ , SPR_FIELD_SIZE_SYS_SR_DME = 5, SPR_FIELD_SIZE_SYS_SR_IME = 6, SPR_FIELD_SIZE_SYS_SR_LEE = 7, SPR_FIELD_SIZE_SYS_SR_CE = 8 -+ , SPR_FIELD_SIZE_SYS_SR_F = 9, SPR_FIELD_SIZE_SYS_SR_CY = 10, SPR_FIELD_SIZE_SYS_SR_OV = 11, SPR_FIELD_SIZE_SYS_SR_OVE = 12 -+ , SPR_FIELD_SIZE_SYS_SR_DSX = 13, SPR_FIELD_SIZE_SYS_SR_EPH = 14, SPR_FIELD_SIZE_SYS_SR_FO = 15, SPR_FIELD_SIZE_SYS_SR_SUMRA = 16 -+ , SPR_FIELD_SIZE_SYS_SR_CID = 28, SPR_FIELD_SIZE_SYS_FPCSR_FPEE = 0, SPR_FIELD_SIZE_SYS_FPCSR_RM = 1, SPR_FIELD_SIZE_SYS_FPCSR_OVF = 3 -+ , SPR_FIELD_SIZE_SYS_FPCSR_UNF = 4, SPR_FIELD_SIZE_SYS_FPCSR_SNF = 5, SPR_FIELD_SIZE_SYS_FPCSR_QNF = 6, SPR_FIELD_SIZE_SYS_FPCSR_ZF = 7 -+ , SPR_FIELD_SIZE_SYS_FPCSR_IXF = 8, SPR_FIELD_SIZE_SYS_FPCSR_IVF = 9, SPR_FIELD_SIZE_SYS_FPCSR_INF = 10, SPR_FIELD_SIZE_SYS_FPCSR_DZF = 11 -+} SPR_FIELD_LSBS; -+ -+/* Enum declaration for SPR field masks. */ -+typedef enum spr_field_masks { -+ SPR_FIELD_MASK_SYS_VR_REV = 63, SPR_FIELD_MASK_SYS_VR_CFG = 16711680, SPR_FIELD_MASK_SYS_VR_VER = 4278190080u, SPR_FIELD_MASK_SYS_UPR_UP = 1 -+ , SPR_FIELD_MASK_SYS_UPR_DCP = 2, SPR_FIELD_MASK_SYS_UPR_ICP = 4, SPR_FIELD_MASK_SYS_UPR_DMP = 8, SPR_FIELD_MASK_SYS_UPR_MP = 16 -+ , SPR_FIELD_MASK_SYS_UPR_IMP = 32, SPR_FIELD_MASK_SYS_UPR_DUP = 64, SPR_FIELD_MASK_SYS_UPR_PCUP = 128, SPR_FIELD_MASK_SYS_UPR_PICP = 256 -+ , SPR_FIELD_MASK_SYS_UPR_PMP = 512, SPR_FIELD_MASK_SYS_UPR_TTP = 1024, SPR_FIELD_MASK_SYS_UPR_CUP = 4278190080u, SPR_FIELD_MASK_SYS_CPUCFGR_NSGR = 15 -+ , SPR_FIELD_MASK_SYS_CPUCFGR_CGF = 16, SPR_FIELD_MASK_SYS_CPUCFGR_OB32S = 32, SPR_FIELD_MASK_SYS_CPUCFGR_OB64S = 64, SPR_FIELD_MASK_SYS_CPUCFGR_OF32S = 128 -+ , SPR_FIELD_MASK_SYS_CPUCFGR_OF64S = 256, SPR_FIELD_MASK_SYS_CPUCFGR_OV64S = 512, SPR_FIELD_MASK_SYS_CPUCFGR_ND = 1024, SPR_FIELD_MASK_SYS_SR_SM = 1 -+ , SPR_FIELD_MASK_SYS_SR_TEE = 2, SPR_FIELD_MASK_SYS_SR_IEE = 4, SPR_FIELD_MASK_SYS_SR_DCE = 8, SPR_FIELD_MASK_SYS_SR_ICE = 16 -+ , SPR_FIELD_MASK_SYS_SR_DME = 32, SPR_FIELD_MASK_SYS_SR_IME = 64, SPR_FIELD_MASK_SYS_SR_LEE = 128, SPR_FIELD_MASK_SYS_SR_CE = 256 -+ , SPR_FIELD_MASK_SYS_SR_F = 512, SPR_FIELD_MASK_SYS_SR_CY = 1024, SPR_FIELD_MASK_SYS_SR_OV = 2048, SPR_FIELD_MASK_SYS_SR_OVE = 4096 -+ , SPR_FIELD_MASK_SYS_SR_DSX = 8192, SPR_FIELD_MASK_SYS_SR_EPH = 16384, SPR_FIELD_MASK_SYS_SR_FO = 32768, SPR_FIELD_MASK_SYS_SR_SUMRA = 65536 -+ , SPR_FIELD_MASK_SYS_SR_CID = 4026531840u, SPR_FIELD_MASK_SYS_FPCSR_FPEE = 1, SPR_FIELD_MASK_SYS_FPCSR_RM = 6, SPR_FIELD_MASK_SYS_FPCSR_OVF = 8 -+ , SPR_FIELD_MASK_SYS_FPCSR_UNF = 16, SPR_FIELD_MASK_SYS_FPCSR_SNF = 32, SPR_FIELD_MASK_SYS_FPCSR_QNF = 64, SPR_FIELD_MASK_SYS_FPCSR_ZF = 128 -+ , SPR_FIELD_MASK_SYS_FPCSR_IXF = 256, SPR_FIELD_MASK_SYS_FPCSR_IVF = 512, SPR_FIELD_MASK_SYS_FPCSR_INF = 1024, SPR_FIELD_MASK_SYS_FPCSR_DZF = 2048 -+} SPR_FIELD_MASKS; -+ -+/* Enum declaration for insn main opcode enums. */ -+typedef enum insn_opcode { -+ OPC_J = 0, OPC_JAL = 1, OPC_BNF = 3, OPC_BF = 4 -+ , OPC_NOP = 5, OPC_MOVHIMACRC = 6, OPC_SYSTRAPSYNCS = 8, OPC_RFE = 9 -+ , OPC_VECTOR = 10, OPC_JR = 17, OPC_JALR = 18, OPC_MACI = 19 -+ , OPC_LWA = 27, OPC_CUST1 = 28, OPC_CUST2 = 29, OPC_CUST3 = 30 -+ , OPC_CUST4 = 31, OPC_LD = 32, OPC_LWZ = 33, OPC_LWS = 34 -+ , OPC_LBZ = 35, OPC_LBS = 36, OPC_LHZ = 37, OPC_LHS = 38 -+ , OPC_ADDI = 39, OPC_ADDIC = 40, OPC_ANDI = 41, OPC_ORI = 42 -+ , OPC_XORI = 43, OPC_MULI = 44, OPC_MFSPR = 45, OPC_SHROTI = 46 -+ , OPC_SFI = 47, OPC_MTSPR = 48, OPC_MAC = 49, OPC_FLOAT = 50 -+ , OPC_SWA = 51, OPC_SD = 52, OPC_SW = 53, OPC_SB = 54 -+ , OPC_SH = 55, OPC_ALU = 56, OPC_SF = 57, OPC_CUST5 = 60 -+ , OPC_CUST6 = 61, OPC_CUST7 = 62, OPC_CUST8 = 63 -+} INSN_OPCODE; -+ -+/* Enum declaration for systrapsync insn opcode enums. */ -+typedef enum insn_opcode_systrapsyncs { -+ OPC_SYSTRAPSYNCS_SYSCALL = 0, OPC_SYSTRAPSYNCS_TRAP = 8, OPC_SYSTRAPSYNCS_MSYNC = 16, OPC_SYSTRAPSYNCS_PSYNC = 20 -+ , OPC_SYSTRAPSYNCS_CSYNC = 24 -+} INSN_OPCODE_SYSTRAPSYNCS; -+ -+/* Enum declaration for movhi/macrc insn opcode enums. */ -+typedef enum insn_opcode_movehimacrc { -+ OPC_MOVHIMACRC_MOVHI, OPC_MOVHIMACRC_MACRC -+} INSN_OPCODE_MOVEHIMACRC; -+ -+/* Enum declaration for multiply/accumulate insn opcode enums. */ -+typedef enum insn_opcode_mac { -+ OPC_MAC_MAC = 1, OPC_MAC_MSB = 2 -+} INSN_OPCODE_MAC; -+ -+/* Enum declaration for shift/rotate insn opcode enums. */ -+typedef enum insn_opcode_shorts { -+ OPC_SHROTS_SLL, OPC_SHROTS_SRL, OPC_SHROTS_SRA, OPC_SHROTS_ROR -+} INSN_OPCODE_SHORTS; -+ -+/* Enum declaration for extend byte/half opcode enums. */ -+typedef enum insn_opcode_extbhs { -+ OPC_EXTBHS_EXTHS, OPC_EXTBHS_EXTBS, OPC_EXTBHS_EXTHZ, OPC_EXTBHS_EXTBZ -+} INSN_OPCODE_EXTBHS; -+ -+/* Enum declaration for extend word opcode enums. */ -+typedef enum insn_opcode_extws { -+ OPC_EXTWS_EXTWS, OPC_EXTWS_EXTWZ -+} INSN_OPCODE_EXTWS; -+ -+/* Enum declaration for alu reg/reg insn opcode enums. */ -+typedef enum insn_opcode_alu_regreg { -+ OPC_ALU_REGREG_ADD = 0, OPC_ALU_REGREG_ADDC = 1, OPC_ALU_REGREG_SUB = 2, OPC_ALU_REGREG_AND = 3 -+ , OPC_ALU_REGREG_OR = 4, OPC_ALU_REGREG_XOR = 5, OPC_ALU_REGREG_MUL = 6, OPC_ALU_REGREG_SHROT = 8 -+ , OPC_ALU_REGREG_DIV = 9, OPC_ALU_REGREG_DIVU = 10, OPC_ALU_REGREG_MULU = 11, OPC_ALU_REGREG_EXTBH = 12 -+ , OPC_ALU_REGREG_EXTW = 13, OPC_ALU_REGREG_CMOV = 14, OPC_ALU_REGREG_FFL1 = 15 -+} INSN_OPCODE_ALU_REGREG; -+ -+/* Enum declaration for setflag insn opcode enums. */ -+typedef enum insn_opcode_setflag { -+ OPC_SF_EQ = 0, OPC_SF_NE = 1, OPC_SF_GTU = 2, OPC_SF_GEU = 3 -+ , OPC_SF_LTU = 4, OPC_SF_LEU = 5, OPC_SF_GTS = 10, OPC_SF_GES = 11 -+ , OPC_SF_LTS = 12, OPC_SF_LES = 13 -+} INSN_OPCODE_SETFLAG; -+ -+/* Enum declaration for floating point reg/reg insn opcode enums. */ -+typedef enum insn_opcode_float_regreg { -+ OPC_FLOAT_REGREG_ADD_S = 0, OPC_FLOAT_REGREG_SUB_S = 1, OPC_FLOAT_REGREG_MUL_S = 2, OPC_FLOAT_REGREG_DIV_S = 3 -+ , OPC_FLOAT_REGREG_ITOF_S = 4, OPC_FLOAT_REGREG_FTOI_S = 5, OPC_FLOAT_REGREG_REM_S = 6, OPC_FLOAT_REGREG_MADD_S = 7 -+ , OPC_FLOAT_REGREG_SFEQ_S = 8, OPC_FLOAT_REGREG_SFNE_S = 9, OPC_FLOAT_REGREG_SFGT_S = 10, OPC_FLOAT_REGREG_SFGE_S = 11 -+ , OPC_FLOAT_REGREG_SFLT_S = 12, OPC_FLOAT_REGREG_SFLE_S = 13, OPC_FLOAT_REGREG_ADD_D = 16, OPC_FLOAT_REGREG_SUB_D = 17 -+ , OPC_FLOAT_REGREG_MUL_D = 18, OPC_FLOAT_REGREG_DIV_D = 19, OPC_FLOAT_REGREG_ITOF_D = 20, OPC_FLOAT_REGREG_FTOI_D = 21 -+ , OPC_FLOAT_REGREG_REM_D = 22, OPC_FLOAT_REGREG_MADD_D = 23, OPC_FLOAT_REGREG_SFEQ_D = 24, OPC_FLOAT_REGREG_SFNE_D = 25 -+ , OPC_FLOAT_REGREG_SFGT_D = 26, OPC_FLOAT_REGREG_SFGE_D = 27, OPC_FLOAT_REGREG_SFLT_D = 28, OPC_FLOAT_REGREG_SFLE_D = 29 -+ , OPC_FLOAT_REGREG_CUST1_S = 208, OPC_FLOAT_REGREG_CUST1_D = 224 -+} INSN_OPCODE_FLOAT_REGREG; -+ -+/* Attributes. */ -+ -+/* Enum declaration for machine type selection. */ -+typedef enum mach_attr { -+ MACH_BASE, MACH_OR32, MACH_OR32ND, MACH_OR64 -+ , MACH_OR64ND, MACH_MAX -+} MACH_ATTR; -+ -+/* Enum declaration for instruction set selection. */ -+typedef enum isa_attr { -+ ISA_OPENRISC, ISA_MAX -+} ISA_ATTR; -+ -+/* Number of architecture variants. */ -+#define MAX_ISAS 1 -+#define MAX_MACHS ((int) MACH_MAX) -+ -+/* Ifield support. */ -+ -+/* Ifield attribute indices. */ -+ -+/* Enum declaration for cgen_ifld attrs. */ -+typedef enum cgen_ifld_attr { -+ CGEN_IFLD_VIRTUAL, CGEN_IFLD_PCREL_ADDR, CGEN_IFLD_ABS_ADDR, CGEN_IFLD_RESERVED -+ , CGEN_IFLD_SIGN_OPT, CGEN_IFLD_SIGNED, CGEN_IFLD_END_BOOLS, CGEN_IFLD_START_NBOOLS = 31 -+ , CGEN_IFLD_MACH, CGEN_IFLD_END_NBOOLS -+} CGEN_IFLD_ATTR; -+ -+/* Number of non-boolean elements in cgen_ifld_attr. */ -+#define CGEN_IFLD_NBOOL_ATTRS (CGEN_IFLD_END_NBOOLS - CGEN_IFLD_START_NBOOLS - 1) -+ -+/* cgen_ifld attribute accessor macros. */ -+#define CGEN_ATTR_CGEN_IFLD_MACH_VALUE(attrs) ((attrs)->nonbool[CGEN_IFLD_MACH-CGEN_IFLD_START_NBOOLS-1].nonbitset) -+#define CGEN_ATTR_CGEN_IFLD_VIRTUAL_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_IFLD_VIRTUAL)) != 0) -+#define CGEN_ATTR_CGEN_IFLD_PCREL_ADDR_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_IFLD_PCREL_ADDR)) != 0) -+#define CGEN_ATTR_CGEN_IFLD_ABS_ADDR_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_IFLD_ABS_ADDR)) != 0) -+#define CGEN_ATTR_CGEN_IFLD_RESERVED_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_IFLD_RESERVED)) != 0) -+#define CGEN_ATTR_CGEN_IFLD_SIGN_OPT_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_IFLD_SIGN_OPT)) != 0) -+#define CGEN_ATTR_CGEN_IFLD_SIGNED_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_IFLD_SIGNED)) != 0) -+ -+/* Enum declaration for or1k ifield types. */ -+typedef enum ifield_type { -+ OR1K_F_NIL, OR1K_F_ANYOF, OR1K_F_OPCODE, OR1K_F_R1 -+ , OR1K_F_R2, OR1K_F_R3, OR1K_F_OP_25_2, OR1K_F_OP_25_5 -+ , OR1K_F_OP_16_1, OR1K_F_OP_7_4, OR1K_F_OP_3_4, OR1K_F_OP_9_2 -+ , OR1K_F_OP_9_4, OR1K_F_OP_7_8, OR1K_F_OP_7_2, OR1K_F_RESV_25_26 -+ , OR1K_F_RESV_25_10, OR1K_F_RESV_25_5, OR1K_F_RESV_23_8, OR1K_F_RESV_20_21 -+ , OR1K_F_RESV_20_5, OR1K_F_RESV_20_4, OR1K_F_RESV_15_8, OR1K_F_RESV_15_6 -+ , OR1K_F_RESV_10_11, OR1K_F_RESV_10_7, OR1K_F_RESV_10_3, OR1K_F_RESV_10_1 -+ , OR1K_F_RESV_7_4, OR1K_F_RESV_5_2, OR1K_F_IMM16_25_5, OR1K_F_IMM16_10_11 -+ , OR1K_F_DISP26, OR1K_F_UIMM16, OR1K_F_SIMM16, OR1K_F_UIMM6 -+ , OR1K_F_UIMM16_SPLIT, OR1K_F_SIMM16_SPLIT, OR1K_F_MAX -+} IFIELD_TYPE; -+ -+#define MAX_IFLD ((int) OR1K_F_MAX) -+ -+/* Hardware attribute indices. */ -+ -+/* Enum declaration for cgen_hw attrs. */ -+typedef enum cgen_hw_attr { -+ CGEN_HW_VIRTUAL, CGEN_HW_CACHE_ADDR, CGEN_HW_PC, CGEN_HW_PROFILE -+ , CGEN_HW_END_BOOLS, CGEN_HW_START_NBOOLS = 31, CGEN_HW_MACH, CGEN_HW_END_NBOOLS -+} CGEN_HW_ATTR; -+ -+/* Number of non-boolean elements in cgen_hw_attr. */ -+#define CGEN_HW_NBOOL_ATTRS (CGEN_HW_END_NBOOLS - CGEN_HW_START_NBOOLS - 1) -+ -+/* cgen_hw attribute accessor macros. */ -+#define CGEN_ATTR_CGEN_HW_MACH_VALUE(attrs) ((attrs)->nonbool[CGEN_HW_MACH-CGEN_HW_START_NBOOLS-1].nonbitset) -+#define CGEN_ATTR_CGEN_HW_VIRTUAL_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_HW_VIRTUAL)) != 0) -+#define CGEN_ATTR_CGEN_HW_CACHE_ADDR_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_HW_CACHE_ADDR)) != 0) -+#define CGEN_ATTR_CGEN_HW_PC_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_HW_PC)) != 0) -+#define CGEN_ATTR_CGEN_HW_PROFILE_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_HW_PROFILE)) != 0) -+ -+/* Enum declaration for or1k hardware types. */ -+typedef enum cgen_hw_type { -+ HW_H_MEMORY, HW_H_SINT, HW_H_UINT, HW_H_ADDR -+ , HW_H_IADDR, HW_H_PC, HW_H_FSR, HW_H_FDR -+ , HW_H_SPR, HW_H_GPR, HW_H_SYS_VR, HW_H_SYS_UPR -+ , HW_H_SYS_CPUCFGR, HW_H_SYS_DMMUCFGR, HW_H_SYS_IMMUCFGR, HW_H_SYS_DCCFGR -+ , HW_H_SYS_ICCFGR, HW_H_SYS_DCFGR, HW_H_SYS_PCCFGR, HW_H_SYS_NPC -+ , HW_H_SYS_SR, HW_H_SYS_PPC, HW_H_SYS_FPCSR, HW_H_SYS_EPCR0 -+ , HW_H_SYS_EPCR1, HW_H_SYS_EPCR2, HW_H_SYS_EPCR3, HW_H_SYS_EPCR4 -+ , HW_H_SYS_EPCR5, HW_H_SYS_EPCR6, HW_H_SYS_EPCR7, HW_H_SYS_EPCR8 -+ , HW_H_SYS_EPCR9, HW_H_SYS_EPCR10, HW_H_SYS_EPCR11, HW_H_SYS_EPCR12 -+ , HW_H_SYS_EPCR13, HW_H_SYS_EPCR14, HW_H_SYS_EPCR15, HW_H_SYS_EEAR0 -+ , HW_H_SYS_EEAR1, HW_H_SYS_EEAR2, HW_H_SYS_EEAR3, HW_H_SYS_EEAR4 -+ , HW_H_SYS_EEAR5, HW_H_SYS_EEAR6, HW_H_SYS_EEAR7, HW_H_SYS_EEAR8 -+ , HW_H_SYS_EEAR9, HW_H_SYS_EEAR10, HW_H_SYS_EEAR11, HW_H_SYS_EEAR12 -+ , HW_H_SYS_EEAR13, HW_H_SYS_EEAR14, HW_H_SYS_EEAR15, HW_H_SYS_ESR0 -+ , HW_H_SYS_ESR1, HW_H_SYS_ESR2, HW_H_SYS_ESR3, HW_H_SYS_ESR4 -+ , HW_H_SYS_ESR5, HW_H_SYS_ESR6, HW_H_SYS_ESR7, HW_H_SYS_ESR8 -+ , HW_H_SYS_ESR9, HW_H_SYS_ESR10, HW_H_SYS_ESR11, HW_H_SYS_ESR12 -+ , HW_H_SYS_ESR13, HW_H_SYS_ESR14, HW_H_SYS_ESR15, HW_H_SYS_GPR0 -+ , HW_H_SYS_GPR1, HW_H_SYS_GPR2, HW_H_SYS_GPR3, HW_H_SYS_GPR4 -+ , HW_H_SYS_GPR5, HW_H_SYS_GPR6, HW_H_SYS_GPR7, HW_H_SYS_GPR8 -+ , HW_H_SYS_GPR9, HW_H_SYS_GPR10, HW_H_SYS_GPR11, HW_H_SYS_GPR12 -+ , HW_H_SYS_GPR13, HW_H_SYS_GPR14, HW_H_SYS_GPR15, HW_H_SYS_GPR16 -+ , HW_H_SYS_GPR17, HW_H_SYS_GPR18, HW_H_SYS_GPR19, HW_H_SYS_GPR20 -+ , HW_H_SYS_GPR21, HW_H_SYS_GPR22, HW_H_SYS_GPR23, HW_H_SYS_GPR24 -+ , HW_H_SYS_GPR25, HW_H_SYS_GPR26, HW_H_SYS_GPR27, HW_H_SYS_GPR28 -+ , HW_H_SYS_GPR29, HW_H_SYS_GPR30, HW_H_SYS_GPR31, HW_H_SYS_GPR32 -+ , HW_H_SYS_GPR33, HW_H_SYS_GPR34, HW_H_SYS_GPR35, HW_H_SYS_GPR36 -+ , HW_H_SYS_GPR37, HW_H_SYS_GPR38, HW_H_SYS_GPR39, HW_H_SYS_GPR40 -+ , HW_H_SYS_GPR41, HW_H_SYS_GPR42, HW_H_SYS_GPR43, HW_H_SYS_GPR44 -+ , HW_H_SYS_GPR45, HW_H_SYS_GPR46, HW_H_SYS_GPR47, HW_H_SYS_GPR48 -+ , HW_H_SYS_GPR49, HW_H_SYS_GPR50, HW_H_SYS_GPR51, HW_H_SYS_GPR52 -+ , HW_H_SYS_GPR53, HW_H_SYS_GPR54, HW_H_SYS_GPR55, HW_H_SYS_GPR56 -+ , HW_H_SYS_GPR57, HW_H_SYS_GPR58, HW_H_SYS_GPR59, HW_H_SYS_GPR60 -+ , HW_H_SYS_GPR61, HW_H_SYS_GPR62, HW_H_SYS_GPR63, HW_H_SYS_GPR64 -+ , HW_H_SYS_GPR65, HW_H_SYS_GPR66, HW_H_SYS_GPR67, HW_H_SYS_GPR68 -+ , HW_H_SYS_GPR69, HW_H_SYS_GPR70, HW_H_SYS_GPR71, HW_H_SYS_GPR72 -+ , HW_H_SYS_GPR73, HW_H_SYS_GPR74, HW_H_SYS_GPR75, HW_H_SYS_GPR76 -+ , HW_H_SYS_GPR77, HW_H_SYS_GPR78, HW_H_SYS_GPR79, HW_H_SYS_GPR80 -+ , HW_H_SYS_GPR81, HW_H_SYS_GPR82, HW_H_SYS_GPR83, HW_H_SYS_GPR84 -+ , HW_H_SYS_GPR85, HW_H_SYS_GPR86, HW_H_SYS_GPR87, HW_H_SYS_GPR88 -+ , HW_H_SYS_GPR89, HW_H_SYS_GPR90, HW_H_SYS_GPR91, HW_H_SYS_GPR92 -+ , HW_H_SYS_GPR93, HW_H_SYS_GPR94, HW_H_SYS_GPR95, HW_H_SYS_GPR96 -+ , HW_H_SYS_GPR97, HW_H_SYS_GPR98, HW_H_SYS_GPR99, HW_H_SYS_GPR100 -+ , HW_H_SYS_GPR101, HW_H_SYS_GPR102, HW_H_SYS_GPR103, HW_H_SYS_GPR104 -+ , HW_H_SYS_GPR105, HW_H_SYS_GPR106, HW_H_SYS_GPR107, HW_H_SYS_GPR108 -+ , HW_H_SYS_GPR109, HW_H_SYS_GPR110, HW_H_SYS_GPR111, HW_H_SYS_GPR112 -+ , HW_H_SYS_GPR113, HW_H_SYS_GPR114, HW_H_SYS_GPR115, HW_H_SYS_GPR116 -+ , HW_H_SYS_GPR117, HW_H_SYS_GPR118, HW_H_SYS_GPR119, HW_H_SYS_GPR120 -+ , HW_H_SYS_GPR121, HW_H_SYS_GPR122, HW_H_SYS_GPR123, HW_H_SYS_GPR124 -+ , HW_H_SYS_GPR125, HW_H_SYS_GPR126, HW_H_SYS_GPR127, HW_H_SYS_GPR128 -+ , HW_H_SYS_GPR129, HW_H_SYS_GPR130, HW_H_SYS_GPR131, HW_H_SYS_GPR132 -+ , HW_H_SYS_GPR133, HW_H_SYS_GPR134, HW_H_SYS_GPR135, HW_H_SYS_GPR136 -+ , HW_H_SYS_GPR137, HW_H_SYS_GPR138, HW_H_SYS_GPR139, HW_H_SYS_GPR140 -+ , HW_H_SYS_GPR141, HW_H_SYS_GPR142, HW_H_SYS_GPR143, HW_H_SYS_GPR144 -+ , HW_H_SYS_GPR145, HW_H_SYS_GPR146, HW_H_SYS_GPR147, HW_H_SYS_GPR148 -+ , HW_H_SYS_GPR149, HW_H_SYS_GPR150, HW_H_SYS_GPR151, HW_H_SYS_GPR152 -+ , HW_H_SYS_GPR153, HW_H_SYS_GPR154, HW_H_SYS_GPR155, HW_H_SYS_GPR156 -+ , HW_H_SYS_GPR157, HW_H_SYS_GPR158, HW_H_SYS_GPR159, HW_H_SYS_GPR160 -+ , HW_H_SYS_GPR161, HW_H_SYS_GPR162, HW_H_SYS_GPR163, HW_H_SYS_GPR164 -+ , HW_H_SYS_GPR165, HW_H_SYS_GPR166, HW_H_SYS_GPR167, HW_H_SYS_GPR168 -+ , HW_H_SYS_GPR169, HW_H_SYS_GPR170, HW_H_SYS_GPR171, HW_H_SYS_GPR172 -+ , HW_H_SYS_GPR173, HW_H_SYS_GPR174, HW_H_SYS_GPR175, HW_H_SYS_GPR176 -+ , HW_H_SYS_GPR177, HW_H_SYS_GPR178, HW_H_SYS_GPR179, HW_H_SYS_GPR180 -+ , HW_H_SYS_GPR181, HW_H_SYS_GPR182, HW_H_SYS_GPR183, HW_H_SYS_GPR184 -+ , HW_H_SYS_GPR185, HW_H_SYS_GPR186, HW_H_SYS_GPR187, HW_H_SYS_GPR188 -+ , HW_H_SYS_GPR189, HW_H_SYS_GPR190, HW_H_SYS_GPR191, HW_H_SYS_GPR192 -+ , HW_H_SYS_GPR193, HW_H_SYS_GPR194, HW_H_SYS_GPR195, HW_H_SYS_GPR196 -+ , HW_H_SYS_GPR197, HW_H_SYS_GPR198, HW_H_SYS_GPR199, HW_H_SYS_GPR200 -+ , HW_H_SYS_GPR201, HW_H_SYS_GPR202, HW_H_SYS_GPR203, HW_H_SYS_GPR204 -+ , HW_H_SYS_GPR205, HW_H_SYS_GPR206, HW_H_SYS_GPR207, HW_H_SYS_GPR208 -+ , HW_H_SYS_GPR209, HW_H_SYS_GPR210, HW_H_SYS_GPR211, HW_H_SYS_GPR212 -+ , HW_H_SYS_GPR213, HW_H_SYS_GPR214, HW_H_SYS_GPR215, HW_H_SYS_GPR216 -+ , HW_H_SYS_GPR217, HW_H_SYS_GPR218, HW_H_SYS_GPR219, HW_H_SYS_GPR220 -+ , HW_H_SYS_GPR221, HW_H_SYS_GPR222, HW_H_SYS_GPR223, HW_H_SYS_GPR224 -+ , HW_H_SYS_GPR225, HW_H_SYS_GPR226, HW_H_SYS_GPR227, HW_H_SYS_GPR228 -+ , HW_H_SYS_GPR229, HW_H_SYS_GPR230, HW_H_SYS_GPR231, HW_H_SYS_GPR232 -+ , HW_H_SYS_GPR233, HW_H_SYS_GPR234, HW_H_SYS_GPR235, HW_H_SYS_GPR236 -+ , HW_H_SYS_GPR237, HW_H_SYS_GPR238, HW_H_SYS_GPR239, HW_H_SYS_GPR240 -+ , HW_H_SYS_GPR241, HW_H_SYS_GPR242, HW_H_SYS_GPR243, HW_H_SYS_GPR244 -+ , HW_H_SYS_GPR245, HW_H_SYS_GPR246, HW_H_SYS_GPR247, HW_H_SYS_GPR248 -+ , HW_H_SYS_GPR249, HW_H_SYS_GPR250, HW_H_SYS_GPR251, HW_H_SYS_GPR252 -+ , HW_H_SYS_GPR253, HW_H_SYS_GPR254, HW_H_SYS_GPR255, HW_H_SYS_GPR256 -+ , HW_H_SYS_GPR257, HW_H_SYS_GPR258, HW_H_SYS_GPR259, HW_H_SYS_GPR260 -+ , HW_H_SYS_GPR261, HW_H_SYS_GPR262, HW_H_SYS_GPR263, HW_H_SYS_GPR264 -+ , HW_H_SYS_GPR265, HW_H_SYS_GPR266, HW_H_SYS_GPR267, HW_H_SYS_GPR268 -+ , HW_H_SYS_GPR269, HW_H_SYS_GPR270, HW_H_SYS_GPR271, HW_H_SYS_GPR272 -+ , HW_H_SYS_GPR273, HW_H_SYS_GPR274, HW_H_SYS_GPR275, HW_H_SYS_GPR276 -+ , HW_H_SYS_GPR277, HW_H_SYS_GPR278, HW_H_SYS_GPR279, HW_H_SYS_GPR280 -+ , HW_H_SYS_GPR281, HW_H_SYS_GPR282, HW_H_SYS_GPR283, HW_H_SYS_GPR284 -+ , HW_H_SYS_GPR285, HW_H_SYS_GPR286, HW_H_SYS_GPR287, HW_H_SYS_GPR288 -+ , HW_H_SYS_GPR289, HW_H_SYS_GPR290, HW_H_SYS_GPR291, HW_H_SYS_GPR292 -+ , HW_H_SYS_GPR293, HW_H_SYS_GPR294, HW_H_SYS_GPR295, HW_H_SYS_GPR296 -+ , HW_H_SYS_GPR297, HW_H_SYS_GPR298, HW_H_SYS_GPR299, HW_H_SYS_GPR300 -+ , HW_H_SYS_GPR301, HW_H_SYS_GPR302, HW_H_SYS_GPR303, HW_H_SYS_GPR304 -+ , HW_H_SYS_GPR305, HW_H_SYS_GPR306, HW_H_SYS_GPR307, HW_H_SYS_GPR308 -+ , HW_H_SYS_GPR309, HW_H_SYS_GPR310, HW_H_SYS_GPR311, HW_H_SYS_GPR312 -+ , HW_H_SYS_GPR313, HW_H_SYS_GPR314, HW_H_SYS_GPR315, HW_H_SYS_GPR316 -+ , HW_H_SYS_GPR317, HW_H_SYS_GPR318, HW_H_SYS_GPR319, HW_H_SYS_GPR320 -+ , HW_H_SYS_GPR321, HW_H_SYS_GPR322, HW_H_SYS_GPR323, HW_H_SYS_GPR324 -+ , HW_H_SYS_GPR325, HW_H_SYS_GPR326, HW_H_SYS_GPR327, HW_H_SYS_GPR328 -+ , HW_H_SYS_GPR329, HW_H_SYS_GPR330, HW_H_SYS_GPR331, HW_H_SYS_GPR332 -+ , HW_H_SYS_GPR333, HW_H_SYS_GPR334, HW_H_SYS_GPR335, HW_H_SYS_GPR336 -+ , HW_H_SYS_GPR337, HW_H_SYS_GPR338, HW_H_SYS_GPR339, HW_H_SYS_GPR340 -+ , HW_H_SYS_GPR341, HW_H_SYS_GPR342, HW_H_SYS_GPR343, HW_H_SYS_GPR344 -+ , HW_H_SYS_GPR345, HW_H_SYS_GPR346, HW_H_SYS_GPR347, HW_H_SYS_GPR348 -+ , HW_H_SYS_GPR349, HW_H_SYS_GPR350, HW_H_SYS_GPR351, HW_H_SYS_GPR352 -+ , HW_H_SYS_GPR353, HW_H_SYS_GPR354, HW_H_SYS_GPR355, HW_H_SYS_GPR356 -+ , HW_H_SYS_GPR357, HW_H_SYS_GPR358, HW_H_SYS_GPR359, HW_H_SYS_GPR360 -+ , HW_H_SYS_GPR361, HW_H_SYS_GPR362, HW_H_SYS_GPR363, HW_H_SYS_GPR364 -+ , HW_H_SYS_GPR365, HW_H_SYS_GPR366, HW_H_SYS_GPR367, HW_H_SYS_GPR368 -+ , HW_H_SYS_GPR369, HW_H_SYS_GPR370, HW_H_SYS_GPR371, HW_H_SYS_GPR372 -+ , HW_H_SYS_GPR373, HW_H_SYS_GPR374, HW_H_SYS_GPR375, HW_H_SYS_GPR376 -+ , HW_H_SYS_GPR377, HW_H_SYS_GPR378, HW_H_SYS_GPR379, HW_H_SYS_GPR380 -+ , HW_H_SYS_GPR381, HW_H_SYS_GPR382, HW_H_SYS_GPR383, HW_H_SYS_GPR384 -+ , HW_H_SYS_GPR385, HW_H_SYS_GPR386, HW_H_SYS_GPR387, HW_H_SYS_GPR388 -+ , HW_H_SYS_GPR389, HW_H_SYS_GPR390, HW_H_SYS_GPR391, HW_H_SYS_GPR392 -+ , HW_H_SYS_GPR393, HW_H_SYS_GPR394, HW_H_SYS_GPR395, HW_H_SYS_GPR396 -+ , HW_H_SYS_GPR397, HW_H_SYS_GPR398, HW_H_SYS_GPR399, HW_H_SYS_GPR400 -+ , HW_H_SYS_GPR401, HW_H_SYS_GPR402, HW_H_SYS_GPR403, HW_H_SYS_GPR404 -+ , HW_H_SYS_GPR405, HW_H_SYS_GPR406, HW_H_SYS_GPR407, HW_H_SYS_GPR408 -+ , HW_H_SYS_GPR409, HW_H_SYS_GPR410, HW_H_SYS_GPR411, HW_H_SYS_GPR412 -+ , HW_H_SYS_GPR413, HW_H_SYS_GPR414, HW_H_SYS_GPR415, HW_H_SYS_GPR416 -+ , HW_H_SYS_GPR417, HW_H_SYS_GPR418, HW_H_SYS_GPR419, HW_H_SYS_GPR420 -+ , HW_H_SYS_GPR421, HW_H_SYS_GPR422, HW_H_SYS_GPR423, HW_H_SYS_GPR424 -+ , HW_H_SYS_GPR425, HW_H_SYS_GPR426, HW_H_SYS_GPR427, HW_H_SYS_GPR428 -+ , HW_H_SYS_GPR429, HW_H_SYS_GPR430, HW_H_SYS_GPR431, HW_H_SYS_GPR432 -+ , HW_H_SYS_GPR433, HW_H_SYS_GPR434, HW_H_SYS_GPR435, HW_H_SYS_GPR436 -+ , HW_H_SYS_GPR437, HW_H_SYS_GPR438, HW_H_SYS_GPR439, HW_H_SYS_GPR440 -+ , HW_H_SYS_GPR441, HW_H_SYS_GPR442, HW_H_SYS_GPR443, HW_H_SYS_GPR444 -+ , HW_H_SYS_GPR445, HW_H_SYS_GPR446, HW_H_SYS_GPR447, HW_H_SYS_GPR448 -+ , HW_H_SYS_GPR449, HW_H_SYS_GPR450, HW_H_SYS_GPR451, HW_H_SYS_GPR452 -+ , HW_H_SYS_GPR453, HW_H_SYS_GPR454, HW_H_SYS_GPR455, HW_H_SYS_GPR456 -+ , HW_H_SYS_GPR457, HW_H_SYS_GPR458, HW_H_SYS_GPR459, HW_H_SYS_GPR460 -+ , HW_H_SYS_GPR461, HW_H_SYS_GPR462, HW_H_SYS_GPR463, HW_H_SYS_GPR464 -+ , HW_H_SYS_GPR465, HW_H_SYS_GPR466, HW_H_SYS_GPR467, HW_H_SYS_GPR468 -+ , HW_H_SYS_GPR469, HW_H_SYS_GPR470, HW_H_SYS_GPR471, HW_H_SYS_GPR472 -+ , HW_H_SYS_GPR473, HW_H_SYS_GPR474, HW_H_SYS_GPR475, HW_H_SYS_GPR476 -+ , HW_H_SYS_GPR477, HW_H_SYS_GPR478, HW_H_SYS_GPR479, HW_H_SYS_GPR480 -+ , HW_H_SYS_GPR481, HW_H_SYS_GPR482, HW_H_SYS_GPR483, HW_H_SYS_GPR484 -+ , HW_H_SYS_GPR485, HW_H_SYS_GPR486, HW_H_SYS_GPR487, HW_H_SYS_GPR488 -+ , HW_H_SYS_GPR489, HW_H_SYS_GPR490, HW_H_SYS_GPR491, HW_H_SYS_GPR492 -+ , HW_H_SYS_GPR493, HW_H_SYS_GPR494, HW_H_SYS_GPR495, HW_H_SYS_GPR496 -+ , HW_H_SYS_GPR497, HW_H_SYS_GPR498, HW_H_SYS_GPR499, HW_H_SYS_GPR500 -+ , HW_H_SYS_GPR501, HW_H_SYS_GPR502, HW_H_SYS_GPR503, HW_H_SYS_GPR504 -+ , HW_H_SYS_GPR505, HW_H_SYS_GPR506, HW_H_SYS_GPR507, HW_H_SYS_GPR508 -+ , HW_H_SYS_GPR509, HW_H_SYS_GPR510, HW_H_SYS_GPR511, HW_H_MAC_MACLO -+ , HW_H_MAC_MACHI, HW_H_TICK_TTMR, HW_H_SYS_VR_REV, HW_H_SYS_VR_CFG -+ , HW_H_SYS_VR_VER, HW_H_SYS_UPR_UP, HW_H_SYS_UPR_DCP, HW_H_SYS_UPR_ICP -+ , HW_H_SYS_UPR_DMP, HW_H_SYS_UPR_MP, HW_H_SYS_UPR_IMP, HW_H_SYS_UPR_DUP -+ , HW_H_SYS_UPR_PCUP, HW_H_SYS_UPR_PICP, HW_H_SYS_UPR_PMP, HW_H_SYS_UPR_TTP -+ , HW_H_SYS_UPR_CUP, HW_H_SYS_CPUCFGR_NSGR, HW_H_SYS_CPUCFGR_CGF, HW_H_SYS_CPUCFGR_OB32S -+ , HW_H_SYS_CPUCFGR_OB64S, HW_H_SYS_CPUCFGR_OF32S, HW_H_SYS_CPUCFGR_OF64S, HW_H_SYS_CPUCFGR_OV64S -+ , HW_H_SYS_CPUCFGR_ND, HW_H_SYS_SR_SM, HW_H_SYS_SR_TEE, HW_H_SYS_SR_IEE -+ , HW_H_SYS_SR_DCE, HW_H_SYS_SR_ICE, HW_H_SYS_SR_DME, HW_H_SYS_SR_IME -+ , HW_H_SYS_SR_LEE, HW_H_SYS_SR_CE, HW_H_SYS_SR_F, HW_H_SYS_SR_CY -+ , HW_H_SYS_SR_OV, HW_H_SYS_SR_OVE, HW_H_SYS_SR_DSX, HW_H_SYS_SR_EPH -+ , HW_H_SYS_SR_FO, HW_H_SYS_SR_SUMRA, HW_H_SYS_SR_CID, HW_H_SYS_FPCSR_FPEE -+ , HW_H_SYS_FPCSR_RM, HW_H_SYS_FPCSR_OVF, HW_H_SYS_FPCSR_UNF, HW_H_SYS_FPCSR_SNF -+ , HW_H_SYS_FPCSR_QNF, HW_H_SYS_FPCSR_ZF, HW_H_SYS_FPCSR_IXF, HW_H_SYS_FPCSR_IVF -+ , HW_H_SYS_FPCSR_INF, HW_H_SYS_FPCSR_DZF, HW_H_SIMM16, HW_H_UIMM16 -+ , HW_H_UIMM6, HW_H_ATOMIC_RESERVE, HW_H_ATOMIC_ADDRESS, HW_MAX -+} CGEN_HW_TYPE; -+ -+#define MAX_HW ((int) HW_MAX) -+ -+/* Operand attribute indices. */ -+ -+/* Enum declaration for cgen_operand attrs. */ -+typedef enum cgen_operand_attr { -+ CGEN_OPERAND_VIRTUAL, CGEN_OPERAND_PCREL_ADDR, CGEN_OPERAND_ABS_ADDR, CGEN_OPERAND_SIGN_OPT -+ , CGEN_OPERAND_SIGNED, CGEN_OPERAND_NEGATIVE, CGEN_OPERAND_RELAX, CGEN_OPERAND_SEM_ONLY -+ , CGEN_OPERAND_END_BOOLS, CGEN_OPERAND_START_NBOOLS = 31, CGEN_OPERAND_MACH, CGEN_OPERAND_END_NBOOLS -+} CGEN_OPERAND_ATTR; -+ -+/* Number of non-boolean elements in cgen_operand_attr. */ -+#define CGEN_OPERAND_NBOOL_ATTRS (CGEN_OPERAND_END_NBOOLS - CGEN_OPERAND_START_NBOOLS - 1) -+ -+/* cgen_operand attribute accessor macros. */ -+#define CGEN_ATTR_CGEN_OPERAND_MACH_VALUE(attrs) ((attrs)->nonbool[CGEN_OPERAND_MACH-CGEN_OPERAND_START_NBOOLS-1].nonbitset) -+#define CGEN_ATTR_CGEN_OPERAND_VIRTUAL_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_OPERAND_VIRTUAL)) != 0) -+#define CGEN_ATTR_CGEN_OPERAND_PCREL_ADDR_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_OPERAND_PCREL_ADDR)) != 0) -+#define CGEN_ATTR_CGEN_OPERAND_ABS_ADDR_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_OPERAND_ABS_ADDR)) != 0) -+#define CGEN_ATTR_CGEN_OPERAND_SIGN_OPT_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_OPERAND_SIGN_OPT)) != 0) -+#define CGEN_ATTR_CGEN_OPERAND_SIGNED_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_OPERAND_SIGNED)) != 0) -+#define CGEN_ATTR_CGEN_OPERAND_NEGATIVE_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_OPERAND_NEGATIVE)) != 0) -+#define CGEN_ATTR_CGEN_OPERAND_RELAX_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_OPERAND_RELAX)) != 0) -+#define CGEN_ATTR_CGEN_OPERAND_SEM_ONLY_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_OPERAND_SEM_ONLY)) != 0) -+ -+/* Enum declaration for or1k operand types. */ -+typedef enum cgen_operand_type { -+ OR1K_OPERAND_PC, OR1K_OPERAND_SYS_SR, OR1K_OPERAND_SYS_ESR0, OR1K_OPERAND_SYS_EPCR0 -+ , OR1K_OPERAND_SYS_SR_LEE, OR1K_OPERAND_SYS_SR_F, OR1K_OPERAND_SYS_SR_CY, OR1K_OPERAND_SYS_SR_OV -+ , OR1K_OPERAND_SYS_SR_OVE, OR1K_OPERAND_SYS_CPUCFGR_OB64S, OR1K_OPERAND_SYS_CPUCFGR_ND, OR1K_OPERAND_SYS_FPCSR_RM -+ , OR1K_OPERAND_MAC_MACHI, OR1K_OPERAND_MAC_MACLO, OR1K_OPERAND_ATOMIC_RESERVE, OR1K_OPERAND_ATOMIC_ADDRESS -+ , OR1K_OPERAND_UIMM6, OR1K_OPERAND_RD, OR1K_OPERAND_RA, OR1K_OPERAND_RB -+ , OR1K_OPERAND_DISP26, OR1K_OPERAND_SIMM16, OR1K_OPERAND_UIMM16, OR1K_OPERAND_SIMM16_SPLIT -+ , OR1K_OPERAND_UIMM16_SPLIT, OR1K_OPERAND_RDSF, OR1K_OPERAND_RASF, OR1K_OPERAND_RBSF -+ , OR1K_OPERAND_RDDF, OR1K_OPERAND_RADF, OR1K_OPERAND_RBDF, OR1K_OPERAND_MAX -+} CGEN_OPERAND_TYPE; -+ -+/* Number of operands types. */ -+#define MAX_OPERANDS 31 -+ -+/* Maximum number of operands referenced by any insn. */ -+#define MAX_OPERAND_INSTANCES 9 -+ -+/* Insn attribute indices. */ -+ -+/* Enum declaration for cgen_insn attrs. */ -+typedef enum cgen_insn_attr { -+ CGEN_INSN_ALIAS, CGEN_INSN_VIRTUAL, CGEN_INSN_UNCOND_CTI, CGEN_INSN_COND_CTI -+ , CGEN_INSN_SKIP_CTI, CGEN_INSN_DELAY_SLOT, CGEN_INSN_RELAXABLE, CGEN_INSN_RELAXED -+ , CGEN_INSN_NO_DIS, CGEN_INSN_PBB, CGEN_INSN_DELAYED_CTI, CGEN_INSN_NOT_IN_DELAY_SLOT -+ , CGEN_INSN_FORCED_CTI, CGEN_INSN_END_BOOLS, CGEN_INSN_START_NBOOLS = 31, CGEN_INSN_MACH -+ , CGEN_INSN_END_NBOOLS -+} CGEN_INSN_ATTR; -+ -+/* Number of non-boolean elements in cgen_insn_attr. */ -+#define CGEN_INSN_NBOOL_ATTRS (CGEN_INSN_END_NBOOLS - CGEN_INSN_START_NBOOLS - 1) -+ -+/* cgen_insn attribute accessor macros. */ -+#define CGEN_ATTR_CGEN_INSN_MACH_VALUE(attrs) ((attrs)->nonbool[CGEN_INSN_MACH-CGEN_INSN_START_NBOOLS-1].nonbitset) -+#define CGEN_ATTR_CGEN_INSN_ALIAS_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_INSN_ALIAS)) != 0) -+#define CGEN_ATTR_CGEN_INSN_VIRTUAL_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_INSN_VIRTUAL)) != 0) -+#define CGEN_ATTR_CGEN_INSN_UNCOND_CTI_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_INSN_UNCOND_CTI)) != 0) -+#define CGEN_ATTR_CGEN_INSN_COND_CTI_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_INSN_COND_CTI)) != 0) -+#define CGEN_ATTR_CGEN_INSN_SKIP_CTI_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_INSN_SKIP_CTI)) != 0) -+#define CGEN_ATTR_CGEN_INSN_DELAY_SLOT_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_INSN_DELAY_SLOT)) != 0) -+#define CGEN_ATTR_CGEN_INSN_RELAXABLE_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_INSN_RELAXABLE)) != 0) -+#define CGEN_ATTR_CGEN_INSN_RELAXED_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_INSN_RELAXED)) != 0) -+#define CGEN_ATTR_CGEN_INSN_NO_DIS_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_INSN_NO_DIS)) != 0) -+#define CGEN_ATTR_CGEN_INSN_PBB_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_INSN_PBB)) != 0) -+#define CGEN_ATTR_CGEN_INSN_DELAYED_CTI_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_INSN_DELAYED_CTI)) != 0) -+#define CGEN_ATTR_CGEN_INSN_NOT_IN_DELAY_SLOT_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_INSN_NOT_IN_DELAY_SLOT)) != 0) -+#define CGEN_ATTR_CGEN_INSN_FORCED_CTI_VALUE(attrs) (((attrs)->bool_ & (1 << CGEN_INSN_FORCED_CTI)) != 0) -+ -+/* cgen.h uses things we just defined. */ -+#include "opcode/cgen.h" -+ -+extern const struct cgen_ifld or1k_cgen_ifld_table[]; -+ -+/* Attributes. */ -+extern const CGEN_ATTR_TABLE or1k_cgen_hardware_attr_table[]; -+extern const CGEN_ATTR_TABLE or1k_cgen_ifield_attr_table[]; -+extern const CGEN_ATTR_TABLE or1k_cgen_operand_attr_table[]; -+extern const CGEN_ATTR_TABLE or1k_cgen_insn_attr_table[]; -+ -+/* Hardware decls. */ -+ -+extern CGEN_KEYWORD or1k_cgen_opval_h_fsr; -+extern CGEN_KEYWORD or1k_cgen_opval_h_fdr; -+extern CGEN_KEYWORD or1k_cgen_opval_h_gpr; -+ -+extern const CGEN_HW_ENTRY or1k_cgen_hw_table[]; -+ -+ -+ -+#endif /* OR1K_CPU_H */ -diff -rNU3 dist.orig/opcodes/or1k-dis.c dist/opcodes/or1k-dis.c ---- dist.orig/opcodes/or1k-dis.c 1970-01-01 01:00:00.000000000 +0100 -+++ dist/opcodes/or1k-dis.c 2015-10-18 13:11:20.000000000 +0200 -@@ -0,0 +1,561 @@ -+/* Disassembler interface for targets using CGEN. -*- C -*- -+ CGEN: Cpu tools GENerator -+ -+ THIS FILE IS MACHINE GENERATED WITH CGEN. -+ - the resultant file is machine generated, cgen-dis.in isn't -+ -+ Copyright (C) 1996-2014 Free Software Foundation, Inc. -+ -+ This file is part of libopcodes. -+ -+ This library is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3, or (at your option) -+ any later version. -+ -+ It is distributed in the hope that it will be useful, but WITHOUT -+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -+ License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, write to the Free Software Foundation, Inc., -+ 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -+ -+/* ??? Eventually more and more of this stuff can go to cpu-independent files. -+ Keep that in mind. */ -+ -+#include "sysdep.h" -+#include -+#include "ansidecl.h" -+#include "dis-asm.h" -+#include "bfd.h" -+#include "symcat.h" -+#include "libiberty.h" -+#include "or1k-desc.h" -+#include "or1k-opc.h" -+#include "opintl.h" -+ -+/* Default text to print if an instruction isn't recognized. */ -+#define UNKNOWN_INSN_MSG _("*unknown*") -+ -+static void print_normal -+ (CGEN_CPU_DESC, void *, long, unsigned int, bfd_vma, int); -+static void print_address -+ (CGEN_CPU_DESC, void *, bfd_vma, unsigned int, bfd_vma, int) ATTRIBUTE_UNUSED; -+static void print_keyword -+ (CGEN_CPU_DESC, void *, CGEN_KEYWORD *, long, unsigned int) ATTRIBUTE_UNUSED; -+static void print_insn_normal -+ (CGEN_CPU_DESC, void *, const CGEN_INSN *, CGEN_FIELDS *, bfd_vma, int); -+static int print_insn -+ (CGEN_CPU_DESC, bfd_vma, disassemble_info *, bfd_byte *, unsigned); -+static int default_print_insn -+ (CGEN_CPU_DESC, bfd_vma, disassemble_info *) ATTRIBUTE_UNUSED; -+static int read_insn -+ (CGEN_CPU_DESC, bfd_vma, disassemble_info *, bfd_byte *, int, CGEN_EXTRACT_INFO *, -+ unsigned long *); -+ -+/* -- disassembler routines inserted here. */ -+ -+ -+void or1k_cgen_print_operand -+ (CGEN_CPU_DESC, int, PTR, CGEN_FIELDS *, void const *, bfd_vma, int); -+ -+/* Main entry point for printing operands. -+ XINFO is a `void *' and not a `disassemble_info *' to not put a requirement -+ of dis-asm.h on cgen.h. -+ -+ This function is basically just a big switch statement. Earlier versions -+ used tables to look up the function to use, but -+ - if the table contains both assembler and disassembler functions then -+ the disassembler contains much of the assembler and vice-versa, -+ - there's a lot of inlining possibilities as things grow, -+ - using a switch statement avoids the function call overhead. -+ -+ This function could be moved into `print_insn_normal', but keeping it -+ separate makes clear the interface between `print_insn_normal' and each of -+ the handlers. */ -+ -+void -+or1k_cgen_print_operand (CGEN_CPU_DESC cd, -+ int opindex, -+ void * xinfo, -+ CGEN_FIELDS *fields, -+ void const *attrs ATTRIBUTE_UNUSED, -+ bfd_vma pc, -+ int length) -+{ -+ disassemble_info *info = (disassemble_info *) xinfo; -+ -+ switch (opindex) -+ { -+ case OR1K_OPERAND_DISP26 : -+ print_address (cd, info, fields->f_disp26, 0|(1<f_r2, 0); -+ break; -+ case OR1K_OPERAND_RADF : -+ print_keyword (cd, info, & or1k_cgen_opval_h_fdr, fields->f_r1, 0); -+ break; -+ case OR1K_OPERAND_RASF : -+ print_keyword (cd, info, & or1k_cgen_opval_h_fsr, fields->f_r2, 0); -+ break; -+ case OR1K_OPERAND_RB : -+ print_keyword (cd, info, & or1k_cgen_opval_h_gpr, fields->f_r3, 0); -+ break; -+ case OR1K_OPERAND_RBDF : -+ print_keyword (cd, info, & or1k_cgen_opval_h_fdr, fields->f_r1, 0); -+ break; -+ case OR1K_OPERAND_RBSF : -+ print_keyword (cd, info, & or1k_cgen_opval_h_fsr, fields->f_r3, 0); -+ break; -+ case OR1K_OPERAND_RD : -+ print_keyword (cd, info, & or1k_cgen_opval_h_gpr, fields->f_r1, 0); -+ break; -+ case OR1K_OPERAND_RDDF : -+ print_keyword (cd, info, & or1k_cgen_opval_h_fdr, fields->f_r1, 0); -+ break; -+ case OR1K_OPERAND_RDSF : -+ print_keyword (cd, info, & or1k_cgen_opval_h_fsr, fields->f_r1, 0); -+ break; -+ case OR1K_OPERAND_SIMM16 : -+ print_normal (cd, info, fields->f_simm16, 0|(1<f_simm16_split, 0|(1<f_uimm16, 0, pc, length); -+ break; -+ case OR1K_OPERAND_UIMM16_SPLIT : -+ print_normal (cd, info, fields->f_uimm16_split, 0|(1<f_uimm6, 0, pc, length); -+ break; -+ -+ default : -+ /* xgettext:c-format */ -+ fprintf (stderr, _("Unrecognized field %d while printing insn.\n"), -+ opindex); -+ abort (); -+ } -+} -+ -+cgen_print_fn * const or1k_cgen_print_handlers[] = -+{ -+ print_insn_normal, -+}; -+ -+ -+void -+or1k_cgen_init_dis (CGEN_CPU_DESC cd) -+{ -+ or1k_cgen_init_opcode_table (cd); -+ or1k_cgen_init_ibld_table (cd); -+ cd->print_handlers = & or1k_cgen_print_handlers[0]; -+ cd->print_operand = or1k_cgen_print_operand; -+} -+ -+ -+/* Default print handler. */ -+ -+static void -+print_normal (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, -+ void *dis_info, -+ long value, -+ unsigned int attrs, -+ bfd_vma pc ATTRIBUTE_UNUSED, -+ int length ATTRIBUTE_UNUSED) -+{ -+ disassemble_info *info = (disassemble_info *) dis_info; -+ -+ /* Print the operand as directed by the attributes. */ -+ if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SEM_ONLY)) -+ ; /* nothing to do */ -+ else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SIGNED)) -+ (*info->fprintf_func) (info->stream, "%ld", value); -+ else -+ (*info->fprintf_func) (info->stream, "0x%lx", value); -+} -+ -+/* Default address handler. */ -+ -+static void -+print_address (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, -+ void *dis_info, -+ bfd_vma value, -+ unsigned int attrs, -+ bfd_vma pc ATTRIBUTE_UNUSED, -+ int length ATTRIBUTE_UNUSED) -+{ -+ disassemble_info *info = (disassemble_info *) dis_info; -+ -+ /* Print the operand as directed by the attributes. */ -+ if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SEM_ONLY)) -+ ; /* Nothing to do. */ -+ else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_PCREL_ADDR)) -+ (*info->print_address_func) (value, info); -+ else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_ABS_ADDR)) -+ (*info->print_address_func) (value, info); -+ else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SIGNED)) -+ (*info->fprintf_func) (info->stream, "%ld", (long) value); -+ else -+ (*info->fprintf_func) (info->stream, "0x%lx", (long) value); -+} -+ -+/* Keyword print handler. */ -+ -+static void -+print_keyword (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, -+ void *dis_info, -+ CGEN_KEYWORD *keyword_table, -+ long value, -+ unsigned int attrs ATTRIBUTE_UNUSED) -+{ -+ disassemble_info *info = (disassemble_info *) dis_info; -+ const CGEN_KEYWORD_ENTRY *ke; -+ -+ ke = cgen_keyword_lookup_value (keyword_table, value); -+ if (ke != NULL) -+ (*info->fprintf_func) (info->stream, "%s", ke->name); -+ else -+ (*info->fprintf_func) (info->stream, "???"); -+} -+ -+/* Default insn printer. -+ -+ DIS_INFO is defined as `void *' so the disassembler needn't know anything -+ about disassemble_info. */ -+ -+static void -+print_insn_normal (CGEN_CPU_DESC cd, -+ void *dis_info, -+ const CGEN_INSN *insn, -+ CGEN_FIELDS *fields, -+ bfd_vma pc, -+ int length) -+{ -+ const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn); -+ disassemble_info *info = (disassemble_info *) dis_info; -+ const CGEN_SYNTAX_CHAR_TYPE *syn; -+ -+ CGEN_INIT_PRINT (cd); -+ -+ for (syn = CGEN_SYNTAX_STRING (syntax); *syn; ++syn) -+ { -+ if (CGEN_SYNTAX_MNEMONIC_P (*syn)) -+ { -+ (*info->fprintf_func) (info->stream, "%s", CGEN_INSN_MNEMONIC (insn)); -+ continue; -+ } -+ if (CGEN_SYNTAX_CHAR_P (*syn)) -+ { -+ (*info->fprintf_func) (info->stream, "%c", CGEN_SYNTAX_CHAR (*syn)); -+ continue; -+ } -+ -+ /* We have an operand. */ -+ or1k_cgen_print_operand (cd, CGEN_SYNTAX_FIELD (*syn), info, -+ fields, CGEN_INSN_ATTRS (insn), pc, length); -+ } -+} -+ -+/* Subroutine of print_insn. Reads an insn into the given buffers and updates -+ the extract info. -+ Returns 0 if all is well, non-zero otherwise. */ -+ -+static int -+read_insn (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, -+ bfd_vma pc, -+ disassemble_info *info, -+ bfd_byte *buf, -+ int buflen, -+ CGEN_EXTRACT_INFO *ex_info, -+ unsigned long *insn_value) -+{ -+ int status = (*info->read_memory_func) (pc, buf, buflen, info); -+ -+ if (status != 0) -+ { -+ (*info->memory_error_func) (status, pc, info); -+ return -1; -+ } -+ -+ ex_info->dis_info = info; -+ ex_info->valid = (1 << buflen) - 1; -+ ex_info->insn_bytes = buf; -+ -+ *insn_value = bfd_get_bits (buf, buflen * 8, info->endian == BFD_ENDIAN_BIG); -+ return 0; -+} -+ -+/* Utility to print an insn. -+ BUF is the base part of the insn, target byte order, BUFLEN bytes long. -+ The result is the size of the insn in bytes or zero for an unknown insn -+ or -1 if an error occurs fetching data (memory_error_func will have -+ been called). */ -+ -+static int -+print_insn (CGEN_CPU_DESC cd, -+ bfd_vma pc, -+ disassemble_info *info, -+ bfd_byte *buf, -+ unsigned int buflen) -+{ -+ CGEN_INSN_INT insn_value; -+ const CGEN_INSN_LIST *insn_list; -+ CGEN_EXTRACT_INFO ex_info; -+ int basesize; -+ -+ /* Extract base part of instruction, just in case CGEN_DIS_* uses it. */ -+ basesize = cd->base_insn_bitsize < buflen * 8 ? -+ cd->base_insn_bitsize : buflen * 8; -+ insn_value = cgen_get_insn_value (cd, buf, basesize); -+ -+ -+ /* Fill in ex_info fields like read_insn would. Don't actually call -+ read_insn, since the incoming buffer is already read (and possibly -+ modified a la m32r). */ -+ ex_info.valid = (1 << buflen) - 1; -+ ex_info.dis_info = info; -+ ex_info.insn_bytes = buf; -+ -+ /* The instructions are stored in hash lists. -+ Pick the first one and keep trying until we find the right one. */ -+ -+ insn_list = CGEN_DIS_LOOKUP_INSN (cd, (char *) buf, insn_value); -+ while (insn_list != NULL) -+ { -+ const CGEN_INSN *insn = insn_list->insn; -+ CGEN_FIELDS fields; -+ int length; -+ unsigned long insn_value_cropped; -+ -+#ifdef CGEN_VALIDATE_INSN_SUPPORTED -+ /* Not needed as insn shouldn't be in hash lists if not supported. */ -+ /* Supported by this cpu? */ -+ if (! or1k_cgen_insn_supported (cd, insn)) -+ { -+ insn_list = CGEN_DIS_NEXT_INSN (insn_list); -+ continue; -+ } -+#endif -+ -+ /* Basic bit mask must be correct. */ -+ /* ??? May wish to allow target to defer this check until the extract -+ handler. */ -+ -+ /* Base size may exceed this instruction's size. Extract the -+ relevant part from the buffer. */ -+ if ((unsigned) (CGEN_INSN_BITSIZE (insn) / 8) < buflen && -+ (unsigned) (CGEN_INSN_BITSIZE (insn) / 8) <= sizeof (unsigned long)) -+ insn_value_cropped = bfd_get_bits (buf, CGEN_INSN_BITSIZE (insn), -+ info->endian == BFD_ENDIAN_BIG); -+ else -+ insn_value_cropped = insn_value; -+ -+ if ((insn_value_cropped & CGEN_INSN_BASE_MASK (insn)) -+ == CGEN_INSN_BASE_VALUE (insn)) -+ { -+ /* Printing is handled in two passes. The first pass parses the -+ machine insn and extracts the fields. The second pass prints -+ them. */ -+ -+ /* Make sure the entire insn is loaded into insn_value, if it -+ can fit. */ -+ if (((unsigned) CGEN_INSN_BITSIZE (insn) > cd->base_insn_bitsize) && -+ (unsigned) (CGEN_INSN_BITSIZE (insn) / 8) <= sizeof (unsigned long)) -+ { -+ unsigned long full_insn_value; -+ int rc = read_insn (cd, pc, info, buf, -+ CGEN_INSN_BITSIZE (insn) / 8, -+ & ex_info, & full_insn_value); -+ if (rc != 0) -+ return rc; -+ length = CGEN_EXTRACT_FN (cd, insn) -+ (cd, insn, &ex_info, full_insn_value, &fields, pc); -+ } -+ else -+ length = CGEN_EXTRACT_FN (cd, insn) -+ (cd, insn, &ex_info, insn_value_cropped, &fields, pc); -+ -+ /* Length < 0 -> error. */ -+ if (length < 0) -+ return length; -+ if (length > 0) -+ { -+ CGEN_PRINT_FN (cd, insn) (cd, info, insn, &fields, pc, length); -+ /* Length is in bits, result is in bytes. */ -+ return length / 8; -+ } -+ } -+ -+ insn_list = CGEN_DIS_NEXT_INSN (insn_list); -+ } -+ -+ return 0; -+} -+ -+/* Default value for CGEN_PRINT_INSN. -+ The result is the size of the insn in bytes or zero for an unknown insn -+ or -1 if an error occured fetching bytes. */ -+ -+#ifndef CGEN_PRINT_INSN -+#define CGEN_PRINT_INSN default_print_insn -+#endif -+ -+static int -+default_print_insn (CGEN_CPU_DESC cd, bfd_vma pc, disassemble_info *info) -+{ -+ bfd_byte buf[CGEN_MAX_INSN_SIZE]; -+ int buflen; -+ int status; -+ -+ /* Attempt to read the base part of the insn. */ -+ buflen = cd->base_insn_bitsize / 8; -+ status = (*info->read_memory_func) (pc, buf, buflen, info); -+ -+ /* Try again with the minimum part, if min < base. */ -+ if (status != 0 && (cd->min_insn_bitsize < cd->base_insn_bitsize)) -+ { -+ buflen = cd->min_insn_bitsize / 8; -+ status = (*info->read_memory_func) (pc, buf, buflen, info); -+ } -+ -+ if (status != 0) -+ { -+ (*info->memory_error_func) (status, pc, info); -+ return -1; -+ } -+ -+ return print_insn (cd, pc, info, buf, buflen); -+} -+ -+/* Main entry point. -+ Print one instruction from PC on INFO->STREAM. -+ Return the size of the instruction (in bytes). */ -+ -+typedef struct cpu_desc_list -+{ -+ struct cpu_desc_list *next; -+ CGEN_BITSET *isa; -+ int mach; -+ int endian; -+ CGEN_CPU_DESC cd; -+} cpu_desc_list; -+ -+int -+print_insn_or1k (bfd_vma pc, disassemble_info *info) -+{ -+ static cpu_desc_list *cd_list = 0; -+ cpu_desc_list *cl = 0; -+ static CGEN_CPU_DESC cd = 0; -+ static CGEN_BITSET *prev_isa; -+ static int prev_mach; -+ static int prev_endian; -+ int length; -+ CGEN_BITSET *isa; -+ int mach; -+ int endian = (info->endian == BFD_ENDIAN_BIG -+ ? CGEN_ENDIAN_BIG -+ : CGEN_ENDIAN_LITTLE); -+ enum bfd_architecture arch; -+ -+ /* ??? gdb will set mach but leave the architecture as "unknown" */ -+#ifndef CGEN_BFD_ARCH -+#define CGEN_BFD_ARCH bfd_arch_or1k -+#endif -+ arch = info->arch; -+ if (arch == bfd_arch_unknown) -+ arch = CGEN_BFD_ARCH; -+ -+ /* There's no standard way to compute the machine or isa number -+ so we leave it to the target. */ -+#ifdef CGEN_COMPUTE_MACH -+ mach = CGEN_COMPUTE_MACH (info); -+#else -+ mach = info->mach; -+#endif -+ -+#ifdef CGEN_COMPUTE_ISA -+ { -+ static CGEN_BITSET *permanent_isa; -+ -+ if (!permanent_isa) -+ permanent_isa = cgen_bitset_create (MAX_ISAS); -+ isa = permanent_isa; -+ cgen_bitset_clear (isa); -+ cgen_bitset_add (isa, CGEN_COMPUTE_ISA (info)); -+ } -+#else -+ isa = info->insn_sets; -+#endif -+ -+ /* If we've switched cpu's, try to find a handle we've used before */ -+ if (cd -+ && (cgen_bitset_compare (isa, prev_isa) != 0 -+ || mach != prev_mach -+ || endian != prev_endian)) -+ { -+ cd = 0; -+ for (cl = cd_list; cl; cl = cl->next) -+ { -+ if (cgen_bitset_compare (cl->isa, isa) == 0 && -+ cl->mach == mach && -+ cl->endian == endian) -+ { -+ cd = cl->cd; -+ prev_isa = cd->isas; -+ break; -+ } -+ } -+ } -+ -+ /* If we haven't initialized yet, initialize the opcode table. */ -+ if (! cd) -+ { -+ const bfd_arch_info_type *arch_type = bfd_lookup_arch (arch, mach); -+ const char *mach_name; -+ -+ if (!arch_type) -+ abort (); -+ mach_name = arch_type->printable_name; -+ -+ prev_isa = cgen_bitset_copy (isa); -+ prev_mach = mach; -+ prev_endian = endian; -+ cd = or1k_cgen_cpu_open (CGEN_CPU_OPEN_ISAS, prev_isa, -+ CGEN_CPU_OPEN_BFDMACH, mach_name, -+ CGEN_CPU_OPEN_ENDIAN, prev_endian, -+ CGEN_CPU_OPEN_END); -+ if (!cd) -+ abort (); -+ -+ /* Save this away for future reference. */ -+ cl = xmalloc (sizeof (struct cpu_desc_list)); -+ cl->cd = cd; -+ cl->isa = prev_isa; -+ cl->mach = mach; -+ cl->endian = endian; -+ cl->next = cd_list; -+ cd_list = cl; -+ -+ or1k_cgen_init_dis (cd); -+ } -+ -+ /* We try to have as much common code as possible. -+ But at this point some targets need to take over. */ -+ /* ??? Some targets may need a hook elsewhere. Try to avoid this, -+ but if not possible try to move this hook elsewhere rather than -+ have two hooks. */ -+ length = CGEN_PRINT_INSN (cd, pc, info); -+ if (length > 0) -+ return length; -+ if (length < 0) -+ return -1; -+ -+ (*info->fprintf_func) (info->stream, UNKNOWN_INSN_MSG); -+ return cd->default_insn_bitsize / 8; -+} -diff -rNU3 dist.orig/opcodes/or1k-ibld.c dist/opcodes/or1k-ibld.c ---- dist.orig/opcodes/or1k-ibld.c 1970-01-01 01:00:00.000000000 +0100 -+++ dist/opcodes/or1k-ibld.c 2015-10-18 13:11:20.000000000 +0200 -@@ -0,0 +1,1050 @@ -+/* Instruction building/extraction support for or1k. -*- C -*- -+ -+ THIS FILE IS MACHINE GENERATED WITH CGEN: Cpu tools GENerator. -+ - the resultant file is machine generated, cgen-ibld.in isn't -+ -+ Copyright (C) 1996-2014 Free Software Foundation, Inc. -+ -+ This file is part of libopcodes. -+ -+ This library is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3, or (at your option) -+ any later version. -+ -+ It is distributed in the hope that it will be useful, but WITHOUT -+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -+ License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, write to the Free Software Foundation, Inc., -+ 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -+ -+/* ??? Eventually more and more of this stuff can go to cpu-independent files. -+ Keep that in mind. */ -+ -+#include "sysdep.h" -+#include -+#include "ansidecl.h" -+#include "dis-asm.h" -+#include "bfd.h" -+#include "symcat.h" -+#include "or1k-desc.h" -+#include "or1k-opc.h" -+#include "cgen/basic-modes.h" -+#include "opintl.h" -+#include "safe-ctype.h" -+ -+#undef min -+#define min(a,b) ((a) < (b) ? (a) : (b)) -+#undef max -+#define max(a,b) ((a) > (b) ? (a) : (b)) -+ -+/* Used by the ifield rtx function. */ -+#define FLD(f) (fields->f) -+ -+static const char * insert_normal -+ (CGEN_CPU_DESC, long, unsigned int, unsigned int, unsigned int, -+ unsigned int, unsigned int, unsigned int, CGEN_INSN_BYTES_PTR); -+static const char * insert_insn_normal -+ (CGEN_CPU_DESC, const CGEN_INSN *, -+ CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma); -+static int extract_normal -+ (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, CGEN_INSN_INT, -+ unsigned int, unsigned int, unsigned int, unsigned int, -+ unsigned int, unsigned int, bfd_vma, long *); -+static int extract_insn_normal -+ (CGEN_CPU_DESC, const CGEN_INSN *, CGEN_EXTRACT_INFO *, -+ CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma); -+#if CGEN_INT_INSN_P -+static void put_insn_int_value -+ (CGEN_CPU_DESC, CGEN_INSN_BYTES_PTR, int, int, CGEN_INSN_INT); -+#endif -+#if ! CGEN_INT_INSN_P -+static CGEN_INLINE void insert_1 -+ (CGEN_CPU_DESC, unsigned long, int, int, int, unsigned char *); -+static CGEN_INLINE int fill_cache -+ (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, int, int, bfd_vma); -+static CGEN_INLINE long extract_1 -+ (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, int, int, int, unsigned char *, bfd_vma); -+#endif -+ -+/* Operand insertion. */ -+ -+#if ! CGEN_INT_INSN_P -+ -+/* Subroutine of insert_normal. */ -+ -+static CGEN_INLINE void -+insert_1 (CGEN_CPU_DESC cd, -+ unsigned long value, -+ int start, -+ int length, -+ int word_length, -+ unsigned char *bufp) -+{ -+ unsigned long x,mask; -+ int shift; -+ -+ x = cgen_get_insn_value (cd, bufp, word_length); -+ -+ /* Written this way to avoid undefined behaviour. */ -+ mask = (((1L << (length - 1)) - 1) << 1) | 1; -+ if (CGEN_INSN_LSB0_P) -+ shift = (start + 1) - length; -+ else -+ shift = (word_length - (start + length)); -+ x = (x & ~(mask << shift)) | ((value & mask) << shift); -+ -+ cgen_put_insn_value (cd, bufp, word_length, (bfd_vma) x); -+} -+ -+#endif /* ! CGEN_INT_INSN_P */ -+ -+/* Default insertion routine. -+ -+ ATTRS is a mask of the boolean attributes. -+ WORD_OFFSET is the offset in bits from the start of the insn of the value. -+ WORD_LENGTH is the length of the word in bits in which the value resides. -+ START is the starting bit number in the word, architecture origin. -+ LENGTH is the length of VALUE in bits. -+ TOTAL_LENGTH is the total length of the insn in bits. -+ -+ The result is an error message or NULL if success. */ -+ -+/* ??? This duplicates functionality with bfd's howto table and -+ bfd_install_relocation. */ -+/* ??? This doesn't handle bfd_vma's. Create another function when -+ necessary. */ -+ -+static const char * -+insert_normal (CGEN_CPU_DESC cd, -+ long value, -+ unsigned int attrs, -+ unsigned int word_offset, -+ unsigned int start, -+ unsigned int length, -+ unsigned int word_length, -+ unsigned int total_length, -+ CGEN_INSN_BYTES_PTR buffer) -+{ -+ static char errbuf[100]; -+ /* Written this way to avoid undefined behaviour. */ -+ unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1; -+ -+ /* If LENGTH is zero, this operand doesn't contribute to the value. */ -+ if (length == 0) -+ return NULL; -+ -+ if (word_length > 8 * sizeof (CGEN_INSN_INT)) -+ abort (); -+ -+ /* For architectures with insns smaller than the base-insn-bitsize, -+ word_length may be too big. */ -+ if (cd->min_insn_bitsize < cd->base_insn_bitsize) -+ { -+ if (word_offset == 0 -+ && word_length > total_length) -+ word_length = total_length; -+ } -+ -+ /* Ensure VALUE will fit. */ -+ if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGN_OPT)) -+ { -+ long minval = - (1L << (length - 1)); -+ unsigned long maxval = mask; -+ -+ if ((value > 0 && (unsigned long) value > maxval) -+ || value < minval) -+ { -+ /* xgettext:c-format */ -+ sprintf (errbuf, -+ _("operand out of range (%ld not between %ld and %lu)"), -+ value, minval, maxval); -+ return errbuf; -+ } -+ } -+ else if (! CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED)) -+ { -+ unsigned long maxval = mask; -+ unsigned long val = (unsigned long) value; -+ -+ /* For hosts with a word size > 32 check to see if value has been sign -+ extended beyond 32 bits. If so then ignore these higher sign bits -+ as the user is attempting to store a 32-bit signed value into an -+ unsigned 32-bit field which is allowed. */ -+ if (sizeof (unsigned long) > 4 && ((value >> 32) == -1)) -+ val &= 0xFFFFFFFF; -+ -+ if (val > maxval) -+ { -+ /* xgettext:c-format */ -+ sprintf (errbuf, -+ _("operand out of range (0x%lx not between 0 and 0x%lx)"), -+ val, maxval); -+ return errbuf; -+ } -+ } -+ else -+ { -+ if (! cgen_signed_overflow_ok_p (cd)) -+ { -+ long minval = - (1L << (length - 1)); -+ long maxval = (1L << (length - 1)) - 1; -+ -+ if (value < minval || value > maxval) -+ { -+ sprintf -+ /* xgettext:c-format */ -+ (errbuf, _("operand out of range (%ld not between %ld and %ld)"), -+ value, minval, maxval); -+ return errbuf; -+ } -+ } -+ } -+ -+#if CGEN_INT_INSN_P -+ -+ { -+ int shift; -+ -+ if (CGEN_INSN_LSB0_P) -+ shift = (word_offset + start + 1) - length; -+ else -+ shift = total_length - (word_offset + start + length); -+ *buffer = (*buffer & ~(mask << shift)) | ((value & mask) << shift); -+ } -+ -+#else /* ! CGEN_INT_INSN_P */ -+ -+ { -+ unsigned char *bufp = (unsigned char *) buffer + word_offset / 8; -+ -+ insert_1 (cd, value, start, length, word_length, bufp); -+ } -+ -+#endif /* ! CGEN_INT_INSN_P */ -+ -+ return NULL; -+} -+ -+/* Default insn builder (insert handler). -+ The instruction is recorded in CGEN_INT_INSN_P byte order (meaning -+ that if CGEN_INSN_BYTES_PTR is an int * and thus, the value is -+ recorded in host byte order, otherwise BUFFER is an array of bytes -+ and the value is recorded in target byte order). -+ The result is an error message or NULL if success. */ -+ -+static const char * -+insert_insn_normal (CGEN_CPU_DESC cd, -+ const CGEN_INSN * insn, -+ CGEN_FIELDS * fields, -+ CGEN_INSN_BYTES_PTR buffer, -+ bfd_vma pc) -+{ -+ const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn); -+ unsigned long value; -+ const CGEN_SYNTAX_CHAR_TYPE * syn; -+ -+ CGEN_INIT_INSERT (cd); -+ value = CGEN_INSN_BASE_VALUE (insn); -+ -+ /* If we're recording insns as numbers (rather than a string of bytes), -+ target byte order handling is deferred until later. */ -+ -+#if CGEN_INT_INSN_P -+ -+ put_insn_int_value (cd, buffer, cd->base_insn_bitsize, -+ CGEN_FIELDS_BITSIZE (fields), value); -+ -+#else -+ -+ cgen_put_insn_value (cd, buffer, min ((unsigned) cd->base_insn_bitsize, -+ (unsigned) CGEN_FIELDS_BITSIZE (fields)), -+ value); -+ -+#endif /* ! CGEN_INT_INSN_P */ -+ -+ /* ??? It would be better to scan the format's fields. -+ Still need to be able to insert a value based on the operand though; -+ e.g. storing a branch displacement that got resolved later. -+ Needs more thought first. */ -+ -+ for (syn = CGEN_SYNTAX_STRING (syntax); * syn; ++ syn) -+ { -+ const char *errmsg; -+ -+ if (CGEN_SYNTAX_CHAR_P (* syn)) -+ continue; -+ -+ errmsg = (* cd->insert_operand) (cd, CGEN_SYNTAX_FIELD (*syn), -+ fields, buffer, pc); -+ if (errmsg) -+ return errmsg; -+ } -+ -+ return NULL; -+} -+ -+#if CGEN_INT_INSN_P -+/* Cover function to store an insn value into an integral insn. Must go here -+ because it needs -desc.h for CGEN_INT_INSN_P. */ -+ -+static void -+put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, -+ CGEN_INSN_BYTES_PTR buf, -+ int length, -+ int insn_length, -+ CGEN_INSN_INT value) -+{ -+ /* For architectures with insns smaller than the base-insn-bitsize, -+ length may be too big. */ -+ if (length > insn_length) -+ *buf = value; -+ else -+ { -+ int shift = insn_length - length; -+ /* Written this way to avoid undefined behaviour. */ -+ CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1; -+ -+ *buf = (*buf & ~(mask << shift)) | ((value & mask) << shift); -+ } -+} -+#endif -+ -+/* Operand extraction. */ -+ -+#if ! CGEN_INT_INSN_P -+ -+/* Subroutine of extract_normal. -+ Ensure sufficient bytes are cached in EX_INFO. -+ OFFSET is the offset in bytes from the start of the insn of the value. -+ BYTES is the length of the needed value. -+ Returns 1 for success, 0 for failure. */ -+ -+static CGEN_INLINE int -+fill_cache (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, -+ CGEN_EXTRACT_INFO *ex_info, -+ int offset, -+ int bytes, -+ bfd_vma pc) -+{ -+ /* It's doubtful that the middle part has already been fetched so -+ we don't optimize that case. kiss. */ -+ unsigned int mask; -+ disassemble_info *info = (disassemble_info *) ex_info->dis_info; -+ -+ /* First do a quick check. */ -+ mask = (1 << bytes) - 1; -+ if (((ex_info->valid >> offset) & mask) == mask) -+ return 1; -+ -+ /* Search for the first byte we need to read. */ -+ for (mask = 1 << offset; bytes > 0; --bytes, ++offset, mask <<= 1) -+ if (! (mask & ex_info->valid)) -+ break; -+ -+ if (bytes) -+ { -+ int status; -+ -+ pc += offset; -+ status = (*info->read_memory_func) -+ (pc, ex_info->insn_bytes + offset, bytes, info); -+ -+ if (status != 0) -+ { -+ (*info->memory_error_func) (status, pc, info); -+ return 0; -+ } -+ -+ ex_info->valid |= ((1 << bytes) - 1) << offset; -+ } -+ -+ return 1; -+} -+ -+/* Subroutine of extract_normal. */ -+ -+static CGEN_INLINE long -+extract_1 (CGEN_CPU_DESC cd, -+ CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED, -+ int start, -+ int length, -+ int word_length, -+ unsigned char *bufp, -+ bfd_vma pc ATTRIBUTE_UNUSED) -+{ -+ unsigned long x; -+ int shift; -+ -+ x = cgen_get_insn_value (cd, bufp, word_length); -+ -+ if (CGEN_INSN_LSB0_P) -+ shift = (start + 1) - length; -+ else -+ shift = (word_length - (start + length)); -+ return x >> shift; -+} -+ -+#endif /* ! CGEN_INT_INSN_P */ -+ -+/* Default extraction routine. -+ -+ INSN_VALUE is the first base_insn_bitsize bits of the insn in host order, -+ or sometimes less for cases like the m32r where the base insn size is 32 -+ but some insns are 16 bits. -+ ATTRS is a mask of the boolean attributes. We only need `SIGNED', -+ but for generality we take a bitmask of all of them. -+ WORD_OFFSET is the offset in bits from the start of the insn of the value. -+ WORD_LENGTH is the length of the word in bits in which the value resides. -+ START is the starting bit number in the word, architecture origin. -+ LENGTH is the length of VALUE in bits. -+ TOTAL_LENGTH is the total length of the insn in bits. -+ -+ Returns 1 for success, 0 for failure. */ -+ -+/* ??? The return code isn't properly used. wip. */ -+ -+/* ??? This doesn't handle bfd_vma's. Create another function when -+ necessary. */ -+ -+static int -+extract_normal (CGEN_CPU_DESC cd, -+#if ! CGEN_INT_INSN_P -+ CGEN_EXTRACT_INFO *ex_info, -+#else -+ CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED, -+#endif -+ CGEN_INSN_INT insn_value, -+ unsigned int attrs, -+ unsigned int word_offset, -+ unsigned int start, -+ unsigned int length, -+ unsigned int word_length, -+ unsigned int total_length, -+#if ! CGEN_INT_INSN_P -+ bfd_vma pc, -+#else -+ bfd_vma pc ATTRIBUTE_UNUSED, -+#endif -+ long *valuep) -+{ -+ long value, mask; -+ -+ /* If LENGTH is zero, this operand doesn't contribute to the value -+ so give it a standard value of zero. */ -+ if (length == 0) -+ { -+ *valuep = 0; -+ return 1; -+ } -+ -+ if (word_length > 8 * sizeof (CGEN_INSN_INT)) -+ abort (); -+ -+ /* For architectures with insns smaller than the insn-base-bitsize, -+ word_length may be too big. */ -+ if (cd->min_insn_bitsize < cd->base_insn_bitsize) -+ { -+ if (word_offset + word_length > total_length) -+ word_length = total_length - word_offset; -+ } -+ -+ /* Does the value reside in INSN_VALUE, and at the right alignment? */ -+ -+ if (CGEN_INT_INSN_P || (word_offset == 0 && word_length == total_length)) -+ { -+ if (CGEN_INSN_LSB0_P) -+ value = insn_value >> ((word_offset + start + 1) - length); -+ else -+ value = insn_value >> (total_length - ( word_offset + start + length)); -+ } -+ -+#if ! CGEN_INT_INSN_P -+ -+ else -+ { -+ unsigned char *bufp = ex_info->insn_bytes + word_offset / 8; -+ -+ if (word_length > 8 * sizeof (CGEN_INSN_INT)) -+ abort (); -+ -+ if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0) -+ return 0; -+ -+ value = extract_1 (cd, ex_info, start, length, word_length, bufp, pc); -+ } -+ -+#endif /* ! CGEN_INT_INSN_P */ -+ -+ /* Written this way to avoid undefined behaviour. */ -+ mask = (((1L << (length - 1)) - 1) << 1) | 1; -+ -+ value &= mask; -+ /* sign extend? */ -+ if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED) -+ && (value & (1L << (length - 1)))) -+ value |= ~mask; -+ -+ *valuep = value; -+ -+ return 1; -+} -+ -+/* Default insn extractor. -+ -+ INSN_VALUE is the first base_insn_bitsize bits, translated to host order. -+ The extracted fields are stored in FIELDS. -+ EX_INFO is used to handle reading variable length insns. -+ Return the length of the insn in bits, or 0 if no match, -+ or -1 if an error occurs fetching data (memory_error_func will have -+ been called). */ -+ -+static int -+extract_insn_normal (CGEN_CPU_DESC cd, -+ const CGEN_INSN *insn, -+ CGEN_EXTRACT_INFO *ex_info, -+ CGEN_INSN_INT insn_value, -+ CGEN_FIELDS *fields, -+ bfd_vma pc) -+{ -+ const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn); -+ const CGEN_SYNTAX_CHAR_TYPE *syn; -+ -+ CGEN_FIELDS_BITSIZE (fields) = CGEN_INSN_BITSIZE (insn); -+ -+ CGEN_INIT_EXTRACT (cd); -+ -+ for (syn = CGEN_SYNTAX_STRING (syntax); *syn; ++syn) -+ { -+ int length; -+ -+ if (CGEN_SYNTAX_CHAR_P (*syn)) -+ continue; -+ -+ length = (* cd->extract_operand) (cd, CGEN_SYNTAX_FIELD (*syn), -+ ex_info, insn_value, fields, pc); -+ if (length <= 0) -+ return length; -+ } -+ -+ /* We recognized and successfully extracted this insn. */ -+ return CGEN_INSN_BITSIZE (insn); -+} -+ -+/* Machine generated code added here. */ -+ -+const char * or1k_cgen_insert_operand -+ (CGEN_CPU_DESC, int, CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma); -+ -+/* Main entry point for operand insertion. -+ -+ This function is basically just a big switch statement. Earlier versions -+ used tables to look up the function to use, but -+ - if the table contains both assembler and disassembler functions then -+ the disassembler contains much of the assembler and vice-versa, -+ - there's a lot of inlining possibilities as things grow, -+ - using a switch statement avoids the function call overhead. -+ -+ This function could be moved into `parse_insn_normal', but keeping it -+ separate makes clear the interface between `parse_insn_normal' and each of -+ the handlers. It's also needed by GAS to insert operands that couldn't be -+ resolved during parsing. */ -+ -+const char * -+or1k_cgen_insert_operand (CGEN_CPU_DESC cd, -+ int opindex, -+ CGEN_FIELDS * fields, -+ CGEN_INSN_BYTES_PTR buffer, -+ bfd_vma pc ATTRIBUTE_UNUSED) -+{ -+ const char * errmsg = NULL; -+ unsigned int total_length = CGEN_FIELDS_BITSIZE (fields); -+ -+ switch (opindex) -+ { -+ case OR1K_OPERAND_DISP26 : -+ { -+ long value = fields->f_disp26; -+ value = ((SI) (((value) - (pc))) >> (2)); -+ errmsg = insert_normal (cd, value, 0|(1<f_r2, 0, 0, 20, 5, 32, total_length, buffer); -+ break; -+ case OR1K_OPERAND_RADF : -+ errmsg = insert_normal (cd, fields->f_r1, 0, 0, 25, 5, 32, total_length, buffer); -+ break; -+ case OR1K_OPERAND_RASF : -+ errmsg = insert_normal (cd, fields->f_r2, 0, 0, 20, 5, 32, total_length, buffer); -+ break; -+ case OR1K_OPERAND_RB : -+ errmsg = insert_normal (cd, fields->f_r3, 0, 0, 15, 5, 32, total_length, buffer); -+ break; -+ case OR1K_OPERAND_RBDF : -+ errmsg = insert_normal (cd, fields->f_r1, 0, 0, 25, 5, 32, total_length, buffer); -+ break; -+ case OR1K_OPERAND_RBSF : -+ errmsg = insert_normal (cd, fields->f_r3, 0, 0, 15, 5, 32, total_length, buffer); -+ break; -+ case OR1K_OPERAND_RD : -+ errmsg = insert_normal (cd, fields->f_r1, 0, 0, 25, 5, 32, total_length, buffer); -+ break; -+ case OR1K_OPERAND_RDDF : -+ errmsg = insert_normal (cd, fields->f_r1, 0, 0, 25, 5, 32, total_length, buffer); -+ break; -+ case OR1K_OPERAND_RDSF : -+ errmsg = insert_normal (cd, fields->f_r1, 0, 0, 25, 5, 32, total_length, buffer); -+ break; -+ case OR1K_OPERAND_SIMM16 : -+ errmsg = insert_normal (cd, fields->f_simm16, 0|(1<> (11))) & (31)); -+ FLD (f_imm16_10_11) = ((FLD (f_simm16_split)) & (2047)); -+} -+ errmsg = insert_normal (cd, fields->f_imm16_25_5, 0, 0, 25, 5, 32, total_length, buffer); -+ if (errmsg) -+ break; -+ errmsg = insert_normal (cd, fields->f_imm16_10_11, 0, 0, 10, 11, 32, total_length, buffer); -+ if (errmsg) -+ break; -+ } -+ break; -+ case OR1K_OPERAND_UIMM16 : -+ errmsg = insert_normal (cd, fields->f_uimm16, 0, 0, 15, 16, 32, total_length, buffer); -+ break; -+ case OR1K_OPERAND_UIMM16_SPLIT : -+ { -+{ -+ FLD (f_imm16_25_5) = ((((UINT) (FLD (f_uimm16_split)) >> (11))) & (31)); -+ FLD (f_imm16_10_11) = ((FLD (f_uimm16_split)) & (2047)); -+} -+ errmsg = insert_normal (cd, fields->f_imm16_25_5, 0, 0, 25, 5, 32, total_length, buffer); -+ if (errmsg) -+ break; -+ errmsg = insert_normal (cd, fields->f_imm16_10_11, 0, 0, 10, 11, 32, total_length, buffer); -+ if (errmsg) -+ break; -+ } -+ break; -+ case OR1K_OPERAND_UIMM6 : -+ errmsg = insert_normal (cd, fields->f_uimm6, 0, 0, 5, 6, 32, total_length, buffer); -+ break; -+ -+ default : -+ /* xgettext:c-format */ -+ fprintf (stderr, _("Unrecognized field %d while building insn.\n"), -+ opindex); -+ abort (); -+ } -+ -+ return errmsg; -+} -+ -+int or1k_cgen_extract_operand -+ (CGEN_CPU_DESC, int, CGEN_EXTRACT_INFO *, CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma); -+ -+/* Main entry point for operand extraction. -+ The result is <= 0 for error, >0 for success. -+ ??? Actual values aren't well defined right now. -+ -+ This function is basically just a big switch statement. Earlier versions -+ used tables to look up the function to use, but -+ - if the table contains both assembler and disassembler functions then -+ the disassembler contains much of the assembler and vice-versa, -+ - there's a lot of inlining possibilities as things grow, -+ - using a switch statement avoids the function call overhead. -+ -+ This function could be moved into `print_insn_normal', but keeping it -+ separate makes clear the interface between `print_insn_normal' and each of -+ the handlers. */ -+ -+int -+or1k_cgen_extract_operand (CGEN_CPU_DESC cd, -+ int opindex, -+ CGEN_EXTRACT_INFO *ex_info, -+ CGEN_INSN_INT insn_value, -+ CGEN_FIELDS * fields, -+ bfd_vma pc) -+{ -+ /* Assume success (for those operands that are nops). */ -+ int length = 1; -+ unsigned int total_length = CGEN_FIELDS_BITSIZE (fields); -+ -+ switch (opindex) -+ { -+ case OR1K_OPERAND_DISP26 : -+ { -+ long value; -+ length = extract_normal (cd, ex_info, insn_value, 0|(1<f_disp26 = value; -+ } -+ break; -+ case OR1K_OPERAND_RA : -+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 20, 5, 32, total_length, pc, & fields->f_r2); -+ break; -+ case OR1K_OPERAND_RADF : -+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 5, 32, total_length, pc, & fields->f_r1); -+ break; -+ case OR1K_OPERAND_RASF : -+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 20, 5, 32, total_length, pc, & fields->f_r2); -+ break; -+ case OR1K_OPERAND_RB : -+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 5, 32, total_length, pc, & fields->f_r3); -+ break; -+ case OR1K_OPERAND_RBDF : -+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 5, 32, total_length, pc, & fields->f_r1); -+ break; -+ case OR1K_OPERAND_RBSF : -+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 5, 32, total_length, pc, & fields->f_r3); -+ break; -+ case OR1K_OPERAND_RD : -+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 5, 32, total_length, pc, & fields->f_r1); -+ break; -+ case OR1K_OPERAND_RDDF : -+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 5, 32, total_length, pc, & fields->f_r1); -+ break; -+ case OR1K_OPERAND_RDSF : -+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 5, 32, total_length, pc, & fields->f_r1); -+ break; -+ case OR1K_OPERAND_SIMM16 : -+ length = extract_normal (cd, ex_info, insn_value, 0|(1<f_simm16); -+ break; -+ case OR1K_OPERAND_SIMM16_SPLIT : -+ { -+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 5, 32, total_length, pc, & fields->f_imm16_25_5); -+ if (length <= 0) break; -+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 10, 11, 32, total_length, pc, & fields->f_imm16_10_11); -+ if (length <= 0) break; -+ FLD (f_simm16_split) = ((HI) (UINT) (((((FLD (f_imm16_25_5)) << (11))) | (FLD (f_imm16_10_11))))); -+ } -+ break; -+ case OR1K_OPERAND_UIMM16 : -+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 16, 32, total_length, pc, & fields->f_uimm16); -+ break; -+ case OR1K_OPERAND_UIMM16_SPLIT : -+ { -+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 5, 32, total_length, pc, & fields->f_imm16_25_5); -+ if (length <= 0) break; -+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 10, 11, 32, total_length, pc, & fields->f_imm16_10_11); -+ if (length <= 0) break; -+ FLD (f_uimm16_split) = ((UHI) (UINT) (((((FLD (f_imm16_25_5)) << (11))) | (FLD (f_imm16_10_11))))); -+ } -+ break; -+ case OR1K_OPERAND_UIMM6 : -+ length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_uimm6); -+ break; -+ -+ default : -+ /* xgettext:c-format */ -+ fprintf (stderr, _("Unrecognized field %d while decoding insn.\n"), -+ opindex); -+ abort (); -+ } -+ -+ return length; -+} -+ -+cgen_insert_fn * const or1k_cgen_insert_handlers[] = -+{ -+ insert_insn_normal, -+}; -+ -+cgen_extract_fn * const or1k_cgen_extract_handlers[] = -+{ -+ extract_insn_normal, -+}; -+ -+int or1k_cgen_get_int_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *); -+bfd_vma or1k_cgen_get_vma_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *); -+ -+/* Getting values from cgen_fields is handled by a collection of functions. -+ They are distinguished by the type of the VALUE argument they return. -+ TODO: floating point, inlining support, remove cases where result type -+ not appropriate. */ -+ -+int -+or1k_cgen_get_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, -+ int opindex, -+ const CGEN_FIELDS * fields) -+{ -+ int value; -+ -+ switch (opindex) -+ { -+ case OR1K_OPERAND_DISP26 : -+ value = fields->f_disp26; -+ break; -+ case OR1K_OPERAND_RA : -+ value = fields->f_r2; -+ break; -+ case OR1K_OPERAND_RADF : -+ value = fields->f_r1; -+ break; -+ case OR1K_OPERAND_RASF : -+ value = fields->f_r2; -+ break; -+ case OR1K_OPERAND_RB : -+ value = fields->f_r3; -+ break; -+ case OR1K_OPERAND_RBDF : -+ value = fields->f_r1; -+ break; -+ case OR1K_OPERAND_RBSF : -+ value = fields->f_r3; -+ break; -+ case OR1K_OPERAND_RD : -+ value = fields->f_r1; -+ break; -+ case OR1K_OPERAND_RDDF : -+ value = fields->f_r1; -+ break; -+ case OR1K_OPERAND_RDSF : -+ value = fields->f_r1; -+ break; -+ case OR1K_OPERAND_SIMM16 : -+ value = fields->f_simm16; -+ break; -+ case OR1K_OPERAND_SIMM16_SPLIT : -+ value = fields->f_simm16_split; -+ break; -+ case OR1K_OPERAND_UIMM16 : -+ value = fields->f_uimm16; -+ break; -+ case OR1K_OPERAND_UIMM16_SPLIT : -+ value = fields->f_uimm16_split; -+ break; -+ case OR1K_OPERAND_UIMM6 : -+ value = fields->f_uimm6; -+ break; -+ -+ default : -+ /* xgettext:c-format */ -+ fprintf (stderr, _("Unrecognized field %d while getting int operand.\n"), -+ opindex); -+ abort (); -+ } -+ -+ return value; -+} -+ -+bfd_vma -+or1k_cgen_get_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, -+ int opindex, -+ const CGEN_FIELDS * fields) -+{ -+ bfd_vma value; -+ -+ switch (opindex) -+ { -+ case OR1K_OPERAND_DISP26 : -+ value = fields->f_disp26; -+ break; -+ case OR1K_OPERAND_RA : -+ value = fields->f_r2; -+ break; -+ case OR1K_OPERAND_RADF : -+ value = fields->f_r1; -+ break; -+ case OR1K_OPERAND_RASF : -+ value = fields->f_r2; -+ break; -+ case OR1K_OPERAND_RB : -+ value = fields->f_r3; -+ break; -+ case OR1K_OPERAND_RBDF : -+ value = fields->f_r1; -+ break; -+ case OR1K_OPERAND_RBSF : -+ value = fields->f_r3; -+ break; -+ case OR1K_OPERAND_RD : -+ value = fields->f_r1; -+ break; -+ case OR1K_OPERAND_RDDF : -+ value = fields->f_r1; -+ break; -+ case OR1K_OPERAND_RDSF : -+ value = fields->f_r1; -+ break; -+ case OR1K_OPERAND_SIMM16 : -+ value = fields->f_simm16; -+ break; -+ case OR1K_OPERAND_SIMM16_SPLIT : -+ value = fields->f_simm16_split; -+ break; -+ case OR1K_OPERAND_UIMM16 : -+ value = fields->f_uimm16; -+ break; -+ case OR1K_OPERAND_UIMM16_SPLIT : -+ value = fields->f_uimm16_split; -+ break; -+ case OR1K_OPERAND_UIMM6 : -+ value = fields->f_uimm6; -+ break; -+ -+ default : -+ /* xgettext:c-format */ -+ fprintf (stderr, _("Unrecognized field %d while getting vma operand.\n"), -+ opindex); -+ abort (); -+ } -+ -+ return value; -+} -+ -+void or1k_cgen_set_int_operand (CGEN_CPU_DESC, int, CGEN_FIELDS *, int); -+void or1k_cgen_set_vma_operand (CGEN_CPU_DESC, int, CGEN_FIELDS *, bfd_vma); -+ -+/* Stuffing values in cgen_fields is handled by a collection of functions. -+ They are distinguished by the type of the VALUE argument they accept. -+ TODO: floating point, inlining support, remove cases where argument type -+ not appropriate. */ -+ -+void -+or1k_cgen_set_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, -+ int opindex, -+ CGEN_FIELDS * fields, -+ int value) -+{ -+ switch (opindex) -+ { -+ case OR1K_OPERAND_DISP26 : -+ fields->f_disp26 = value; -+ break; -+ case OR1K_OPERAND_RA : -+ fields->f_r2 = value; -+ break; -+ case OR1K_OPERAND_RADF : -+ fields->f_r1 = value; -+ break; -+ case OR1K_OPERAND_RASF : -+ fields->f_r2 = value; -+ break; -+ case OR1K_OPERAND_RB : -+ fields->f_r3 = value; -+ break; -+ case OR1K_OPERAND_RBDF : -+ fields->f_r1 = value; -+ break; -+ case OR1K_OPERAND_RBSF : -+ fields->f_r3 = value; -+ break; -+ case OR1K_OPERAND_RD : -+ fields->f_r1 = value; -+ break; -+ case OR1K_OPERAND_RDDF : -+ fields->f_r1 = value; -+ break; -+ case OR1K_OPERAND_RDSF : -+ fields->f_r1 = value; -+ break; -+ case OR1K_OPERAND_SIMM16 : -+ fields->f_simm16 = value; -+ break; -+ case OR1K_OPERAND_SIMM16_SPLIT : -+ fields->f_simm16_split = value; -+ break; -+ case OR1K_OPERAND_UIMM16 : -+ fields->f_uimm16 = value; -+ break; -+ case OR1K_OPERAND_UIMM16_SPLIT : -+ fields->f_uimm16_split = value; -+ break; -+ case OR1K_OPERAND_UIMM6 : -+ fields->f_uimm6 = value; -+ break; -+ -+ default : -+ /* xgettext:c-format */ -+ fprintf (stderr, _("Unrecognized field %d while setting int operand.\n"), -+ opindex); -+ abort (); -+ } -+} -+ -+void -+or1k_cgen_set_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, -+ int opindex, -+ CGEN_FIELDS * fields, -+ bfd_vma value) -+{ -+ switch (opindex) -+ { -+ case OR1K_OPERAND_DISP26 : -+ fields->f_disp26 = value; -+ break; -+ case OR1K_OPERAND_RA : -+ fields->f_r2 = value; -+ break; -+ case OR1K_OPERAND_RADF : -+ fields->f_r1 = value; -+ break; -+ case OR1K_OPERAND_RASF : -+ fields->f_r2 = value; -+ break; -+ case OR1K_OPERAND_RB : -+ fields->f_r3 = value; -+ break; -+ case OR1K_OPERAND_RBDF : -+ fields->f_r1 = value; -+ break; -+ case OR1K_OPERAND_RBSF : -+ fields->f_r3 = value; -+ break; -+ case OR1K_OPERAND_RD : -+ fields->f_r1 = value; -+ break; -+ case OR1K_OPERAND_RDDF : -+ fields->f_r1 = value; -+ break; -+ case OR1K_OPERAND_RDSF : -+ fields->f_r1 = value; -+ break; -+ case OR1K_OPERAND_SIMM16 : -+ fields->f_simm16 = value; -+ break; -+ case OR1K_OPERAND_SIMM16_SPLIT : -+ fields->f_simm16_split = value; -+ break; -+ case OR1K_OPERAND_UIMM16 : -+ fields->f_uimm16 = value; -+ break; -+ case OR1K_OPERAND_UIMM16_SPLIT : -+ fields->f_uimm16_split = value; -+ break; -+ case OR1K_OPERAND_UIMM6 : -+ fields->f_uimm6 = value; -+ break; -+ -+ default : -+ /* xgettext:c-format */ -+ fprintf (stderr, _("Unrecognized field %d while setting vma operand.\n"), -+ opindex); -+ abort (); -+ } -+} -+ -+/* Function to call before using the instruction builder tables. */ -+ -+void -+or1k_cgen_init_ibld_table (CGEN_CPU_DESC cd) -+{ -+ cd->insert_handlers = & or1k_cgen_insert_handlers[0]; -+ cd->extract_handlers = & or1k_cgen_extract_handlers[0]; -+ -+ cd->insert_operand = or1k_cgen_insert_operand; -+ cd->extract_operand = or1k_cgen_extract_operand; -+ -+ cd->get_int_operand = or1k_cgen_get_int_operand; -+ cd->set_int_operand = or1k_cgen_set_int_operand; -+ cd->get_vma_operand = or1k_cgen_get_vma_operand; -+ cd->set_vma_operand = or1k_cgen_set_vma_operand; -+} -diff -rNU3 dist.orig/opcodes/or1k-opc.c dist/opcodes/or1k-opc.c ---- dist.orig/opcodes/or1k-opc.c 1970-01-01 01:00:00.000000000 +0100 -+++ dist/opcodes/or1k-opc.c 2015-10-18 13:11:20.000000000 +0200 -@@ -0,0 +1,1081 @@ -+/* Instruction opcode table for or1k. -+ -+THIS FILE IS MACHINE GENERATED WITH CGEN. -+ -+Copyright (C) 1996-2014 Free Software Foundation, Inc. -+ -+This file is part of the GNU Binutils and/or GDB, the GNU debugger. -+ -+ This file is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3, or (at your option) -+ any later version. -+ -+ It is distributed in the hope that it will be useful, but WITHOUT -+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -+ License for more details. -+ -+ You should have received a copy of the GNU General Public License along -+ with this program; if not, write to the Free Software Foundation, Inc., -+ 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. -+ -+*/ -+ -+#include "sysdep.h" -+#include "ansidecl.h" -+#include "bfd.h" -+#include "symcat.h" -+#include "or1k-desc.h" -+#include "or1k-opc.h" -+#include "libiberty.h" -+ -+/* -- opc.c */ -+/* -- */ -+/* The hash functions are recorded here to help keep assembler code out of -+ the disassembler and vice versa. */ -+ -+static int asm_hash_insn_p (const CGEN_INSN *); -+static unsigned int asm_hash_insn (const char *); -+static int dis_hash_insn_p (const CGEN_INSN *); -+static unsigned int dis_hash_insn (const char *, CGEN_INSN_INT); -+ -+/* Instruction formats. */ -+ -+#define F(f) & or1k_cgen_ifld_table[OR1K_##f] -+static const CGEN_IFMT ifmt_empty ATTRIBUTE_UNUSED = { -+ 0, 0, 0x0, { { 0 } } -+}; -+ -+static const CGEN_IFMT ifmt_l_j ATTRIBUTE_UNUSED = { -+ 32, 32, 0xfc000000, { { F (F_OPCODE) }, { F (F_DISP26) }, { 0 } } -+}; -+ -+static const CGEN_IFMT ifmt_l_jr ATTRIBUTE_UNUSED = { -+ 32, 32, 0xffff07ff, { { F (F_OPCODE) }, { F (F_RESV_25_10) }, { F (F_R3) }, { F (F_RESV_10_11) }, { 0 } } -+}; -+ -+static const CGEN_IFMT ifmt_l_trap ATTRIBUTE_UNUSED = { -+ 32, 32, 0xffff0000, { { F (F_OPCODE) }, { F (F_OP_25_5) }, { F (F_RESV_20_5) }, { F (F_UIMM16) }, { 0 } } -+}; -+ -+static const CGEN_IFMT ifmt_l_msync ATTRIBUTE_UNUSED = { -+ 32, 32, 0xffffffff, { { F (F_OPCODE) }, { F (F_OP_25_5) }, { F (F_RESV_20_21) }, { 0 } } -+}; -+ -+static const CGEN_IFMT ifmt_l_rfe ATTRIBUTE_UNUSED = { -+ 32, 32, 0xffffffff, { { F (F_OPCODE) }, { F (F_RESV_25_26) }, { 0 } } -+}; -+ -+static const CGEN_IFMT ifmt_l_nop_imm ATTRIBUTE_UNUSED = { -+ 32, 32, 0xffff0000, { { F (F_OPCODE) }, { F (F_OP_25_2) }, { F (F_RESV_23_8) }, { F (F_UIMM16) }, { 0 } } -+}; -+ -+static const CGEN_IFMT ifmt_l_movhi ATTRIBUTE_UNUSED = { -+ 32, 32, 0xfc1f0000, { { F (F_OPCODE) }, { F (F_R1) }, { F (F_RESV_20_4) }, { F (F_OP_16_1) }, { F (F_UIMM16) }, { 0 } } -+}; -+ -+static const CGEN_IFMT ifmt_l_macrc ATTRIBUTE_UNUSED = { -+ 32, 32, 0xfc1fffff, { { F (F_OPCODE) }, { F (F_R1) }, { F (F_RESV_20_4) }, { F (F_OP_16_1) }, { F (F_UIMM16) }, { 0 } } -+}; -+ -+static const CGEN_IFMT ifmt_l_mfspr ATTRIBUTE_UNUSED = { -+ 32, 32, 0xfc000000, { { F (F_OPCODE) }, { F (F_R1) }, { F (F_R2) }, { F (F_UIMM16) }, { 0 } } -+}; -+ -+static const CGEN_IFMT ifmt_l_mtspr ATTRIBUTE_UNUSED = { -+ 32, 32, 0xfc000000, { { F (F_OPCODE) }, { F (F_R2) }, { F (F_R3) }, { F (F_UIMM16_SPLIT) }, { 0 } } -+}; -+ -+static const CGEN_IFMT ifmt_l_lwz ATTRIBUTE_UNUSED = { -+ 32, 32, 0xfc000000, { { F (F_OPCODE) }, { F (F_R1) }, { F (F_R2) }, { F (F_SIMM16) }, { 0 } } -+}; -+ -+static const CGEN_IFMT ifmt_l_sw ATTRIBUTE_UNUSED = { -+ 32, 32, 0xfc000000, { { F (F_OPCODE) }, { F (F_R2) }, { F (F_R3) }, { F (F_SIMM16_SPLIT) }, { 0 } } -+}; -+ -+static const CGEN_IFMT ifmt_l_swa ATTRIBUTE_UNUSED = { -+ 32, 32, 0xfc000000, { { F (F_OPCODE) }, { F (F_R2) }, { F (F_R3) }, { F (F_SIMM16) }, { 0 } } -+}; -+ -+static const CGEN_IFMT ifmt_l_sll ATTRIBUTE_UNUSED = { -+ 32, 32, 0xfc0007ff, { { F (F_OPCODE) }, { F (F_R1) }, { F (F_R2) }, { F (F_R3) }, { F (F_RESV_10_3) }, { F (F_OP_7_2) }, { F (F_RESV_5_2) }, { F (F_OP_3_4) }, { 0 } } -+}; -+ -+static const CGEN_IFMT ifmt_l_slli ATTRIBUTE_UNUSED = { -+ 32, 32, 0xfc00ffc0, { { F (F_OPCODE) }, { F (F_R1) }, { F (F_R2) }, { F (F_RESV_15_8) }, { F (F_OP_7_2) }, { F (F_UIMM6) }, { 0 } } -+}; -+ -+static const CGEN_IFMT ifmt_l_and ATTRIBUTE_UNUSED = { -+ 32, 32, 0xfc0007ff, { { F (F_OPCODE) }, { F (F_R1) }, { F (F_R2) }, { F (F_R3) }, { F (F_RESV_10_7) }, { F (F_OP_3_4) }, { 0 } } -+}; -+ -+static const CGEN_IFMT ifmt_l_exths ATTRIBUTE_UNUSED = { -+ 32, 32, 0xfc00ffff, { { F (F_OPCODE) }, { F (F_R1) }, { F (F_R2) }, { F (F_RESV_15_6) }, { F (F_OP_9_4) }, { F (F_RESV_5_2) }, { F (F_OP_3_4) }, { 0 } } -+}; -+ -+static const CGEN_IFMT ifmt_l_cmov ATTRIBUTE_UNUSED = { -+ 32, 32, 0xfc0007ff, { { F (F_OPCODE) }, { F (F_R1) }, { F (F_R2) }, { F (F_R3) }, { F (F_RESV_10_1) }, { F (F_OP_9_2) }, { F (F_RESV_7_4) }, { F (F_OP_3_4) }, { 0 } } -+}; -+ -+static const CGEN_IFMT ifmt_l_sfgts ATTRIBUTE_UNUSED = { -+ 32, 32, 0xffe007ff, { { F (F_OPCODE) }, { F (F_OP_25_5) }, { F (F_R2) }, { F (F_R3) }, { F (F_RESV_10_11) }, { 0 } } -+}; -+ -+static const CGEN_IFMT ifmt_l_sfgtsi ATTRIBUTE_UNUSED = { -+ 32, 32, 0xffe00000, { { F (F_OPCODE) }, { F (F_OP_25_5) }, { F (F_R2) }, { F (F_SIMM16) }, { 0 } } -+}; -+ -+static const CGEN_IFMT ifmt_l_mac ATTRIBUTE_UNUSED = { -+ 32, 32, 0xffe007ff, { { F (F_OPCODE) }, { F (F_OP_25_5) }, { F (F_R2) }, { F (F_R3) }, { F (F_RESV_10_7) }, { F (F_OP_3_4) }, { 0 } } -+}; -+ -+static const CGEN_IFMT ifmt_l_maci ATTRIBUTE_UNUSED = { -+ 32, 32, 0xffe00000, { { F (F_OPCODE) }, { F (F_RESV_25_5) }, { F (F_R2) }, { F (F_SIMM16) }, { 0 } } -+}; -+ -+static const CGEN_IFMT ifmt_lf_add_s ATTRIBUTE_UNUSED = { -+ 32, 32, 0xfc0007ff, { { F (F_OPCODE) }, { F (F_R1) }, { F (F_R2) }, { F (F_R3) }, { F (F_RESV_10_3) }, { F (F_OP_7_8) }, { 0 } } -+}; -+ -+static const CGEN_IFMT ifmt_lf_add_d ATTRIBUTE_UNUSED = { -+ 32, 32, 0xfc0007ff, { { F (F_OPCODE) }, { F (F_R1) }, { F (F_R1) }, { F (F_R1) }, { F (F_RESV_10_3) }, { F (F_OP_7_8) }, { 0 } } -+}; -+ -+static const CGEN_IFMT ifmt_lf_itof_s ATTRIBUTE_UNUSED = { -+ 32, 32, 0xfc00ffff, { { F (F_OPCODE) }, { F (F_R1) }, { F (F_R2) }, { F (F_R3) }, { F (F_RESV_10_3) }, { F (F_OP_7_8) }, { 0 } } -+}; -+ -+static const CGEN_IFMT ifmt_lf_ftoi_s ATTRIBUTE_UNUSED = { -+ 32, 32, 0xfc00ffff, { { F (F_OPCODE) }, { F (F_R1) }, { F (F_R2) }, { F (F_R3) }, { F (F_RESV_10_3) }, { F (F_OP_7_8) }, { 0 } } -+}; -+ -+static const CGEN_IFMT ifmt_lf_ftoi_d ATTRIBUTE_UNUSED = { -+ 32, 32, 0xfc00ffff, { { F (F_OPCODE) }, { F (F_R1) }, { F (F_R1) }, { F (F_R3) }, { F (F_RESV_10_3) }, { F (F_OP_7_8) }, { 0 } } -+}; -+ -+static const CGEN_IFMT ifmt_lf_eq_s ATTRIBUTE_UNUSED = { -+ 32, 32, 0xffe007ff, { { F (F_OPCODE) }, { F (F_R1) }, { F (F_R2) }, { F (F_R3) }, { F (F_RESV_10_3) }, { F (F_OP_7_8) }, { 0 } } -+}; -+ -+static const CGEN_IFMT ifmt_lf_cust1_s ATTRIBUTE_UNUSED = { -+ 32, 32, 0xffe007ff, { { F (F_OPCODE) }, { F (F_RESV_25_5) }, { F (F_R2) }, { F (F_R3) }, { F (F_RESV_10_3) }, { F (F_OP_7_8) }, { 0 } } -+}; -+ -+static const CGEN_IFMT ifmt_lf_cust1_d ATTRIBUTE_UNUSED = { -+ 32, 32, 0xffe007ff, { { F (F_OPCODE) }, { F (F_RESV_25_5) }, { F (F_R1) }, { F (F_R1) }, { F (F_RESV_10_3) }, { F (F_OP_7_8) }, { 0 } } -+}; -+ -+#undef F -+ -+#define A(a) (1 << CGEN_INSN_##a) -+#define OPERAND(op) OR1K_OPERAND_##op -+#define MNEM CGEN_SYNTAX_MNEMONIC /* syntax value for mnemonic */ -+#define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field)) -+ -+/* The instruction table. */ -+ -+static const CGEN_OPCODE or1k_cgen_insn_opcode_table[MAX_INSNS] = -+{ -+ /* Special null first entry. -+ A `num' value of zero is thus invalid. -+ Also, the special `invalid' insn resides here. */ -+ { { 0, 0, 0, 0 }, {{0}}, 0, {0}}, -+/* l.j ${disp26} */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (DISP26), 0 } }, -+ & ifmt_l_j, { 0x0 } -+ }, -+/* l.jal ${disp26} */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (DISP26), 0 } }, -+ & ifmt_l_j, { 0x4000000 } -+ }, -+/* l.jr $rB */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RB), 0 } }, -+ & ifmt_l_jr, { 0x44000000 } -+ }, -+/* l.jalr $rB */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RB), 0 } }, -+ & ifmt_l_jr, { 0x48000000 } -+ }, -+/* l.bnf ${disp26} */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (DISP26), 0 } }, -+ & ifmt_l_j, { 0xc000000 } -+ }, -+/* l.bf ${disp26} */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (DISP26), 0 } }, -+ & ifmt_l_j, { 0x10000000 } -+ }, -+/* l.trap ${uimm16} */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (UIMM16), 0 } }, -+ & ifmt_l_trap, { 0x21000000 } -+ }, -+/* l.sys ${uimm16} */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (UIMM16), 0 } }, -+ & ifmt_l_trap, { 0x20000000 } -+ }, -+/* l.msync */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, 0 } }, -+ & ifmt_l_msync, { 0x22000000 } -+ }, -+/* l.psync */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, 0 } }, -+ & ifmt_l_msync, { 0x22800000 } -+ }, -+/* l.csync */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, 0 } }, -+ & ifmt_l_msync, { 0x23000000 } -+ }, -+/* l.rfe */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, 0 } }, -+ & ifmt_l_rfe, { 0x24000000 } -+ }, -+/* l.nop ${uimm16} */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (UIMM16), 0 } }, -+ & ifmt_l_nop_imm, { 0x15000000 } -+ }, -+/* l.nop */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, 0 } }, -+ & ifmt_l_nop_imm, { 0x15000000 } -+ }, -+/* l.movhi $rD,$uimm16 */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (UIMM16), 0 } }, -+ & ifmt_l_movhi, { 0x18000000 } -+ }, -+/* l.macrc $rD */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), 0 } }, -+ & ifmt_l_macrc, { 0x18010000 } -+ }, -+/* l.mfspr $rD,$rA,${uimm16} */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (UIMM16), 0 } }, -+ & ifmt_l_mfspr, { 0xb4000000 } -+ }, -+/* l.mtspr $rA,$rB,${uimm16-split} */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RA), ',', OP (RB), ',', OP (UIMM16_SPLIT), 0 } }, -+ & ifmt_l_mtspr, { 0xc0000000 } -+ }, -+/* l.lwz $rD,${simm16}($rA) */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (SIMM16), '(', OP (RA), ')', 0 } }, -+ & ifmt_l_lwz, { 0x84000000 } -+ }, -+/* l.lws $rD,${simm16}($rA) */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (SIMM16), '(', OP (RA), ')', 0 } }, -+ & ifmt_l_lwz, { 0x88000000 } -+ }, -+/* l.lwa $rD,${simm16}($rA) */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (SIMM16), '(', OP (RA), ')', 0 } }, -+ & ifmt_l_lwz, { 0x6c000000 } -+ }, -+/* l.lbz $rD,${simm16}($rA) */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (SIMM16), '(', OP (RA), ')', 0 } }, -+ & ifmt_l_lwz, { 0x8c000000 } -+ }, -+/* l.lbs $rD,${simm16}($rA) */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (SIMM16), '(', OP (RA), ')', 0 } }, -+ & ifmt_l_lwz, { 0x90000000 } -+ }, -+/* l.lhz $rD,${simm16}($rA) */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (SIMM16), '(', OP (RA), ')', 0 } }, -+ & ifmt_l_lwz, { 0x94000000 } -+ }, -+/* l.lhs $rD,${simm16}($rA) */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (SIMM16), '(', OP (RA), ')', 0 } }, -+ & ifmt_l_lwz, { 0x98000000 } -+ }, -+/* l.sw ${simm16-split}($rA),$rB */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (SIMM16_SPLIT), '(', OP (RA), ')', ',', OP (RB), 0 } }, -+ & ifmt_l_sw, { 0xd4000000 } -+ }, -+/* l.sb ${simm16-split}($rA),$rB */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (SIMM16_SPLIT), '(', OP (RA), ')', ',', OP (RB), 0 } }, -+ & ifmt_l_sw, { 0xd8000000 } -+ }, -+/* l.sh ${simm16-split}($rA),$rB */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (SIMM16_SPLIT), '(', OP (RA), ')', ',', OP (RB), 0 } }, -+ & ifmt_l_sw, { 0xdc000000 } -+ }, -+/* l.swa ${simm16-split}($rA),$rB */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (SIMM16_SPLIT), '(', OP (RA), ')', ',', OP (RB), 0 } }, -+ & ifmt_l_swa, { 0xcc000000 } -+ }, -+/* l.sll $rD,$rA,$rB */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, -+ & ifmt_l_sll, { 0xe0000008 } -+ }, -+/* l.slli $rD,$rA,${uimm6} */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (UIMM6), 0 } }, -+ & ifmt_l_slli, { 0xb8000000 } -+ }, -+/* l.srl $rD,$rA,$rB */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, -+ & ifmt_l_sll, { 0xe0000048 } -+ }, -+/* l.srli $rD,$rA,${uimm6} */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (UIMM6), 0 } }, -+ & ifmt_l_slli, { 0xb8000040 } -+ }, -+/* l.sra $rD,$rA,$rB */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, -+ & ifmt_l_sll, { 0xe0000088 } -+ }, -+/* l.srai $rD,$rA,${uimm6} */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (UIMM6), 0 } }, -+ & ifmt_l_slli, { 0xb8000080 } -+ }, -+/* l.ror $rD,$rA,$rB */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, -+ & ifmt_l_sll, { 0xe00000c8 } -+ }, -+/* l.rori $rD,$rA,${uimm6} */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (UIMM6), 0 } }, -+ & ifmt_l_slli, { 0xb80000c0 } -+ }, -+/* l.and $rD,$rA,$rB */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, -+ & ifmt_l_and, { 0xe0000003 } -+ }, -+/* l.or $rD,$rA,$rB */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, -+ & ifmt_l_and, { 0xe0000004 } -+ }, -+/* l.xor $rD,$rA,$rB */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, -+ & ifmt_l_and, { 0xe0000005 } -+ }, -+/* l.add $rD,$rA,$rB */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, -+ & ifmt_l_and, { 0xe0000000 } -+ }, -+/* l.sub $rD,$rA,$rB */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, -+ & ifmt_l_and, { 0xe0000002 } -+ }, -+/* l.addc $rD,$rA,$rB */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, -+ & ifmt_l_and, { 0xe0000001 } -+ }, -+/* l.mul $rD,$rA,$rB */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, -+ & ifmt_l_and, { 0xe0000306 } -+ }, -+/* l.mulu $rD,$rA,$rB */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, -+ & ifmt_l_and, { 0xe000030b } -+ }, -+/* l.div $rD,$rA,$rB */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, -+ & ifmt_l_and, { 0xe0000309 } -+ }, -+/* l.divu $rD,$rA,$rB */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, -+ & ifmt_l_and, { 0xe000030a } -+ }, -+/* l.ff1 $rD,$rA */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), 0 } }, -+ & ifmt_l_and, { 0xe000000f } -+ }, -+/* l.fl1 $rD,$rA */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), 0 } }, -+ & ifmt_l_and, { 0xe000010f } -+ }, -+/* l.andi $rD,$rA,$uimm16 */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (UIMM16), 0 } }, -+ & ifmt_l_mfspr, { 0xa4000000 } -+ }, -+/* l.ori $rD,$rA,$uimm16 */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (UIMM16), 0 } }, -+ & ifmt_l_mfspr, { 0xa8000000 } -+ }, -+/* l.xori $rD,$rA,$simm16 */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (SIMM16), 0 } }, -+ & ifmt_l_lwz, { 0xac000000 } -+ }, -+/* l.addi $rD,$rA,$simm16 */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (SIMM16), 0 } }, -+ & ifmt_l_lwz, { 0x9c000000 } -+ }, -+/* l.addic $rD,$rA,$simm16 */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (SIMM16), 0 } }, -+ & ifmt_l_lwz, { 0xa0000000 } -+ }, -+/* l.muli $rD,$rA,$simm16 */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (SIMM16), 0 } }, -+ & ifmt_l_lwz, { 0xb0000000 } -+ }, -+/* l.exths $rD,$rA */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), 0 } }, -+ & ifmt_l_exths, { 0xe000000c } -+ }, -+/* l.extbs $rD,$rA */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), 0 } }, -+ & ifmt_l_exths, { 0xe000004c } -+ }, -+/* l.exthz $rD,$rA */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), 0 } }, -+ & ifmt_l_exths, { 0xe000008c } -+ }, -+/* l.extbz $rD,$rA */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), 0 } }, -+ & ifmt_l_exths, { 0xe00000cc } -+ }, -+/* l.extws $rD,$rA */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), 0 } }, -+ & ifmt_l_exths, { 0xe000000d } -+ }, -+/* l.extwz $rD,$rA */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), 0 } }, -+ & ifmt_l_exths, { 0xe000004d } -+ }, -+/* l.cmov $rD,$rA,$rB */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RA), ',', OP (RB), 0 } }, -+ & ifmt_l_cmov, { 0xe000000e } -+ }, -+/* l.sfgts $rA,$rB */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, -+ & ifmt_l_sfgts, { 0xe5400000 } -+ }, -+/* l.sfgtsi $rA,$simm16 */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RA), ',', OP (SIMM16), 0 } }, -+ & ifmt_l_sfgtsi, { 0xbd400000 } -+ }, -+/* l.sfgtu $rA,$rB */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, -+ & ifmt_l_sfgts, { 0xe4400000 } -+ }, -+/* l.sfgtui $rA,$simm16 */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RA), ',', OP (SIMM16), 0 } }, -+ & ifmt_l_sfgtsi, { 0xbc400000 } -+ }, -+/* l.sfges $rA,$rB */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, -+ & ifmt_l_sfgts, { 0xe5600000 } -+ }, -+/* l.sfgesi $rA,$simm16 */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RA), ',', OP (SIMM16), 0 } }, -+ & ifmt_l_sfgtsi, { 0xbd600000 } -+ }, -+/* l.sfgeu $rA,$rB */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, -+ & ifmt_l_sfgts, { 0xe4600000 } -+ }, -+/* l.sfgeui $rA,$simm16 */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RA), ',', OP (SIMM16), 0 } }, -+ & ifmt_l_sfgtsi, { 0xbc600000 } -+ }, -+/* l.sflts $rA,$rB */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, -+ & ifmt_l_sfgts, { 0xe5800000 } -+ }, -+/* l.sfltsi $rA,$simm16 */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RA), ',', OP (SIMM16), 0 } }, -+ & ifmt_l_sfgtsi, { 0xbd800000 } -+ }, -+/* l.sfltu $rA,$rB */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, -+ & ifmt_l_sfgts, { 0xe4800000 } -+ }, -+/* l.sfltui $rA,$simm16 */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RA), ',', OP (SIMM16), 0 } }, -+ & ifmt_l_sfgtsi, { 0xbc800000 } -+ }, -+/* l.sfles $rA,$rB */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, -+ & ifmt_l_sfgts, { 0xe5a00000 } -+ }, -+/* l.sflesi $rA,$simm16 */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RA), ',', OP (SIMM16), 0 } }, -+ & ifmt_l_sfgtsi, { 0xbda00000 } -+ }, -+/* l.sfleu $rA,$rB */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, -+ & ifmt_l_sfgts, { 0xe4a00000 } -+ }, -+/* l.sfleui $rA,$simm16 */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RA), ',', OP (SIMM16), 0 } }, -+ & ifmt_l_sfgtsi, { 0xbca00000 } -+ }, -+/* l.sfeq $rA,$rB */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, -+ & ifmt_l_sfgts, { 0xe4000000 } -+ }, -+/* l.sfeqi $rA,$simm16 */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RA), ',', OP (SIMM16), 0 } }, -+ & ifmt_l_sfgtsi, { 0xbc000000 } -+ }, -+/* l.sfne $rA,$rB */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, -+ & ifmt_l_sfgts, { 0xe4200000 } -+ }, -+/* l.sfnei $rA,$simm16 */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RA), ',', OP (SIMM16), 0 } }, -+ & ifmt_l_sfgtsi, { 0xbc200000 } -+ }, -+/* l.mac $rA,$rB */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, -+ & ifmt_l_mac, { 0xc4000001 } -+ }, -+/* l.msb $rA,$rB */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RA), ',', OP (RB), 0 } }, -+ & ifmt_l_mac, { 0xc4000002 } -+ }, -+/* l.maci $rA,${simm16} */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RA), ',', OP (SIMM16), 0 } }, -+ & ifmt_l_maci, { 0x4c000000 } -+ }, -+/* l.cust1 */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, 0 } }, -+ & ifmt_l_rfe, { 0x70000000 } -+ }, -+/* l.cust2 */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, 0 } }, -+ & ifmt_l_rfe, { 0x74000000 } -+ }, -+/* l.cust3 */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, 0 } }, -+ & ifmt_l_rfe, { 0x78000000 } -+ }, -+/* l.cust4 */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, 0 } }, -+ & ifmt_l_rfe, { 0x7c000000 } -+ }, -+/* l.cust5 */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, 0 } }, -+ & ifmt_l_rfe, { 0xf0000000 } -+ }, -+/* l.cust6 */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, 0 } }, -+ & ifmt_l_rfe, { 0xf4000000 } -+ }, -+/* l.cust7 */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, 0 } }, -+ & ifmt_l_rfe, { 0xf8000000 } -+ }, -+/* l.cust8 */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, 0 } }, -+ & ifmt_l_rfe, { 0xfc000000 } -+ }, -+/* lf.add.s $rDSF,$rASF,$rBSF */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RDSF), ',', OP (RASF), ',', OP (RBSF), 0 } }, -+ & ifmt_lf_add_s, { 0xc8000000 } -+ }, -+/* lf.add.d $rDDF,$rADF,$rBDF */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RDDF), ',', OP (RADF), ',', OP (RBDF), 0 } }, -+ & ifmt_lf_add_d, { 0xc8000010 } -+ }, -+/* lf.sub.s $rDSF,$rASF,$rBSF */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RDSF), ',', OP (RASF), ',', OP (RBSF), 0 } }, -+ & ifmt_lf_add_s, { 0xc8000001 } -+ }, -+/* lf.sub.d $rDDF,$rADF,$rBDF */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RDDF), ',', OP (RADF), ',', OP (RBDF), 0 } }, -+ & ifmt_lf_add_d, { 0xc8000011 } -+ }, -+/* lf.mul.s $rDSF,$rASF,$rBSF */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RDSF), ',', OP (RASF), ',', OP (RBSF), 0 } }, -+ & ifmt_lf_add_s, { 0xc8000002 } -+ }, -+/* lf.mul.d $rDDF,$rADF,$rBDF */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RDDF), ',', OP (RADF), ',', OP (RBDF), 0 } }, -+ & ifmt_lf_add_d, { 0xc8000012 } -+ }, -+/* lf.div.s $rDSF,$rASF,$rBSF */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RDSF), ',', OP (RASF), ',', OP (RBSF), 0 } }, -+ & ifmt_lf_add_s, { 0xc8000003 } -+ }, -+/* lf.div.d $rDDF,$rADF,$rBDF */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RDDF), ',', OP (RADF), ',', OP (RBDF), 0 } }, -+ & ifmt_lf_add_d, { 0xc8000013 } -+ }, -+/* lf.rem.s $rDSF,$rASF,$rBSF */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RDSF), ',', OP (RASF), ',', OP (RBSF), 0 } }, -+ & ifmt_lf_add_s, { 0xc8000006 } -+ }, -+/* lf.rem.d $rDDF,$rADF,$rBDF */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RDDF), ',', OP (RADF), ',', OP (RBDF), 0 } }, -+ & ifmt_lf_add_d, { 0xc8000016 } -+ }, -+/* lf.itof.s $rDSF,$rA */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RDSF), ',', OP (RA), 0 } }, -+ & ifmt_lf_itof_s, { 0xc8000004 } -+ }, -+/* lf.itof.d $rDSF,$rA */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RDSF), ',', OP (RA), 0 } }, -+ & ifmt_lf_itof_s, { 0xc8000014 } -+ }, -+/* lf.ftoi.s $rD,$rASF */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RASF), 0 } }, -+ & ifmt_lf_ftoi_s, { 0xc8000005 } -+ }, -+/* lf.ftoi.d $rD,$rADF */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RD), ',', OP (RADF), 0 } }, -+ & ifmt_lf_ftoi_d, { 0xc8000015 } -+ }, -+/* lf.sfeq.s $rASF,$rBSF */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RASF), ',', OP (RBSF), 0 } }, -+ & ifmt_lf_eq_s, { 0xc8000008 } -+ }, -+/* lf.sfeq.d $rASF,$rBSF */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RASF), ',', OP (RBSF), 0 } }, -+ & ifmt_lf_eq_s, { 0xc8000018 } -+ }, -+/* lf.sfne.s $rASF,$rBSF */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RASF), ',', OP (RBSF), 0 } }, -+ & ifmt_lf_eq_s, { 0xc8000009 } -+ }, -+/* lf.sfne.d $rASF,$rBSF */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RASF), ',', OP (RBSF), 0 } }, -+ & ifmt_lf_eq_s, { 0xc8000019 } -+ }, -+/* lf.sfge.s $rASF,$rBSF */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RASF), ',', OP (RBSF), 0 } }, -+ & ifmt_lf_eq_s, { 0xc800000b } -+ }, -+/* lf.sfge.d $rASF,$rBSF */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RASF), ',', OP (RBSF), 0 } }, -+ & ifmt_lf_eq_s, { 0xc800001b } -+ }, -+/* lf.sfgt.s $rASF,$rBSF */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RASF), ',', OP (RBSF), 0 } }, -+ & ifmt_lf_eq_s, { 0xc800000a } -+ }, -+/* lf.sfgt.d $rASF,$rBSF */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RASF), ',', OP (RBSF), 0 } }, -+ & ifmt_lf_eq_s, { 0xc800001a } -+ }, -+/* lf.sflt.s $rASF,$rBSF */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RASF), ',', OP (RBSF), 0 } }, -+ & ifmt_lf_eq_s, { 0xc800000c } -+ }, -+/* lf.sflt.d $rASF,$rBSF */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RASF), ',', OP (RBSF), 0 } }, -+ & ifmt_lf_eq_s, { 0xc800001c } -+ }, -+/* lf.sfle.s $rASF,$rBSF */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RASF), ',', OP (RBSF), 0 } }, -+ & ifmt_lf_eq_s, { 0xc800000d } -+ }, -+/* lf.sfle.d $rASF,$rBSF */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RASF), ',', OP (RBSF), 0 } }, -+ & ifmt_lf_eq_s, { 0xc800001d } -+ }, -+/* lf.madd.s $rDSF,$rASF,$rBSF */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RDSF), ',', OP (RASF), ',', OP (RBSF), 0 } }, -+ & ifmt_lf_add_s, { 0xc8000007 } -+ }, -+/* lf.madd.d $rDDF,$rADF,$rBDF */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RDDF), ',', OP (RADF), ',', OP (RBDF), 0 } }, -+ & ifmt_lf_add_d, { 0xc8000017 } -+ }, -+/* lf.cust1.s $rASF,$rBSF */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, ' ', OP (RASF), ',', OP (RBSF), 0 } }, -+ & ifmt_lf_cust1_s, { 0xc80000d0 } -+ }, -+/* lf.cust1.d */ -+ { -+ { 0, 0, 0, 0 }, -+ { { MNEM, 0 } }, -+ & ifmt_lf_cust1_d, { 0xc80000e0 } -+ }, -+}; -+ -+#undef A -+#undef OPERAND -+#undef MNEM -+#undef OP -+ -+/* Formats for ALIAS macro-insns. */ -+ -+#define F(f) & or1k_cgen_ifld_table[OR1K_##f] -+#undef F -+ -+/* Each non-simple macro entry points to an array of expansion possibilities. */ -+ -+#define A(a) (1 << CGEN_INSN_##a) -+#define OPERAND(op) OR1K_OPERAND_##op -+#define MNEM CGEN_SYNTAX_MNEMONIC /* syntax value for mnemonic */ -+#define OP(field) CGEN_SYNTAX_MAKE_FIELD (OPERAND (field)) -+ -+/* The macro instruction table. */ -+ -+static const CGEN_IBASE or1k_cgen_macro_insn_table[] = -+{ -+}; -+ -+/* The macro instruction opcode table. */ -+ -+static const CGEN_OPCODE or1k_cgen_macro_insn_opcode_table[] = -+{ -+}; -+ -+#undef A -+#undef OPERAND -+#undef MNEM -+#undef OP -+ -+#ifndef CGEN_ASM_HASH_P -+#define CGEN_ASM_HASH_P(insn) 1 -+#endif -+ -+#ifndef CGEN_DIS_HASH_P -+#define CGEN_DIS_HASH_P(insn) 1 -+#endif -+ -+/* Return non-zero if INSN is to be added to the hash table. -+ Targets are free to override CGEN_{ASM,DIS}_HASH_P in the .opc file. */ -+ -+static int -+asm_hash_insn_p (insn) -+ const CGEN_INSN *insn ATTRIBUTE_UNUSED; -+{ -+ return CGEN_ASM_HASH_P (insn); -+} -+ -+static int -+dis_hash_insn_p (insn) -+ const CGEN_INSN *insn; -+{ -+ /* If building the hash table and the NO-DIS attribute is present, -+ ignore. */ -+ if (CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_NO_DIS)) -+ return 0; -+ return CGEN_DIS_HASH_P (insn); -+} -+ -+#ifndef CGEN_ASM_HASH -+#define CGEN_ASM_HASH_SIZE 127 -+#ifdef CGEN_MNEMONIC_OPERANDS -+#define CGEN_ASM_HASH(mnem) (*(unsigned char *) (mnem) % CGEN_ASM_HASH_SIZE) -+#else -+#define CGEN_ASM_HASH(mnem) (*(unsigned char *) (mnem) % CGEN_ASM_HASH_SIZE) /*FIXME*/ -+#endif -+#endif -+ -+/* It doesn't make much sense to provide a default here, -+ but while this is under development we do. -+ BUFFER is a pointer to the bytes of the insn, target order. -+ VALUE is the first base_insn_bitsize bits as an int in host order. */ -+ -+#ifndef CGEN_DIS_HASH -+#define CGEN_DIS_HASH_SIZE 256 -+#define CGEN_DIS_HASH(buf, value) (*(unsigned char *) (buf)) -+#endif -+ -+/* The result is the hash value of the insn. -+ Targets are free to override CGEN_{ASM,DIS}_HASH in the .opc file. */ -+ -+static unsigned int -+asm_hash_insn (mnem) -+ const char * mnem; -+{ -+ return CGEN_ASM_HASH (mnem); -+} -+ -+/* BUF is a pointer to the bytes of the insn, target order. -+ VALUE is the first base_insn_bitsize bits as an int in host order. */ -+ -+static unsigned int -+dis_hash_insn (buf, value) -+ const char * buf ATTRIBUTE_UNUSED; -+ CGEN_INSN_INT value ATTRIBUTE_UNUSED; -+{ -+ return CGEN_DIS_HASH (buf, value); -+} -+ -+/* Set the recorded length of the insn in the CGEN_FIELDS struct. */ -+ -+static void -+set_fields_bitsize (CGEN_FIELDS *fields, int size) -+{ -+ CGEN_FIELDS_BITSIZE (fields) = size; -+} -+ -+/* Function to call before using the operand instance table. -+ This plugs the opcode entries and macro instructions into the cpu table. */ -+ -+void -+or1k_cgen_init_opcode_table (CGEN_CPU_DESC cd) -+{ -+ int i; -+ int num_macros = (sizeof (or1k_cgen_macro_insn_table) / -+ sizeof (or1k_cgen_macro_insn_table[0])); -+ const CGEN_IBASE *ib = & or1k_cgen_macro_insn_table[0]; -+ const CGEN_OPCODE *oc = & or1k_cgen_macro_insn_opcode_table[0]; -+ CGEN_INSN *insns = xmalloc (num_macros * sizeof (CGEN_INSN)); -+ -+ /* This test has been added to avoid a warning generated -+ if memset is called with a third argument of value zero. */ -+ if (num_macros >= 1) -+ memset (insns, 0, num_macros * sizeof (CGEN_INSN)); -+ for (i = 0; i < num_macros; ++i) -+ { -+ insns[i].base = &ib[i]; -+ insns[i].opcode = &oc[i]; -+ or1k_cgen_build_insn_regex (& insns[i]); -+ } -+ cd->macro_insn_table.init_entries = insns; -+ cd->macro_insn_table.entry_size = sizeof (CGEN_IBASE); -+ cd->macro_insn_table.num_init_entries = num_macros; -+ -+ oc = & or1k_cgen_insn_opcode_table[0]; -+ insns = (CGEN_INSN *) cd->insn_table.init_entries; -+ for (i = 0; i < MAX_INSNS; ++i) -+ { -+ insns[i].opcode = &oc[i]; -+ or1k_cgen_build_insn_regex (& insns[i]); -+ } -+ -+ cd->sizeof_fields = sizeof (CGEN_FIELDS); -+ cd->set_fields_bitsize = set_fields_bitsize; -+ -+ cd->asm_hash_p = asm_hash_insn_p; -+ cd->asm_hash = asm_hash_insn; -+ cd->asm_hash_size = CGEN_ASM_HASH_SIZE; -+ -+ cd->dis_hash_p = dis_hash_insn_p; -+ cd->dis_hash = dis_hash_insn; -+ cd->dis_hash_size = CGEN_DIS_HASH_SIZE; -+} -diff -rNU3 dist.orig/opcodes/or1k-opc.h dist/opcodes/or1k-opc.h ---- dist.orig/opcodes/or1k-opc.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/opcodes/or1k-opc.h 2015-10-18 13:11:20.000000000 +0200 -@@ -0,0 +1,135 @@ -+/* Instruction opcode header for or1k. -+ -+THIS FILE IS MACHINE GENERATED WITH CGEN. -+ -+Copyright (C) 1996-2014 Free Software Foundation, Inc. -+ -+This file is part of the GNU Binutils and/or GDB, the GNU debugger. -+ -+ This file is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3, or (at your option) -+ any later version. -+ -+ It is distributed in the hope that it will be useful, but WITHOUT -+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -+ License for more details. -+ -+ You should have received a copy of the GNU General Public License along -+ with this program; if not, write to the Free Software Foundation, Inc., -+ 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. -+ -+*/ -+ -+#ifndef OR1K_OPC_H -+#define OR1K_OPC_H -+ -+/* -- opc.h */ -+ -+#undef CGEN_DIS_HASH_SIZE -+#define CGEN_DIS_HASH_SIZE 256 -+#undef CGEN_DIS_HASH -+#define CGEN_DIS_HASH(buffer, value) (((unsigned char *) (buffer))[0] >> 2) -+ -+/* -- */ -+/* Enum declaration for or1k instruction types. */ -+typedef enum cgen_insn_type { -+ OR1K_INSN_INVALID, OR1K_INSN_L_J, OR1K_INSN_L_JAL, OR1K_INSN_L_JR -+ , OR1K_INSN_L_JALR, OR1K_INSN_L_BNF, OR1K_INSN_L_BF, OR1K_INSN_L_TRAP -+ , OR1K_INSN_L_SYS, OR1K_INSN_L_MSYNC, OR1K_INSN_L_PSYNC, OR1K_INSN_L_CSYNC -+ , OR1K_INSN_L_RFE, OR1K_INSN_L_NOP_IMM, OR1K_INSN_L_NOP, OR1K_INSN_L_MOVHI -+ , OR1K_INSN_L_MACRC, OR1K_INSN_L_MFSPR, OR1K_INSN_L_MTSPR, OR1K_INSN_L_LWZ -+ , OR1K_INSN_L_LWS, OR1K_INSN_L_LWA, OR1K_INSN_L_LBZ, OR1K_INSN_L_LBS -+ , OR1K_INSN_L_LHZ, OR1K_INSN_L_LHS, OR1K_INSN_L_SW, OR1K_INSN_L_SB -+ , OR1K_INSN_L_SH, OR1K_INSN_L_SWA, OR1K_INSN_L_SLL, OR1K_INSN_L_SLLI -+ , OR1K_INSN_L_SRL, OR1K_INSN_L_SRLI, OR1K_INSN_L_SRA, OR1K_INSN_L_SRAI -+ , OR1K_INSN_L_ROR, OR1K_INSN_L_RORI, OR1K_INSN_L_AND, OR1K_INSN_L_OR -+ , OR1K_INSN_L_XOR, OR1K_INSN_L_ADD, OR1K_INSN_L_SUB, OR1K_INSN_L_ADDC -+ , OR1K_INSN_L_MUL, OR1K_INSN_L_MULU, OR1K_INSN_L_DIV, OR1K_INSN_L_DIVU -+ , OR1K_INSN_L_FF1, OR1K_INSN_L_FL1, OR1K_INSN_L_ANDI, OR1K_INSN_L_ORI -+ , OR1K_INSN_L_XORI, OR1K_INSN_L_ADDI, OR1K_INSN_L_ADDIC, OR1K_INSN_L_MULI -+ , OR1K_INSN_L_EXTHS, OR1K_INSN_L_EXTBS, OR1K_INSN_L_EXTHZ, OR1K_INSN_L_EXTBZ -+ , OR1K_INSN_L_EXTWS, OR1K_INSN_L_EXTWZ, OR1K_INSN_L_CMOV, OR1K_INSN_L_SFGTS -+ , OR1K_INSN_L_SFGTSI, OR1K_INSN_L_SFGTU, OR1K_INSN_L_SFGTUI, OR1K_INSN_L_SFGES -+ , OR1K_INSN_L_SFGESI, OR1K_INSN_L_SFGEU, OR1K_INSN_L_SFGEUI, OR1K_INSN_L_SFLTS -+ , OR1K_INSN_L_SFLTSI, OR1K_INSN_L_SFLTU, OR1K_INSN_L_SFLTUI, OR1K_INSN_L_SFLES -+ , OR1K_INSN_L_SFLESI, OR1K_INSN_L_SFLEU, OR1K_INSN_L_SFLEUI, OR1K_INSN_L_SFEQ -+ , OR1K_INSN_L_SFEQI, OR1K_INSN_L_SFNE, OR1K_INSN_L_SFNEI, OR1K_INSN_L_MAC -+ , OR1K_INSN_L_MSB, OR1K_INSN_L_MACI, OR1K_INSN_L_CUST1, OR1K_INSN_L_CUST2 -+ , OR1K_INSN_L_CUST3, OR1K_INSN_L_CUST4, OR1K_INSN_L_CUST5, OR1K_INSN_L_CUST6 -+ , OR1K_INSN_L_CUST7, OR1K_INSN_L_CUST8, OR1K_INSN_LF_ADD_S, OR1K_INSN_LF_ADD_D -+ , OR1K_INSN_LF_SUB_S, OR1K_INSN_LF_SUB_D, OR1K_INSN_LF_MUL_S, OR1K_INSN_LF_MUL_D -+ , OR1K_INSN_LF_DIV_S, OR1K_INSN_LF_DIV_D, OR1K_INSN_LF_REM_S, OR1K_INSN_LF_REM_D -+ , OR1K_INSN_LF_ITOF_S, OR1K_INSN_LF_ITOF_D, OR1K_INSN_LF_FTOI_S, OR1K_INSN_LF_FTOI_D -+ , OR1K_INSN_LF_EQ_S, OR1K_INSN_LF_EQ_D, OR1K_INSN_LF_NE_S, OR1K_INSN_LF_NE_D -+ , OR1K_INSN_LF_GE_S, OR1K_INSN_LF_GE_D, OR1K_INSN_LF_GT_S, OR1K_INSN_LF_GT_D -+ , OR1K_INSN_LF_LT_S, OR1K_INSN_LF_LT_D, OR1K_INSN_LF_LE_S, OR1K_INSN_LF_LE_D -+ , OR1K_INSN_LF_MADD_S, OR1K_INSN_LF_MADD_D, OR1K_INSN_LF_CUST1_S, OR1K_INSN_LF_CUST1_D -+} CGEN_INSN_TYPE; -+ -+/* Index of `invalid' insn place holder. */ -+#define CGEN_INSN_INVALID OR1K_INSN_INVALID -+ -+/* Total number of insns in table. */ -+#define MAX_INSNS ((int) OR1K_INSN_LF_CUST1_D + 1) -+ -+/* This struct records data prior to insertion or after extraction. */ -+struct cgen_fields -+{ -+ int length; -+ long f_nil; -+ long f_anyof; -+ long f_opcode; -+ long f_r1; -+ long f_r2; -+ long f_r3; -+ long f_op_25_2; -+ long f_op_25_5; -+ long f_op_16_1; -+ long f_op_7_4; -+ long f_op_3_4; -+ long f_op_9_2; -+ long f_op_9_4; -+ long f_op_7_8; -+ long f_op_7_2; -+ long f_resv_25_26; -+ long f_resv_25_10; -+ long f_resv_25_5; -+ long f_resv_23_8; -+ long f_resv_20_21; -+ long f_resv_20_5; -+ long f_resv_20_4; -+ long f_resv_15_8; -+ long f_resv_15_6; -+ long f_resv_10_11; -+ long f_resv_10_7; -+ long f_resv_10_3; -+ long f_resv_10_1; -+ long f_resv_7_4; -+ long f_resv_5_2; -+ long f_imm16_25_5; -+ long f_imm16_10_11; -+ long f_disp26; -+ long f_uimm16; -+ long f_simm16; -+ long f_uimm6; -+ long f_uimm16_split; -+ long f_simm16_split; -+}; -+ -+#define CGEN_INIT_PARSE(od) \ -+{\ -+} -+#define CGEN_INIT_INSERT(od) \ -+{\ -+} -+#define CGEN_INIT_EXTRACT(od) \ -+{\ -+} -+#define CGEN_INIT_PRINT(od) \ -+{\ -+} -+ -+ -+#endif /* OR1K_OPC_H */ -diff -rNU3 dist.orig/opcodes/or1k-opinst.c dist/opcodes/or1k-opinst.c ---- dist.orig/opcodes/or1k-opinst.c 1970-01-01 01:00:00.000000000 +0100 -+++ dist/opcodes/or1k-opinst.c 2015-10-18 13:11:20.000000000 +0200 -@@ -0,0 +1,590 @@ -+/* Semantic operand instances for or1k. -+ -+THIS FILE IS MACHINE GENERATED WITH CGEN. -+ -+Copyright (C) 1996-2014 Free Software Foundation, Inc. -+ -+This file is part of the GNU Binutils and/or GDB, the GNU debugger. -+ -+ This file is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3, or (at your option) -+ any later version. -+ -+ It is distributed in the hope that it will be useful, but WITHOUT -+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -+ License for more details. -+ -+ You should have received a copy of the GNU General Public License along -+ with this program; if not, write to the Free Software Foundation, Inc., -+ 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. -+ -+*/ -+ -+#include "sysdep.h" -+#include "ansidecl.h" -+#include "bfd.h" -+#include "symcat.h" -+#include "or1k-desc.h" -+#include "or1k-opc.h" -+ -+/* Operand references. */ -+ -+#define OP_ENT(op) OR1K_OPERAND_##op -+#define INPUT CGEN_OPINST_INPUT -+#define OUTPUT CGEN_OPINST_OUTPUT -+#define END CGEN_OPINST_END -+#define COND_REF CGEN_OPINST_COND_REF -+ -+static const CGEN_OPINST sfmt_empty_ops[] ATTRIBUTE_UNUSED = { -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_j_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "disp26", HW_H_IADDR, CGEN_MODE_UDI, OP_ENT (DISP26), 0, 0 }, -+ { INPUT, "sys_cpucfgr_nd", HW_H_SYS_CPUCFGR_ND, CGEN_MODE_UDI, 0, 0, 0 }, -+ { OUTPUT, "pc", HW_H_PC, CGEN_MODE_UDI, 0, 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_jal_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "disp26", HW_H_IADDR, CGEN_MODE_UDI, OP_ENT (DISP26), 0, 0 }, -+ { INPUT, "pc", HW_H_PC, CGEN_MODE_UDI, 0, 0, 0 }, -+ { INPUT, "sys_cpucfgr_nd", HW_H_SYS_CPUCFGR_ND, CGEN_MODE_UDI, 0, 0, 0 }, -+ { OUTPUT, "h_gpr_UDI_9", HW_H_GPR, CGEN_MODE_UDI, 0, 9, 0 }, -+ { OUTPUT, "pc", HW_H_PC, CGEN_MODE_UDI, 0, 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_jr_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "rB", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RB), 0, 0 }, -+ { INPUT, "sys_cpucfgr_nd", HW_H_SYS_CPUCFGR_ND, CGEN_MODE_UDI, 0, 0, 0 }, -+ { OUTPUT, "pc", HW_H_PC, CGEN_MODE_UDI, 0, 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_jalr_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "pc", HW_H_PC, CGEN_MODE_UDI, 0, 0, 0 }, -+ { INPUT, "rB", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RB), 0, 0 }, -+ { INPUT, "sys_cpucfgr_nd", HW_H_SYS_CPUCFGR_ND, CGEN_MODE_UDI, 0, 0, 0 }, -+ { OUTPUT, "h_gpr_UDI_9", HW_H_GPR, CGEN_MODE_UDI, 0, 9, 0 }, -+ { OUTPUT, "pc", HW_H_PC, CGEN_MODE_UDI, 0, 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_bnf_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "disp26", HW_H_IADDR, CGEN_MODE_UDI, OP_ENT (DISP26), 0, COND_REF }, -+ { INPUT, "pc", HW_H_PC, CGEN_MODE_UDI, 0, 0, COND_REF }, -+ { INPUT, "sys_cpucfgr_nd", HW_H_SYS_CPUCFGR_ND, CGEN_MODE_UDI, 0, 0, COND_REF }, -+ { INPUT, "sys_sr_f", HW_H_SYS_SR_F, CGEN_MODE_UDI, 0, 0, 0 }, -+ { OUTPUT, "pc", HW_H_PC, CGEN_MODE_UDI, 0, 0, COND_REF }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_trap_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "pc", HW_H_PC, CGEN_MODE_UDI, 0, 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_msync_ops[] ATTRIBUTE_UNUSED = { -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_nop_imm_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "uimm16", HW_H_UIMM16, CGEN_MODE_UINT, OP_ENT (UIMM16), 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_movhi_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "uimm16", HW_H_UIMM16, CGEN_MODE_UINT, OP_ENT (UIMM16), 0, 0 }, -+ { OUTPUT, "rD", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RD), 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_macrc_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "mac_maclo", HW_H_MAC_MACLO, CGEN_MODE_UDI, 0, 0, 0 }, -+ { OUTPUT, "mac_machi", HW_H_MAC_MACHI, CGEN_MODE_UDI, 0, 0, 0 }, -+ { OUTPUT, "mac_maclo", HW_H_MAC_MACLO, CGEN_MODE_UDI, 0, 0, 0 }, -+ { OUTPUT, "rD", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RD), 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_mfspr_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "rA", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RA), 0, 0 }, -+ { INPUT, "uimm16", HW_H_UIMM16, CGEN_MODE_UINT, OP_ENT (UIMM16), 0, 0 }, -+ { OUTPUT, "rD", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RD), 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_mtspr_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "rA", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RA), 0, 0 }, -+ { INPUT, "rB", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RB), 0, 0 }, -+ { INPUT, "uimm16_split", HW_H_UIMM16, CGEN_MODE_UINT, OP_ENT (UIMM16_SPLIT), 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_lwz_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "h_memory_USI_c_call__AI_@cpu@_make_load_store_addr_rA_ext__SI_simm16_4", HW_H_MEMORY, CGEN_MODE_USI, 0, 0, 0 }, -+ { INPUT, "rA", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RA), 0, 0 }, -+ { INPUT, "simm16", HW_H_SIMM16, CGEN_MODE_INT, OP_ENT (SIMM16), 0, 0 }, -+ { OUTPUT, "rD", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RD), 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_lws_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "h_memory_SI_c_call__AI_@cpu@_make_load_store_addr_rA_ext__SI_simm16_4", HW_H_MEMORY, CGEN_MODE_SI, 0, 0, 0 }, -+ { INPUT, "rA", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RA), 0, 0 }, -+ { INPUT, "simm16", HW_H_SIMM16, CGEN_MODE_INT, OP_ENT (SIMM16), 0, 0 }, -+ { OUTPUT, "rD", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RD), 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_lwa_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "h_memory_USI_c_call__AI_@cpu@_make_load_store_addr_rA_ext__SI_simm16_4", HW_H_MEMORY, CGEN_MODE_USI, 0, 0, 0 }, -+ { INPUT, "rA", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RA), 0, 0 }, -+ { INPUT, "simm16", HW_H_SIMM16, CGEN_MODE_INT, OP_ENT (SIMM16), 0, 0 }, -+ { OUTPUT, "atomic_address", HW_H_ATOMIC_ADDRESS, CGEN_MODE_SI, 0, 0, 0 }, -+ { OUTPUT, "atomic_reserve", HW_H_ATOMIC_RESERVE, CGEN_MODE_BI, 0, 0, 0 }, -+ { OUTPUT, "rD", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RD), 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_lbz_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "h_memory_UQI_c_call__AI_@cpu@_make_load_store_addr_rA_ext__SI_simm16_1", HW_H_MEMORY, CGEN_MODE_UQI, 0, 0, 0 }, -+ { INPUT, "rA", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RA), 0, 0 }, -+ { INPUT, "simm16", HW_H_SIMM16, CGEN_MODE_INT, OP_ENT (SIMM16), 0, 0 }, -+ { OUTPUT, "rD", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RD), 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_lbs_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "h_memory_QI_c_call__AI_@cpu@_make_load_store_addr_rA_ext__SI_simm16_1", HW_H_MEMORY, CGEN_MODE_QI, 0, 0, 0 }, -+ { INPUT, "rA", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RA), 0, 0 }, -+ { INPUT, "simm16", HW_H_SIMM16, CGEN_MODE_INT, OP_ENT (SIMM16), 0, 0 }, -+ { OUTPUT, "rD", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RD), 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_lhz_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "h_memory_UHI_c_call__AI_@cpu@_make_load_store_addr_rA_ext__SI_simm16_2", HW_H_MEMORY, CGEN_MODE_UHI, 0, 0, 0 }, -+ { INPUT, "rA", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RA), 0, 0 }, -+ { INPUT, "simm16", HW_H_SIMM16, CGEN_MODE_INT, OP_ENT (SIMM16), 0, 0 }, -+ { OUTPUT, "rD", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RD), 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_lhs_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "h_memory_HI_c_call__AI_@cpu@_make_load_store_addr_rA_ext__SI_simm16_2", HW_H_MEMORY, CGEN_MODE_HI, 0, 0, 0 }, -+ { INPUT, "rA", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RA), 0, 0 }, -+ { INPUT, "simm16", HW_H_SIMM16, CGEN_MODE_INT, OP_ENT (SIMM16), 0, 0 }, -+ { OUTPUT, "rD", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RD), 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_sw_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "atomic_address", HW_H_ATOMIC_ADDRESS, CGEN_MODE_SI, 0, 0, 0 }, -+ { INPUT, "rA", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RA), 0, 0 }, -+ { INPUT, "rB", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RB), 0, 0 }, -+ { INPUT, "simm16_split", HW_H_SIMM16, CGEN_MODE_INT, OP_ENT (SIMM16_SPLIT), 0, 0 }, -+ { OUTPUT, "atomic_reserve", HW_H_ATOMIC_RESERVE, CGEN_MODE_BI, 0, 0, COND_REF }, -+ { OUTPUT, "h_memory_USI_addr", HW_H_MEMORY, CGEN_MODE_USI, 0, 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_sb_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "atomic_address", HW_H_ATOMIC_ADDRESS, CGEN_MODE_SI, 0, 0, 0 }, -+ { INPUT, "rA", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RA), 0, 0 }, -+ { INPUT, "rB", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RB), 0, 0 }, -+ { INPUT, "simm16_split", HW_H_SIMM16, CGEN_MODE_INT, OP_ENT (SIMM16_SPLIT), 0, 0 }, -+ { OUTPUT, "atomic_reserve", HW_H_ATOMIC_RESERVE, CGEN_MODE_BI, 0, 0, COND_REF }, -+ { OUTPUT, "h_memory_UQI_addr", HW_H_MEMORY, CGEN_MODE_UQI, 0, 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_sh_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "atomic_address", HW_H_ATOMIC_ADDRESS, CGEN_MODE_SI, 0, 0, 0 }, -+ { INPUT, "rA", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RA), 0, 0 }, -+ { INPUT, "rB", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RB), 0, 0 }, -+ { INPUT, "simm16_split", HW_H_SIMM16, CGEN_MODE_INT, OP_ENT (SIMM16_SPLIT), 0, 0 }, -+ { OUTPUT, "atomic_reserve", HW_H_ATOMIC_RESERVE, CGEN_MODE_BI, 0, 0, COND_REF }, -+ { OUTPUT, "h_memory_UHI_addr", HW_H_MEMORY, CGEN_MODE_UHI, 0, 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_swa_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "atomic_address", HW_H_ATOMIC_ADDRESS, CGEN_MODE_SI, 0, 0, 0 }, -+ { INPUT, "atomic_reserve", HW_H_ATOMIC_RESERVE, CGEN_MODE_BI, 0, 0, 0 }, -+ { INPUT, "rA", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RA), 0, 0 }, -+ { INPUT, "rB", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RB), 0, COND_REF }, -+ { INPUT, "simm16_split", HW_H_SIMM16, CGEN_MODE_INT, OP_ENT (SIMM16_SPLIT), 0, 0 }, -+ { INPUT, "sys_sr_f", HW_H_SYS_SR_F, CGEN_MODE_UDI, 0, 0, 0 }, -+ { OUTPUT, "atomic_reserve", HW_H_ATOMIC_RESERVE, CGEN_MODE_BI, 0, 0, 0 }, -+ { OUTPUT, "h_memory_USI_addr", HW_H_MEMORY, CGEN_MODE_USI, 0, 0, COND_REF }, -+ { OUTPUT, "sys_sr_f", HW_H_SYS_SR_F, CGEN_MODE_UDI, 0, 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_sll_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "rA", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RA), 0, 0 }, -+ { INPUT, "rB", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RB), 0, 0 }, -+ { OUTPUT, "rD", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RD), 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_slli_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "rA", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RA), 0, 0 }, -+ { INPUT, "uimm6", HW_H_UIMM6, CGEN_MODE_UINT, OP_ENT (UIMM6), 0, 0 }, -+ { OUTPUT, "rD", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RD), 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_and_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "rA", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RA), 0, 0 }, -+ { INPUT, "rB", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RB), 0, 0 }, -+ { OUTPUT, "rD", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RD), 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_add_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "pc", HW_H_PC, CGEN_MODE_UDI, 0, 0, COND_REF }, -+ { INPUT, "rA", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RA), 0, 0 }, -+ { INPUT, "rB", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RB), 0, 0 }, -+ { INPUT, "sys_sr_ov", HW_H_SYS_SR_OV, CGEN_MODE_UDI, 0, 0, 0 }, -+ { INPUT, "sys_sr_ove", HW_H_SYS_SR_OVE, CGEN_MODE_UDI, 0, 0, 0 }, -+ { OUTPUT, "rD", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RD), 0, 0 }, -+ { OUTPUT, "sys_sr_cy", HW_H_SYS_SR_CY, CGEN_MODE_UDI, 0, 0, 0 }, -+ { OUTPUT, "sys_sr_ov", HW_H_SYS_SR_OV, CGEN_MODE_UDI, 0, 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_addc_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "pc", HW_H_PC, CGEN_MODE_UDI, 0, 0, COND_REF }, -+ { INPUT, "rA", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RA), 0, 0 }, -+ { INPUT, "rB", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RB), 0, 0 }, -+ { INPUT, "sys_sr_cy", HW_H_SYS_SR_CY, CGEN_MODE_UDI, 0, 0, 0 }, -+ { INPUT, "sys_sr_ov", HW_H_SYS_SR_OV, CGEN_MODE_UDI, 0, 0, 0 }, -+ { INPUT, "sys_sr_ove", HW_H_SYS_SR_OVE, CGEN_MODE_UDI, 0, 0, 0 }, -+ { OUTPUT, "rD", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RD), 0, 0 }, -+ { OUTPUT, "sys_sr_cy", HW_H_SYS_SR_CY, CGEN_MODE_UDI, 0, 0, 0 }, -+ { OUTPUT, "sys_sr_ov", HW_H_SYS_SR_OV, CGEN_MODE_UDI, 0, 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_div_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "pc", HW_H_PC, CGEN_MODE_UDI, 0, 0, COND_REF }, -+ { INPUT, "rA", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RA), 0, COND_REF }, -+ { INPUT, "rB", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RB), 0, 0 }, -+ { INPUT, "sys_sr_cy", HW_H_SYS_SR_CY, CGEN_MODE_UDI, 0, 0, 0 }, -+ { INPUT, "sys_sr_ove", HW_H_SYS_SR_OVE, CGEN_MODE_UDI, 0, 0, 0 }, -+ { OUTPUT, "rD", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RD), 0, COND_REF }, -+ { OUTPUT, "sys_sr_cy", HW_H_SYS_SR_CY, CGEN_MODE_UDI, 0, 0, COND_REF }, -+ { OUTPUT, "sys_sr_ov", HW_H_SYS_SR_OV, CGEN_MODE_UDI, 0, 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_ff1_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "rA", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RA), 0, 0 }, -+ { OUTPUT, "rD", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RD), 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_xori_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "rA", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RA), 0, 0 }, -+ { INPUT, "simm16", HW_H_SIMM16, CGEN_MODE_INT, OP_ENT (SIMM16), 0, 0 }, -+ { OUTPUT, "rD", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RD), 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_addi_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "pc", HW_H_PC, CGEN_MODE_UDI, 0, 0, COND_REF }, -+ { INPUT, "rA", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RA), 0, 0 }, -+ { INPUT, "simm16", HW_H_SIMM16, CGEN_MODE_INT, OP_ENT (SIMM16), 0, 0 }, -+ { INPUT, "sys_sr_ov", HW_H_SYS_SR_OV, CGEN_MODE_UDI, 0, 0, 0 }, -+ { INPUT, "sys_sr_ove", HW_H_SYS_SR_OVE, CGEN_MODE_UDI, 0, 0, 0 }, -+ { OUTPUT, "rD", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RD), 0, 0 }, -+ { OUTPUT, "sys_sr_cy", HW_H_SYS_SR_CY, CGEN_MODE_UDI, 0, 0, 0 }, -+ { OUTPUT, "sys_sr_ov", HW_H_SYS_SR_OV, CGEN_MODE_UDI, 0, 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_addic_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "pc", HW_H_PC, CGEN_MODE_UDI, 0, 0, COND_REF }, -+ { INPUT, "rA", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RA), 0, 0 }, -+ { INPUT, "simm16", HW_H_SIMM16, CGEN_MODE_INT, OP_ENT (SIMM16), 0, 0 }, -+ { INPUT, "sys_sr_cy", HW_H_SYS_SR_CY, CGEN_MODE_UDI, 0, 0, 0 }, -+ { INPUT, "sys_sr_ov", HW_H_SYS_SR_OV, CGEN_MODE_UDI, 0, 0, 0 }, -+ { INPUT, "sys_sr_ove", HW_H_SYS_SR_OVE, CGEN_MODE_UDI, 0, 0, 0 }, -+ { OUTPUT, "rD", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RD), 0, 0 }, -+ { OUTPUT, "sys_sr_cy", HW_H_SYS_SR_CY, CGEN_MODE_UDI, 0, 0, 0 }, -+ { OUTPUT, "sys_sr_ov", HW_H_SYS_SR_OV, CGEN_MODE_UDI, 0, 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_exths_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "rA", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RA), 0, 0 }, -+ { OUTPUT, "rD", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RD), 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_cmov_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "rA", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RA), 0, COND_REF }, -+ { INPUT, "rB", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RB), 0, COND_REF }, -+ { INPUT, "sys_sr_f", HW_H_SYS_SR_F, CGEN_MODE_UDI, 0, 0, 0 }, -+ { OUTPUT, "rD", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RD), 0, COND_REF }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_sfgts_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "rA", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RA), 0, 0 }, -+ { INPUT, "rB", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RB), 0, 0 }, -+ { OUTPUT, "sys_sr_f", HW_H_SYS_SR_F, CGEN_MODE_UDI, 0, 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_sfgtsi_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "rA", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RA), 0, 0 }, -+ { INPUT, "simm16", HW_H_SIMM16, CGEN_MODE_INT, OP_ENT (SIMM16), 0, 0 }, -+ { OUTPUT, "sys_sr_f", HW_H_SYS_SR_F, CGEN_MODE_UDI, 0, 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_mac_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "mac_machi", HW_H_MAC_MACHI, CGEN_MODE_UDI, 0, 0, 0 }, -+ { INPUT, "mac_maclo", HW_H_MAC_MACLO, CGEN_MODE_UDI, 0, 0, 0 }, -+ { INPUT, "rA", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RA), 0, 0 }, -+ { INPUT, "rB", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RB), 0, 0 }, -+ { OUTPUT, "mac_machi", HW_H_MAC_MACHI, CGEN_MODE_UDI, 0, 0, 0 }, -+ { OUTPUT, "mac_maclo", HW_H_MAC_MACLO, CGEN_MODE_UDI, 0, 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_l_maci_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "mac_machi", HW_H_MAC_MACHI, CGEN_MODE_UDI, 0, 0, 0 }, -+ { INPUT, "mac_maclo", HW_H_MAC_MACLO, CGEN_MODE_UDI, 0, 0, 0 }, -+ { INPUT, "rA", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RA), 0, 0 }, -+ { INPUT, "simm16", HW_H_SIMM16, CGEN_MODE_INT, OP_ENT (SIMM16), 0, 0 }, -+ { OUTPUT, "mac_machi", HW_H_MAC_MACHI, CGEN_MODE_UDI, 0, 0, 0 }, -+ { OUTPUT, "mac_maclo", HW_H_MAC_MACLO, CGEN_MODE_UDI, 0, 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_lf_add_s_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "rASF", HW_H_FSR, CGEN_MODE_SF, OP_ENT (RASF), 0, 0 }, -+ { INPUT, "rBSF", HW_H_FSR, CGEN_MODE_SF, OP_ENT (RBSF), 0, 0 }, -+ { OUTPUT, "rDSF", HW_H_FSR, CGEN_MODE_SF, OP_ENT (RDSF), 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_lf_add_d_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "rADF", HW_H_FDR, CGEN_MODE_DF, OP_ENT (RADF), 0, 0 }, -+ { INPUT, "rBDF", HW_H_FDR, CGEN_MODE_DF, OP_ENT (RBDF), 0, 0 }, -+ { OUTPUT, "rDDF", HW_H_FDR, CGEN_MODE_DF, OP_ENT (RDDF), 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_lf_itof_s_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "rA", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RA), 0, 0 }, -+ { INPUT, "sys_fpcsr_rm", HW_H_SYS_FPCSR_RM, CGEN_MODE_UDI, 0, 0, 0 }, -+ { OUTPUT, "rDSF", HW_H_FSR, CGEN_MODE_SF, OP_ENT (RDSF), 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_lf_itof_d_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "rA", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RA), 0, 0 }, -+ { INPUT, "sys_fpcsr_rm", HW_H_SYS_FPCSR_RM, CGEN_MODE_UDI, 0, 0, 0 }, -+ { OUTPUT, "rDDF", HW_H_FDR, CGEN_MODE_DF, OP_ENT (RDDF), 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_lf_ftoi_s_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "rASF", HW_H_FSR, CGEN_MODE_SF, OP_ENT (RASF), 0, 0 }, -+ { INPUT, "sys_fpcsr_rm", HW_H_SYS_FPCSR_RM, CGEN_MODE_UDI, 0, 0, 0 }, -+ { OUTPUT, "rD", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RD), 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_lf_ftoi_d_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "rADF", HW_H_FDR, CGEN_MODE_DF, OP_ENT (RADF), 0, 0 }, -+ { INPUT, "sys_fpcsr_rm", HW_H_SYS_FPCSR_RM, CGEN_MODE_UDI, 0, 0, 0 }, -+ { OUTPUT, "rD", HW_H_GPR, CGEN_MODE_UDI, OP_ENT (RD), 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_lf_eq_s_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "rASF", HW_H_FSR, CGEN_MODE_SF, OP_ENT (RASF), 0, 0 }, -+ { INPUT, "rBSF", HW_H_FSR, CGEN_MODE_SF, OP_ENT (RBSF), 0, 0 }, -+ { OUTPUT, "sys_sr_f", HW_H_SYS_SR_F, CGEN_MODE_UDI, 0, 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_lf_eq_d_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "rADF", HW_H_FDR, CGEN_MODE_DF, OP_ENT (RADF), 0, 0 }, -+ { INPUT, "rBDF", HW_H_FDR, CGEN_MODE_DF, OP_ENT (RBDF), 0, 0 }, -+ { OUTPUT, "sys_sr_f", HW_H_SYS_SR_F, CGEN_MODE_UDI, 0, 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_lf_madd_s_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "rASF", HW_H_FSR, CGEN_MODE_SF, OP_ENT (RASF), 0, 0 }, -+ { INPUT, "rBSF", HW_H_FSR, CGEN_MODE_SF, OP_ENT (RBSF), 0, 0 }, -+ { INPUT, "rDSF", HW_H_FSR, CGEN_MODE_SF, OP_ENT (RDSF), 0, 0 }, -+ { OUTPUT, "rDSF", HW_H_FSR, CGEN_MODE_SF, OP_ENT (RDSF), 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+static const CGEN_OPINST sfmt_lf_madd_d_ops[] ATTRIBUTE_UNUSED = { -+ { INPUT, "rADF", HW_H_FDR, CGEN_MODE_DF, OP_ENT (RADF), 0, 0 }, -+ { INPUT, "rBDF", HW_H_FDR, CGEN_MODE_DF, OP_ENT (RBDF), 0, 0 }, -+ { INPUT, "rDDF", HW_H_FDR, CGEN_MODE_DF, OP_ENT (RDDF), 0, 0 }, -+ { OUTPUT, "rDDF", HW_H_FDR, CGEN_MODE_DF, OP_ENT (RDDF), 0, 0 }, -+ { END, (const char *)0, (enum cgen_hw_type)0, (enum cgen_mode)0, (enum cgen_operand_type)0, 0, 0 } -+}; -+ -+#undef OP_ENT -+#undef INPUT -+#undef OUTPUT -+#undef END -+#undef COND_REF -+ -+/* Operand instance lookup table. */ -+ -+static const CGEN_OPINST *or1k_cgen_opinst_table[MAX_INSNS] = { -+ 0, -+ & sfmt_l_j_ops[0], -+ & sfmt_l_jal_ops[0], -+ & sfmt_l_jr_ops[0], -+ & sfmt_l_jalr_ops[0], -+ & sfmt_l_bnf_ops[0], -+ & sfmt_l_bnf_ops[0], -+ & sfmt_l_trap_ops[0], -+ & sfmt_l_trap_ops[0], -+ & sfmt_l_msync_ops[0], -+ & sfmt_l_msync_ops[0], -+ & sfmt_l_msync_ops[0], -+ & sfmt_l_msync_ops[0], -+ & sfmt_l_nop_imm_ops[0], -+ & sfmt_l_msync_ops[0], -+ & sfmt_l_movhi_ops[0], -+ & sfmt_l_macrc_ops[0], -+ & sfmt_l_mfspr_ops[0], -+ & sfmt_l_mtspr_ops[0], -+ & sfmt_l_lwz_ops[0], -+ & sfmt_l_lws_ops[0], -+ & sfmt_l_lwa_ops[0], -+ & sfmt_l_lbz_ops[0], -+ & sfmt_l_lbs_ops[0], -+ & sfmt_l_lhz_ops[0], -+ & sfmt_l_lhs_ops[0], -+ & sfmt_l_sw_ops[0], -+ & sfmt_l_sb_ops[0], -+ & sfmt_l_sh_ops[0], -+ & sfmt_l_swa_ops[0], -+ & sfmt_l_sll_ops[0], -+ & sfmt_l_slli_ops[0], -+ & sfmt_l_sll_ops[0], -+ & sfmt_l_slli_ops[0], -+ & sfmt_l_sll_ops[0], -+ & sfmt_l_slli_ops[0], -+ & sfmt_l_sll_ops[0], -+ & sfmt_l_slli_ops[0], -+ & sfmt_l_and_ops[0], -+ & sfmt_l_and_ops[0], -+ & sfmt_l_and_ops[0], -+ & sfmt_l_add_ops[0], -+ & sfmt_l_add_ops[0], -+ & sfmt_l_addc_ops[0], -+ & sfmt_l_add_ops[0], -+ & sfmt_l_add_ops[0], -+ & sfmt_l_div_ops[0], -+ & sfmt_l_div_ops[0], -+ & sfmt_l_ff1_ops[0], -+ & sfmt_l_ff1_ops[0], -+ & sfmt_l_mfspr_ops[0], -+ & sfmt_l_mfspr_ops[0], -+ & sfmt_l_xori_ops[0], -+ & sfmt_l_addi_ops[0], -+ & sfmt_l_addic_ops[0], -+ & sfmt_l_addi_ops[0], -+ & sfmt_l_exths_ops[0], -+ & sfmt_l_exths_ops[0], -+ & sfmt_l_exths_ops[0], -+ & sfmt_l_exths_ops[0], -+ & sfmt_l_exths_ops[0], -+ & sfmt_l_exths_ops[0], -+ & sfmt_l_cmov_ops[0], -+ & sfmt_l_sfgts_ops[0], -+ & sfmt_l_sfgtsi_ops[0], -+ & sfmt_l_sfgts_ops[0], -+ & sfmt_l_sfgtsi_ops[0], -+ & sfmt_l_sfgts_ops[0], -+ & sfmt_l_sfgtsi_ops[0], -+ & sfmt_l_sfgts_ops[0], -+ & sfmt_l_sfgtsi_ops[0], -+ & sfmt_l_sfgts_ops[0], -+ & sfmt_l_sfgtsi_ops[0], -+ & sfmt_l_sfgts_ops[0], -+ & sfmt_l_sfgtsi_ops[0], -+ & sfmt_l_sfgts_ops[0], -+ & sfmt_l_sfgtsi_ops[0], -+ & sfmt_l_sfgts_ops[0], -+ & sfmt_l_sfgtsi_ops[0], -+ & sfmt_l_sfgts_ops[0], -+ & sfmt_l_sfgtsi_ops[0], -+ & sfmt_l_sfgts_ops[0], -+ & sfmt_l_sfgtsi_ops[0], -+ & sfmt_l_mac_ops[0], -+ & sfmt_l_mac_ops[0], -+ & sfmt_l_maci_ops[0], -+ & sfmt_l_msync_ops[0], -+ & sfmt_l_msync_ops[0], -+ & sfmt_l_msync_ops[0], -+ & sfmt_l_msync_ops[0], -+ & sfmt_l_msync_ops[0], -+ & sfmt_l_msync_ops[0], -+ & sfmt_l_msync_ops[0], -+ & sfmt_l_msync_ops[0], -+ & sfmt_lf_add_s_ops[0], -+ & sfmt_lf_add_d_ops[0], -+ & sfmt_lf_add_s_ops[0], -+ & sfmt_lf_add_d_ops[0], -+ & sfmt_lf_add_s_ops[0], -+ & sfmt_lf_add_d_ops[0], -+ & sfmt_lf_add_s_ops[0], -+ & sfmt_lf_add_d_ops[0], -+ & sfmt_lf_add_s_ops[0], -+ & sfmt_lf_add_d_ops[0], -+ & sfmt_lf_itof_s_ops[0], -+ & sfmt_lf_itof_d_ops[0], -+ & sfmt_lf_ftoi_s_ops[0], -+ & sfmt_lf_ftoi_d_ops[0], -+ & sfmt_lf_eq_s_ops[0], -+ & sfmt_lf_eq_d_ops[0], -+ & sfmt_lf_eq_s_ops[0], -+ & sfmt_lf_eq_d_ops[0], -+ & sfmt_lf_eq_s_ops[0], -+ & sfmt_lf_eq_d_ops[0], -+ & sfmt_lf_eq_s_ops[0], -+ & sfmt_lf_eq_d_ops[0], -+ & sfmt_lf_eq_s_ops[0], -+ & sfmt_lf_eq_d_ops[0], -+ & sfmt_lf_eq_s_ops[0], -+ & sfmt_lf_eq_d_ops[0], -+ & sfmt_lf_madd_s_ops[0], -+ & sfmt_lf_madd_d_ops[0], -+ & sfmt_l_msync_ops[0], -+ & sfmt_l_msync_ops[0], -+}; -+ -+/* Function to call before using the operand instance table. */ -+ -+void -+or1k_cgen_init_opinst_table (cd) -+ CGEN_CPU_DESC cd; -+{ -+ int i; -+ const CGEN_OPINST **oi = & or1k_cgen_opinst_table[0]; -+ CGEN_INSN *insns = (CGEN_INSN *) cd->insn_table.init_entries; -+ for (i = 0; i < MAX_INSNS; ++i) -+ insns[i].opinst = oi[i]; -+} -diff -rNU3 dist.orig/opcodes/or32-dis.c dist/opcodes/or32-dis.c ---- dist.orig/opcodes/or32-dis.c 2012-05-18 03:59:38.000000000 +0200 -+++ dist/opcodes/or32-dis.c 1970-01-01 01:00:00.000000000 +0100 -@@ -1,325 +0,0 @@ --/* Instruction printing code for the OpenRISC 1000 -- Copyright (C) 2002, 2005, 2007, 2012 Free Software Foundation, Inc. -- Contributed by Damjan Lampret . -- Modified from a29k port. -- -- This file is part of the GNU opcodes library. -- -- This library is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3, or (at your option) -- any later version. -- -- It is distributed in the hope that it will be useful, but WITHOUT -- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, -- MA 02110-1301, USA. */ -- --#ifndef DEBUG --#define DEBUG 0 --#endif -- --#include "sysdep.h" --#include "dis-asm.h" --#include "opcode/or32.h" --#include "safe-ctype.h" -- --#define EXTEND29(x) ((x) & (unsigned long) 0x10000000 ? ((x) | (unsigned long) 0xf0000000) : ((x))) -- --/* Now find the four bytes of INSN_CH and put them in *INSN. */ -- --static void --find_bytes_big (unsigned char *insn_ch, unsigned long *insn) --{ -- *insn = -- ((unsigned long) insn_ch[0] << 24) + -- ((unsigned long) insn_ch[1] << 16) + -- ((unsigned long) insn_ch[2] << 8) + -- ((unsigned long) insn_ch[3]); --#if DEBUG -- printf ("find_bytes_big3: %lx\n", *insn); --#endif --} -- --static void --find_bytes_little (unsigned char *insn_ch, unsigned long *insn) --{ -- *insn = -- ((unsigned long) insn_ch[3] << 24) + -- ((unsigned long) insn_ch[2] << 16) + -- ((unsigned long) insn_ch[1] << 8) + -- ((unsigned long) insn_ch[0]); --} -- --typedef void (*find_byte_func_type) (unsigned char *, unsigned long *); -- --static unsigned long --or32_extract (char param_ch, char *enc_initial, unsigned long insn) --{ -- char *enc; -- unsigned long ret = 0; -- int opc_pos = 0; -- int param_pos = 0; -- -- for (enc = enc_initial; *enc != '\0'; enc++) -- if (*enc == param_ch) -- { -- if (enc - 2 >= enc_initial && (*(enc - 2) == '0') && (*(enc - 1) == 'x')) -- continue; -- else -- param_pos++; -- } -- --#if DEBUG -- printf ("or32_extract: %c %x ", param_ch, param_pos); --#endif -- opc_pos = 32; -- -- for (enc = enc_initial; *enc != '\0'; ) -- if ((*enc == '0') && (*(enc + 1) == 'x')) -- { -- opc_pos -= 4; -- -- if ((param_ch == '0') || (param_ch == '1')) -- { -- unsigned long tmp = strtoul (enc, NULL, 16); --#if DEBUG -- printf (" enc=%s, tmp=%lx ", enc, tmp); --#endif -- if (param_ch == '0') -- tmp = 15 - tmp; -- ret |= tmp << opc_pos; -- } -- enc += 3; -- } -- else if ((*enc == '0') || (*enc == '1')) -- { -- opc_pos--; -- if (param_ch == *enc) -- ret |= 1 << opc_pos; -- enc++; -- } -- else if (*enc == param_ch) -- { -- opc_pos--; -- param_pos--; --#if DEBUG -- printf ("\n ret=%lx opc_pos=%x, param_pos=%x\n", ret, opc_pos, param_pos); --#endif -- ret += ((insn >> opc_pos) & 0x1) << param_pos; -- -- if (!param_pos -- && letter_signed (param_ch) -- && ret >> (letter_range (param_ch) - 1)) -- { --#if DEBUG -- printf ("\n ret=%lx opc_pos=%x, param_pos=%x\n", -- ret, opc_pos, param_pos); --#endif -- ret |= 0xffffffff << letter_range(param_ch); --#if DEBUG -- printf ("\n after conversion to signed: ret=%lx\n", ret); --#endif -- } -- enc++; -- } -- else if (ISALPHA (*enc)) -- { -- opc_pos--; -- enc++; -- } -- else if (*enc == '-') -- { -- opc_pos--; -- enc++; -- } -- else -- enc++; -- --#if DEBUG -- printf ("ret=%lx\n", ret); --#endif -- return ret; --} -- --static int --or32_opcode_match (unsigned long insn, char *encoding) --{ -- unsigned long ones, zeros; -- --#if DEBUG -- printf ("or32_opcode_match: %.8lx\n", insn); --#endif -- ones = or32_extract ('1', encoding, insn); -- zeros = or32_extract ('0', encoding, insn); -- --#if DEBUG -- printf ("ones: %lx \n", ones); -- printf ("zeros: %lx \n", zeros); --#endif -- if ((insn & ones) != ones) -- { --#if DEBUG -- printf ("ret1\n"); --#endif -- return 0; -- } -- -- if ((~insn & zeros) != zeros) -- { --#if DEBUG -- printf ("ret2\n"); --#endif -- return 0; -- } -- --#if DEBUG -- printf ("ret3\n"); --#endif -- return 1; --} -- --/* Print register to INFO->STREAM. Used only by print_insn. */ -- --static void --or32_print_register (char param_ch, -- char *encoding, -- unsigned long insn, -- struct disassemble_info *info) --{ -- int regnum = or32_extract (param_ch, encoding, insn); -- --#if DEBUG -- printf ("or32_print_register: %c, %s, %lx\n", param_ch, encoding, insn); --#endif -- if (param_ch == 'A') -- (*info->fprintf_func) (info->stream, "r%d", regnum); -- else if (param_ch == 'B') -- (*info->fprintf_func) (info->stream, "r%d", regnum); -- else if (param_ch == 'D') -- (*info->fprintf_func) (info->stream, "r%d", regnum); -- else if (regnum < 16) -- (*info->fprintf_func) (info->stream, "r%d", regnum); -- else if (regnum < 32) -- (*info->fprintf_func) (info->stream, "r%d", regnum-16); -- else -- (*info->fprintf_func) (info->stream, "X%d", regnum); --} -- --/* Print immediate to INFO->STREAM. Used only by print_insn. */ -- --static void --or32_print_immediate (char param_ch, -- char *encoding, -- unsigned long insn, -- struct disassemble_info *info) --{ -- int imm = or32_extract(param_ch, encoding, insn); -- -- if (letter_signed(param_ch)) -- (*info->fprintf_func) (info->stream, "0x%x", imm); --/* (*info->fprintf_func) (info->stream, "%d", imm); */ -- else -- (*info->fprintf_func) (info->stream, "0x%x", imm); --} -- --/* Print one instruction from MEMADDR on INFO->STREAM. -- Return the size of the instruction (always 4 on or32). */ -- --static int --print_insn (bfd_vma memaddr, struct disassemble_info *info) --{ -- /* The raw instruction. */ -- unsigned char insn_ch[4]; -- /* Address. Will be sign extened 27-bit. */ -- unsigned long addr; -- /* The four bytes of the instruction. */ -- unsigned long insn; -- find_byte_func_type find_byte_func = (find_byte_func_type) info->private_data; -- struct or32_opcode const * opcode; -- -- { -- int status = -- (*info->read_memory_func) (memaddr, (bfd_byte *) &insn_ch[0], 4, info); -- -- if (status != 0) -- { -- (*info->memory_error_func) (status, memaddr, info); -- return -1; -- } -- } -- -- (*find_byte_func) (&insn_ch[0], &insn); -- -- for (opcode = &or32_opcodes[0]; -- opcode < &or32_opcodes[or32_num_opcodes]; -- ++opcode) -- { -- if (or32_opcode_match (insn, opcode->encoding)) -- { -- char *s; -- -- (*info->fprintf_func) (info->stream, "%s ", opcode->name); -- -- for (s = opcode->args; *s != '\0'; ++s) -- { -- switch (*s) -- { -- case '\0': -- return 4; -- -- case 'r': -- or32_print_register (*++s, opcode->encoding, insn, info); -- break; -- -- case 'X': -- addr = or32_extract ('X', opcode->encoding, insn) << 2; -- -- /* Calulate the correct address. XXX is this really correct ?? */ -- addr = memaddr + EXTEND29 (addr); -- -- (*info->print_address_func) -- (addr, info); -- break; -- -- default: -- if (strchr (opcode->encoding, *s)) -- or32_print_immediate (*s, opcode->encoding, insn, info); -- else -- (*info->fprintf_func) (info->stream, "%c", *s); -- } -- } -- -- return 4; -- } -- } -- -- /* This used to be %8x for binutils. */ -- (*info->fprintf_func) -- (info->stream, ".word 0x%08lx", insn); -- return 4; --} -- --/* Disassemble a big-endian or32 instruction. */ -- --int --print_insn_big_or32 (bfd_vma memaddr, struct disassemble_info *info) --{ -- info->private_data = find_bytes_big; -- -- return print_insn (memaddr, info); --} -- --/* Disassemble a little-endian or32 instruction. */ -- --int --print_insn_little_or32 (bfd_vma memaddr, struct disassemble_info *info) --{ -- info->private_data = find_bytes_little; -- return print_insn (memaddr, info); --} -diff -rNU3 dist.orig/opcodes/or32-opc.c dist/opcodes/or32-opc.c ---- dist.orig/opcodes/or32-opc.c 2012-05-17 17:13:25.000000000 +0200 -+++ dist/opcodes/or32-opc.c 1970-01-01 01:00:00.000000000 +0100 -@@ -1,1031 +0,0 @@ --/* Table of opcodes for the OpenRISC 1000 ISA. -- Copyright 2002, 2004, 2005, 2007, 2008, 2009, 2012 -- Free Software Foundation, Inc. -- Contributed by Damjan Lampret (lampret@opencores.org). -- -- This file is part of the GNU opcodes library. -- -- This library is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3, or (at your option) -- any later version. -- -- It is distributed in the hope that it will be useful, but WITHOUT -- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -- License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program; if not, write to the Free Software -- Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, -- MA 02110-1301, USA. */ -- --#include "sysdep.h" --#include --#include --#include --#include "safe-ctype.h" --#include "ansidecl.h" --#include "opcode/or32.h" -- --/* We treat all letters the same in encode/decode routines so -- we need to assign some characteristics to them like signess etc. */ -- --const struct or32_letter or32_letters[] = --{ -- { 'A', NUM_UNSIGNED }, -- { 'B', NUM_UNSIGNED }, -- { 'D', NUM_UNSIGNED }, -- { 'I', NUM_SIGNED }, -- { 'K', NUM_UNSIGNED }, -- { 'L', NUM_UNSIGNED }, -- { 'N', NUM_SIGNED }, -- { '0', NUM_UNSIGNED }, -- { '\0', 0 } /* Dummy entry. */ --}; -- --/* Opcode encoding: -- machine[31:30]: first two bits of opcode -- 00 - neither of source operands is GPR -- 01 - second source operand is GPR (rB) -- 10 - first source operand is GPR (rA) -- 11 - both source operands are GPRs (rA and rB) -- machine[29:26]: next four bits of opcode -- machine[25:00]: instruction operands (specific to individual instruction) -- -- Recommendation: irrelevant instruction bits should be set with a value of -- bits in same positions of instruction preceding current instruction in the -- code (when assembling). */ -- --#define EFN &l_none -- --#ifdef HAS_EXECUTION --#define EF(func) &(func) --#define EFI &l_invalid --#else /* HAS_EXECUTION */ --#define EF(func) EFN --#define EFI EFN --#endif /* HAS_EXECUTION */ -- --const struct or32_opcode or32_opcodes[] = --{ -- { "l.j", "N", "00 0x0 NNNNN NNNNN NNNN NNNN NNNN NNNN", EF(l_j), OR32_IF_DELAY }, -- { "l.jal", "N", "00 0x1 NNNNN NNNNN NNNN NNNN NNNN NNNN", EF(l_jal), OR32_IF_DELAY }, -- { "l.bnf", "N", "00 0x3 NNNNN NNNNN NNNN NNNN NNNN NNNN", EF(l_bnf), OR32_IF_DELAY | OR32_R_FLAG}, -- { "l.bf", "N", "00 0x4 NNNNN NNNNN NNNN NNNN NNNN NNNN", EF(l_bf), OR32_IF_DELAY | OR32_R_FLAG }, -- { "l.nop", "K", "00 0x5 01--- ----- KKKK KKKK KKKK KKKK", EF(l_nop), 0 }, -- { "l.movhi", "rD,K", "00 0x6 DDDDD ----0 KKKK KKKK KKKK KKKK", EF(l_movhi), 0 }, /*MM*/ -- { "l.macrc", "rD", "00 0x6 DDDDD ----1 0000 0000 0000 0000", EF(l_macrc), 0 }, /*MM*/ -- -- { "l.sys", "K", "00 0x8 00000 00000 KKKK KKKK KKKK KKKK", EF(l_sys), 0 }, -- { "l.trap", "K", "00 0x8 01000 00000 KKKK KKKK KKKK KKKK", EF(l_trap), 0 }, /* CZ 21/06/01 */ -- { "l.msync", "", "00 0x8 10000 00000 0000 0000 0000 0000", EFN, 0 }, -- { "l.psync", "", "00 0x8 10100 00000 0000 0000 0000 0000", EFN, 0 }, -- { "l.csync", "", "00 0x8 11000 00000 0000 0000 0000 0000", EFN, 0 }, -- { "l.rfe", "", "00 0x9 ----- ----- ---- ---- ---- ----", EF(l_rfe), OR32_IF_DELAY }, -- -- { "lv.all_eq.b","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x1 0x0", EFI, 0 }, -- { "lv.all_eq.h","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x1 0x1", EFI, 0 }, -- { "lv.all_ge.b","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x1 0x2", EFI, 0 }, -- { "lv.all_ge.h","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x1 0x3", EFI, 0 }, -- { "lv.all_gt.b","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x1 0x4", EFI, 0 }, -- { "lv.all_gt.h","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x1 0x5", EFI, 0 }, -- { "lv.all_le.b","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x1 0x6", EFI, 0 }, -- { "lv.all_le.h","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x1 0x7", EFI, 0 }, -- { "lv.all_lt.b","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x1 0x8", EFI, 0 }, -- { "lv.all_lt.h","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x1 0x9", EFI, 0 }, -- { "lv.all_ne.b","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x1 0xA", EFI, 0 }, -- { "lv.all_ne.h","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x1 0xB", EFI, 0 }, -- { "lv.any_eq.b","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x2 0x0", EFI, 0 }, -- { "lv.any_eq.h","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x2 0x1", EFI, 0 }, -- { "lv.any_ge.b","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x2 0x2", EFI, 0 }, -- { "lv.any_ge.h","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x2 0x3", EFI, 0 }, -- { "lv.any_gt.b","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x2 0x4", EFI, 0 }, -- { "lv.any_gt.h","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x2 0x5", EFI, 0 }, -- { "lv.any_le.b","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x2 0x6", EFI, 0 }, -- { "lv.any_le.h","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x2 0x7", EFI, 0 }, -- { "lv.any_lt.b","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x2 0x8", EFI, 0 }, -- { "lv.any_lt.h","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x2 0x9", EFI, 0 }, -- { "lv.any_ne.b","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x2 0xA", EFI, 0 }, -- { "lv.any_ne.h","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x2 0xB", EFI, 0 }, -- { "lv.add.b", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x3 0x0", EFI, 0 }, -- { "lv.add.h", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x3 0x1", EFI, 0 }, -- { "lv.adds.b", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x3 0x2", EFI, 0 }, -- { "lv.adds.h", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x3 0x3", EFI, 0 }, -- { "lv.addu.b", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x3 0x4", EFI, 0 }, -- { "lv.addu.h", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x3 0x5", EFI, 0 }, -- { "lv.addus.b","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x3 0x6", EFI, 0 }, -- { "lv.addus.h","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x3 0x7", EFI, 0 }, -- { "lv.and", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x3 0x8", EFI, 0 }, -- { "lv.avg.b", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x3 0x9", EFI, 0 }, -- { "lv.avg.h", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x3 0xA", EFI, 0 }, -- { "lv.cmp_eq.b","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x4 0x0", EFI, 0 }, -- { "lv.cmp_eq.h","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x4 0x1", EFI, 0 }, -- { "lv.cmp_ge.b","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x4 0x2", EFI, 0 }, -- { "lv.cmp_ge.h","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x4 0x3", EFI, 0 }, -- { "lv.cmp_gt.b","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x4 0x4", EFI, 0 }, -- { "lv.cmp_gt.h","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x4 0x5", EFI, 0 }, -- { "lv.cmp_le.b","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x4 0x6", EFI, 0 }, -- { "lv.cmp_le.h","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x4 0x7", EFI, 0 }, -- { "lv.cmp_lt.b","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x4 0x8", EFI, 0 }, -- { "lv.cmp_lt.h","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x4 0x9", EFI, 0 }, -- { "lv.cmp_ne.b","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x4 0xA", EFI, 0 }, -- { "lv.cmp_ne.h","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x4 0xB", EFI, 0 }, -- { "lv.madds.h","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x5 0x4", EFI, 0 }, -- { "lv.max.b", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x5 0x5", EFI, 0 }, -- { "lv.max.h", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x5 0x6", EFI, 0 }, -- { "lv.merge.b","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x5 0x7", EFI, 0 }, -- { "lv.merge.h","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x5 0x8", EFI, 0 }, -- { "lv.min.b", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x5 0x9", EFI, 0 }, -- { "lv.min.h", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x5 0xA", EFI, 0 }, -- { "lv.msubs.h","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x5 0xB", EFI, 0 }, -- { "lv.muls.h", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x5 0xC", EFI, 0 }, -- { "lv.nand", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x5 0xD", EFI, 0 }, -- { "lv.nor", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x5 0xE", EFI, 0 }, -- { "lv.or", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x5 0xF", EFI, 0 }, -- { "lv.pack.b", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x6 0x0", EFI, 0 }, -- { "lv.pack.h", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x6 0x1", EFI, 0 }, -- { "lv.packs.b","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x6 0x2", EFI, 0 }, -- { "lv.packs.h","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x6 0x3", EFI, 0 }, -- { "lv.packus.b","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x6 0x4", EFI, 0 }, -- { "lv.packus.h","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x6 0x5", EFI, 0 }, -- { "lv.perm.n", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x6 0x6", EFI, 0 }, -- { "lv.rl.b", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x6 0x7", EFI, 0 }, -- { "lv.rl.h", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x6 0x8", EFI, 0 }, -- { "lv.sll.b", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x6 0x9", EFI, 0 }, -- { "lv.sll.h", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x6 0xA", EFI, 0 }, -- { "lv.sll", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x6 0xB", EFI, 0 }, -- { "lv.srl.b", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x6 0xC", EFI, 0 }, -- { "lv.srl.h", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x6 0xD", EFI, 0 }, -- { "lv.sra.b", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x6 0xE", EFI, 0 }, -- { "lv.sra.h", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x6 0xF", EFI, 0 }, -- { "lv.srl", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x7 0x0", EFI, 0 }, -- { "lv.sub.b", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x7 0x1", EFI, 0 }, -- { "lv.sub.h", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x7 0x2", EFI, 0 }, -- { "lv.subs.b", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x7 0x3", EFI, 0 }, -- { "lv.subs.h", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x7 0x4", EFI, 0 }, -- { "lv.subu.b", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x7 0x5", EFI, 0 }, -- { "lv.subu.h", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x7 0x6", EFI, 0 }, -- { "lv.subus.b","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x7 0x7", EFI, 0 }, -- { "lv.subus.h","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x7 0x8", EFI, 0 }, -- { "lv.unpack.b","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x7 0x9", EFI, 0 }, -- { "lv.unpack.h","rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x7 0xA", EFI, 0 }, -- { "lv.xor", "rD,rA,rB", "00 0xA DDDDD AAAAA BBBB B--- 0x7 0xB", EFI, 0 }, -- { "lv.cust1", "", "00 0xA ----- ----- ---- ---- 0xC ----", EFI, 0 }, -- { "lv.cust2", "", "00 0xA ----- ----- ---- ---- 0xD ----", EFI, 0 }, -- { "lv.cust3", "", "00 0xA ----- ----- ---- ---- 0xE ----", EFI, 0 }, -- { "lv.cust4", "", "00 0xA ----- ----- ---- ---- 0xF ----", EFI, 0 }, -- -- { "lf.add.s", "rD,rA,rB", "00 0xB DDDDD AAAAA BBBB B--- 0x1 0x0", EFI, 0 }, -- { "lf.sub.s", "rD,rA,rB", "00 0xB DDDDD AAAAA BBBB B--- 0x1 0x1", EFI, 0 }, -- { "lf.mul.s", "rD,rA,rB", "00 0xB DDDDD AAAAA BBBB B--- 0x1 0x2", EFI, 0 }, -- { "lf.div.s", "rD,rA,rB", "00 0xB DDDDD AAAAA BBBB B--- 0x1 0x3", EFI, 0 }, -- { "lf.itof.s", "rD,rA", "00 0xB DDDDD AAAAA BBBB B--- 0x1 0x4", EFI, 0 }, -- { "lf.ftoi.s", "rD,rA", "00 0xB DDDDD AAAAA BBBB B--- 0x1 0x5", EFI, 0 }, -- { "lf.rem.s", "rD,rA,rB", "00 0xB DDDDD AAAAA BBBB B--- 0x1 0x6", EFI, 0 }, -- { "lf.madd.s", "rD,rA,rB", "00 0xB DDDDD AAAAA BBBB B--- 0x1 0x7", EFI, 0 }, -- { "lf.sfeq.s", "rA,rB", "00 0xB ----- AAAAA BBBB B--- 0x1 0x8", EFI, 0 }, -- { "lf.sfne.s", "rA,rB", "00 0xB ----- AAAAA BBBB B--- 0x1 0x9", EFI, 0 }, -- { "lf.sfgt.s", "rA,rB", "00 0xB ----- AAAAA BBBB B--- 0x1 0xA", EFI, 0 }, -- { "lf.sfge.s", "rA,rB", "00 0xB ----- AAAAA BBBB B--- 0x1 0xB", EFI, 0 }, -- { "lf.sflt.s", "rA,rB", "00 0xB ----- AAAAA BBBB B--- 0x1 0xC", EFI, 0 }, -- { "lf.sfle.s", "rA,rB", "00 0xB ----- AAAAA BBBB B--- 0x1 0xD", EFI, 0 }, -- { "lf.cust1.s", "", "00 0xB ----- ----- ---- ---- 0xE ----", EFI, 0 }, -- -- { "lf.add.d", "rD,rA,rB", "00 0xC DDDDD AAAAA BBBB B--- 0x1 0x0", EFI, 0 }, -- { "lf.sub.d", "rD,rA,rB", "00 0xC DDDDD AAAAA BBBB B--- 0x1 0x1", EFI, 0 }, -- { "lf.mul.d", "rD,rA,rB", "00 0xC DDDDD AAAAA BBBB B--- 0x1 0x2", EFI, 0 }, -- { "lf.div.d", "rD,rA,rB", "00 0xC DDDDD AAAAA BBBB B--- 0x1 0x3", EFI, 0 }, -- { "lf.itof.d", "rD,rA", "00 0xC DDDDD AAAAA BBBB B--- 0x1 0x4", EFI, 0 }, -- { "lf.ftoi.d", "rD,rA", "00 0xC DDDDD AAAAA BBBB B--- 0x1 0x5", EFI, 0 }, -- { "lf.rem.d", "rD,rA,rB", "00 0xC DDDDD AAAAA BBBB B--- 0x1 0x6", EFI, 0 }, -- { "lf.madd.d", "rD,rA,rB", "00 0xC DDDDD AAAAA BBBB B--- 0x1 0x7", EFI, 0 }, -- { "lf.sfeq.d", "rA,rB", "00 0xC ----- AAAAA BBBB B--- 0x1 0x8", EFI, 0 }, -- { "lf.sfne.d", "rA,rB", "00 0xC ----- AAAAA BBBB B--- 0x1 0x9", EFI, 0 }, -- { "lf.sfgt.d", "rA,rB", "00 0xC ----- AAAAA BBBB B--- 0x1 0xA", EFI, 0 }, -- { "lf.sfge.d", "rA,rB", "00 0xC ----- AAAAA BBBB B--- 0x1 0xB", EFI, 0 }, -- { "lf.sflt.d", "rA,rB", "00 0xC ----- AAAAA BBBB B--- 0x1 0xC", EFI, 0 }, -- { "lf.sfle.d", "rA,rB", "00 0xC ----- AAAAA BBBB B--- 0x1 0xD", EFI, 0 }, -- { "lf.cust1.d", "", "00 0xC ----- ----- ---- ---- 0xE ----", EFI, 0 }, -- -- { "lvf.ld", "rD,0(rA)", "00 0xD DDDDD AAAAA ---- ---- 0x0 0x0", EFI, 0 }, -- { "lvf.lw", "rD,0(rA)", "00 0xD DDDDD AAAAA ---- ---- 0x0 0x1", EFI, 0 }, -- { "lvf.sd", "0(rA),rB", "00 0xD ----- AAAAA BBBB B--- 0x1 0x0", EFI, 0 }, -- { "lvf.sw", "0(rA),rB", "00 0xD ----- AAAAA BBBB B--- 0x1 0x1", EFI, 0 }, -- -- { "l.jr", "rB", "01 0x1 ----- ----- BBBB B--- ---- ----", EF(l_jr), OR32_IF_DELAY }, -- { "l.jalr", "rB", "01 0x2 ----- ----- BBBB B--- ---- ----", EF(l_jalr), OR32_IF_DELAY }, -- { "l.maci", "rB,I", "01 0x3 IIIII ----- BBBB BIII IIII IIII", EF(l_mac), 0 }, -- { "l.cust1", "", "01 0xC ----- ----- ---- ---- ---- ----", EF(l_cust1), 0 }, -- { "l.cust2", "", "01 0xD ----- ----- ---- ---- ---- ----", EF(l_cust2), 0 }, -- { "l.cust3", "", "01 0xE ----- ----- ---- ---- ---- ----", EF(l_cust3), 0 }, -- { "l.cust4", "", "01 0xF ----- ----- ---- ---- ---- ----", EF(l_cust4), 0 }, -- -- { "l.ld", "rD,I(rA)", "10 0x0 DDDDD AAAAA IIII IIII IIII IIII", EFI, 0 }, -- { "l.lwz", "rD,I(rA)", "10 0x1 DDDDD AAAAA IIII IIII IIII IIII", EF(l_lwz), 0 }, -- { "l.lws", "rD,I(rA)", "10 0x2 DDDDD AAAAA IIII IIII IIII IIII", EFI, 0 }, -- { "l.lbz", "rD,I(rA)", "10 0x3 DDDDD AAAAA IIII IIII IIII IIII", EF(l_lbz), 0 }, -- { "l.lbs", "rD,I(rA)", "10 0x4 DDDDD AAAAA IIII IIII IIII IIII", EF(l_lbs), 0 }, -- { "l.lhz", "rD,I(rA)", "10 0x5 DDDDD AAAAA IIII IIII IIII IIII", EF(l_lhz), 0 }, -- { "l.lhs", "rD,I(rA)", "10 0x6 DDDDD AAAAA IIII IIII IIII IIII", EF(l_lhs), 0 }, -- -- { "l.addi", "rD,rA,I", "10 0x7 DDDDD AAAAA IIII IIII IIII IIII", EF(l_add), 0 }, -- { "l.addic", "rD,rA,I", "10 0x8 DDDDD AAAAA IIII IIII IIII IIII", EFI, 0 }, -- { "l.andi", "rD,rA,K", "10 0x9 DDDDD AAAAA KKKK KKKK KKKK KKKK", EF(l_and), 0 }, -- { "l.ori", "rD,rA,K", "10 0xA DDDDD AAAAA KKKK KKKK KKKK KKKK", EF(l_or), 0 }, -- { "l.xori", "rD,rA,I", "10 0xB DDDDD AAAAA IIII IIII IIII IIII", EF(l_xor), 0 }, -- { "l.muli", "rD,rA,I", "10 0xC DDDDD AAAAA IIII IIII IIII IIII", EFI, 0 }, -- { "l.mfspr", "rD,rA,K", "10 0xD DDDDD AAAAA KKKK KKKK KKKK KKKK", EF(l_mfspr), 0 }, -- { "l.slli", "rD,rA,L", "10 0xE DDDDD AAAAA ---- ---- 00LL LLLL", EF(l_sll), 0 }, -- { "l.srli", "rD,rA,L", "10 0xE DDDDD AAAAA ---- ---- 01LL LLLL", EF(l_srl), 0 }, -- { "l.srai", "rD,rA,L", "10 0xE DDDDD AAAAA ---- ---- 10LL LLLL", EF(l_sra), 0 }, -- { "l.rori", "rD,rA,L", "10 0xE DDDDD AAAAA ---- ---- 11LL LLLL", EFI, 0 }, -- -- { "l.sfeqi", "rA,I", "10 0xF 00000 AAAAA IIII IIII IIII IIII", EF(l_sfeq), OR32_W_FLAG }, -- { "l.sfnei", "rA,I", "10 0xF 00001 AAAAA IIII IIII IIII IIII", EF(l_sfne), OR32_W_FLAG }, -- { "l.sfgtui", "rA,I", "10 0xF 00010 AAAAA IIII IIII IIII IIII", EF(l_sfgtu), OR32_W_FLAG }, -- { "l.sfgeui", "rA,I", "10 0xF 00011 AAAAA IIII IIII IIII IIII", EF(l_sfgeu), OR32_W_FLAG }, -- { "l.sfltui", "rA,I", "10 0xF 00100 AAAAA IIII IIII IIII IIII", EF(l_sfltu), OR32_W_FLAG }, -- { "l.sfleui", "rA,I", "10 0xF 00101 AAAAA IIII IIII IIII IIII", EF(l_sfleu), OR32_W_FLAG }, -- { "l.sfgtsi", "rA,I", "10 0xF 01010 AAAAA IIII IIII IIII IIII", EF(l_sfgts), OR32_W_FLAG }, -- { "l.sfgesi", "rA,I", "10 0xF 01011 AAAAA IIII IIII IIII IIII", EF(l_sfges), OR32_W_FLAG }, -- { "l.sfltsi", "rA,I", "10 0xF 01100 AAAAA IIII IIII IIII IIII", EF(l_sflts), OR32_W_FLAG }, -- { "l.sflesi", "rA,I", "10 0xF 01101 AAAAA IIII IIII IIII IIII", EF(l_sfles), OR32_W_FLAG }, -- -- { "l.mtspr", "rA,rB,K", "11 0x0 KKKKK AAAAA BBBB BKKK KKKK KKKK", EF(l_mtspr), 0 }, -- { "l.mac", "rA,rB", "11 0x1 ----- AAAAA BBBB B--- ---- 0x1", EF(l_mac), 0 }, /*MM*/ -- { "l.msb", "rA,rB", "11 0x1 ----- AAAAA BBBB B--- ---- 0x2", EF(l_msb), 0 }, /*MM*/ -- -- { "l.sd", "I(rA),rB", "11 0x4 IIIII AAAAA BBBB BIII IIII IIII", EFI, 0 }, -- { "l.sw", "I(rA),rB", "11 0x5 IIIII AAAAA BBBB BIII IIII IIII", EF(l_sw), 0 }, -- { "l.sb", "I(rA),rB", "11 0x6 IIIII AAAAA BBBB BIII IIII IIII", EF(l_sb), 0 }, -- { "l.sh", "I(rA),rB", "11 0x7 IIIII AAAAA BBBB BIII IIII IIII", EF(l_sh), 0 }, -- -- { "l.add", "rD,rA,rB", "11 0x8 DDDDD AAAAA BBBB B-00 ---- 0x0", EF(l_add), 0 }, -- { "l.addc", "rD,rA,rB", "11 0x8 DDDDD AAAAA BBBB B-00 ---- 0x1", EFI, 0 }, -- { "l.sub", "rD,rA,rB", "11 0x8 DDDDD AAAAA BBBB B-00 ---- 0x2", EF(l_sub), 0 }, -- { "l.and", "rD,rA,rB", "11 0x8 DDDDD AAAAA BBBB B-00 ---- 0x3", EF(l_and), 0 }, -- { "l.or", "rD,rA,rB", "11 0x8 DDDDD AAAAA BBBB B-00 ---- 0x4", EF(l_or), 0 }, -- { "l.xor", "rD,rA,rB", "11 0x8 DDDDD AAAAA BBBB B-00 ---- 0x5", EF(l_xor), 0 }, -- { "l.mul", "rD,rA,rB", "11 0x8 DDDDD AAAAA BBBB B-11 ---- 0x6", EF(l_mul), 0 }, -- -- { "l.sll", "rD,rA,rB", "11 0x8 DDDDD AAAAA BBBB B-00 00-- 0x8", EF(l_sll), 0 }, -- { "l.srl", "rD,rA,rB", "11 0x8 DDDDD AAAAA BBBB B-00 01-- 0x8", EF(l_srl), 0 }, -- { "l.sra", "rD,rA,rB", "11 0x8 DDDDD AAAAA BBBB B-00 10-- 0x8", EF(l_sra), 0 }, -- { "l.ror", "rD,rA,rB", "11 0x8 DDDDD AAAAA BBBB B-00 11-- 0x8", EFI, 0 }, -- { "l.div", "rD,rA,rB", "11 0x8 DDDDD AAAAA BBBB B-00 ---- 0x9", EF(l_div), 0 }, -- { "l.divu", "rD,rA,rB", "11 0x8 DDDDD AAAAA BBBB B-00 ---- 0xA", EF(l_divu), 0 }, -- { "l.mulu", "rD,rA,rB", "11 0x8 DDDDD AAAAA BBBB B-11 ---- 0xB", EFI, 0 }, -- { "l.exths", "rD,rA,rB", "11 0x8 DDDDD AAAAA BBBB B-00 00-- 0xC", EFI, 0 }, -- { "l.extbs", "rD,rA,rB", "11 0x8 DDDDD AAAAA BBBB B-00 01-- 0xC", EFI, 0 }, -- { "l.exthz", "rD,rA,rB", "11 0x8 DDDDD AAAAA BBBB B-00 10-- 0xC", EFI, 0 }, -- { "l.extbz", "rD,rA,rB", "11 0x8 DDDDD AAAAA BBBB B-00 11-- 0xC", EFI, 0 }, -- { "l.extws", "rD,rA,rB", "11 0x8 DDDDD AAAAA BBBB B-00 00-- 0xD", EFI, 0 }, -- { "l.extwz", "rD,rA,rB", "11 0x8 DDDDD AAAAA BBBB B-00 01-- 0xD", EFI, 0 }, -- { "l.cmov", "rD,rA,rB", "11 0x8 DDDDD AAAAA BBBB B-00 ---- 0xE", EFI, 0 }, -- { "l.ff1", "rD,rA,rB", "11 0x8 DDDDD AAAAA BBBB B-00 ---- 0xF", EFI, 0 }, -- -- { "l.sfeq", "rA,rB", "11 0x9 00000 AAAAA BBBB B--- ---- ----", EF(l_sfeq), OR32_W_FLAG }, -- { "l.sfne", "rA,rB", "11 0x9 00001 AAAAA BBBB B--- ---- ----", EF(l_sfne), OR32_W_FLAG }, -- { "l.sfgtu", "rA,rB", "11 0x9 00010 AAAAA BBBB B--- ---- ----", EF(l_sfgtu), OR32_W_FLAG }, -- { "l.sfgeu", "rA,rB", "11 0x9 00011 AAAAA BBBB B--- ---- ----", EF(l_sfgeu), OR32_W_FLAG }, -- { "l.sfltu", "rA,rB", "11 0x9 00100 AAAAA BBBB B--- ---- ----", EF(l_sfltu), OR32_W_FLAG }, -- { "l.sfleu", "rA,rB", "11 0x9 00101 AAAAA BBBB B--- ---- ----", EF(l_sfleu), OR32_W_FLAG }, -- { "l.sfgts", "rA,rB", "11 0x9 01010 AAAAA BBBB B--- ---- ----", EF(l_sfgts), OR32_W_FLAG }, -- { "l.sfges", "rA,rB", "11 0x9 01011 AAAAA BBBB B--- ---- ----", EF(l_sfges), OR32_W_FLAG }, -- { "l.sflts", "rA,rB", "11 0x9 01100 AAAAA BBBB B--- ---- ----", EF(l_sflts), OR32_W_FLAG }, -- { "l.sfles", "rA,rB", "11 0x9 01101 AAAAA BBBB B--- ---- ----", EF(l_sfles), OR32_W_FLAG }, -- -- { "l.cust5", "", "11 0xC ----- ----- ---- ---- ---- ----", EFI, 0 }, -- { "l.cust6", "", "11 0xD ----- ----- ---- ---- ---- ----", EFI, 0 }, -- { "l.cust7", "", "11 0xE ----- ----- ---- ---- ---- ----", EFI, 0 }, -- { "l.cust8", "", "11 0xF ----- ----- ---- ---- ---- ----", EFI, 0 }, -- -- /* This section should not be defined in or1ksim, since it contains duplicates, -- which would cause machine builder to complain. */ --#ifdef HAS_CUST -- { "l.cust5_1", "rD", "11 0xC DDDDD ----- ---- ---- ---- ----", EFI, 0 }, -- { "l.cust5_2", "rD,rA" , "11 0xC DDDDD AAAAA ---- ---- ---- ----", EFI, 0 }, -- { "l.cust5_3", "rD,rA,rB", "11 0xC DDDDD AAAAA BBBB B--- ---- ----", EFI, 0 }, -- -- { "l.cust6_1", "rD", "11 0xD DDDDD ----- ---- ---- ---- ----", EFI, 0 }, -- { "l.cust6_2", "rD,rA" , "11 0xD DDDDD AAAAA ---- ---- ---- ----", EFI, 0 }, -- { "l.cust6_3", "rD,rA,rB", "11 0xD DDDDD AAAAA BBBB B--- ---- ----", EFI, 0 }, -- -- { "l.cust7_1", "rD", "11 0xE DDDDD ----- ---- ---- ---- ----", EFI, 0 }, -- { "l.cust7_2", "rD,rA" , "11 0xE DDDDD AAAAA ---- ---- ---- ----", EFI, 0 }, -- { "l.cust7_3", "rD,rA,rB", "11 0xE DDDDD AAAAA BBBB B--- ---- ----", EFI, 0 }, -- -- { "l.cust8_1", "rD", "11 0xF DDDDD ----- ---- ---- ---- ----", EFI, 0 }, -- { "l.cust8_2", "rD,rA" , "11 0xF DDDDD AAAAA ---- ---- ---- ----", EFI, 0 }, -- { "l.cust8_3", "rD,rA,rB", "11 0xF DDDDD AAAAA BBBB B--- ---- ----", EFI, 0 }, --#endif -- -- /* Dummy entry, not included in num_opcodes. This -- lets code examine entry i+1 without checking -- if we've run off the end of the table. */ -- { "", "", "", EFI, 0 } --}; -- --#undef EFI --#undef EFN --#undef EF -- --/* Define dummy, if debug is not defined. */ -- --#if !defined HAS_DEBUG --static void ATTRIBUTE_PRINTF_2 --debug (int level ATTRIBUTE_UNUSED, const char *format ATTRIBUTE_UNUSED, ...) --{ --} --#endif -- --const unsigned int or32_num_opcodes = ((sizeof(or32_opcodes)) / (sizeof(struct or32_opcode))) - 1; -- --/* Calculates instruction length in bytes. Always 4 for OR32. */ -- --int --insn_len (int i_index ATTRIBUTE_UNUSED) --{ -- return 4; --} -- --/* Is individual insn's operand signed or unsigned? */ -- --int --letter_signed (char l) --{ -- const struct or32_letter *pletter; -- -- for (pletter = or32_letters; pletter->letter != '\0'; pletter++) -- if (pletter->letter == l) -- return pletter->sign; -- -- printf ("letter_signed(%c): Unknown letter.\n", l); -- return 0; --} -- --/* Number of letters in the individual lettered operand. */ -- --int --letter_range (char l) --{ -- const struct or32_opcode *pinsn; -- char *enc; -- int range = 0; -- -- for (pinsn = or32_opcodes; strlen (pinsn->name); pinsn ++) -- { -- if (strchr (pinsn->encoding,l)) -- { -- for (enc = pinsn->encoding; *enc != '\0'; enc ++) -- if ((*enc == '0') && (*(enc + 1) == 'x')) -- enc += 2; -- else if (*enc == l) -- range++; -- return range; -- } -- } -- -- printf ("\nABORT: letter_range(%c): Never used letter.\n", l); -- exit (1); --} -- --/* MM: Returns index of given instruction name. */ -- --int --insn_index (char *insn) --{ -- unsigned int i; -- int found = -1; -- -- for (i = 0; i < or32_num_opcodes; i++) -- if (!strcmp (or32_opcodes[i].name, insn)) -- { -- found = i; -- break; -- } -- return found; --} -- --const char * --insn_name (int op_index) --{ -- if (op_index >= 0 && op_index < (int) or32_num_opcodes) -- return or32_opcodes[op_index].name; -- else -- return "???"; --} -- --void --l_none (void) --{ --} -- --/* Finite automata for instruction decoding building code. */ -- --/* Find simbols in encoding. */ -- --static unsigned long --insn_extract (char param_ch, char *enc_initial) --{ -- char *enc; -- unsigned long ret = 0; -- unsigned opc_pos = 32; -- -- for (enc = enc_initial; *enc != '\0'; ) -- if ((*enc == '0') && (*(enc + 1) == 'x')) -- { -- unsigned long tmp = strtol (enc+2, NULL, 16); -- -- opc_pos -= 4; -- if (param_ch == '0' || param_ch == '1') -- { -- if (param_ch == '0') -- tmp = 15 - tmp; -- ret |= tmp << opc_pos; -- } -- enc += 3; -- } -- else -- { -- if (*enc == '0' || *enc == '1' || *enc == '-' || ISALPHA (*enc)) -- { -- opc_pos--; -- if (param_ch == *enc) -- ret |= 1 << opc_pos; -- } -- enc++; -- } -- return ret; --} -- --#define MAX_AUTOMATA_SIZE 1200 --#define MAX_OP_TABLE_SIZE 1200 --#define LEAF_FLAG 0x80000000 --#define MAX_LEN 8 -- --#ifndef MIN --#define MIN(x, y) ((x) < (y) ? (x) : (y)) --#endif -- --unsigned long *automata; --int nuncovered; --int curpass = 0; -- --/* MM: Struct that hold runtime build information about instructions. */ --struct temp_insn_struct --{ -- unsigned long insn; -- unsigned long insn_mask; -- int in_pass; --} *ti; -- --struct insn_op_struct *op_data, **op_start; -- --/* Recursive utility function used to find best match and to build automata. */ -- --static unsigned long * --cover_insn (unsigned long * cur, int pass, unsigned int mask) --{ -- int best_first = 0, last_match = -1, ninstr = 0; -- unsigned int best_len = 0; -- unsigned int i; -- unsigned long cur_mask = mask; -- unsigned long *next; -- -- for (i = 0; i < or32_num_opcodes; i++) -- if (ti[i].in_pass == pass) -- { -- cur_mask &= ti[i].insn_mask; -- ninstr++; -- last_match = i; -- } -- -- debug (8, "%08X %08lX\n", mask, cur_mask); -- -- if (ninstr == 0) -- return 0; -- -- if (ninstr == 1) -- { -- /* Leaf holds instruction index. */ -- debug (8, "%li>I%i %s\n", -- (long)(cur - automata), last_match, or32_opcodes[last_match].name); -- -- *cur = LEAF_FLAG | last_match; -- cur++; -- nuncovered--; -- } -- else -- { -- /* Find longest match. */ -- for (i = 0; i < 32; i++) -- { -- unsigned int len; -- -- for (len = best_len + 1; len < MIN (MAX_LEN, 33 - i); len++) -- { -- unsigned long m = (1UL << ((unsigned long) len)) - 1; -- -- debug (9, " (%i(%08lX & %08lX>>%i = %08lX, %08lX)", -- len,m, cur_mask, i, (cur_mask >> (unsigned)i), -- (cur_mask >> (unsigned) i) & m); -- -- if ((m & (cur_mask >> (unsigned) i)) == m) -- { -- best_len = len; -- best_first = i; -- debug (9, "!"); -- } -- else -- break; -- } -- } -- -- debug (9, "\n"); -- -- if (!best_len) -- { -- fprintf (stderr, "%i instructions match mask 0x%08X:\n", ninstr, mask); -- -- for (i = 0; i < or32_num_opcodes; i++) -- if (ti[i].in_pass == pass) -- fprintf (stderr, "%s ", or32_opcodes[i].name); -- -- fprintf (stderr, "\n"); -- exit (1); -- } -- -- debug (8, "%li> #### %i << %i (%i) ####\n", -- (long)(cur - automata), best_len, best_first, ninstr); -- -- *cur = best_first; -- cur++; -- *cur = (1 << best_len) - 1; -- cur++; -- next = cur; -- -- /* Allocate space for pointers. */ -- cur += 1 << best_len; -- cur_mask = (1 << (unsigned long) best_len) - 1; -- -- for (i = 0; i < ((unsigned) 1 << best_len); i++) -- { -- unsigned int j; -- unsigned long *c; -- -- curpass++; -- for (j = 0; j < or32_num_opcodes; j++) -- if (ti[j].in_pass == pass -- && ((ti[j].insn >> best_first) & cur_mask) == (unsigned long) i -- && ((ti[j].insn_mask >> best_first) & cur_mask) == cur_mask) -- ti[j].in_pass = curpass; -- -- debug (9, "%08X %08lX %i\n", mask, cur_mask, best_first); -- c = cover_insn (cur, curpass, mask & (~(cur_mask << best_first))); -- if (c) -- { -- debug (8, "%li> #%X -> %lu\n", (long)(next - automata), i, -- (unsigned long)(cur - automata)); -- *next = cur - automata; -- cur = c; -- } -- else -- { -- debug (8, "%li> N/A\n", (long)(next - automata)); -- *next = 0; -- } -- next++; -- } -- } -- return cur; --} -- --/* Returns number of nonzero bits. */ -- --static int --num_ones (unsigned long value) --{ -- int c = 0; -- -- while (value) -- { -- if (value & 1) -- c++; -- value >>= 1; -- } -- return c; --} -- --/* Utility function, which converts parameters from or32_opcode -- format to more binary form. Parameters are stored in ti struct. */ -- --static struct insn_op_struct * --parse_params (const struct or32_opcode * opcode, -- struct insn_op_struct * cur) --{ -- char *args = opcode->args; -- int i, type; -- -- i = 0; -- type = 0; -- /* In case we don't have any parameters, we add dummy read from r0. */ -- -- if (!(*args)) -- { -- cur->type = OPTYPE_REG | OPTYPE_OP | OPTYPE_LAST; -- cur->data = 0; -- debug (9, "#%08lX %08lX\n", cur->type, cur->data); -- cur++; -- return cur; -- } -- -- while (*args != '\0') -- { -- if (*args == 'r') -- { -- args++; -- type |= OPTYPE_REG; -- } -- else if (ISALPHA (*args)) -- { -- unsigned long arg; -- -- arg = insn_extract (*args, opcode->encoding); -- debug (9, "%s : %08lX ------\n", opcode->name, arg); -- if (letter_signed (*args)) -- { -- type |= OPTYPE_SIG; -- type |= ((num_ones (arg) - 1) << OPTYPE_SBIT_SHR) & OPTYPE_SBIT; -- } -- -- /* Split argument to sequences of consecutive ones. */ -- while (arg) -- { -- int shr = 0; -- unsigned long tmp = arg, mask = 0; -- -- while ((tmp & 1) == 0) -- { -- shr++; -- tmp >>= 1; -- } -- while (tmp & 1) -- { -- mask++; -- tmp >>= 1; -- } -- cur->type = type | shr; -- cur->data = mask; -- arg &= ~(((1 << mask) - 1) << shr); -- debug (6, "|%08lX %08lX\n", cur->type, cur->data); -- cur++; -- } -- args++; -- } -- else if (*args == '(') -- { -- /* Next param is displacement. -- Later we will treat them as one operand. */ -- cur--; -- cur->type = type | cur->type | OPTYPE_DIS | OPTYPE_OP; -- debug (9, ">%08lX %08lX\n", cur->type, cur->data); -- cur++; -- type = 0; -- i++; -- args++; -- } -- else if (*args == OPERAND_DELIM) -- { -- cur--; -- cur->type = type | cur->type | OPTYPE_OP; -- debug (9, ">%08lX %08lX\n", cur->type, cur->data); -- cur++; -- type = 0; -- i++; -- args++; -- } -- else if (*args == '0') -- { -- cur->type = type; -- cur->data = 0; -- debug (9, ">%08lX %08lX\n", cur->type, cur->data); -- cur++; -- type = 0; -- i++; -- args++; -- } -- else if (*args == ')') -- args++; -- else -- { -- fprintf (stderr, "%s : parse error in args.\n", opcode->name); -- exit (1); -- } -- } -- -- cur--; -- cur->type = type | cur->type | OPTYPE_OP | OPTYPE_LAST; -- debug (9, "#%08lX %08lX\n", cur->type, cur->data); -- cur++; -- -- return cur; --} -- --/* Constructs new automata based on or32_opcodes array. */ -- --void --build_automata (void) --{ -- unsigned int i; -- unsigned long *end; -- struct insn_op_struct *cur; -- -- automata = malloc (MAX_AUTOMATA_SIZE * sizeof (unsigned long)); -- ti = malloc (sizeof (struct temp_insn_struct) * or32_num_opcodes); -- -- nuncovered = or32_num_opcodes; -- printf ("Building automata... "); -- /* Build temporary information about instructions. */ -- for (i = 0; i < or32_num_opcodes; i++) -- { -- unsigned long ones, zeros; -- char *encoding = or32_opcodes[i].encoding; -- -- ones = insn_extract('1', encoding); -- zeros = insn_extract('0', encoding); -- -- ti[i].insn_mask = ones | zeros; -- ti[i].insn = ones; -- ti[i].in_pass = curpass = 0; -- -- /*debug(9, "%s: %s %08X %08X\n", or32_opcodes[i].name, -- or32_opcodes[i].encoding, ti[i].insn_mask, ti[i].insn);*/ -- } -- -- /* Until all are covered search for best criteria to separate them. */ -- end = cover_insn (automata, curpass, 0xFFFFFFFF); -- -- if (end - automata > MAX_AUTOMATA_SIZE) -- { -- fprintf (stderr, "Automata too large. Increase MAX_AUTOMATA_SIZE."); -- exit (1); -- } -- -- printf ("done, num uncovered: %i/%i.\n", nuncovered, or32_num_opcodes); -- printf ("Parsing operands data... "); -- -- op_data = malloc (MAX_OP_TABLE_SIZE * sizeof (struct insn_op_struct)); -- op_start = malloc (or32_num_opcodes * sizeof (struct insn_op_struct *)); -- cur = op_data; -- -- for (i = 0; i < or32_num_opcodes; i++) -- { -- op_start[i] = cur; -- cur = parse_params (&or32_opcodes[i], cur); -- -- if (cur - op_data > MAX_OP_TABLE_SIZE) -- { -- fprintf (stderr, "Operands table too small, increase MAX_OP_TABLE_SIZE.\n"); -- exit (1); -- } -- } -- printf ("done.\n"); --} -- --void --destruct_automata (void) --{ -- free (ti); -- free (automata); -- free (op_data); -- free (op_start); --} -- --/* Decodes instruction and returns instruction index. */ -- --int --insn_decode (unsigned int insn) --{ -- unsigned long *a = automata; -- int i; -- -- while (!(*a & LEAF_FLAG)) -- { -- unsigned int first = *a; -- -- debug (9, "%li ", (long)(a - automata)); -- -- a++; -- i = (insn >> first) & *a; -- a++; -- if (!*(a + i)) -- { -- /* Invalid instruction found? */ -- debug (9, "XXX\n"); -- return -1; -- } -- a = automata + *(a + i); -- } -- -- i = *a & ~LEAF_FLAG; -- -- debug (9, "%i\n", i); -- -- /* Final check - do we have direct match? -- (based on or32_opcodes this should be the only possibility, -- but in case of invalid/missing instruction we must perform a check) */ -- if ((ti[i].insn_mask & insn) == ti[i].insn) -- return i; -- else -- return -1; --} -- --static char disassembled_str[50]; --char *disassembled = &disassembled_str[0]; -- --/* Automagically does zero- or sign- extension and also finds correct -- sign bit position if sign extension is correct extension. Which extension -- is proper is figured out from letter description. */ -- --static unsigned long --extend_imm (unsigned long imm, char l) --{ -- unsigned long mask; -- int letter_bits; -- -- /* First truncate all bits above valid range for this letter -- in case it is zero extend. */ -- letter_bits = letter_range (l); -- mask = (1 << letter_bits) - 1; -- imm &= mask; -- -- /* Do sign extend if this is the right one. */ -- if (letter_signed(l) && (imm >> (letter_bits - 1))) -- imm |= (~mask); -- -- return imm; --} -- --static unsigned long --or32_extract (char param_ch, char *enc_initial, unsigned long insn) --{ -- char *enc; -- unsigned long ret = 0; -- int opc_pos = 0; -- int param_pos = 0; -- -- for (enc = enc_initial; *enc != '\0'; enc++) -- if (*enc == param_ch) -- { -- if (enc - 2 >= enc_initial && (*(enc - 2) == '0') && (*(enc - 1) == 'x')) -- continue; -- else -- param_pos++; -- } -- --#if DEBUG -- printf ("or32_extract: %x ", param_pos); --#endif -- opc_pos = 32; -- -- for (enc = enc_initial; *enc != '\0'; ) -- if ((*enc == '0') && (*(enc + 1) == 'x')) -- { -- opc_pos -= 4; -- if ((param_ch == '0') || (param_ch == '1')) -- { -- unsigned long tmp = strtol (enc, NULL, 16); --#if DEBUG -- printf (" enc=%s, tmp=%lx ", enc, tmp); --#endif -- if (param_ch == '0') -- tmp = 15 - tmp; -- ret |= tmp << opc_pos; -- } -- enc += 3; -- } -- else if ((*enc == '0') || (*enc == '1')) -- { -- opc_pos--; -- if (param_ch == *enc) -- ret |= 1 << opc_pos; -- enc++; -- } -- else if (*enc == param_ch) -- { -- opc_pos--; -- param_pos--; --#if DEBUG -- printf ("\n ret=%lx opc_pos=%x, param_pos=%x\n", ret, opc_pos, param_pos); --#endif -- if (ISLOWER (param_ch)) -- ret -= ((insn >> opc_pos) & 0x1) << param_pos; -- else -- ret += ((insn >> opc_pos) & 0x1) << param_pos; -- enc++; -- } -- else if (ISALPHA (*enc)) -- { -- opc_pos--; -- enc++; -- } -- else if (*enc == '-') -- { -- opc_pos--; -- enc++; -- } -- else -- enc++; -- --#if DEBUG -- printf ("ret=%lx\n", ret); --#endif -- return ret; --} -- --/* Print register. Used only by print_insn. */ -- --static void --or32_print_register (char param_ch, char *encoding, unsigned long insn) --{ -- int regnum = or32_extract(param_ch, encoding, insn); -- char s_regnum[20]; -- -- sprintf (s_regnum, "r%d", regnum); -- strcat (disassembled, s_regnum); --} -- --/* Print immediate. Used only by print_insn. */ -- --static void --or32_print_immediate (char param_ch, char *encoding, unsigned long insn) --{ -- int imm = or32_extract (param_ch, encoding, insn); -- char s_imm[20]; -- -- imm = extend_imm (imm, param_ch); -- -- if (letter_signed (param_ch)) -- { -- if (imm < 0) -- sprintf (s_imm, "%d", imm); -- else -- sprintf (s_imm, "0x%x", imm); -- } -- else -- sprintf (s_imm, "%#x", imm); -- strcat (disassembled, s_imm); --} -- --/* Disassemble one instruction from insn to disassemble. -- Return the size of the instruction. */ -- --int --disassemble_insn (unsigned long insn) --{ -- int op_index; -- op_index = insn_decode (insn); -- -- if (op_index >= 0) -- { -- struct or32_opcode const *opcode = &or32_opcodes[op_index]; -- char *s; -- -- sprintf (disassembled, "%s ", opcode->name); -- for (s = opcode->args; *s != '\0'; ++s) -- { -- switch (*s) -- { -- case '\0': -- return 4; -- -- case 'r': -- or32_print_register (*++s, opcode->encoding, insn); -- break; -- -- default: -- if (strchr (opcode->encoding, *s)) -- or32_print_immediate (*s, opcode->encoding, insn); -- else -- { -- char s_encoding[2] = { *s, '\0' }; -- -- strcat (disassembled, s_encoding); -- } -- -- } -- } -- } -- else -- { -- char s_insn[20]; -- -- /* This used to be %8x for binutils. */ -- sprintf (s_insn, ".word 0x%08lx", insn); -- strcat (disassembled, s_insn); -- } -- -- return insn_len (insn); --} -diff -rNU3 dist.orig/opcodes/riscv-dis.c dist/opcodes/riscv-dis.c ---- dist.orig/opcodes/riscv-dis.c 1970-01-01 01:00:00.000000000 +0100 -+++ dist/opcodes/riscv-dis.c 2015-10-18 13:11:20.000000000 +0200 -@@ -0,0 +1,492 @@ -+/* RISC-V disassembler -+ Copyright 2011-2014 Free Software Foundation, Inc. -+ -+ Contributed by Andrew Waterman (waterman@cs.berkeley.edu) at UC Berkeley. -+ Based on MIPS target. -+ -+ This file is part of the GNU opcodes library. -+ -+ This library is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3, or (at your option) -+ any later version. -+ -+ It is distributed in the hope that it will be useful, but WITHOUT -+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -+ License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this program; if not, write to the Free Software -+ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, -+ MA 02110-1301, USA. */ -+ -+#include "sysdep.h" -+#include "dis-asm.h" -+#include "libiberty.h" -+#include "opcode/riscv.h" -+#include "opintl.h" -+#include "elf-bfd.h" -+#include "elf/riscv.h" -+ -+#include -+#include -+ -+struct riscv_private_data -+{ -+ bfd_vma gp; -+ bfd_vma print_addr; -+ bfd_vma hi_addr[OP_MASK_RD + 1]; -+}; -+ -+static const char * const *riscv_gpr_names; -+static const char * const *riscv_fpr_names; -+ -+/* Other options */ -+static int no_aliases; /* If set disassemble as most general inst. */ -+ -+static void -+set_default_riscv_dis_options (void) -+{ -+ riscv_gpr_names = riscv_gpr_names_abi; -+ riscv_fpr_names = riscv_fpr_names_abi; -+ no_aliases = 0; -+} -+ -+static void -+parse_riscv_dis_option (const char *option) -+{ -+ if (CONST_STRNEQ (option, "no-aliases")) -+ no_aliases = 1; -+ else if (CONST_STRNEQ (option, "numeric")) -+ { -+ riscv_gpr_names = riscv_gpr_names_numeric; -+ riscv_fpr_names = riscv_fpr_names_numeric; -+ } -+ -+ /* Invalid option. */ -+ fprintf (stderr, _("Unrecognized disassembler option: %s\n"), option); -+} -+ -+static void -+parse_riscv_dis_options (const char *opts_in) -+{ -+ char *opts = xstrdup (opts_in), *opt = opts, *opt_end = opts; -+ -+ set_default_riscv_dis_options (); -+ -+ for ( ; opt_end != NULL; opt = opt_end + 1) -+ { -+ if ((opt_end = strchr (opt, ',')) != NULL) -+ *opt_end = 0; -+ parse_riscv_dis_option (opt); -+ } -+ -+ free (opts); -+} -+ -+/* Print one argument from an array. */ -+ -+static void -+arg_print (struct disassemble_info *info, unsigned long val, -+ const char* const* array, size_t size) -+{ -+ const char *s = val >= size || array[val] == NULL ? "unknown" : array[val]; -+ (*info->fprintf_func) (info->stream, "%s", s); -+} -+ -+static void -+maybe_print_address (struct riscv_private_data *pd, int base_reg, int offset) -+{ -+ if (pd->hi_addr[base_reg] != (bfd_vma)-1) -+ { -+ pd->print_addr = pd->hi_addr[base_reg] + offset; -+ pd->hi_addr[base_reg] = -1; -+ } -+ else if (base_reg == X_GP && pd->gp != (bfd_vma)-1) -+ pd->print_addr = pd->gp + offset; -+ else if (base_reg == X_TP) -+ pd->print_addr = offset; -+} -+ -+/* Print insn arguments for 32/64-bit code. */ -+ -+static void -+print_insn_args (const char *d, insn_t l, bfd_vma pc, disassemble_info *info) -+{ -+ struct riscv_private_data *pd = info->private_data; -+ int rs1 = (l >> OP_SH_RS1) & OP_MASK_RS1; -+ int rd = (l >> OP_SH_RD) & OP_MASK_RD; -+ -+ if (*d != '\0') -+ (*info->fprintf_func) (info->stream, "\t"); -+ -+ for (; *d != '\0'; d++) -+ { -+ switch (*d) -+ { -+ /* Xcustom */ -+ case '^': -+ switch (*++d) -+ { -+ case 'd': -+ (*info->fprintf_func) (info->stream, "%d", rd); -+ break; -+ case 's': -+ (*info->fprintf_func) (info->stream, "%d", rs1); -+ break; -+ case 't': -+ (*info->fprintf_func) -+ ( info->stream, "%d", (int)((l >> OP_SH_RS2) & OP_MASK_RS2)); -+ break; -+ case 'j': -+ (*info->fprintf_func) -+ ( info->stream, "%d", (int)((l >> OP_SH_CUSTOM_IMM) & OP_MASK_CUSTOM_IMM)); -+ break; -+ } -+ break; -+ -+ /* Xhwacha */ -+ case '#': -+ switch ( *++d ) { -+ case 'g': -+ (*info->fprintf_func) -+ ( info->stream, "%d", -+ (int)((l >> OP_SH_IMMNGPR) & OP_MASK_IMMNGPR)); -+ break; -+ case 'f': -+ (*info->fprintf_func) -+ ( info->stream, "%d", -+ (int)((l >> OP_SH_IMMNFPR) & OP_MASK_IMMNFPR)); -+ break; -+ case 'p': -+ (*info->fprintf_func) -+ ( info->stream, "%d", -+ (int)((l >> OP_SH_CUSTOM_IMM) & OP_MASK_CUSTOM_IMM)); -+ break; -+ case 'n': -+ (*info->fprintf_func) -+ ( info->stream, "%d", -+ (int)(((l >> OP_SH_IMMSEGNELM) & OP_MASK_IMMSEGNELM) + 1)); -+ break; -+ case 'd': -+ (*info->fprintf_func) -+ ( info->stream, "%s", -+ riscv_vec_gpr_names[(l >> OP_SH_VRD) & OP_MASK_VRD]); -+ break; -+ case 's': -+ (*info->fprintf_func) -+ ( info->stream, "%s", -+ riscv_vec_gpr_names[(l >> OP_SH_VRS) & OP_MASK_VRS]); -+ break; -+ case 't': -+ (*info->fprintf_func) -+ ( info->stream, "%s", -+ riscv_vec_gpr_names[(l >> OP_SH_VRT) & OP_MASK_VRT]); -+ break; -+ case 'r': -+ (*info->fprintf_func) -+ ( info->stream, "%s", -+ riscv_vec_gpr_names[(l >> OP_SH_VRR) & OP_MASK_VRR]); -+ break; -+ case 'D': -+ (*info->fprintf_func) -+ ( info->stream, "%s", -+ riscv_vec_fpr_names[(l >> OP_SH_VFD) & OP_MASK_VFD]); -+ break; -+ case 'S': -+ (*info->fprintf_func) -+ ( info->stream, "%s", -+ riscv_vec_fpr_names[(l >> OP_SH_VFS) & OP_MASK_VFS]); -+ break; -+ case 'T': -+ (*info->fprintf_func) -+ ( info->stream, "%s", -+ riscv_vec_fpr_names[(l >> OP_SH_VFT) & OP_MASK_VFT]); -+ break; -+ case 'R': -+ (*info->fprintf_func) -+ ( info->stream, "%s", -+ riscv_vec_fpr_names[(l >> OP_SH_VFR) & OP_MASK_VFR]); -+ break; -+ } -+ break; -+ -+ case ',': -+ case '(': -+ case ')': -+ case '[': -+ case ']': -+ (*info->fprintf_func) (info->stream, "%c", *d); -+ break; -+ -+ case '0': -+ break; -+ -+ case 'b': -+ case 's': -+ (*info->fprintf_func) (info->stream, "%s", riscv_gpr_names[rs1]); -+ break; -+ -+ case 't': -+ (*info->fprintf_func) (info->stream, "%s", -+ riscv_gpr_names[(l >> OP_SH_RS2) & OP_MASK_RS2]); -+ break; -+ -+ case 'u': -+ (*info->fprintf_func) (info->stream, "0x%x", (unsigned)EXTRACT_UTYPE_IMM (l) >> RISCV_IMM_BITS); -+ break; -+ -+ case 'm': -+ arg_print(info, (l >> OP_SH_RM) & OP_MASK_RM, -+ riscv_rm, ARRAY_SIZE(riscv_rm)); -+ break; -+ -+ case 'P': -+ arg_print(info, (l >> OP_SH_PRED) & OP_MASK_PRED, -+ riscv_pred_succ, ARRAY_SIZE(riscv_pred_succ)); -+ break; -+ -+ case 'Q': -+ arg_print(info, (l >> OP_SH_SUCC) & OP_MASK_SUCC, -+ riscv_pred_succ, ARRAY_SIZE(riscv_pred_succ)); -+ break; -+ -+ case 'o': -+ maybe_print_address (pd, rs1, EXTRACT_ITYPE_IMM (l)); -+ case 'j': -+ if ((l & MASK_ADDI) == MATCH_ADDI || (l & MASK_JALR) == MATCH_JALR) -+ maybe_print_address (pd, rs1, EXTRACT_ITYPE_IMM (l)); -+ (*info->fprintf_func) (info->stream, "%d", (int)EXTRACT_ITYPE_IMM (l)); -+ break; -+ -+ case 'q': -+ maybe_print_address (pd, rs1, EXTRACT_STYPE_IMM (l)); -+ (*info->fprintf_func) (info->stream, "%d", (int)EXTRACT_STYPE_IMM (l)); -+ break; -+ -+ case 'a': -+ info->target = EXTRACT_UJTYPE_IMM (l) + pc; -+ (*info->print_address_func) (info->target, info); -+ break; -+ -+ case 'p': -+ info->target = EXTRACT_SBTYPE_IMM (l) + pc; -+ (*info->print_address_func) (info->target, info); -+ break; -+ -+ case 'd': -+ if ((l & MASK_AUIPC) == MATCH_AUIPC) -+ pd->hi_addr[rd] = pc + EXTRACT_UTYPE_IMM (l); -+ else if ((l & MASK_LUI) == MATCH_LUI) -+ pd->hi_addr[rd] = EXTRACT_UTYPE_IMM (l); -+ (*info->fprintf_func) (info->stream, "%s", riscv_gpr_names[rd]); -+ break; -+ -+ case 'z': -+ (*info->fprintf_func) (info->stream, "%s", riscv_gpr_names[0]); -+ break; -+ -+ case '>': -+ (*info->fprintf_func) (info->stream, "0x%x", -+ (unsigned)((l >> OP_SH_SHAMT) & OP_MASK_SHAMT)); -+ break; -+ -+ case '<': -+ (*info->fprintf_func) (info->stream, "0x%x", -+ (unsigned)((l >> OP_SH_SHAMTW) & OP_MASK_SHAMTW)); -+ break; -+ -+ case 'S': -+ case 'U': -+ (*info->fprintf_func) (info->stream, "%s", riscv_fpr_names[rs1]); -+ break; -+ -+ case 'T': -+ (*info->fprintf_func) (info->stream, "%s", -+ riscv_fpr_names[(l >> OP_SH_RS2) & OP_MASK_RS2]); -+ break; -+ -+ case 'D': -+ (*info->fprintf_func) (info->stream, "%s", riscv_fpr_names[rd]); -+ break; -+ -+ case 'R': -+ (*info->fprintf_func) (info->stream, "%s", -+ riscv_fpr_names[(l >> OP_SH_RS3) & OP_MASK_RS3]); -+ break; -+ -+ case 'E': -+ { -+ const char* csr_name = NULL; -+ unsigned int csr = (l >> OP_SH_CSR) & OP_MASK_CSR; -+ switch (csr) -+ { -+ #define DECLARE_CSR(name, num) case num: csr_name = #name; break; -+ #include "opcode/riscv-opc.h" -+ #undef DECLARE_CSR -+ } -+ if (csr_name) -+ (*info->fprintf_func) (info->stream, "%s", csr_name); -+ else -+ (*info->fprintf_func) (info->stream, "0x%x", csr); -+ break; -+ } -+ -+ case 'Z': -+ (*info->fprintf_func) (info->stream, "%d", rs1); -+ break; -+ -+ default: -+ /* xgettext:c-format */ -+ (*info->fprintf_func) (info->stream, -+ _("# internal error, undefined modifier (%c)"), -+ *d); -+ return; -+ } -+ } -+} -+ -+/* Print the RISC-V instruction at address MEMADDR in debugged memory, -+ on using INFO. Returns length of the instruction, in bytes. -+ BIGENDIAN must be 1 if this is big-endian code, 0 if -+ this is little-endian code. */ -+ -+static int -+riscv_disassemble_insn (bfd_vma memaddr, insn_t word, disassemble_info *info) -+{ -+ const struct riscv_opcode *op; -+ static bfd_boolean init = 0; -+ static const char *extension = NULL; -+ static const struct riscv_opcode *riscv_hash[OP_MASK_OP + 1]; -+ struct riscv_private_data *pd; -+ int insnlen; -+ -+ /* Build a hash table to shorten the search time. */ -+ if (! init) -+ { -+ unsigned int i; -+ unsigned int e_flags = elf_elfheader (info->section->owner)->e_flags; -+ extension = riscv_elf_flag_to_name(EF_GET_RISCV_EXT(e_flags)); -+ -+ for (i = 0; i <= OP_MASK_OP; i++) -+ for (op = riscv_opcodes; op < &riscv_opcodes[NUMOPCODES]; op++) -+ if (i == ((op->match >> OP_SH_OP) & OP_MASK_OP)) -+ { -+ riscv_hash[i] = op; -+ break; -+ } -+ -+ init = 1; -+ } -+ -+ if (info->private_data == NULL) -+ { -+ int i; -+ -+ pd = info->private_data = calloc(1, sizeof (struct riscv_private_data)); -+ pd->gp = -1; -+ pd->print_addr = -1; -+ for (i = 0; i < (int) ARRAY_SIZE(pd->hi_addr); i++) -+ pd->hi_addr[i] = -1; -+ -+ for (i = 0; i < info->symtab_size; i++) -+ if (strcmp (bfd_asymbol_name (info->symtab[i]), "_gp") == 0) -+ pd->gp = bfd_asymbol_value (info->symtab[i]); -+ } -+ else -+ pd = info->private_data; -+ -+ insnlen = riscv_insn_length (word); -+ -+ info->bytes_per_chunk = insnlen % 4 == 0 ? 4 : 2; -+ info->bytes_per_line = 8; -+ info->display_endian = info->endian; -+ info->insn_info_valid = 1; -+ info->branch_delay_insns = 0; -+ info->data_size = 0; -+ info->insn_type = dis_nonbranch; -+ info->target = 0; -+ info->target2 = 0; -+ -+ op = riscv_hash[(word >> OP_SH_OP) & OP_MASK_OP]; -+ if (op != NULL) -+ { -+ for (; op < &riscv_opcodes[NUMOPCODES]; op++) -+ { -+ if ((op->match_func) (op, word) -+ && !(no_aliases && (op->pinfo & INSN_ALIAS)) -+ && !(op->subset[0] == 'X' && strcmp(op->subset, extension))) -+ { -+ (*info->fprintf_func) (info->stream, "%s", op->name); -+ print_insn_args (op->args, word, memaddr, info); -+ if (pd->print_addr != (bfd_vma)-1) -+ { -+ info->target = pd->print_addr; -+ (*info->fprintf_func) (info->stream, " # "); -+ (*info->print_address_func) (info->target, info); -+ pd->print_addr = -1; -+ } -+ return insnlen; -+ } -+ } -+ } -+ -+ /* Handle undefined instructions. */ -+ info->insn_type = dis_noninsn; -+ (*info->fprintf_func) (info->stream, "0x%llx", (unsigned long long)word); -+ return insnlen; -+} -+ -+int -+print_insn_riscv (bfd_vma memaddr, struct disassemble_info *info) -+{ -+ uint16_t i2; -+ insn_t insn = 0; -+ bfd_vma n; -+ int status; -+ -+ if (info->disassembler_options != NULL) -+ { -+ parse_riscv_dis_options (info->disassembler_options); -+ /* Avoid repeatedly parsing the options. */ -+ info->disassembler_options = NULL; -+ } -+ else if (riscv_gpr_names == NULL) -+ set_default_riscv_dis_options (); -+ -+ /* Instructions are a sequence of 2-byte packets in little-endian order. */ -+ for (n = 0; n < sizeof(insn) && n < riscv_insn_length (insn); n += 2) -+ { -+ status = (*info->read_memory_func) (memaddr + n, (bfd_byte*)&i2, 2, info); -+ if (status != 0) -+ { -+ if (n > 0) /* Don't fail just because we fell off the end. */ -+ break; -+ (*info->memory_error_func) (status, memaddr, info); -+ return status; -+ } -+ -+ i2 = bfd_getl16 (&i2); -+ insn |= (insn_t)i2 << (8*n); -+ } -+ -+ return riscv_disassemble_insn (memaddr, insn, info); -+} -+ -+void -+print_riscv_disassembler_options (FILE *stream) -+{ -+ fprintf (stream, _("\n\ -+The following RISC-V-specific disassembler options are supported for use\n\ -+with the -M switch (multiple options should be separated by commas):\n")); -+ -+ fprintf (stream, _("\n\ -+ numeric Print numeric reigster names, rather than ABI names.\n")); -+ -+ fprintf (stream, _("\n\ -+ no-aliases Disassemble only into canonical instructions, rather\n\ -+ than into pseudoinstructions.\n")); -+ -+ fprintf (stream, _("\n")); -+} -diff -rNU3 dist.orig/opcodes/riscv-opc.c dist/opcodes/riscv-opc.c ---- dist.orig/opcodes/riscv-opc.c 1970-01-01 01:00:00.000000000 +0100 -+++ dist/opcodes/riscv-opc.c 2015-10-18 13:11:20.000000000 +0200 -@@ -0,0 +1,734 @@ -+/* RISC-V opcode list -+ Copyright 2011-2014 Free Software Foundation, Inc. -+ -+ Contributed by Andrew Waterman (waterman@cs.berkeley.edu) at UC Berkeley. -+ Based on MIPS target. -+ -+ This file is part of the GNU opcodes library. -+ -+ This library is free software; you can redistribute it and/or modify -+ it under the terms of the GNU General Public License as published by -+ the Free Software Foundation; either version 3, or (at your option) -+ any later version. -+ -+ It is distributed in the hope that it will be useful, but WITHOUT -+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -+ License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with this file; see the file COPYING. If not, write to the -+ Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston, -+ MA 02110-1301, USA. */ -+ -+#include "sysdep.h" -+#include "opcode/riscv.h" -+#include -+ -+/* Register names used by gas and objdump. */ -+ -+const char * const riscv_gpr_names_numeric[32] = -+{ -+ "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", -+ "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15", -+ "x16", "x17", "x18", "x19", "x20", "x21", "x22", "x23", -+ "x24", "x25", "x26", "x27", "x28", "x29", "x30", "x31" -+}; -+ -+const char * const riscv_gpr_names_abi[32] = { -+ "zero", "ra", "sp", "gp", "tp", "t0", "t1", "t2", -+ "s0", "s1", "a0", "a1", "a2", "a3", "a4", "a5", -+ "a6", "a7", "s2", "s3", "s4", "s5", "s6", "s7", -+ "s8", "s9", "s10", "s11", "t3", "t4", "t5", "t6" -+}; -+ -+const char * const riscv_fpr_names_numeric[32] = -+{ -+ "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", -+ "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", -+ "f16", "f17", "f18", "f19", "f20", "f21", "f22", "f23", -+ "f24", "f25", "f26", "f27", "f28", "f29", "f30", "f31" -+}; -+ -+const char * const riscv_fpr_names_abi[32] = { -+ "ft0", "ft1", "ft2", "ft3", "ft4", "ft5", "ft6", "ft7", -+ "fs0", "fs1", "fa0", "fa1", "fa2", "fa3", "fa4", "fa5", -+ "fa6", "fa7", "fs2", "fs3", "fs4", "fs5", "fs6", "fs7", -+ "fs8", "fs9", "fs10", "fs11", "ft8", "ft9", "ft10", "ft11" -+}; -+ -+const char * const riscv_vec_gpr_names[32] = -+{ -+ "vx0", "vx1", "vx2", "vx3", "vx4", "vx5", "vx6", "vx7", -+ "vx8", "vx9", "vx10", "vx11", "vx12", "vx13", "vx14", "vx15", -+ "vx16", "vx17", "vx18", "vx19", "vx20", "vx21", "vx22", "vx23", -+ "vx24", "vx25", "vx26", "vx27", "vx28", "vx29", "vx30", "vx31" -+}; -+ -+const char * const riscv_vec_fpr_names[32] = -+{ -+ "vf0", "vf1", "vf2", "vf3", "vf4", "vf5", "vf6", "vf7", -+ "vf8", "vf9", "vf10", "vf11", "vf12", "vf13", "vf14", "vf15", -+ "vf16", "vf17", "vf18", "vf19", "vf20", "vf21", "vf22", "vf23", -+ "vf24", "vf25", "vf26", "vf27", "vf28", "vf29", "vf30", "vf31" -+}; -+ -+/* The order of overloaded instructions matters. Label arguments and -+ register arguments look the same. Instructions that can have either -+ for arguments must apear in the correct order in this table for the -+ assembler to pick the right one. In other words, entries with -+ immediate operands must apear after the same instruction with -+ registers. -+ -+ Because of the lookup algorithm used, entries with the same opcode -+ name must be contiguous. */ -+ -+#define WR_xd INSN_WRITE_GPR_D -+#define WR_fd INSN_WRITE_FPR_D -+#define RD_xs1 INSN_READ_GPR_S -+#define RD_xs2 INSN_READ_GPR_T -+#define RD_fs1 INSN_READ_FPR_S -+#define RD_fs2 INSN_READ_FPR_T -+#define RD_fs3 INSN_READ_FPR_R -+ -+#define MASK_RS1 (OP_MASK_RS1 << OP_SH_RS1) -+#define MASK_RS2 (OP_MASK_RS2 << OP_SH_RS2) -+#define MASK_RD (OP_MASK_RD << OP_SH_RD) -+#define MASK_IMM ENCODE_ITYPE_IMM(-1U) -+#define MASK_UIMM ENCODE_UTYPE_IMM(-1U) -+#define MASK_RM (OP_MASK_RM << OP_SH_RM) -+#define MASK_PRED (OP_MASK_PRED << OP_SH_PRED) -+#define MASK_SUCC (OP_MASK_SUCC << OP_SH_SUCC) -+#define MASK_AQ (OP_MASK_AQ << OP_SH_AQ) -+#define MASK_RL (OP_MASK_RL << OP_SH_RL) -+#define MASK_AQRL (MASK_AQ | MASK_RL) -+ -+static int match_opcode(const struct riscv_opcode *op, insn_t insn) -+{ -+ return (insn & op->mask) == op->match; -+} -+ -+static int match_never(const struct riscv_opcode *op ATTRIBUTE_UNUSED, -+ insn_t insn ATTRIBUTE_UNUSED) -+{ -+ return 0; -+} -+ -+static int match_rs1_eq_rs2(const struct riscv_opcode *op, insn_t insn) -+{ -+ return match_opcode(op, insn) && -+ ((insn & MASK_RS1) >> OP_SH_RS1) == ((insn & MASK_RS2) >> OP_SH_RS2); -+} -+ -+const struct riscv_opcode riscv_builtin_opcodes[] = -+{ -+/* These instructions appear first so that the disassembler will find -+ them first. The assemblers uses a hash table based on the -+ instruction name anyhow. */ -+/* name, isa, operands, match, mask, pinfo */ -+{"unimp", "I", "", 0, 0xffff, match_opcode, 0 }, -+{"nop", "I", "", MATCH_ADDI, MASK_ADDI | MASK_RD | MASK_RS1 | MASK_IMM, match_opcode, INSN_ALIAS }, -+{"li", "I", "d,j", MATCH_ADDI, MASK_ADDI | MASK_RS1, match_opcode, INSN_ALIAS|WR_xd }, /* addi */ -+{"li", "I", "d,I", 0, (int) M_LI, match_never, INSN_MACRO }, -+{"mv", "I", "d,s", MATCH_ADDI, MASK_ADDI | MASK_IMM, match_opcode, INSN_ALIAS|WR_xd|RD_xs1 }, -+{"move", "I", "d,s", MATCH_ADDI, MASK_ADDI | MASK_IMM, match_opcode, INSN_ALIAS|WR_xd|RD_xs1 }, -+{"andi", "I", "d,s,j", MATCH_ANDI, MASK_ANDI, match_opcode, WR_xd|RD_xs1 }, -+{"and", "I", "d,s,t", MATCH_AND, MASK_AND, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"and", "I", "d,s,j", MATCH_ANDI, MASK_ANDI, match_opcode, INSN_ALIAS|WR_xd|RD_xs1 }, -+{"beqz", "I", "s,p", MATCH_BEQ, MASK_BEQ | MASK_RS2, match_opcode, INSN_ALIAS|RD_xs1 }, -+{"beq", "I", "s,t,p", MATCH_BEQ, MASK_BEQ, match_opcode, RD_xs1|RD_xs2 }, -+{"blez", "I", "t,p", MATCH_BGE, MASK_BGE | MASK_RS1, match_opcode, INSN_ALIAS|RD_xs2 }, -+{"bgez", "I", "s,p", MATCH_BGE, MASK_BGE | MASK_RS2, match_opcode, INSN_ALIAS|RD_xs1 }, -+{"ble", "I", "t,s,p", MATCH_BGE, MASK_BGE, match_opcode, INSN_ALIAS|RD_xs1|RD_xs2 }, -+{"bleu", "I", "t,s,p", MATCH_BGEU, MASK_BGEU, match_opcode, INSN_ALIAS|RD_xs1|RD_xs2 }, -+{"bge", "I", "s,t,p", MATCH_BGE, MASK_BGE, match_opcode, RD_xs1|RD_xs2 }, -+{"bgeu", "I", "s,t,p", MATCH_BGEU, MASK_BGEU, match_opcode, RD_xs1|RD_xs2 }, -+{"bltz", "I", "s,p", MATCH_BLT, MASK_BLT | MASK_RS2, match_opcode, INSN_ALIAS|RD_xs1 }, -+{"bgtz", "I", "t,p", MATCH_BLT, MASK_BLT | MASK_RS1, match_opcode, INSN_ALIAS|RD_xs2 }, -+{"blt", "I", "s,t,p", MATCH_BLT, MASK_BLT, match_opcode, RD_xs1|RD_xs2 }, -+{"bltu", "I", "s,t,p", MATCH_BLTU, MASK_BLTU, match_opcode, RD_xs1|RD_xs2 }, -+{"bgt", "I", "t,s,p", MATCH_BLT, MASK_BLT, match_opcode, INSN_ALIAS|RD_xs1|RD_xs2 }, -+{"bgtu", "I", "t,s,p", MATCH_BLTU, MASK_BLTU, match_opcode, INSN_ALIAS|RD_xs1|RD_xs2 }, -+{"bnez", "I", "s,p", MATCH_BNE, MASK_BNE | MASK_RS2, match_opcode, INSN_ALIAS|RD_xs1 }, -+{"bne", "I", "s,t,p", MATCH_BNE, MASK_BNE, match_opcode, RD_xs1|RD_xs2 }, -+{"addi", "I", "d,s,j", MATCH_ADDI, MASK_ADDI, match_opcode, WR_xd|RD_xs1 }, -+{"add", "I", "d,s,t", MATCH_ADD, MASK_ADD, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"add", "I", "d,s,t,0",MATCH_ADD, MASK_ADD, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"add", "I", "d,s,j", MATCH_ADDI, MASK_ADDI, match_opcode, INSN_ALIAS|WR_xd|RD_xs1 }, -+{"la", "I", "d,A", 0, (int) M_LA, match_never, INSN_MACRO }, -+{"lla", "I", "d,A", 0, (int) M_LLA, match_never, INSN_MACRO }, -+{"la.tls.gd", "I", "d,A", 0, (int) M_LA_TLS_GD, match_never, INSN_MACRO }, -+{"la.tls.ie", "I", "d,A", 0, (int) M_LA_TLS_IE, match_never, INSN_MACRO }, -+{"neg", "I", "d,t", MATCH_SUB, MASK_SUB | MASK_RS1, match_opcode, INSN_ALIAS|WR_xd|RD_xs2 }, /* sub 0 */ -+{"slli", "I", "d,s,>", MATCH_SLLI, MASK_SLLI, match_opcode, WR_xd|RD_xs1 }, -+{"sll", "I", "d,s,t", MATCH_SLL, MASK_SLL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"sll", "I", "d,s,>", MATCH_SLLI, MASK_SLLI, match_opcode, INSN_ALIAS|WR_xd|RD_xs1 }, -+{"srli", "I", "d,s,>", MATCH_SRLI, MASK_SRLI, match_opcode, WR_xd|RD_xs1 }, -+{"srl", "I", "d,s,t", MATCH_SRL, MASK_SRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"srl", "I", "d,s,>", MATCH_SRLI, MASK_SRLI, match_opcode, INSN_ALIAS|WR_xd|RD_xs1 }, -+{"srai", "I", "d,s,>", MATCH_SRAI, MASK_SRAI, match_opcode, WR_xd|RD_xs1 }, -+{"sra", "I", "d,s,t", MATCH_SRA, MASK_SRA, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"sra", "I", "d,s,>", MATCH_SRAI, MASK_SRAI, match_opcode, INSN_ALIAS|WR_xd|RD_xs1 }, -+{"sub", "I", "d,s,t", MATCH_SUB, MASK_SUB, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"ret", "I", "", MATCH_JALR | (X_RA << OP_SH_RS1), MASK_JALR | MASK_RD | MASK_RS1 | MASK_IMM, match_opcode, INSN_ALIAS|WR_xd|RD_xs1 }, -+{"j", "I", "a", MATCH_JAL, MASK_JAL | MASK_RD, match_opcode, INSN_ALIAS }, -+{"jal", "I", "a", MATCH_JAL | (X_RA << OP_SH_RD), MASK_JAL | MASK_RD, match_opcode, INSN_ALIAS|WR_xd }, -+{"jal", "I", "d,a", MATCH_JAL, MASK_JAL, match_opcode, WR_xd }, -+{"call", "I", "c", (X_T0 << OP_SH_RS1) | (X_RA << OP_SH_RD), (int) M_CALL, match_never, INSN_MACRO }, -+{"tail", "I", "c", (X_T0 << OP_SH_RS1), (int) M_CALL, match_never, INSN_MACRO }, -+{"jump", "I", "c,s", 0, (int) M_CALL, match_never, INSN_MACRO }, -+{"jr", "I", "s", MATCH_JALR, MASK_JALR | MASK_RD | MASK_IMM, match_opcode, INSN_ALIAS|WR_xd|RD_xs1 }, -+{"jr", "I", "s,j", MATCH_JALR, MASK_JALR | MASK_RD, match_opcode, INSN_ALIAS|WR_xd|RD_xs1 }, -+{"jalr", "I", "s", MATCH_JALR | (X_RA << OP_SH_RD), MASK_JALR | MASK_RD | MASK_IMM, match_opcode, INSN_ALIAS|WR_xd|RD_xs1 }, -+{"jalr", "I", "s,j", MATCH_JALR | (X_RA << OP_SH_RD), MASK_JALR | MASK_RD, match_opcode, INSN_ALIAS|WR_xd|RD_xs1 }, -+{"jalr", "I", "d,s", MATCH_JALR, MASK_JALR | MASK_IMM, match_opcode, INSN_ALIAS|WR_xd|RD_xs1 }, -+{"jalr", "I", "d,s,j", MATCH_JALR, MASK_JALR, match_opcode, WR_xd|RD_xs1 }, -+{"lb", "I", "d,o(s)", MATCH_LB, MASK_LB, match_opcode, WR_xd|RD_xs1 }, -+{"lb", "I", "d,A", 0, (int) M_LB, match_never, INSN_MACRO }, -+{"lbu", "I", "d,o(s)", MATCH_LBU, MASK_LBU, match_opcode, WR_xd|RD_xs1 }, -+{"lbu", "I", "d,A", 0, (int) M_LBU, match_never, INSN_MACRO }, -+{"lh", "I", "d,o(s)", MATCH_LH, MASK_LH, match_opcode, WR_xd|RD_xs1 }, -+{"lh", "I", "d,A", 0, (int) M_LH, match_never, INSN_MACRO }, -+{"lhu", "I", "d,o(s)", MATCH_LHU, MASK_LHU, match_opcode, WR_xd|RD_xs1 }, -+{"lhu", "I", "d,A", 0, (int) M_LHU, match_never, INSN_MACRO }, -+{"lw", "I", "d,o(s)", MATCH_LW, MASK_LW, match_opcode, WR_xd|RD_xs1 }, -+{"lw", "I", "d,A", 0, (int) M_LW, match_never, INSN_MACRO }, -+{"lui", "I", "d,u", MATCH_LUI, MASK_LUI, match_opcode, WR_xd }, -+{"not", "I", "d,s", MATCH_XORI | MASK_IMM, MASK_XORI | MASK_IMM, match_opcode, INSN_ALIAS|WR_xd|RD_xs1 }, -+{"ori", "I", "d,s,j", MATCH_ORI, MASK_ORI, match_opcode, WR_xd|RD_xs1 }, -+{"or", "I", "d,s,t", MATCH_OR, MASK_OR, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"or", "I", "d,s,j", MATCH_ORI, MASK_ORI, match_opcode, INSN_ALIAS|WR_xd|RD_xs1 }, -+{"auipc", "I", "d,u", MATCH_AUIPC, MASK_AUIPC, match_opcode, WR_xd }, -+{"seqz", "I", "d,s", MATCH_SLTIU | ENCODE_ITYPE_IMM(1), MASK_SLTIU | MASK_IMM, match_opcode, INSN_ALIAS|WR_xd|RD_xs1 }, -+{"snez", "I", "d,t", MATCH_SLTU, MASK_SLTU | MASK_RS1, match_opcode, INSN_ALIAS|WR_xd|RD_xs2 }, -+{"sltz", "I", "d,s", MATCH_SLT, MASK_SLT | MASK_RS2, match_opcode, INSN_ALIAS|WR_xd|RD_xs1 }, -+{"sgtz", "I", "d,t", MATCH_SLT, MASK_SLT | MASK_RS1, match_opcode, INSN_ALIAS|WR_xd|RD_xs2 }, -+{"slti", "I", "d,s,j", MATCH_SLTI, MASK_SLTI, match_opcode, INSN_ALIAS|WR_xd|RD_xs1 }, -+{"slt", "I", "d,s,t", MATCH_SLT, MASK_SLT, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"slt", "I", "d,s,j", MATCH_SLTI, MASK_SLTI, match_opcode, WR_xd|RD_xs1 }, -+{"sltiu", "I", "d,s,j", MATCH_SLTIU, MASK_SLTIU, match_opcode, WR_xd|RD_xs1 }, -+{"sltu", "I", "d,s,t", MATCH_SLTU, MASK_SLTU, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"sltu", "I", "d,s,j", MATCH_SLTIU, MASK_SLTIU, match_opcode, INSN_ALIAS|WR_xd|RD_xs1 }, -+{"sgt", "I", "d,t,s", MATCH_SLT, MASK_SLT, match_opcode, INSN_ALIAS|WR_xd|RD_xs1|RD_xs2 }, -+{"sgtu", "I", "d,t,s", MATCH_SLTU, MASK_SLTU, match_opcode, INSN_ALIAS|WR_xd|RD_xs1|RD_xs2 }, -+{"sb", "I", "t,q(s)", MATCH_SB, MASK_SB, match_opcode, RD_xs1|RD_xs2 }, -+{"sb", "I", "t,A,s", 0, (int) M_SB, match_never, INSN_MACRO }, -+{"sh", "I", "t,q(s)", MATCH_SH, MASK_SH, match_opcode, RD_xs1|RD_xs2 }, -+{"sh", "I", "t,A,s", 0, (int) M_SH, match_never, INSN_MACRO }, -+{"sw", "I", "t,q(s)", MATCH_SW, MASK_SW, match_opcode, RD_xs1|RD_xs2 }, -+{"sw", "I", "t,A,s", 0, (int) M_SW, match_never, INSN_MACRO }, -+{"fence", "I", "", MATCH_FENCE | MASK_PRED | MASK_SUCC, MASK_FENCE | MASK_RD | MASK_RS1 | MASK_IMM, match_opcode, INSN_ALIAS }, -+{"fence", "I", "P,Q", MATCH_FENCE, MASK_FENCE | MASK_RD | MASK_RS1 | (MASK_IMM & ~MASK_PRED & ~MASK_SUCC), match_opcode, 0 }, -+{"fence.i", "I", "", MATCH_FENCE_I, MASK_FENCE | MASK_RD | MASK_RS1 | MASK_IMM, match_opcode, 0 }, -+{"rdcycle", "I", "d", MATCH_RDCYCLE, MASK_RDCYCLE, match_opcode, WR_xd }, -+{"rdinstret", "I", "d", MATCH_RDINSTRET, MASK_RDINSTRET, match_opcode, WR_xd }, -+{"rdtime", "I", "d", MATCH_RDTIME, MASK_RDTIME, match_opcode, WR_xd }, -+{"rdcycleh", "32I", "d", MATCH_RDCYCLEH, MASK_RDCYCLEH, match_opcode, WR_xd }, -+{"rdinstreth","32I", "d", MATCH_RDINSTRETH, MASK_RDINSTRETH, match_opcode, WR_xd }, -+{"rdtimeh", "32I", "d", MATCH_RDTIMEH, MASK_RDTIMEH, match_opcode, WR_xd }, -+{"sbreak", "I", "", MATCH_SBREAK, MASK_SBREAK, match_opcode, 0 }, -+{"scall", "I", "", MATCH_SCALL, MASK_SCALL, match_opcode, 0 }, -+{"ecall", "I", "", MATCH_SCALL, MASK_SCALL, match_opcode, 0 }, -+{"xori", "I", "d,s,j", MATCH_XORI, MASK_XORI, match_opcode, WR_xd|RD_xs1 }, -+{"xor", "I", "d,s,t", MATCH_XOR, MASK_XOR, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"xor", "I", "d,s,j", MATCH_XORI, MASK_XORI, match_opcode, INSN_ALIAS|WR_xd|RD_xs1 }, -+{"lwu", "64I", "d,o(s)", MATCH_LWU, MASK_LWU, match_opcode, WR_xd|RD_xs1 }, -+{"lwu", "64I", "d,A", 0, (int) M_LWU, match_never, INSN_MACRO }, -+{"ld", "64I", "d,o(s)", MATCH_LD, MASK_LD, match_opcode, WR_xd|RD_xs1 }, -+{"ld", "64I", "d,A", 0, (int) M_LD, match_never, INSN_MACRO }, -+{"sd", "64I", "t,q(s)", MATCH_SD, MASK_SD, match_opcode, RD_xs1|RD_xs2 }, -+{"sd", "64I", "t,A,s", 0, (int) M_SD, match_never, INSN_MACRO }, -+{"sext.w", "64I", "d,s", MATCH_ADDIW, MASK_ADDIW | MASK_IMM, match_opcode, INSN_ALIAS|WR_xd|RD_xs1 }, -+{"addiw", "64I", "d,s,j", MATCH_ADDIW, MASK_ADDIW, match_opcode, WR_xd|RD_xs1 }, -+{"addw", "64I", "d,s,t", MATCH_ADDW, MASK_ADDW, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"addw", "64I", "d,s,j", MATCH_ADDIW, MASK_ADDIW, match_opcode, INSN_ALIAS|WR_xd|RD_xs1 }, -+{"negw", "64I", "d,t", MATCH_SUBW, MASK_SUBW | MASK_RS1, match_opcode, INSN_ALIAS|WR_xd|RD_xs2 }, /* sub 0 */ -+{"slliw", "64I", "d,s,<", MATCH_SLLIW, MASK_SLLIW, match_opcode, WR_xd|RD_xs1 }, -+{"sllw", "64I", "d,s,t", MATCH_SLLW, MASK_SLLW, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"sllw", "64I", "d,s,<", MATCH_SLLIW, MASK_SLLIW, match_opcode, INSN_ALIAS|WR_xd|RD_xs1 }, -+{"srliw", "64I", "d,s,<", MATCH_SRLIW, MASK_SRLIW, match_opcode, WR_xd|RD_xs1 }, -+{"srlw", "64I", "d,s,t", MATCH_SRLW, MASK_SRLW, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"srlw", "64I", "d,s,<", MATCH_SRLIW, MASK_SRLIW, match_opcode, INSN_ALIAS|WR_xd|RD_xs1 }, -+{"sraiw", "64I", "d,s,<", MATCH_SRAIW, MASK_SRAIW, match_opcode, WR_xd|RD_xs1 }, -+{"sraw", "64I", "d,s,t", MATCH_SRAW, MASK_SRAW, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"sraw", "64I", "d,s,<", MATCH_SRAIW, MASK_SRAIW, match_opcode, INSN_ALIAS|WR_xd|RD_xs1 }, -+{"subw", "64I", "d,s,t", MATCH_SUBW, MASK_SUBW, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+ -+/* Atomic memory operation instruction subset */ -+{"lr.w", "A", "d,0(s)", MATCH_LR_W, MASK_LR_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1 }, -+{"sc.w", "A", "d,t,0(s)", MATCH_SC_W, MASK_SC_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoadd.w", "A", "d,t,0(s)", MATCH_AMOADD_W, MASK_AMOADD_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoswap.w", "A", "d,t,0(s)", MATCH_AMOSWAP_W, MASK_AMOSWAP_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoand.w", "A", "d,t,0(s)", MATCH_AMOAND_W, MASK_AMOAND_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoor.w", "A", "d,t,0(s)", MATCH_AMOOR_W, MASK_AMOOR_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoxor.w", "A", "d,t,0(s)", MATCH_AMOXOR_W, MASK_AMOXOR_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amomax.w", "A", "d,t,0(s)", MATCH_AMOMAX_W, MASK_AMOMAX_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amomaxu.w", "A", "d,t,0(s)", MATCH_AMOMAXU_W, MASK_AMOMAXU_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amomin.w", "A", "d,t,0(s)", MATCH_AMOMIN_W, MASK_AMOMIN_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amominu.w", "A", "d,t,0(s)", MATCH_AMOMINU_W, MASK_AMOMINU_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"lr.w.aq", "A", "d,0(s)", MATCH_LR_W | MASK_AQ, MASK_LR_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1 }, -+{"sc.w.aq", "A", "d,t,0(s)", MATCH_SC_W | MASK_AQ, MASK_SC_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoadd.w.aq", "A", "d,t,0(s)", MATCH_AMOADD_W | MASK_AQ, MASK_AMOADD_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoswap.w.aq", "A", "d,t,0(s)", MATCH_AMOSWAP_W | MASK_AQ, MASK_AMOSWAP_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoand.w.aq", "A", "d,t,0(s)", MATCH_AMOAND_W | MASK_AQ, MASK_AMOAND_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoor.w.aq", "A", "d,t,0(s)", MATCH_AMOOR_W | MASK_AQ, MASK_AMOOR_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoxor.w.aq", "A", "d,t,0(s)", MATCH_AMOXOR_W | MASK_AQ, MASK_AMOXOR_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amomax.w.aq", "A", "d,t,0(s)", MATCH_AMOMAX_W | MASK_AQ, MASK_AMOMAX_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amomaxu.w.aq", "A", "d,t,0(s)", MATCH_AMOMAXU_W | MASK_AQ, MASK_AMOMAXU_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amomin.w.aq", "A", "d,t,0(s)", MATCH_AMOMIN_W | MASK_AQ, MASK_AMOMIN_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amominu.w.aq", "A", "d,t,0(s)", MATCH_AMOMINU_W | MASK_AQ, MASK_AMOMINU_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"lr.w.rl", "A", "d,0(s)", MATCH_LR_W | MASK_RL, MASK_LR_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1 }, -+{"sc.w.rl", "A", "d,t,0(s)", MATCH_SC_W | MASK_RL, MASK_SC_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoadd.w.rl", "A", "d,t,0(s)", MATCH_AMOADD_W | MASK_RL, MASK_AMOADD_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoswap.w.rl", "A", "d,t,0(s)", MATCH_AMOSWAP_W | MASK_RL, MASK_AMOSWAP_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoand.w.rl", "A", "d,t,0(s)", MATCH_AMOAND_W | MASK_RL, MASK_AMOAND_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoor.w.rl", "A", "d,t,0(s)", MATCH_AMOOR_W | MASK_RL, MASK_AMOOR_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoxor.w.rl", "A", "d,t,0(s)", MATCH_AMOXOR_W | MASK_RL, MASK_AMOXOR_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amomax.w.rl", "A", "d,t,0(s)", MATCH_AMOMAX_W | MASK_RL, MASK_AMOMAX_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amomaxu.w.rl", "A", "d,t,0(s)", MATCH_AMOMAXU_W | MASK_RL, MASK_AMOMAXU_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amomin.w.rl", "A", "d,t,0(s)", MATCH_AMOMIN_W | MASK_RL, MASK_AMOMIN_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amominu.w.rl", "A", "d,t,0(s)", MATCH_AMOMINU_W | MASK_RL, MASK_AMOMINU_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"lr.w.sc", "A", "d,0(s)", MATCH_LR_W | MASK_AQRL, MASK_LR_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1 }, -+{"sc.w.sc", "A", "d,t,0(s)", MATCH_SC_W | MASK_AQRL, MASK_SC_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoadd.w.sc", "A", "d,t,0(s)", MATCH_AMOADD_W | MASK_AQRL, MASK_AMOADD_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoswap.w.sc", "A", "d,t,0(s)", MATCH_AMOSWAP_W | MASK_AQRL, MASK_AMOSWAP_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoand.w.sc", "A", "d,t,0(s)", MATCH_AMOAND_W | MASK_AQRL, MASK_AMOAND_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoor.w.sc", "A", "d,t,0(s)", MATCH_AMOOR_W | MASK_AQRL, MASK_AMOOR_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoxor.w.sc", "A", "d,t,0(s)", MATCH_AMOXOR_W | MASK_AQRL, MASK_AMOXOR_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amomax.w.sc", "A", "d,t,0(s)", MATCH_AMOMAX_W | MASK_AQRL, MASK_AMOMAX_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amomaxu.w.sc", "A", "d,t,0(s)", MATCH_AMOMAXU_W | MASK_AQRL, MASK_AMOMAXU_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amomin.w.sc", "A", "d,t,0(s)", MATCH_AMOMIN_W | MASK_AQRL, MASK_AMOMIN_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amominu.w.sc", "A", "d,t,0(s)", MATCH_AMOMINU_W | MASK_AQRL, MASK_AMOMINU_W | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"lr.d", "64A", "d,0(s)", MATCH_LR_D, MASK_LR_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1 }, -+{"sc.d", "64A", "d,t,0(s)", MATCH_SC_D, MASK_SC_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoadd.d", "64A", "d,t,0(s)", MATCH_AMOADD_D, MASK_AMOADD_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoswap.d", "64A", "d,t,0(s)", MATCH_AMOSWAP_D, MASK_AMOSWAP_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoand.d", "64A", "d,t,0(s)", MATCH_AMOAND_D, MASK_AMOAND_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoor.d", "64A", "d,t,0(s)", MATCH_AMOOR_D, MASK_AMOOR_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoxor.d", "64A", "d,t,0(s)", MATCH_AMOXOR_D, MASK_AMOXOR_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amomax.d", "64A", "d,t,0(s)", MATCH_AMOMAX_D, MASK_AMOMAX_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amomaxu.d", "64A", "d,t,0(s)", MATCH_AMOMAXU_D, MASK_AMOMAXU_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amomin.d", "64A", "d,t,0(s)", MATCH_AMOMIN_D, MASK_AMOMIN_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amominu.d", "64A", "d,t,0(s)", MATCH_AMOMINU_D, MASK_AMOMINU_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"lr.d.aq", "64A", "d,0(s)", MATCH_LR_D | MASK_AQ, MASK_LR_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1 }, -+{"sc.d.aq", "64A", "d,t,0(s)", MATCH_SC_D | MASK_AQ, MASK_SC_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoadd.d.aq", "64A", "d,t,0(s)", MATCH_AMOADD_D | MASK_AQ, MASK_AMOADD_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoswap.d.aq", "64A", "d,t,0(s)", MATCH_AMOSWAP_D | MASK_AQ, MASK_AMOSWAP_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoand.d.aq", "64A", "d,t,0(s)", MATCH_AMOAND_D | MASK_AQ, MASK_AMOAND_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoor.d.aq", "64A", "d,t,0(s)", MATCH_AMOOR_D | MASK_AQ, MASK_AMOOR_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoxor.d.aq", "64A", "d,t,0(s)", MATCH_AMOXOR_D | MASK_AQ, MASK_AMOXOR_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amomax.d.aq", "64A", "d,t,0(s)", MATCH_AMOMAX_D | MASK_AQ, MASK_AMOMAX_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amomaxu.d.aq", "64A", "d,t,0(s)", MATCH_AMOMAXU_D | MASK_AQ, MASK_AMOMAXU_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amomin.d.aq", "64A", "d,t,0(s)", MATCH_AMOMIN_D | MASK_AQ, MASK_AMOMIN_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amominu.d.aq", "64A", "d,t,0(s)", MATCH_AMOMINU_D | MASK_AQ, MASK_AMOMINU_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"lr.d.rl", "64A", "d,0(s)", MATCH_LR_D | MASK_RL, MASK_LR_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1 }, -+{"sc.d.rl", "64A", "d,t,0(s)", MATCH_SC_D | MASK_RL, MASK_SC_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoadd.d.rl", "64A", "d,t,0(s)", MATCH_AMOADD_D | MASK_RL, MASK_AMOADD_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoswap.d.rl", "64A", "d,t,0(s)", MATCH_AMOSWAP_D | MASK_RL, MASK_AMOSWAP_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoand.d.rl", "64A", "d,t,0(s)", MATCH_AMOAND_D | MASK_RL, MASK_AMOAND_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoor.d.rl", "64A", "d,t,0(s)", MATCH_AMOOR_D | MASK_RL, MASK_AMOOR_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoxor.d.rl", "64A", "d,t,0(s)", MATCH_AMOXOR_D | MASK_RL, MASK_AMOXOR_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amomax.d.rl", "64A", "d,t,0(s)", MATCH_AMOMAX_D | MASK_RL, MASK_AMOMAX_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amomaxu.d.rl", "64A", "d,t,0(s)", MATCH_AMOMAXU_D | MASK_RL, MASK_AMOMAXU_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amomin.d.rl", "64A", "d,t,0(s)", MATCH_AMOMIN_D | MASK_RL, MASK_AMOMIN_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amominu.d.rl", "64A", "d,t,0(s)", MATCH_AMOMINU_D | MASK_RL, MASK_AMOMINU_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"lr.d.sc", "64A", "d,0(s)", MATCH_LR_D | MASK_AQRL, MASK_LR_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1 }, -+{"sc.d.sc", "64A", "d,t,0(s)", MATCH_SC_D | MASK_AQRL, MASK_SC_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoadd.d.sc", "64A", "d,t,0(s)", MATCH_AMOADD_D | MASK_AQRL, MASK_AMOADD_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoswap.d.sc", "64A", "d,t,0(s)", MATCH_AMOSWAP_D | MASK_AQRL, MASK_AMOSWAP_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoand.d.sc", "64A", "d,t,0(s)", MATCH_AMOAND_D | MASK_AQRL, MASK_AMOAND_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoor.d.sc", "64A", "d,t,0(s)", MATCH_AMOOR_D | MASK_AQRL, MASK_AMOOR_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amoxor.d.sc", "64A", "d,t,0(s)", MATCH_AMOXOR_D | MASK_AQRL, MASK_AMOXOR_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amomax.d.sc", "64A", "d,t,0(s)", MATCH_AMOMAX_D | MASK_AQRL, MASK_AMOMAX_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amomaxu.d.sc", "64A", "d,t,0(s)", MATCH_AMOMAXU_D | MASK_AQRL, MASK_AMOMAXU_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amomin.d.sc", "64A", "d,t,0(s)", MATCH_AMOMIN_D | MASK_AQRL, MASK_AMOMIN_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"amominu.d.sc", "64A", "d,t,0(s)", MATCH_AMOMINU_D | MASK_AQRL, MASK_AMOMINU_D | MASK_AQRL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+ -+/* Multiply/Divide instruction subset */ -+{"mul", "M", "d,s,t", MATCH_MUL, MASK_MUL, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"mulh", "M", "d,s,t", MATCH_MULH, MASK_MULH, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"mulhu", "M", "d,s,t", MATCH_MULHU, MASK_MULHU, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"mulhsu", "M", "d,s,t", MATCH_MULHSU, MASK_MULHSU, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"div", "M", "d,s,t", MATCH_DIV, MASK_DIV, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"divu", "M", "d,s,t", MATCH_DIVU, MASK_DIVU, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"rem", "M", "d,s,t", MATCH_REM, MASK_REM, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"remu", "M", "d,s,t", MATCH_REMU, MASK_REMU, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"mulw", "64M", "d,s,t", MATCH_MULW, MASK_MULW, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"divw", "64M", "d,s,t", MATCH_DIVW, MASK_DIVW, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"divuw", "64M", "d,s,t", MATCH_DIVUW, MASK_DIVUW, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"remw", "64M", "d,s,t", MATCH_REMW, MASK_REMW, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+{"remuw", "64M", "d,s,t", MATCH_REMUW, MASK_REMUW, match_opcode, WR_xd|RD_xs1|RD_xs2 }, -+ -+/* Single-precision floating-point instruction subset */ -+{"frsr", "F", "d", MATCH_FRCSR, MASK_FRCSR, match_opcode, WR_xd }, -+{"fssr", "F", "s", MATCH_FSCSR, MASK_FSCSR | MASK_RD, match_opcode, RD_xs1 }, -+{"fssr", "F", "d,s", MATCH_FSCSR, MASK_FSCSR, match_opcode, WR_xd|RD_xs1 }, -+{"frcsr", "F", "d", MATCH_FRCSR, MASK_FRCSR, match_opcode, WR_xd }, -+{"fscsr", "F", "s", MATCH_FSCSR, MASK_FSCSR | MASK_RD, match_opcode, RD_xs1 }, -+{"fscsr", "F", "d,s", MATCH_FSCSR, MASK_FSCSR, match_opcode, WR_xd|RD_xs1 }, -+{"frrm", "F", "d", MATCH_FRRM, MASK_FRRM, match_opcode, WR_xd }, -+{"fsrm", "F", "s", MATCH_FSRM, MASK_FSRM | MASK_RD, match_opcode, RD_xs1 }, -+{"fsrm", "F", "d,s", MATCH_FSRM, MASK_FSRM, match_opcode, WR_xd|RD_xs1 }, -+{"frflags", "F", "d", MATCH_FRFLAGS, MASK_FRFLAGS, match_opcode, WR_xd }, -+{"fsflags", "F", "s", MATCH_FSFLAGS, MASK_FSFLAGS | MASK_RD, match_opcode, RD_xs1 }, -+{"fsflags", "F", "d,s", MATCH_FSFLAGS, MASK_FSFLAGS, match_opcode, WR_xd|RD_xs1 }, -+{"flw", "F", "D,o(s)", MATCH_FLW, MASK_FLW, match_opcode, WR_fd|RD_xs1 }, -+{"flw", "F", "D,A,s", 0, (int) M_FLW, match_never, INSN_MACRO }, -+{"fsw", "F", "T,q(s)", MATCH_FSW, MASK_FSW, match_opcode, RD_xs1|RD_fs2 }, -+{"fsw", "F", "T,A,s", 0, (int) M_FSW, match_never, INSN_MACRO }, -+{"fmv.x.s", "F", "d,S", MATCH_FMV_X_S, MASK_FMV_X_S, match_opcode, WR_xd|RD_fs1 }, -+{"fmv.s.x", "F", "D,s", MATCH_FMV_S_X, MASK_FMV_S_X, match_opcode, WR_fd|RD_xs1 }, -+{"fmv.s", "F", "D,U", MATCH_FSGNJ_S, MASK_FSGNJ_S, match_rs1_eq_rs2, INSN_ALIAS|WR_fd|RD_fs1|RD_fs2 }, -+{"fneg.s", "F", "D,U", MATCH_FSGNJN_S, MASK_FSGNJN_S, match_rs1_eq_rs2, INSN_ALIAS|WR_fd|RD_fs1|RD_fs2 }, -+{"fabs.s", "F", "D,U", MATCH_FSGNJX_S, MASK_FSGNJX_S, match_rs1_eq_rs2, INSN_ALIAS|WR_fd|RD_fs1|RD_fs2 }, -+{"fsgnj.s", "F", "D,S,T", MATCH_FSGNJ_S, MASK_FSGNJ_S, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fsgnjn.s", "F", "D,S,T", MATCH_FSGNJN_S, MASK_FSGNJN_S, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fsgnjx.s", "F", "D,S,T", MATCH_FSGNJX_S, MASK_FSGNJX_S, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fadd.s", "F", "D,S,T", MATCH_FADD_S | MASK_RM, MASK_FADD_S | MASK_RM, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fadd.s", "F", "D,S,T,m", MATCH_FADD_S, MASK_FADD_S, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fsub.s", "F", "D,S,T", MATCH_FSUB_S | MASK_RM, MASK_FSUB_S | MASK_RM, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fsub.s", "F", "D,S,T,m", MATCH_FSUB_S, MASK_FSUB_S, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fmul.s", "F", "D,S,T", MATCH_FMUL_S | MASK_RM, MASK_FMUL_S | MASK_RM, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fmul.s", "F", "D,S,T,m", MATCH_FMUL_S, MASK_FMUL_S, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fdiv.s", "F", "D,S,T", MATCH_FDIV_S | MASK_RM, MASK_FDIV_S | MASK_RM, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fdiv.s", "F", "D,S,T,m", MATCH_FDIV_S, MASK_FDIV_S, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fsqrt.s", "F", "D,S", MATCH_FSQRT_S | MASK_RM, MASK_FSQRT_S | MASK_RM, match_opcode, WR_fd|RD_fs1 }, -+{"fsqrt.s", "F", "D,S,m", MATCH_FSQRT_S, MASK_FSQRT_S, match_opcode, WR_fd|RD_fs1 }, -+{"fmin.s", "F", "D,S,T", MATCH_FMIN_S, MASK_FMIN_S, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fmax.s", "F", "D,S,T", MATCH_FMAX_S, MASK_FMAX_S, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fmadd.s", "F", "D,S,T,R", MATCH_FMADD_S | MASK_RM, MASK_FMADD_S | MASK_RM, match_opcode, WR_fd|RD_fs1|RD_fs2|RD_fs3 }, -+{"fmadd.s", "F", "D,S,T,R,m", MATCH_FMADD_S, MASK_FMADD_S, match_opcode, WR_fd|RD_fs1|RD_fs2|RD_fs3 }, -+{"fnmadd.s", "F", "D,S,T,R", MATCH_FNMADD_S | MASK_RM, MASK_FNMADD_S | MASK_RM, match_opcode, WR_fd|RD_fs1|RD_fs2|RD_fs3 }, -+{"fnmadd.s", "F", "D,S,T,R,m", MATCH_FNMADD_S, MASK_FNMADD_S, match_opcode, WR_fd|RD_fs1|RD_fs2|RD_fs3 }, -+{"fmsub.s", "F", "D,S,T,R", MATCH_FMSUB_S | MASK_RM, MASK_FMSUB_S | MASK_RM, match_opcode, WR_fd|RD_fs1|RD_fs2|RD_fs3 }, -+{"fmsub.s", "F", "D,S,T,R,m", MATCH_FMSUB_S, MASK_FMSUB_S, match_opcode, WR_fd|RD_fs1|RD_fs2|RD_fs3 }, -+{"fnmsub.s", "F", "D,S,T,R", MATCH_FNMSUB_S | MASK_RM, MASK_FNMSUB_S | MASK_RM, match_opcode, WR_fd|RD_fs1|RD_fs2|RD_fs3 }, -+{"fnmsub.s", "F", "D,S,T,R,m", MATCH_FNMSUB_S, MASK_FNMSUB_S, match_opcode, WR_fd|RD_fs1|RD_fs2|RD_fs3 }, -+{"fcvt.w.s", "F", "d,S", MATCH_FCVT_W_S | MASK_RM, MASK_FCVT_W_S | MASK_RM, match_opcode, WR_xd|RD_fs1 }, -+{"fcvt.w.s", "F", "d,S,m", MATCH_FCVT_W_S, MASK_FCVT_W_S, match_opcode, WR_xd|RD_fs1 }, -+{"fcvt.wu.s", "F", "d,S", MATCH_FCVT_WU_S | MASK_RM, MASK_FCVT_WU_S | MASK_RM, match_opcode, WR_xd|RD_fs1 }, -+{"fcvt.wu.s", "F", "d,S,m", MATCH_FCVT_WU_S, MASK_FCVT_WU_S, match_opcode, WR_xd|RD_fs1 }, -+{"fcvt.s.w", "F", "D,s", MATCH_FCVT_S_W | MASK_RM, MASK_FCVT_S_W | MASK_RM, match_opcode, WR_fd|RD_xs1 }, -+{"fcvt.s.w", "F", "D,s,m", MATCH_FCVT_S_W, MASK_FCVT_S_W, match_opcode, WR_fd|RD_xs1 }, -+{"fcvt.s.wu", "F", "D,s", MATCH_FCVT_S_WU | MASK_RM, MASK_FCVT_S_W | MASK_RM, match_opcode, WR_fd|RD_xs1 }, -+{"fcvt.s.wu", "F", "D,s,m", MATCH_FCVT_S_WU, MASK_FCVT_S_WU, match_opcode, WR_fd|RD_xs1 }, -+{"fclass.s", "F", "d,S", MATCH_FCLASS_S, MASK_FCLASS_S, match_opcode, WR_xd|RD_fs1 }, -+{"feq.s", "F", "d,S,T", MATCH_FEQ_S, MASK_FEQ_S, match_opcode, WR_xd|RD_fs1|RD_fs2 }, -+{"flt.s", "F", "d,S,T", MATCH_FLT_S, MASK_FLT_S, match_opcode, WR_xd|RD_fs1|RD_fs2 }, -+{"fle.s", "F", "d,S,T", MATCH_FLE_S, MASK_FLE_S, match_opcode, WR_xd|RD_fs1|RD_fs2 }, -+{"fgt.s", "F", "d,T,S", MATCH_FLT_S, MASK_FLT_S, match_opcode, WR_xd|RD_fs1|RD_fs2 }, -+{"fge.s", "F", "d,T,S", MATCH_FLE_S, MASK_FLE_S, match_opcode, WR_xd|RD_fs1|RD_fs2 }, -+{"fcvt.l.s", "64F", "d,S", MATCH_FCVT_L_S | MASK_RM, MASK_FCVT_L_S | MASK_RM, match_opcode, WR_xd|RD_fs1 }, -+{"fcvt.l.s", "64F", "d,S,m", MATCH_FCVT_L_S, MASK_FCVT_L_S, match_opcode, WR_xd|RD_fs1 }, -+{"fcvt.lu.s", "64F", "d,S", MATCH_FCVT_LU_S | MASK_RM, MASK_FCVT_LU_S | MASK_RM, match_opcode, WR_xd|RD_fs1 }, -+{"fcvt.lu.s", "64F", "d,S,m", MATCH_FCVT_LU_S, MASK_FCVT_LU_S, match_opcode, WR_xd|RD_fs1 }, -+{"fcvt.s.l", "64F", "D,s", MATCH_FCVT_S_L | MASK_RM, MASK_FCVT_S_L | MASK_RM, match_opcode, WR_fd|RD_xs1 }, -+{"fcvt.s.l", "64F", "D,s,m", MATCH_FCVT_S_L, MASK_FCVT_S_L, match_opcode, WR_fd|RD_xs1 }, -+{"fcvt.s.lu", "64F", "D,s", MATCH_FCVT_S_LU | MASK_RM, MASK_FCVT_S_L | MASK_RM, match_opcode, WR_fd|RD_xs1 }, -+{"fcvt.s.lu", "64F", "D,s,m", MATCH_FCVT_S_LU, MASK_FCVT_S_LU, match_opcode, WR_fd|RD_xs1 }, -+ -+/* Double-precision floating-point instruction subset */ -+{"fld", "D", "D,o(s)", MATCH_FLD, MASK_FLD, match_opcode, WR_fd|RD_xs1 }, -+{"fld", "D", "D,A,s", 0, (int) M_FLD, match_never, INSN_MACRO }, -+{"fsd", "D", "T,q(s)", MATCH_FSD, MASK_FSD, match_opcode, RD_xs1|RD_fs2 }, -+{"fsd", "D", "T,A,s", 0, (int) M_FSD, match_never, INSN_MACRO }, -+{"fmv.d", "D", "D,U", MATCH_FSGNJ_D, MASK_FSGNJ_D, match_rs1_eq_rs2, INSN_ALIAS|WR_fd|RD_fs1|RD_fs2 }, -+{"fneg.d", "D", "D,U", MATCH_FSGNJN_D, MASK_FSGNJN_D, match_rs1_eq_rs2, INSN_ALIAS|WR_fd|RD_fs1|RD_fs2 }, -+{"fabs.d", "D", "D,U", MATCH_FSGNJX_D, MASK_FSGNJX_D, match_rs1_eq_rs2, INSN_ALIAS|WR_fd|RD_fs1|RD_fs2 }, -+{"fsgnj.d", "D", "D,S,T", MATCH_FSGNJ_D, MASK_FSGNJ_D, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fsgnjn.d", "D", "D,S,T", MATCH_FSGNJN_D, MASK_FSGNJN_D, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fsgnjx.d", "D", "D,S,T", MATCH_FSGNJX_D, MASK_FSGNJX_D, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fadd.d", "D", "D,S,T", MATCH_FADD_D | MASK_RM, MASK_FADD_D | MASK_RM, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fadd.d", "D", "D,S,T,m", MATCH_FADD_D, MASK_FADD_D, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fsub.d", "D", "D,S,T", MATCH_FSUB_D | MASK_RM, MASK_FSUB_D | MASK_RM, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fsub.d", "D", "D,S,T,m", MATCH_FSUB_D, MASK_FSUB_D, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fmul.d", "D", "D,S,T", MATCH_FMUL_D | MASK_RM, MASK_FMUL_D | MASK_RM, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fmul.d", "D", "D,S,T,m", MATCH_FMUL_D, MASK_FMUL_D, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fdiv.d", "D", "D,S,T", MATCH_FDIV_D | MASK_RM, MASK_FDIV_D | MASK_RM, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fdiv.d", "D", "D,S,T,m", MATCH_FDIV_D, MASK_FDIV_D, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fsqrt.d", "D", "D,S", MATCH_FSQRT_D | MASK_RM, MASK_FSQRT_D | MASK_RM, match_opcode, WR_fd|RD_fs1 }, -+{"fsqrt.d", "D", "D,S,m", MATCH_FSQRT_D, MASK_FSQRT_D, match_opcode, WR_fd|RD_fs1 }, -+{"fmin.d", "D", "D,S,T", MATCH_FMIN_D, MASK_FMIN_D, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fmax.d", "D", "D,S,T", MATCH_FMAX_D, MASK_FMAX_D, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fmadd.d", "D", "D,S,T,R", MATCH_FMADD_D | MASK_RM, MASK_FMADD_D | MASK_RM, match_opcode, WR_fd|RD_fs1|RD_fs2|RD_fs3 }, -+{"fmadd.d", "D", "D,S,T,R,m", MATCH_FMADD_D, MASK_FMADD_D, match_opcode, WR_fd|RD_fs1|RD_fs2|RD_fs3 }, -+{"fnmadd.d", "D", "D,S,T,R", MATCH_FNMADD_D | MASK_RM, MASK_FNMADD_D | MASK_RM, match_opcode, WR_fd|RD_fs1|RD_fs2|RD_fs3 }, -+{"fnmadd.d", "D", "D,S,T,R,m", MATCH_FNMADD_D, MASK_FNMADD_D, match_opcode, WR_fd|RD_fs1|RD_fs2|RD_fs3 }, -+{"fmsub.d", "D", "D,S,T,R", MATCH_FMSUB_D | MASK_RM, MASK_FMSUB_D | MASK_RM, match_opcode, WR_fd|RD_fs1|RD_fs2|RD_fs3 }, -+{"fmsub.d", "D", "D,S,T,R,m", MATCH_FMSUB_D, MASK_FMSUB_D, match_opcode, WR_fd|RD_fs1|RD_fs2|RD_fs3 }, -+{"fnmsub.d", "D", "D,S,T,R", MATCH_FNMSUB_D | MASK_RM, MASK_FNMSUB_D | MASK_RM, match_opcode, WR_fd|RD_fs1|RD_fs2|RD_fs3 }, -+{"fnmsub.d", "D", "D,S,T,R,m", MATCH_FNMSUB_D, MASK_FNMSUB_D, match_opcode, WR_fd|RD_fs1|RD_fs2|RD_fs3 }, -+{"fcvt.w.d", "D", "d,S", MATCH_FCVT_W_D | MASK_RM, MASK_FCVT_W_D | MASK_RM, match_opcode, WR_xd|RD_fs1 }, -+{"fcvt.w.d", "D", "d,S,m", MATCH_FCVT_W_D, MASK_FCVT_W_D, match_opcode, WR_xd|RD_fs1 }, -+{"fcvt.wu.d", "D", "d,S", MATCH_FCVT_WU_D | MASK_RM, MASK_FCVT_WU_D | MASK_RM, match_opcode, WR_xd|RD_fs1 }, -+{"fcvt.wu.d", "D", "d,S,m", MATCH_FCVT_WU_D, MASK_FCVT_WU_D, match_opcode, WR_xd|RD_fs1 }, -+{"fcvt.d.w", "D", "D,s", MATCH_FCVT_D_W, MASK_FCVT_D_W | MASK_RM, match_opcode, WR_fd|RD_xs1 }, -+{"fcvt.d.wu", "D", "D,s", MATCH_FCVT_D_WU, MASK_FCVT_D_WU | MASK_RM, match_opcode, WR_fd|RD_xs1 }, -+{"fcvt.d.s", "D", "D,S", MATCH_FCVT_D_S, MASK_FCVT_D_S | MASK_RM, match_opcode, WR_fd|RD_fs1 }, -+{"fcvt.s.d", "D", "D,S", MATCH_FCVT_S_D | MASK_RM, MASK_FCVT_S_D | MASK_RM, match_opcode, WR_fd|RD_fs1 }, -+{"fcvt.s.d", "D", "D,S,m", MATCH_FCVT_S_D, MASK_FCVT_S_D, match_opcode, WR_fd|RD_fs1 }, -+{"fclass.d", "D", "d,S", MATCH_FCLASS_D, MASK_FCLASS_D, match_opcode, WR_xd|RD_fs1 }, -+{"feq.d", "D", "d,S,T", MATCH_FEQ_D, MASK_FEQ_D, match_opcode, WR_xd|RD_fs1|RD_fs2 }, -+{"flt.d", "D", "d,S,T", MATCH_FLT_D, MASK_FLT_D, match_opcode, WR_xd|RD_fs1|RD_fs2 }, -+{"fle.d", "D", "d,S,T", MATCH_FLE_D, MASK_FLE_D, match_opcode, WR_xd|RD_fs1|RD_fs2 }, -+{"fgt.d", "D", "d,T,S", MATCH_FLT_D, MASK_FLT_D, match_opcode, WR_xd|RD_fs1|RD_fs2 }, -+{"fge.d", "D", "d,T,S", MATCH_FLE_D, MASK_FLE_D, match_opcode, WR_xd|RD_fs1|RD_fs2 }, -+{"fmv.x.d", "64D", "d,S", MATCH_FMV_X_D, MASK_FMV_X_D, match_opcode, WR_xd|RD_fs1 }, -+{"fmv.d.x", "64D", "D,s", MATCH_FMV_D_X, MASK_FMV_D_X, match_opcode, WR_fd|RD_xs1 }, -+{"fcvt.l.d", "64D", "d,S", MATCH_FCVT_L_D | MASK_RM, MASK_FCVT_L_D | MASK_RM, match_opcode, WR_xd|RD_fs1 }, -+{"fcvt.l.d", "64D", "d,S,m", MATCH_FCVT_L_D, MASK_FCVT_L_D, match_opcode, WR_xd|RD_fs1 }, -+{"fcvt.lu.d", "64D", "d,S", MATCH_FCVT_LU_D | MASK_RM, MASK_FCVT_LU_D | MASK_RM, match_opcode, WR_xd|RD_fs1 }, -+{"fcvt.lu.d", "64D", "d,S,m", MATCH_FCVT_LU_D, MASK_FCVT_LU_D, match_opcode, WR_xd|RD_fs1 }, -+{"fcvt.d.l", "64D", "D,s", MATCH_FCVT_D_L | MASK_RM, MASK_FCVT_D_L | MASK_RM, match_opcode, WR_fd|RD_xs1 }, -+{"fcvt.d.l", "64D", "D,s,m", MATCH_FCVT_D_L, MASK_FCVT_D_L, match_opcode, WR_fd|RD_xs1 }, -+{"fcvt.d.lu", "64D", "D,s", MATCH_FCVT_D_LU | MASK_RM, MASK_FCVT_D_L | MASK_RM, match_opcode, WR_fd|RD_xs1 }, -+{"fcvt.d.lu", "64D", "D,s,m", MATCH_FCVT_D_LU, MASK_FCVT_D_LU, match_opcode, WR_fd|RD_xs1 }, -+ -+/* Supervisor instructions */ -+{"csrr", "I", "d,E", MATCH_CSRRS, MASK_CSRRS | MASK_RS1, match_opcode, WR_xd }, -+{"csrwi", "I", "E,Z", MATCH_CSRRWI, MASK_CSRRWI | MASK_RD, match_opcode, WR_xd|RD_xs1 }, -+{"csrw", "I", "E,s", MATCH_CSRRW, MASK_CSRRW | MASK_RD, match_opcode, RD_xs1 }, -+{"csrw", "I", "E,Z", MATCH_CSRRWI, MASK_CSRRWI | MASK_RD, match_opcode, WR_xd|RD_xs1 }, -+{"csrsi", "I", "E,Z", MATCH_CSRRSI, MASK_CSRRSI | MASK_RD, match_opcode, WR_xd|RD_xs1 }, -+{"csrs", "I", "E,s", MATCH_CSRRS, MASK_CSRRS | MASK_RD, match_opcode, WR_xd|RD_xs1 }, -+{"csrs", "I", "E,Z", MATCH_CSRRSI, MASK_CSRRSI | MASK_RD, match_opcode, WR_xd|RD_xs1 }, -+{"csrci", "I", "E,Z", MATCH_CSRRCI, MASK_CSRRCI | MASK_RD, match_opcode, WR_xd|RD_xs1 }, -+{"csrc", "I", "E,s", MATCH_CSRRC, MASK_CSRRC | MASK_RD, match_opcode, WR_xd|RD_xs1 }, -+{"csrc", "I", "E,Z", MATCH_CSRRCI, MASK_CSRRCI | MASK_RD, match_opcode, WR_xd|RD_xs1 }, -+{"csrrw", "I", "d,E,s", MATCH_CSRRW, MASK_CSRRW, match_opcode, WR_xd|RD_xs1 }, -+{"csrrw", "I", "d,E,Z", MATCH_CSRRWI, MASK_CSRRWI, match_opcode, WR_xd|RD_xs1 }, -+{"csrrs", "I", "d,E,s", MATCH_CSRRS, MASK_CSRRS, match_opcode, WR_xd|RD_xs1 }, -+{"csrrs", "I", "d,E,Z", MATCH_CSRRSI, MASK_CSRRSI, match_opcode, WR_xd|RD_xs1 }, -+{"csrrc", "I", "d,E,s", MATCH_CSRRC, MASK_CSRRC, match_opcode, WR_xd|RD_xs1 }, -+{"csrrc", "I", "d,E,Z", MATCH_CSRRCI, MASK_CSRRCI, match_opcode, WR_xd|RD_xs1 }, -+{"csrrwi", "I", "d,E,Z", MATCH_CSRRWI, MASK_CSRRWI, match_opcode, WR_xd|RD_xs1 }, -+{"csrrsi", "I", "d,E,Z", MATCH_CSRRSI, MASK_CSRRSI, match_opcode, WR_xd|RD_xs1 }, -+{"csrrci", "I", "d,E,Z", MATCH_CSRRCI, MASK_CSRRCI, match_opcode, WR_xd|RD_xs1 }, -+{"sret", "I", "", MATCH_SRET, MASK_SRET, match_opcode, 0 }, -+{"eret", "I", "", MATCH_SRET, MASK_SRET, match_opcode, 0 }, -+{"mrts", "I", "", MATCH_MRTS, MASK_MRTS, match_opcode, 0 }, -+{"sfence.vm", "I", "", MATCH_SFENCE_VM | MASK_RS1, MASK_SFENCE_VM | MASK_RS1, match_opcode, 0 }, -+{"sfence.vm", "I", "s", MATCH_SFENCE_VM, MASK_SFENCE_VM, match_opcode, RD_xs1 }, -+ -+/* Half-precision floating-point instruction subset */ -+{"flh", "Xhwacha", "D,o(s)", MATCH_FLH, MASK_FLH, match_opcode, WR_fd|RD_xs1 }, -+{"fsh", "Xhwacha", "T,q(s)", MATCH_FSH, MASK_FSH, match_opcode, RD_xs1|RD_fs2 }, -+{"fsgnj.h", "Xhwacha", "D,S,T", MATCH_FSGNJ_H, MASK_FSGNJ_H, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fsgnjn.h", "Xhwacha", "D,S,T", MATCH_FSGNJN_H, MASK_FSGNJN_H, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fsgnjx.h", "Xhwacha", "D,S,T", MATCH_FSGNJX_H, MASK_FSGNJX_H, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fadd.h", "Xhwacha", "D,S,T", MATCH_FADD_H | MASK_RM, MASK_FADD_H | MASK_RM, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fadd.h", "Xhwacha", "D,S,T,m", MATCH_FADD_H, MASK_FADD_H, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fsub.h", "Xhwacha", "D,S,T", MATCH_FSUB_H | MASK_RM, MASK_FSUB_H | MASK_RM, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fsub.h", "Xhwacha", "D,S,T,m", MATCH_FSUB_H, MASK_FSUB_H, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fmul.h", "Xhwacha", "D,S,T", MATCH_FMUL_H | MASK_RM, MASK_FMUL_H | MASK_RM, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fmul.h", "Xhwacha", "D,S,T,m", MATCH_FMUL_H, MASK_FMUL_H, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fdiv.h", "Xhwacha", "D,S,T", MATCH_FDIV_H | MASK_RM, MASK_FDIV_H | MASK_RM, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fdiv.h", "Xhwacha", "D,S,T,m", MATCH_FDIV_H, MASK_FDIV_H, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fsqrt.h", "Xhwacha", "D,S", MATCH_FSQRT_H | MASK_RM, MASK_FSQRT_H | MASK_RM, match_opcode, WR_fd|RD_fs1 }, -+{"fsqrt.h", "Xhwacha", "D,S,m", MATCH_FSQRT_H, MASK_FSQRT_H, match_opcode, WR_fd|RD_fs1 }, -+{"fmin.h", "Xhwacha", "D,S,T", MATCH_FMIN_H, MASK_FMIN_H, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fmax.h", "Xhwacha", "D,S,T", MATCH_FMAX_H, MASK_FMAX_H, match_opcode, WR_fd|RD_fs1|RD_fs2 }, -+{"fmadd.h", "Xhwacha", "D,S,T,R", MATCH_FMADD_H | MASK_RM, MASK_FMADD_H | MASK_RM, match_opcode, WR_fd|RD_fs1|RD_fs2|RD_fs3 }, -+{"fmadd.h", "Xhwacha", "D,S,T,R,m", MATCH_FMADD_H, MASK_FMADD_H, match_opcode, WR_fd|RD_fs1|RD_fs2|RD_fs3 }, -+{"fnmadd.h", "Xhwacha", "D,S,T,R", MATCH_FNMADD_H | MASK_RM, MASK_FNMADD_H | MASK_RM, match_opcode, WR_fd|RD_fs1|RD_fs2|RD_fs3 }, -+{"fnmadd.h", "Xhwacha", "D,S,T,R,m", MATCH_FNMADD_H, MASK_FNMADD_H, match_opcode, WR_fd|RD_fs1|RD_fs2|RD_fs3 }, -+{"fmsub.h", "Xhwacha", "D,S,T,R", MATCH_FMSUB_H | MASK_RM, MASK_FMSUB_H | MASK_RM, match_opcode, WR_fd|RD_fs1|RD_fs2|RD_fs3 }, -+{"fmsub.h", "Xhwacha", "D,S,T,R,m", MATCH_FMSUB_H, MASK_FMSUB_H, match_opcode, WR_fd|RD_fs1|RD_fs2|RD_fs3 }, -+{"fnmsub.h", "Xhwacha", "D,S,T,R", MATCH_FNMSUB_H | MASK_RM, MASK_FNMSUB_H | MASK_RM, match_opcode, WR_fd|RD_fs1|RD_fs2|RD_fs3 }, -+{"fnmsub.h", "Xhwacha", "D,S,T,R,m", MATCH_FNMSUB_H, MASK_FNMSUB_H, match_opcode, WR_fd|RD_fs1|RD_fs2|RD_fs3 }, -+{"fcvt.s.h", "Xhwacha", "D,S", MATCH_FCVT_S_H, MASK_FCVT_S_H | MASK_RM, match_opcode, WR_fd|RD_fs1 }, -+{"fcvt.h.s", "Xhwacha", "D,S", MATCH_FCVT_H_S | MASK_RM, MASK_FCVT_H_S | MASK_RM, match_opcode, WR_fd|RD_fs1 }, -+{"fcvt.h.s", "Xhwacha", "D,S,m", MATCH_FCVT_H_S, MASK_FCVT_H_S, match_opcode, WR_fd|RD_fs1 }, -+{"fcvt.d.h", "Xhwacha", "D,S", MATCH_FCVT_D_H, MASK_FCVT_D_H | MASK_RM, match_opcode, WR_fd|RD_fs1 }, -+{"fcvt.h.d", "Xhwacha", "D,S", MATCH_FCVT_H_D | MASK_RM, MASK_FCVT_H_D | MASK_RM, match_opcode, WR_fd|RD_fs1 }, -+{"fcvt.h.d", "Xhwacha", "D,S,m", MATCH_FCVT_H_D, MASK_FCVT_H_D, match_opcode, WR_fd|RD_fs1 }, -+{"feq.h", "Xhwacha", "d,S,T", MATCH_FEQ_H, MASK_FEQ_H, match_opcode, WR_xd|RD_fs1|RD_fs2 }, -+{"flt.h", "Xhwacha", "d,S,T", MATCH_FLT_H, MASK_FLT_H, match_opcode, WR_xd|RD_fs1|RD_fs2 }, -+{"fle.h", "Xhwacha", "d,S,T", MATCH_FLE_H, MASK_FLE_H, match_opcode, WR_xd|RD_fs1|RD_fs2 }, -+{"fgt.h", "Xhwacha", "d,T,S", MATCH_FLT_H, MASK_FLT_H, match_opcode, WR_xd|RD_fs1|RD_fs2 }, -+{"fge.h", "Xhwacha", "d,T,S", MATCH_FLE_H, MASK_FLE_H, match_opcode, WR_xd|RD_fs1|RD_fs2 }, -+{"fmv.x.h", "Xhwacha", "d,S", MATCH_FMV_X_H, MASK_FMV_X_H, match_opcode, WR_xd|RD_fs1 }, -+{"fmv.h.x", "Xhwacha", "D,s", MATCH_FMV_H_X, MASK_FMV_H_X, match_opcode, WR_fd|RD_xs1 }, -+{"fcvt.w.h", "Xhwacha", "d,S", MATCH_FCVT_W_H | MASK_RM, MASK_FCVT_W_H | MASK_RM, match_opcode, WR_xd|RD_fs1 }, -+{"fcvt.w.h", "Xhwacha", "d,S,m", MATCH_FCVT_W_H, MASK_FCVT_W_H, match_opcode, WR_xd|RD_fs1 }, -+{"fcvt.wu.h", "Xhwacha", "d,S", MATCH_FCVT_WU_H | MASK_RM, MASK_FCVT_WU_H | MASK_RM, match_opcode, WR_xd|RD_fs1 }, -+{"fcvt.wu.h", "Xhwacha", "d,S,m", MATCH_FCVT_WU_H, MASK_FCVT_WU_H, match_opcode, WR_xd|RD_fs1 }, -+{"fcvt.h.w", "Xhwacha", "D,s", MATCH_FCVT_H_W, MASK_FCVT_H_W | MASK_RM, match_opcode, WR_fd|RD_xs1 }, -+{"fcvt.h.wu", "Xhwacha", "D,s", MATCH_FCVT_H_WU, MASK_FCVT_H_WU | MASK_RM, match_opcode, WR_fd|RD_xs1 }, -+{"fcvt.l.h", "Xhwacha", "d,S", MATCH_FCVT_L_H | MASK_RM, MASK_FCVT_L_H | MASK_RM, match_opcode, WR_xd|RD_fs1 }, -+{"fcvt.l.h", "Xhwacha", "d,S,m", MATCH_FCVT_L_H, MASK_FCVT_L_H, match_opcode, WR_xd|RD_fs1 }, -+{"fcvt.lu.h", "Xhwacha", "d,S", MATCH_FCVT_LU_H | MASK_RM, MASK_FCVT_LU_H | MASK_RM, match_opcode, WR_xd|RD_fs1 }, -+{"fcvt.lu.h", "Xhwacha", "d,S,m", MATCH_FCVT_LU_H, MASK_FCVT_LU_H, match_opcode, WR_xd|RD_fs1 }, -+{"fcvt.h.l", "Xhwacha", "D,s", MATCH_FCVT_H_L | MASK_RM, MASK_FCVT_H_L | MASK_RM, match_opcode, WR_fd|RD_xs1 }, -+{"fcvt.h.l", "Xhwacha", "D,s,m", MATCH_FCVT_H_L, MASK_FCVT_H_L, match_opcode, WR_fd|RD_xs1 }, -+{"fcvt.h.lu", "Xhwacha", "D,s", MATCH_FCVT_H_LU | MASK_RM, MASK_FCVT_H_L | MASK_RM, match_opcode, WR_fd|RD_xs1 }, -+{"fcvt.h.lu", "Xhwacha", "D,s,m", MATCH_FCVT_H_LU, MASK_FCVT_H_LU, match_opcode, WR_fd|RD_xs1 }, -+ -+/* Rocket Custom Coprocessor extension */ -+{"custom0", "Xcustom", "d,s,t,^j", MATCH_CUSTOM0_RD_RS1_RS2, MASK_CUSTOM0_RD_RS1_RS2, match_opcode, 0}, -+{"custom0", "Xcustom", "d,s,^t,^j", MATCH_CUSTOM0_RD_RS1, MASK_CUSTOM0_RD_RS1, match_opcode, 0}, -+{"custom0", "Xcustom", "d,^s,^t,^j", MATCH_CUSTOM0_RD, MASK_CUSTOM0_RD, match_opcode, 0}, -+{"custom0", "Xcustom", "^d,s,t,^j", MATCH_CUSTOM0_RS1_RS2, MASK_CUSTOM0_RS1_RS2, match_opcode, 0}, -+{"custom0", "Xcustom", "^d,s,^t,^j", MATCH_CUSTOM0_RS1, MASK_CUSTOM0_RS1, match_opcode, 0}, -+{"custom0", "Xcustom", "^d,^s,^t,^j", MATCH_CUSTOM0, MASK_CUSTOM0, match_opcode, 0}, -+{"custom1", "Xcustom", "d,s,t,^j", MATCH_CUSTOM1_RD_RS1_RS2, MASK_CUSTOM1_RD_RS1_RS2, match_opcode, 0}, -+{"custom1", "Xcustom", "d,s,^t,^j", MATCH_CUSTOM1_RD_RS1, MASK_CUSTOM1_RD_RS1, match_opcode, 0}, -+{"custom1", "Xcustom", "d,^s,^t,^j", MATCH_CUSTOM1_RD, MASK_CUSTOM1_RD, match_opcode, 0}, -+{"custom1", "Xcustom", "^d,s,t,^j", MATCH_CUSTOM1_RS1_RS2, MASK_CUSTOM1_RS1_RS2, match_opcode, 0}, -+{"custom1", "Xcustom", "^d,s,^t,^j", MATCH_CUSTOM1_RS1, MASK_CUSTOM1_RS1, match_opcode, 0}, -+{"custom1", "Xcustom", "^d,^s,^t,^j", MATCH_CUSTOM1, MASK_CUSTOM1, match_opcode, 0}, -+{"custom2", "Xcustom", "d,s,t,^j", MATCH_CUSTOM2_RD_RS1_RS2, MASK_CUSTOM2_RD_RS1_RS2, match_opcode, 0}, -+{"custom2", "Xcustom", "d,s,^t,^j", MATCH_CUSTOM2_RD_RS1, MASK_CUSTOM2_RD_RS1, match_opcode, 0}, -+{"custom2", "Xcustom", "d,^s,^t,^j", MATCH_CUSTOM2_RD, MASK_CUSTOM2_RD, match_opcode, 0}, -+{"custom2", "Xcustom", "^d,s,t,^j", MATCH_CUSTOM2_RS1_RS2, MASK_CUSTOM2_RS1_RS2, match_opcode, 0}, -+{"custom2", "Xcustom", "^d,s,^t,^j", MATCH_CUSTOM2_RS1, MASK_CUSTOM2_RS1, match_opcode, 0}, -+{"custom2", "Xcustom", "^d,^s,^t,^j", MATCH_CUSTOM2, MASK_CUSTOM2, match_opcode, 0}, -+{"custom3", "Xcustom", "d,s,t,^j", MATCH_CUSTOM3_RD_RS1_RS2, MASK_CUSTOM3_RD_RS1_RS2, match_opcode, 0}, -+{"custom3", "Xcustom", "d,s,^t,^j", MATCH_CUSTOM3_RD_RS1, MASK_CUSTOM3_RD_RS1, match_opcode, 0}, -+{"custom3", "Xcustom", "d,^s,^t,^j", MATCH_CUSTOM3_RD, MASK_CUSTOM3_RD, match_opcode, 0}, -+{"custom3", "Xcustom", "^d,s,t,^j", MATCH_CUSTOM3_RS1_RS2, MASK_CUSTOM3_RS1_RS2, match_opcode, 0}, -+{"custom3", "Xcustom", "^d,s,^t,^j", MATCH_CUSTOM3_RS1, MASK_CUSTOM3_RS1, match_opcode, 0}, -+{"custom3", "Xcustom", "^d,^s,^t,^j", MATCH_CUSTOM3, MASK_CUSTOM3, match_opcode, 0}, -+ -+/* Xhwacha extension */ -+{"stop", "Xhwacha", "", MATCH_STOP, MASK_STOP, match_opcode, 0}, -+{"utidx", "Xhwacha", "d", MATCH_UTIDX, MASK_UTIDX, match_opcode, WR_xd}, -+{"movz", "Xhwacha", "d,s,t", MATCH_MOVZ, MASK_MOVZ, match_opcode, WR_xd|RD_xs1|RD_xs2}, -+{"movn", "Xhwacha", "d,s,t", MATCH_MOVN, MASK_MOVN, match_opcode, WR_xd|RD_xs1|RD_xs2}, -+{"fmovz", "Xhwacha", "D,s,T", MATCH_FMOVZ, MASK_FMOVZ, match_opcode, WR_fd|RD_xs1|RD_fs2}, -+{"fmovn", "Xhwacha", "D,s,T", MATCH_FMOVN, MASK_FMOVN, match_opcode, WR_fd|RD_xs1|RD_fs2}, -+ -+/* unit stride */ -+/* xloads */ -+{"vld", "Xhwacha", "#d,s", MATCH_VLD, MASK_VLD, match_opcode, 0}, -+{"vlw", "Xhwacha", "#d,s", MATCH_VLW, MASK_VLW, match_opcode, 0}, -+{"vlwu", "Xhwacha", "#d,s", MATCH_VLWU, MASK_VLWU, match_opcode, 0}, -+{"vlh", "Xhwacha", "#d,s", MATCH_VLH, MASK_VLH, match_opcode, 0}, -+{"vlhu", "Xhwacha", "#d,s", MATCH_VLHU, MASK_VLHU, match_opcode, 0}, -+{"vlb", "Xhwacha", "#d,s", MATCH_VLB, MASK_VLB, match_opcode, 0}, -+{"vlbu", "Xhwacha", "#d,s", MATCH_VLBU, MASK_VLBU, match_opcode, 0}, -+/* floads */ -+{"vfld", "Xhwacha", "#D,s", MATCH_VFLD, MASK_VFLD, match_opcode, 0}, -+{"vflw", "Xhwacha", "#D,s", MATCH_VFLW, MASK_VFLW, match_opcode, 0}, -+ -+/* stride */ -+/* xloads */ -+{"vlstd", "Xhwacha", "#d,s,t", MATCH_VLSTD, MASK_VLSTD, match_opcode, 0}, -+{"vlstw", "Xhwacha", "#d,s,t", MATCH_VLSTW, MASK_VLSTW, match_opcode, 0}, -+{"vlstwu", "Xhwacha", "#d,s,t", MATCH_VLSTWU, MASK_VLSTWU, match_opcode, 0}, -+{"vlsth", "Xhwacha", "#d,s,t", MATCH_VLSTH, MASK_VLSTH, match_opcode, 0}, -+{"vlsthu", "Xhwacha", "#d,s,t", MATCH_VLSTHU, MASK_VLSTHU, match_opcode, 0}, -+{"vlstb", "Xhwacha", "#d,s,t", MATCH_VLSTB, MASK_VLSTB, match_opcode, 0}, -+{"vlstbu", "Xhwacha", "#d,s,t", MATCH_VLSTBU, MASK_VLSTBU, match_opcode, 0}, -+/* floads */ -+{"vflstd", "Xhwacha", "#D,s,t", MATCH_VFLSTD, MASK_VFLSTD, match_opcode, 0}, -+{"vflstw", "Xhwacha", "#D,s,t", MATCH_VFLSTW, MASK_VFLSTW, match_opcode, 0}, -+ -+/* segment */ -+/* xloads */ -+{"vlsegd", "Xhwacha", "#d,s,#n", MATCH_VLSEGD, MASK_VLSEGD, match_opcode, 0}, -+{"vlsegw", "Xhwacha", "#d,s,#n", MATCH_VLSEGW, MASK_VLSEGW, match_opcode, 0}, -+{"vlsegwu", "Xhwacha", "#d,s,#n", MATCH_VLSEGWU, MASK_VLSEGWU, match_opcode, 0}, -+{"vlsegh", "Xhwacha", "#d,s,#n", MATCH_VLSEGH, MASK_VLSEGH, match_opcode, 0}, -+{"vlseghu", "Xhwacha", "#d,s,#n", MATCH_VLSEGHU, MASK_VLSEGHU, match_opcode, 0}, -+{"vlsegb", "Xhwacha", "#d,s,#n", MATCH_VLSEGB, MASK_VLSEGB, match_opcode, 0}, -+{"vlsegbu", "Xhwacha", "#d,s,#n", MATCH_VLSEGBU, MASK_VLSEGBU, match_opcode, 0}, -+/* floads */ -+{"vflsegd", "Xhwacha", "#D,s,#n", MATCH_VFLSEGD, MASK_VFLSEGD, match_opcode, 0}, -+{"vflsegw", "Xhwacha", "#D,s,#n", MATCH_VFLSEGW, MASK_VFLSEGW, match_opcode, 0}, -+ -+/* stride segment */ -+/* xloads */ -+{"vlsegstd", "Xhwacha", "#d,s,t,#n", MATCH_VLSEGSTD, MASK_VLSEGSTD, match_opcode, 0}, -+{"vlsegstw", "Xhwacha", "#d,s,t,#n", MATCH_VLSEGSTW, MASK_VLSEGSTW, match_opcode, 0}, -+{"vlsegstwu", "Xhwacha", "#d,s,t,#n", MATCH_VLSEGSTWU, MASK_VLSEGSTWU, match_opcode, 0}, -+{"vlsegsth", "Xhwacha", "#d,s,t,#n", MATCH_VLSEGSTH, MASK_VLSEGSTH, match_opcode, 0}, -+{"vlsegsthu", "Xhwacha", "#d,s,t,#n", MATCH_VLSEGSTHU, MASK_VLSEGSTHU, match_opcode, 0}, -+{"vlsegstb", "Xhwacha", "#d,s,t,#n", MATCH_VLSEGSTB, MASK_VLSEGSTB, match_opcode, 0}, -+{"vlsegstbu", "Xhwacha", "#d,s,t,#n", MATCH_VLSEGSTBU, MASK_VLSEGSTBU, match_opcode, 0}, -+/* floads */ -+{"vflsegstd", "Xhwacha", "#D,s,t,#n", MATCH_VFLSEGSTD, MASK_VFLSEGSTD, match_opcode, 0}, -+{"vflsegstw", "Xhwacha", "#D,s,t,#n", MATCH_VFLSEGSTW, MASK_VFLSEGSTW, match_opcode, 0}, -+ -+/* unit stride */ -+/* xstores */ -+{"vsd", "Xhwacha", "#d,s", MATCH_VSD, MASK_VSD, match_opcode, 0}, -+{"vsw", "Xhwacha", "#d,s", MATCH_VSW, MASK_VSW, match_opcode, 0}, -+{"vsh", "Xhwacha", "#d,s", MATCH_VSH, MASK_VSH, match_opcode, 0}, -+{"vsb", "Xhwacha", "#d,s", MATCH_VSB, MASK_VSB, match_opcode, 0}, -+/* fstores */ -+{"vfsd", "Xhwacha", "#D,s", MATCH_VFSD, MASK_VFSD, match_opcode, 0}, -+{"vfsw", "Xhwacha", "#D,s", MATCH_VFSW, MASK_VFSW, match_opcode, 0}, -+ -+/* stride */ -+/* xstores */ -+{"vsstd", "Xhwacha", "#d,s,t", MATCH_VSSTD, MASK_VSSTD, match_opcode, 0}, -+{"vsstw", "Xhwacha", "#d,s,t", MATCH_VSSTW, MASK_VSSTW, match_opcode, 0}, -+{"vssth", "Xhwacha", "#d,s,t", MATCH_VSSTH, MASK_VSSTH, match_opcode, 0}, -+{"vsstb", "Xhwacha", "#d,s,t", MATCH_VSSTB, MASK_VSSTB, match_opcode, 0}, -+/* fstores */ -+{"vfsstd", "Xhwacha", "#D,s,t", MATCH_VFSSTD, MASK_VFSSTD, match_opcode, 0}, -+{"vfsstw", "Xhwacha", "#D,s,t", MATCH_VFSSTW, MASK_VFSSTW, match_opcode, 0}, -+ -+/* segment */ -+/* xstores */ -+{"vssegd", "Xhwacha", "#d,s,#n", MATCH_VSSEGD, MASK_VSSEGD, match_opcode, 0}, -+{"vssegw", "Xhwacha", "#d,s,#n", MATCH_VSSEGW, MASK_VSSEGW, match_opcode, 0}, -+{"vssegh", "Xhwacha", "#d,s,#n", MATCH_VSSEGH, MASK_VSSEGH, match_opcode, 0}, -+{"vssegb", "Xhwacha", "#d,s,#n", MATCH_VSSEGB, MASK_VSSEGB, match_opcode, 0}, -+/* fstores */ -+{"vfssegd", "Xhwacha", "#D,s,#n", MATCH_VFSSEGD, MASK_VFSSEGD, match_opcode, 0}, -+{"vfssegw", "Xhwacha", "#D,s,#n", MATCH_VFSSEGW, MASK_VFSSEGW, match_opcode, 0}, -+ -+/* stride segment */ -+/* xsegstores */ -+{"vssegstd", "Xhwacha", "#d,s,t,#n", MATCH_VSSEGSTD, MASK_VSSEGSTD, match_opcode, 0}, -+{"vssegstw", "Xhwacha", "#d,s,t,#n", MATCH_VSSEGSTW, MASK_VSSEGSTW, match_opcode, 0}, -+{"vssegsth", "Xhwacha", "#d,s,t,#n", MATCH_VSSEGSTH, MASK_VSSEGSTH, match_opcode, 0}, -+{"vssegstb", "Xhwacha", "#d,s,t,#n", MATCH_VSSEGSTB, MASK_VSSEGSTB, match_opcode, 0}, -+/* fsegstores */ -+{"vfssegstd", "Xhwacha", "#D,s,t,#n", MATCH_VFSSEGSTD, MASK_VFSSEGSTD, match_opcode, 0}, -+{"vfssegstw", "Xhwacha", "#D,s,t,#n", MATCH_VFSSEGSTW, MASK_VFSSEGSTW, match_opcode, 0}, -+ -+{"vsetcfg", "Xhwacha", "s", MATCH_VSETCFG, MASK_VSETCFG | MASK_IMM, match_opcode, 0}, -+{"vsetcfg", "Xhwacha", "#g,#f", MATCH_VSETCFG, MASK_VSETCFG | MASK_RS1, match_opcode, 0}, -+{"vsetcfg", "Xhwacha", "s,#g,#f", MATCH_VSETCFG, MASK_VSETCFG, match_opcode, 0}, -+{"vsetucfg", "Xhwacha", "d,u", MATCH_LUI, MASK_LUI, match_opcode, INSN_ALIAS | WR_xd}, -+{"vsetvl", "Xhwacha", "d,s", MATCH_VSETVL, MASK_VSETVL, match_opcode, 0}, -+{"vgetcfg", "Xhwacha", "d", MATCH_VGETCFG, MASK_VGETCFG, match_opcode, 0}, -+{"vgetvl", "Xhwacha", "d", MATCH_VGETVL, MASK_VGETVL, match_opcode, 0}, -+ -+{"vmvv", "Xhwacha", "#d,#s", MATCH_VMVV, MASK_VMVV, match_opcode, 0}, -+{"vmsv", "Xhwacha", "#d,s", MATCH_VMSV, MASK_VMSV, match_opcode, 0}, -+{"vfmvv", "Xhwacha", "#D,#S", MATCH_VFMVV, MASK_VFMVV, match_opcode, 0}, -+{"vfmsv.d", "Xhwacha", "#D,s", MATCH_VFMSV_D, MASK_VFMSV_D, match_opcode, 0}, -+{"vfmsv.s", "Xhwacha", "#D,s", MATCH_VFMSV_S, MASK_VFMSV_S, match_opcode, 0}, -+ -+{"vf", "Xhwacha", "q(s)", MATCH_VF, MASK_VF, match_opcode, 0}, -+{"vf", "Xhwacha", "A,s", 0, (int) M_VF, match_never, INSN_MACRO }, -+ -+{"vxcptcause", "Xhwacha", "d", MATCH_VXCPTCAUSE, MASK_VXCPTCAUSE, match_opcode, 0}, -+{"vxcptaux", "Xhwacha", "d", MATCH_VXCPTAUX, MASK_VXCPTAUX, match_opcode, 0}, -+ -+{"vxcptsave", "Xhwacha", "s", MATCH_VXCPTSAVE, MASK_VXCPTSAVE, match_opcode, 0}, -+{"vxcptrestore", "Xhwacha", "s", MATCH_VXCPTRESTORE, MASK_VXCPTRESTORE, match_opcode, 0}, -+{"vxcptkill", "Xhwacha", "", MATCH_VXCPTKILL, MASK_VXCPTKILL, match_opcode, 0}, -+ -+{"vxcptevac", "Xhwacha", "s", MATCH_VXCPTEVAC, MASK_VXCPTEVAC, match_opcode, 0}, -+{"vxcpthold", "Xhwacha", "s", MATCH_VXCPTHOLD, MASK_VXCPTHOLD, match_opcode, 0}, -+{"venqcmd", "Xhwacha", "s,t", MATCH_VENQCMD, MASK_VENQCMD, match_opcode, 0}, -+{"venqimm1", "Xhwacha", "s,t", MATCH_VENQIMM1, MASK_VENQIMM1, match_opcode, 0}, -+{"venqimm2", "Xhwacha", "s,t", MATCH_VENQIMM2, MASK_VENQIMM2, match_opcode, 0}, -+{"venqcnt", "Xhwacha", "s,t", MATCH_VENQCNT, MASK_VENQCNT, match_opcode, 0}, -+}; -+ -+#define RISCV_NUM_OPCODES \ -+ ((sizeof riscv_builtin_opcodes) / (sizeof (riscv_builtin_opcodes[0]))) -+const int bfd_riscv_num_builtin_opcodes = RISCV_NUM_OPCODES; -+ -+/* const removed from the following to allow for dynamic extensions to the -+ * built-in instruction set. */ -+struct riscv_opcode *riscv_opcodes = -+ (struct riscv_opcode *) riscv_builtin_opcodes; -+int bfd_riscv_num_opcodes = RISCV_NUM_OPCODES; -+#undef RISCV_NUM_OPCODES diff --git a/external/gpl3/gcc/patches/0000-gcc_nbsd.patch b/external/gpl3/gcc/patches/0000-gcc_nbsd.patch deleted file mode 100644 index 4856e4371..000000000 --- a/external/gpl3/gcc/patches/0000-gcc_nbsd.patch +++ /dev/null @@ -1,25562 +0,0 @@ -diff -rNU3 dist.orig/.gitignore dist/.gitignore ---- dist.orig/.gitignore 2013-01-10 16:48:46.000000000 +0100 -+++ dist/.gitignore 1970-01-01 01:00:00.000000000 +0100 -@@ -1,42 +0,0 @@ --*.diff --*.patch --*.orig --*.rej -- --*~ --.#* --*# -- --*.flt --*.gmo --*.info --*.la --*.lo --*.o --*.pyc --*.tmp -- --.deps --.libs -- --autom4te.cache --config.cache --config.h --config.intl --config.log --config.status --libtool --POTFILES --*-POTFILES -- --TAGS --TAGS.sub -- --.gdbinit --.gdb_history -- --# ignore core files, but not java/net/protocol/core/ --core --!core/ -- --lost+found -diff -rNU3 dist.orig/config.guess dist/config.guess ---- dist.orig/config.guess 2014-04-04 15:48:08.000000000 +0200 -+++ dist/config.guess 2015-10-18 13:19:49.000000000 +0200 -@@ -171,16 +171,32 @@ - UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \ - /usr/sbin/$sysctl 2>/dev/null || echo unknown)` - case "${UNAME_MACHINE_ARCH}" in -+ earm*eb*) machine=armeb-unknown ;; -+ earm*) machine=arm-unknown ;; - armeb) machine=armeb-unknown ;; - arm*) machine=arm-unknown ;; -+ coldfire) machine=m5407-unknown ;; -+ earm*eb*) machine=armeb-unknown ;; -+ earm*) machine=arm-unknown ;; - sh3el) machine=shl-unknown ;; - sh3eb) machine=sh-unknown ;; - sh5el) machine=sh5le-unknown ;; - *) machine=${UNAME_MACHINE_ARCH}-unknown ;; - esac - # The Operating System including object format, if it has switched -- # to ELF recently, or will in the future. -+ # to ELF recently, or will in the future and ABI. - case "${UNAME_MACHINE_ARCH}" in -+ coldfire) os=netbsdelf ;; -+ earm*) -+ eval $set_cc_for_build -+ if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ -+ | grep -q __ARM_PCS_VFP -+ then -+ os=netbsdelf-eabi -+ else -+ os=netbsdelf-eabihf -+ fi -+ ;; - arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval $set_cc_for_build - if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ -diff -rNU3 dist.orig/config.sub dist/config.sub ---- dist.orig/config.sub 2014-04-04 15:48:08.000000000 +0200 -+++ dist/config.sub 2015-10-18 13:19:49.000000000 +0200 -@@ -117,7 +117,7 @@ - case $maybe_os in - nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \ - linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \ -- knetbsd*-gnu* | netbsd*-gnu* | \ -+ knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \ - kopensolaris*-gnu* | \ - storm-chaos* | os2-emx* | rtmk-nova*) - os=-$maybe_os -@@ -297,7 +297,7 @@ - | nios | nios2 | nios2eb | nios2el \ - | ns16k | ns32k \ - | open8 \ -- | or1k | or32 \ -+ | or1k | or1knd \ - | pdp10 | pdp11 | pj | pjl \ - | powerpc | powerpc64 | powerpc64le | powerpcle \ - | pyramid \ -@@ -329,12 +329,21 @@ - basic_machine=$basic_machine-unknown - os=-none - ;; -- m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k) -+ m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | m5407 \ -+ | v70 | w65 | z8k) - ;; - ms1) - basic_machine=mt-unknown - ;; - -+ riscv32-*) -+ basic_machine=riscv32-ucb -+ ;; -+ -+ riscv*-*) -+ basic_machine=riscv-ucb -+ ;; -+ - strongarm | thumb | xscale) - basic_machine=arm-unknown - ;; -@@ -386,6 +395,7 @@ - | le32-* | le64-* \ - | lm32-* \ - | m32c-* | m32r-* | m32rle-* \ -+ | m5200-* | m5407-* \ - | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ - | m88110-* | m88k-* | maxq-* | mcore-* | metag-* \ - | microblaze-* | microblazeel-* \ -@@ -920,8 +930,11 @@ - basic_machine=hppa1.1-oki - os=-proelf - ;; -- openrisc | openrisc-*) -- basic_machine=or32-unknown -+ or1k | or1k-*) -+ basic_machine=or1k-unknown -+ ;; -+ or1knd | or1knd-*) -+ basic_machine=or1knd-unknown - ;; - os400) - basic_machine=powerpc-ibm -@@ -1597,8 +1610,8 @@ - or1k-*) - os=-elf - ;; -- or32-*) -- os=-coff -+ or1knd-*) -+ os=-elf - ;; - *-tti) # must be before sparc entry or we get the wrong os. - os=-sysv3 -diff -rNU3 dist.orig/configure dist/configure ---- dist.orig/configure 2015-05-03 19:26:29.000000000 +0200 -+++ dist/configure 2015-10-18 13:19:49.000000000 +0200 -@@ -2292,7 +2292,7 @@ - for ac_t in install-sh install.sh shtool; do - if test -f "$ac_dir/$ac_t"; then - ac_aux_dir=$ac_dir -- ac_install_sh="$ac_aux_dir/$ac_t -c" -+ ac_install_sh="$SHELL $ac_aux_dir/$ac_t -c" - break 2 - fi - done -@@ -6287,8 +6287,12 @@ - - if test $target_elf = yes; then : - # ELF platforms build the lto-plugin always. -- build_lto_plugin=yes -- -+ case $target in -+ m68010-*) -+ build_lto_plugin=no;; -+ *) -+ build_lto_plugin=yes;; -+ esac - else - if test x"$default_enable_lto" = x"yes" ; then - case $target in -diff -rNU3 dist.orig/configure.ac dist/configure.ac ---- dist.orig/configure.ac 2015-05-03 19:26:29.000000000 +0200 -+++ dist/configure.ac 2015-10-18 13:19:49.000000000 +0200 -@@ -1685,7 +1685,12 @@ - enable_lto=yes; default_enable_lto=yes) - - ACX_ELF_TARGET_IFELSE([# ELF platforms build the lto-plugin always. -- build_lto_plugin=yes -+ case $target in -+ m68010-*) -+ build_lto_plugin=no;; -+ *) -+ build_lto_plugin=yes;; -+ esac - ],[if test x"$default_enable_lto" = x"yes" ; then - case $target in - *-apple-darwin9* | *-cygwin* | *-mingw*) ;; -diff -rNU3 dist.orig/fixincludes/configure dist/fixincludes/configure ---- dist.orig/fixincludes/configure 2012-05-29 21:28:57.000000000 +0200 -+++ dist/fixincludes/configure 2015-10-18 13:19:49.000000000 +0200 -@@ -2141,7 +2141,7 @@ - for ac_t in install-sh install.sh shtool; do - if test -f "$ac_dir/$ac_t"; then - ac_aux_dir=$ac_dir -- ac_install_sh="$ac_aux_dir/$ac_t -c" -+ ac_install_sh="$SHELL $ac_aux_dir/$ac_t -c" - break 2 - fi - done -diff -rNU3 dist.orig/gcc/Makefile.in dist/gcc/Makefile.in ---- dist.orig/gcc/Makefile.in 2014-04-05 12:26:19.000000000 +0200 -+++ dist/gcc/Makefile.in 2015-10-18 13:19:51.000000000 +0200 -@@ -639,6 +639,9 @@ - exeext = @host_exeext@ - build_exeext = @build_exeext@ - -+# NetBSD mknative-gcc addition -+ENABLE_SHARED = @enable_shared@ -+ - # Directory in which to put man pages. - mandir = @mandir@ - man1dir = $(mandir)/man1 -@@ -706,6 +709,7 @@ - - # Control whether header files are installed. - INSTALL_HEADERS=install-headers install-mkheaders -+INSTALL_HEADERS=install-headers - - # Control whether Info documentation is built and installed. - BUILD_INFO = @BUILD_INFO@ -@@ -747,8 +751,7 @@ - - # Native linker and preprocessor flags. For x-fragment overrides. - BUILD_LDFLAGS=@BUILD_LDFLAGS@ --BUILD_CPPFLAGS= -I. -I$(@D) -I$(srcdir) -I$(srcdir)/$(@D) \ -- -I$(srcdir)/../include @INCINTL@ $(CPPINC) $(CPPFLAGS) -+BUILD_CPPFLAGS=$(BALL_CPPFLAGS) - - # Actual name to use when installing a native compiler. - GCC_INSTALL_NAME := $(shell echo gcc|sed '$(program_transform_name)') -@@ -998,6 +1001,7 @@ - # puts -I options in CPPFLAGS, our include files in the srcdir will always - # win against random include files in /usr/include. - ALL_CPPFLAGS = $(INCLUDES) $(CPPFLAGS) -+BALL_CPPFLAGS = $(BINCLUDES) $(CPPFLAGS) - - # This is the variable to use when using $(COMPILER). - ALL_COMPILERFLAGS = $(ALL_CXXFLAGS) -@@ -1054,6 +1058,10 @@ - -I$(srcdir)/../include @INCINTL@ \ - $(CPPINC) $(GMPINC) $(DECNUMINC) $(BACKTRACEINC) \ - $(CLOOGINC) $(ISLINC) -+BINCLUDES = -I. -I$(@D) -I$(srcdir) -I$(srcdir)/$(@D) \ -+ -I$(srcdir)/../include @INCINTL@ \ -+ $(CPPINC) $(DECNUMINC) $(BACKTRACEINC) \ -+ $(CLOOGINC) $(ISLINC) - - .c.o: - $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $< $(OUTPUT_OPTION) -@@ -1796,7 +1804,7 @@ - - checksum-options: - echo "$(LINKER) $(ALL_LINKERFLAGS) $(LDFLAGS)" > checksum-options.tmp \ -- && $(srcdir)/../move-if-change checksum-options.tmp checksum-options -+ && $(SHELL) $(srcdir)/../move-if-change checksum-options.tmp checksum-options - - # - # Build libgcc.a. -@@ -1804,7 +1812,7 @@ - libgcc-support: libgcc.mvars stmp-int-hdrs $(TCONFIG_H) \ - $(MACHMODE_H) gcov-iov.h - --libgcc.mvars: config.status Makefile specs xgcc$(exeext) -+libgcc.mvars: config.status Makefile - : > tmp-libgcc.mvars - echo GCC_CFLAGS = '$(GCC_CFLAGS)' >> tmp-libgcc.mvars - echo INHIBIT_LIBC_CFLAGS = '$(INHIBIT_LIBC_CFLAGS)' >> tmp-libgcc.mvars -@@ -1819,6 +1827,7 @@ - s-mlib: $(srcdir)/genmultilib Makefile - if test @enable_multilib@ = yes \ - || test -n "$(MULTILIB_OSDIRNAMES)"; then \ -+ CONFIG_SHELL="$(SHELL)" \ - $(SHELL) $(srcdir)/genmultilib \ - "$(MULTILIB_OPTIONS)" \ - "$(MULTILIB_DIRNAMES)" \ -@@ -3909,21 +3918,21 @@ - - gengtype-parse.o build/gengtype-parse.o : gengtype-parse.c gengtype.h \ - $(SYSTEM_H) --gengtype-parse.o: $(CONFIG_H) -+gengtype-parse.o: $(CONFIG_H) $(BCONFIG_H) - CFLAGS-gengtype-parse.o += -DGENERATOR_FILE - build/gengtype-parse.o: $(BCONFIG_H) - - gengtype-state.o build/gengtype-state.o: gengtype-state.c $(SYSTEM_H) \ - gengtype.h errors.h double-int.h version.h $(HASHTAB_H) $(OBSTACK_H) \ - $(XREGEX_H) --gengtype-state.o: $(CONFIG_H) -+gengtype-state.o: $(CONFIG_H) $(BCONFIG_H) - CFLAGS-gengtype-state.o += -DGENERATOR_FILE - build/gengtype-state.o: $(BCONFIG_H) - - gengtype.o build/gengtype.o : gengtype.c $(SYSTEM_H) gengtype.h \ - rtl.def insn-notes.def errors.h double-int.h version.h $(HASHTAB_H) \ - $(OBSTACK_H) $(XREGEX_H) --gengtype.o: $(CONFIG_H) -+gengtype.o: $(CONFIG_H) $(BCONFIG_H) - CFLAGS-gengtype.o += -DGENERATOR_FILE - build/gengtype.o: $(BCONFIG_H) - -@@ -4061,6 +4070,12 @@ - # s-* so that mostlyclean does not force the include directory to - # be rebuilt. - -+unwind.h: $(UNWIND_H) -+ -if [ -d include ] ; then true; else mkdir include; chmod a+rx include; fi -+ rm -f include/unwind.h -+ cp $(UNWIND_H) include/unwind.h -+ chmod a+r include/unwind.h -+ - # Build the include directories. - stmp-int-hdrs: $(STMP_FIXINC) $(USER_H) fixinc_list - # Copy in the headers provided with gcc. -@@ -4076,6 +4091,7 @@ - # e.g. install-no-fixedincludes. - -if [ -d include ] ; then true; else mkdir include; chmod a+rx include; fi - -if [ -d include-fixed ] ; then true; else mkdir include-fixed; chmod a+rx include-fixed; fi -+ if false; then \ - for file in .. $(USER_H); do \ - if [ X$$file != X.. ]; then \ - realfile=`echo $$file | sed -e 's|.*/\([^/]*\)$$|\1|'`; \ -@@ -4084,7 +4100,7 @@ - cp $$file include; \ - chmod a+r include/$$realfile; \ - fi; \ -- done -+ done; \ - for file in .. $(USER_H_INC_NEXT_PRE); do \ - if [ X$$file != X.. ]; then \ - mv include/$$file include/x_$$file; \ -@@ -4093,14 +4109,14 @@ - rm -f include/x_$$file; \ - chmod a+r include/$$file; \ - fi; \ -- done -+ done; \ - for file in .. $(USER_H_INC_NEXT_POST); do \ - if [ X$$file != X.. ]; then \ - echo "#include_next <$$file>" >>include/$$file; \ - chmod a+r include/$$file; \ - fi; \ -- done -- rm -f include/stdint.h -+ done; \ -+ rm -f include/stdint.h; \ - if [ $(USE_GCC_STDINT) = wrap ]; then \ - rm -f include/stdint-gcc.h; \ - cp $(srcdir)/ginclude/stdint-gcc.h include/stdint-gcc.h; \ -@@ -4110,7 +4126,7 @@ - elif [ $(USE_GCC_STDINT) = provide ]; then \ - cp $(srcdir)/ginclude/stdint-gcc.h include/stdint.h; \ - chmod a+r include/stdint.h; \ -- fi -+ fi; \ - set -e; for ml in `cat fixinc_list`; do \ - sysroot_headers_suffix=`echo $${ml} | sed -e 's/;.*$$//'`; \ - multi_dir=`echo $${ml} | sed -e 's/^[^;]*;//'`; \ -@@ -4127,7 +4143,8 @@ - rm -f $${fix_dir}/limits.h; \ - cp -p tmp-limits.h $${fix_dir}/limits.h; \ - chmod a+r $${fix_dir}/limits.h; \ -- done -+ done; \ -+ fi - # Install the README - rm -f include-fixed/README - cp $(srcdir)/../fixincludes/README-fixinc include-fixed/README -@@ -4187,10 +4204,11 @@ - # Abort if no system headers available, unless building a crosscompiler. - # FIXME: abort unless building --without-headers would be more accurate and less ugly - stmp-fixinc: gsyslimits.h macro_list fixinc_list \ -- $(build_objdir)/fixincludes/fixincl \ -+ $(build_objdir)/fixincludes/fixincl$(build_exeext) \ - $(build_objdir)/fixincludes/fixinc.sh -- rm -rf include-fixed; mkdir include-fixed -- -chmod a+rx include-fixed -+ if false; then \ -+ rm -rf include-fixed; mkdir include-fixed; \ -+ -chmod a+rx include-fixed; \ - if [ -d ../prev-gcc ]; then \ - cd ../prev-gcc && \ - $(MAKE) real-$(INSTALL_HEADERS_DIR) DESTDIR=`pwd`/../gcc/ \ -@@ -4224,6 +4242,7 @@ - fi; \ - chmod a+r $${fix_dir}/syslimits.h; \ - done; \ -+ fi; \ - fi - $(STAMP) stmp-fixinc - # -@@ -4710,6 +4729,8 @@ - lang.install-info - - $(DESTDIR)$(infodir)/%.info: doc/%.info installdirs -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_info: - rm -f $@ - if [ -f $< ]; then \ - for f in $(<)*; do \ -diff -rNU3 dist.orig/gcc/c/Make-lang.in dist/gcc/c/Make-lang.in ---- dist.orig/gcc/c/Make-lang.in 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/c/Make-lang.in 2015-10-18 13:19:49.000000000 +0200 -@@ -70,7 +70,7 @@ - $(C_OBJS) $(BACKEND) $(LIBDEPS) - build/genchecksum$(build_exeext) $(C_OBJS) $(BACKEND) $(LIBDEPS) \ - checksum-options > cc1-checksum.c.tmp && \ -- $(srcdir)/../move-if-change cc1-checksum.c.tmp cc1-checksum.c -+ $(SHELL) $(srcdir)/../move-if-change cc1-checksum.c.tmp cc1-checksum.c - - cc1-checksum.o : cc1-checksum.c $(CONFIG_H) $(SYSTEM_H) - -diff -rNU3 dist.orig/gcc/c-family/c-opts.c dist/gcc/c-family/c-opts.c ---- dist.orig/gcc/c-family/c-opts.c 2015-02-11 13:14:54.000000000 +0100 -+++ dist/gcc/c-family/c-opts.c 2015-10-18 13:19:49.000000000 +0200 -@@ -284,6 +284,10 @@ - cpp_opts->discard_comments_in_macro_exp = 0; - break; - -+ case OPT_cxx_isystem: -+ add_path (xstrdup (arg), SYSTEM, 1, true); -+ break; -+ - case OPT_D: - defer_opt (code, arg); - break; -@@ -606,6 +610,10 @@ - add_path (xstrdup (arg), QUOTE, 0, true); - break; - -+ case OPT_iremap: -+ add_cpp_remap_path (arg); -+ break; -+ - case OPT_isysroot: - sysroot = arg; - break; -diff -rNU3 dist.orig/gcc/c-family/c.opt dist/gcc/c-family/c.opt ---- dist.orig/gcc/c-family/c.opt 2014-04-07 08:40:18.000000000 +0200 -+++ dist/gcc/c-family/c.opt 2015-10-18 13:19:49.000000000 +0200 -@@ -801,6 +801,12 @@ - C ObjC C++ ObjC++ - A synonym for -std=c89 (for C) or -std=c++98 (for C++) - -+; This should really just be C++/ObjC++ but we (NetBSD) use it when -+; calling C and ObjC compilers as well. -+cxx-isystem -+C ObjC C++ ObjC++ Joined Separate MissingArgError(missing path after %qs) -+-cxx-isystem Add to the start of the C++ system include path -+ - d - C ObjC C++ ObjC++ Joined - ; Documented in common.opt. FIXME - what about -dI, -dD, -dN and -dD? -@@ -1277,6 +1283,10 @@ - C ObjC C++ ObjC++ Joined Separate MissingArgError(missing path after %qs) - -iquote Add to the end of the quote include path - -+iremap -+C ObjC C++ ObjC++ Joined Separate MissingArgError(missing path after %qs) -+-iremap Convert to if it occurs as prefix in __FILE__. -+ - iwithprefix - C ObjC C++ ObjC++ Joined Separate - -iwithprefix Add to the end of the system include path -diff -rNU3 dist.orig/gcc/cfgexpand.c dist/gcc/cfgexpand.c ---- dist.orig/gcc/cfgexpand.c 2015-01-27 18:07:24.000000000 +0100 -+++ dist/gcc/cfgexpand.c 2015-10-18 13:19:49.000000000 +0200 -@@ -1321,7 +1321,9 @@ - else - len = tree_low_cst (TYPE_SIZE_UNIT (type), 1); - -- if (len < max) -+ if (len == 0) -+ ret = SPCT_HAS_ARRAY; -+ else if (len < max) - ret = SPCT_HAS_SMALL_CHAR_ARRAY | SPCT_HAS_ARRAY; - else - ret = SPCT_HAS_LARGE_CHAR_ARRAY | SPCT_HAS_ARRAY; -diff -rNU3 dist.orig/gcc/common/config/arm/arm-common.c dist/gcc/common/config/arm/arm-common.c ---- dist.orig/gcc/common/config/arm/arm-common.c 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/common/config/arm/arm-common.c 2015-10-18 13:19:49.000000000 +0200 -@@ -48,6 +48,9 @@ - return UI_SJLJ; - #endif - -+ if (ARM_DWARF_UNWIND_TABLES) -+ return UI_DWARF2; -+ - /* If not using ARM EABI unwind tables... */ - if (ARM_UNWIND_INFO) - { -diff -rNU3 dist.orig/gcc/common/config/or1k/or1k-common.c dist/gcc/common/config/or1k/or1k-common.c ---- dist.orig/gcc/common/config/or1k/or1k-common.c 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/common/config/or1k/or1k-common.c 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,30 @@ -+/* Common hooks for VAX. -+ Copyright (C) 1987-2013 Free Software Foundation, Inc. -+ -+This file is part of GCC. -+ -+GCC is free software; you can redistribute it and/or modify -+it under the terms of the GNU General Public License as published by -+the Free Software Foundation; either version 3, or (at your option) -+any later version. -+ -+GCC is distributed in the hope that it will be useful, -+but WITHOUT ANY WARRANTY; without even the implied warranty of -+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+GNU General Public License for more details. -+ -+You should have received a copy of the GNU General Public License -+along with GCC; see the file COPYING3. If not see -+. */ -+ -+#include "config.h" -+#include "system.h" -+#include "coretypes.h" -+#include "tm.h" -+#include "common/common-target.h" -+#include "common/common-target-def.h" -+ -+#undef TARGET_DEFAULT_TARGET_FLAGS -+#define TARGET_DEFAULT_TARGET_FLAGS TARGET_DEFAULT -+ -+struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER; -diff -rNU3 dist.orig/gcc/common/config/riscv/riscv-common.c dist/gcc/common/config/riscv/riscv-common.c ---- dist.orig/gcc/common/config/riscv/riscv-common.c 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/common/config/riscv/riscv-common.c 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,129 @@ -+/* Common hooks for RISC-V. -+ Copyright (C) 1989-2014 Free Software Foundation, Inc. -+ -+This file is part of GCC. -+ -+GCC is free software; you can redistribute it and/or modify -+it under the terms of the GNU General Public License as published by -+the Free Software Foundation; either version 3, or (at your option) -+any later version. -+ -+GCC is distributed in the hope that it will be useful, -+but WITHOUT ANY WARRANTY; without even the implied warranty of -+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+GNU General Public License for more details. -+ -+You should have received a copy of the GNU General Public License -+along with GCC; see the file COPYING3. If not see -+. */ -+ -+#include "config.h" -+#include "system.h" -+#include "coretypes.h" -+#include "tm.h" -+#include "common/common-target.h" -+#include "common/common-target-def.h" -+#include "opts.h" -+#include "flags.h" -+#include "errors.h" -+ -+/* Parse a RISC-V ISA string into an option mask. */ -+ -+static void -+riscv_parse_arch_string (const char *isa, int *flags) -+{ -+ const char *p = isa; -+ -+ if (strncmp (p, "RV32", 4) == 0) -+ *flags |= MASK_32BIT, p += 4; -+ else if (strncmp (p, "RV64", 4) == 0) -+ *flags &= ~MASK_32BIT, p += 4; -+ -+ if (*p++ != 'I') -+ { -+ error ("-march=%s: ISA strings must begin with I, RV32I, or RV64I", isa); -+ return; -+ } -+ -+ *flags &= ~MASK_MULDIV; -+ if (*p == 'M') -+ *flags |= MASK_MULDIV, p++; -+ -+ *flags &= ~MASK_ATOMIC; -+ if (*p == 'A') -+ *flags |= MASK_ATOMIC, p++; -+ -+ *flags |= MASK_SOFT_FLOAT_ABI; -+ if (*p == 'F') -+ *flags &= ~MASK_SOFT_FLOAT_ABI, p++; -+ -+ if (*p == 'D') -+ { -+ p++; -+ if (!TARGET_HARD_FLOAT) -+ { -+ error ("-march=%s: the D extension requires the F extension", isa); -+ return; -+ } -+ } -+ else if (TARGET_HARD_FLOAT) -+ { -+ error ("-march=%s: single-precision-only is not yet supported", isa); -+ return; -+ } -+ -+ if (*p) -+ { -+ error ("-march=%s: unsupported ISA substring %s", isa, p); -+ return; -+ } -+} -+ -+static int -+riscv_flags_from_arch_string (const char *isa) -+{ -+ int flags = 0; -+ riscv_parse_arch_string (isa, &flags); -+ return flags; -+} -+ -+/* Implement TARGET_HANDLE_OPTION. */ -+ -+static bool -+riscv_handle_option (struct gcc_options *opts, -+ struct gcc_options *opts_set ATTRIBUTE_UNUSED, -+ const struct cl_decoded_option *decoded, -+ location_t loc ATTRIBUTE_UNUSED) -+{ -+ switch (decoded->opt_index) -+ { -+ case OPT_march_: -+ riscv_parse_arch_string (decoded->arg, &opts->x_target_flags); -+ return true; -+ -+ default: -+ return true; -+ } -+} -+ -+/* Implement TARGET_OPTION_OPTIMIZATION_TABLE. */ -+static const struct default_options riscv_option_optimization_table[] = -+ { -+ { OPT_LEVELS_1_PLUS, OPT_fsection_anchors, NULL, 1 }, -+ { OPT_LEVELS_1_PLUS, OPT_fomit_frame_pointer, NULL, 1 }, -+ { OPT_LEVELS_NONE, 0, NULL, 0 } -+ }; -+ -+#undef TARGET_OPTION_OPTIMIZATION_TABLE -+#define TARGET_OPTION_OPTIMIZATION_TABLE riscv_option_optimization_table -+ -+#undef TARGET_DEFAULT_TARGET_FLAGS -+#define TARGET_DEFAULT_TARGET_FLAGS \ -+ (TARGET_DEFAULT \ -+ | riscv_flags_from_arch_string (RISCV_ARCH_STRING_DEFAULT) \ -+ | (TARGET_64BIT_DEFAULT ? 0 : MASK_32BIT)) -+ -+#undef TARGET_HANDLE_OPTION -+#define TARGET_HANDLE_OPTION riscv_handle_option -+ -+struct gcc_targetm_common targetm_common = TARGETM_COMMON_INITIALIZER; -diff -rNU3 dist.orig/gcc/config/alpha/alpha.h dist/gcc/config/alpha/alpha.h ---- dist.orig/gcc/config/alpha/alpha.h 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/config/alpha/alpha.h 2015-10-18 13:19:50.000000000 +0200 -@@ -1067,6 +1067,12 @@ - #define ASM_OUTPUT_SOURCE_FILENAME(STREAM, NAME) \ - alpha_output_filename (STREAM, NAME) - -+#define ASM_OUTPUT_COMMON(FILE, NAME, SIZE, ROUNDED) \ -+ ( fputs (".comm ", (FILE)), \ -+ assemble_name ((FILE), (NAME)), \ -+ fprintf ((FILE), ",%u\n", (int)(ROUNDED))) -+ -+ - /* By default, turn on GDB extensions. */ - #define DEFAULT_GDB_EXTENSIONS 1 - -diff -rNU3 dist.orig/gcc/config/alpha/elf.h dist/gcc/config/alpha/elf.h ---- dist.orig/gcc/config/alpha/elf.h 2014-07-25 09:28:47.000000000 +0200 -+++ dist/gcc/config/alpha/elf.h 2015-10-18 13:19:50.000000000 +0200 -@@ -18,6 +18,29 @@ - along with GCC; see the file COPYING3. If not see - . */ - -+#undef OBJECT_FORMAT_COFF -+#undef EXTENDED_COFF -+#define OBJECT_FORMAT_ELF -+ -+/* ??? Move all SDB stuff from alpha.h to osf.h. */ -+#undef SDB_DEBUGGING_INFO -+#undef DBX_DEBUGGING_INFO -+ -+#define DWARF2_DEBUGGING_INFO 1 -+ -+#undef PREFERRED_DEBUGGING_TYPE -+#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG -+ -+#undef ASM_FINAL_SPEC -+ -+/* alpha/ doesn't use elfos.h for some reason. */ -+#define TARGET_OBJFMT_CPP_BUILTINS() \ -+ do \ -+ { \ -+ builtin_define ("__ELF__"); \ -+ } \ -+ while (0) -+ - #undef CC1_SPEC - #define CC1_SPEC "%{G*}" - -@@ -167,6 +190,6 @@ - As of Jan 2002, only glibc 2.2.4 can actually make use of this, but - I imagine that other systems will catch up. In the meantime, it - doesn't harm to make sure that the data exists to be used later. */ --#if defined(HAVE_LD_EH_FRAME_HDR) -+#if defined(HAVE_LD_EH_FRAME_HDR) && !defined(LINK_EH_SPEC) - #define LINK_EH_SPEC "%{!static:--eh-frame-hdr} " - #endif -diff -rNU3 dist.orig/gcc/config/alpha/netbsd.h dist/gcc/config/alpha/netbsd.h ---- dist.orig/gcc/config/alpha/netbsd.h 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/config/alpha/netbsd.h 2015-10-18 13:19:50.000000000 +0200 -@@ -57,6 +57,15 @@ - - #define NETBSD_ENTRY_POINT "__start" - -+/* Provide a STARTFILE_SPEC appropriate for NetBSD. Here we add the -+ (even more) magical crtbegin.o file which provides part of the -+ support for getting C++ file-scope static object constructed -+ before entering `main'. */ -+ -+#undef STARTFILE_SPEC -+#define STARTFILE_SPEC \ -+ "%{!shared: %{pg|p:gcrt0.o%s;:crt0.o%s}}\ -+ crti.o%s %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}" - - /* Provide an ENDFILE_SPEC appropriate for NetBSD/alpha ELF. Here we - add crtend.o, which provides part of the support for getting -diff -rNU3 dist.orig/gcc/config/arm/arm.h dist/gcc/config/arm/arm.h ---- dist.orig/gcc/config/arm/arm.h 2015-01-14 12:02:24.000000000 +0100 -+++ dist/gcc/config/arm/arm.h 2015-10-18 13:19:50.000000000 +0200 -@@ -889,6 +889,11 @@ - #define ARM_UNWIND_INFO 0 - #endif - -+/* Overriden by config/arm/netbsd-eabi.h. */ -+#ifndef ARM_DWARF_UNWIND_TABLES -+#define ARM_DWARF_UNWIND_TABLES 0 -+#endif -+ - /* Use r0 and r1 to pass exception handling information. */ - #define EH_RETURN_DATA_REGNO(N) (((N) < 2) ? N : INVALID_REGNUM) - -@@ -899,11 +904,21 @@ - #ifndef ARM_TARGET2_DWARF_FORMAT - #define ARM_TARGET2_DWARF_FORMAT DW_EH_PE_pcrel - -+# if ARM_DWARF_UNWIND_TABLES -+/* DWARF unwinding uses the normal indirect/pcrel vs absptr format -+ for 32bit platforms. */ -+# define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \ -+ ((flag_pic \ -+ && ((GLOBAL) || (CODE))) \ -+ ? ((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4 \ -+ : DW_EH_PE_absptr) -+# else - /* ttype entries (the only interesting data references used) - use TARGET2 relocations. */ --#define ASM_PREFERRED_EH_DATA_FORMAT(code, data) \ -- (((code) == 0 && (data) == 1 && ARM_UNWIND_INFO) ? ARM_TARGET2_DWARF_FORMAT \ -- : DW_EH_PE_absptr) -+# define ASM_PREFERRED_EH_DATA_FORMAT(code, data) \ -+ (((code) == 0 && (data) == 1 && ARM_UNWIND_INFO) ? ARM_TARGET2_DWARF_FORMAT \ -+ : DW_EH_PE_absptr) -+# endif - #endif - - /* The native (Norcroft) Pascal compiler for the ARM passes the static chain -@@ -2315,7 +2330,7 @@ - - /* -mcpu=native handling only makes sense with compiler running on - an ARM chip. */ --#if defined(__arm__) -+#if defined(__arm__) && defined(__linux__) - extern const char *host_detect_local_cpu (int argc, const char **argv); - # define EXTRA_SPEC_FUNCTIONS \ - { "local_cpu_detect", host_detect_local_cpu }, -diff -rNU3 dist.orig/gcc/config/arm/bpabi-netbsd.c dist/gcc/config/arm/bpabi-netbsd.c ---- dist.orig/gcc/config/arm/bpabi-netbsd.c 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/arm/bpabi-netbsd.c 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1 @@ -+#include "bpabi.c" -diff -rNU3 dist.orig/gcc/config/arm/bpabi.h dist/gcc/config/arm/bpabi.h ---- dist.orig/gcc/config/arm/bpabi.h 2013-01-18 15:26:15.000000000 +0100 -+++ dist/gcc/config/arm/bpabi.h 2015-10-18 13:19:50.000000000 +0200 -@@ -19,12 +19,16 @@ - . */ - - /* Use the AAPCS ABI by default. */ -+#undef ARM_DEFAULT_ABI - #define ARM_DEFAULT_ABI ARM_ABI_AAPCS - - /* Assume that AAPCS ABIs should adhere to the full BPABI. */ -+#undef TARGET_BPABI - #define TARGET_BPABI (TARGET_AAPCS_BASED) - - /* BPABI targets use EABI frame unwinding tables. */ -+#undef ARM_EABI_UNWIND_TABLES -+#define ARM_EABI_UNWIND_TABLES 1 - #undef ARM_UNWIND_INFO - #define ARM_UNWIND_INFO 1 - -diff -rNU3 dist.orig/gcc/config/arm/elf.h dist/gcc/config/arm/elf.h ---- dist.orig/gcc/config/arm/elf.h 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/config/arm/elf.h 2015-10-18 13:19:50.000000000 +0200 -@@ -154,6 +154,8 @@ - #undef L_floatdidf - #undef L_floatdisf - #undef L_floatundidf -+/* XXXMRG: don't take this out, we need it! */ -+# ifndef __NetBSD__ - #undef L_floatundisf -+# endif - #endif -- -diff -rNU3 dist.orig/gcc/config/arm/netbsd-eabi.h dist/gcc/config/arm/netbsd-eabi.h ---- dist.orig/gcc/config/arm/netbsd-eabi.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/arm/netbsd-eabi.h 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,113 @@ -+/* Definitions of target machine for GNU compiler, NetBSD/arm ELF version. -+ Copyright (C) 2002, 2003, 2004, 2005, 2007 Free Software Foundation, Inc. -+ Contributed by Wasabi Systems, Inc. -+ -+ This file is part of GCC. -+ -+ GCC is free software; you can redistribute it and/or modify it -+ under the terms of the GNU General Public License as published -+ by the Free Software Foundation; either version 3, or (at your -+ option) any later version. -+ -+ GCC is distributed in the hope that it will be useful, but WITHOUT -+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -+ License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with GCC; see the file COPYING3. If not see -+ . */ -+ -+/* Run-time Target Specification. */ -+#undef MULTILIB_DEFAULTS -+#define MULTILIB_DEFAULTS { "mabi=aapcs-linux" } -+ -+#define TARGET_LINKER_EABI_SUFFIX \ -+ (TARGET_DEFAULT_FLOAT_ABI == ARM_FLOAT_ABI_SOFT \ -+ ? "%{!mabi=apcs-gnu:%{!mabi=atpcs:%{mfloat-abi=hard:_eabihf;:_eabi}}}" \ -+ : "%{!mabi=apcs-gnu:%{!mabi=atpcs:%{mfloat-abi=soft:_eabi;:_eabihf}}}") -+#define TARGET_LINKER_BIG_EMULATION "armelfb_nbsd%(linker_eabi_suffix)" -+#define TARGET_LINKER_LITTLE_EMULATION "armelf_nbsd%(linker_eabi_suffix)" -+ -+/* TARGET_BIG_ENDIAN_DEFAULT is set in -+ config.gcc for big endian configurations. */ -+#undef TARGET_LINKER_EMULATION -+#if TARGET_BIG_ENDIAN_DEFAULT -+#define TARGET_LINKER_EMULATION TARGET_LINKER_BIG_EMULATION -+#undef BE8_LINK_SPEC -+#define BE8_LINK_SPEC " %{!mlittle-endian:%{march=armv7-a|mcpu=cortex-a5|mcpu=cortex-a8|mcpu=cortex-a9:%{!r:--be8}}}" -+#else -+#define TARGET_LINKER_EMULATION TARGET_LINKER_LITTLE_EMULATION -+#endif -+ -+#undef ARM_DEFAULT_ABI -+#define ARM_DEFAULT_ABI ARM_ABI_AAPCS_LINUX -+ -+#undef ARM_EABI_UNWIND_TABLES -+#define ARM_EABI_UNWIND_TABLES 0 -+#undef ARM_UNWIND_INFO -+#define ARM_UNWIND_INFO 0 -+#undef ARM_DWARF_UNWIND_TABLES -+#define ARM_DWARF_UNWIND_TABLES 1 -+ -+#undef TARGET_OS_CPP_BUILTINS -+#define TARGET_OS_CPP_BUILTINS() \ -+ do \ -+ { \ -+ if (TARGET_AAPCS_BASED) \ -+ TARGET_BPABI_CPP_BUILTINS(); \ -+ NETBSD_OS_CPP_BUILTINS_ELF(); \ -+ if (ARM_DWARF_UNWIND_TABLES) \ -+ builtin_define ("__ARM_DWARF_EH__"); \ -+ if (ARM_EABI_UNWIND_TABLES) \ -+ builtin_define ("__UNWIND_TABLES__"); \ -+ } \ -+ while (0) -+ -+#undef SUBTARGET_CPP_SPEC -+#define SUBTARGET_CPP_SPEC NETBSD_CPP_SPEC -+ -+/* -+ * Override AAPCS types to remain compatible the existing NetBSD types. -+ */ -+#undef WCHAR_TYPE -+#define WCHAR_TYPE "int" -+ -+#undef SIZE_TYPE -+#define SIZE_TYPE "long unsigned int" -+ -+#undef PTRDIFF_TYPE -+#define PTRDIFF_TYPE "long int" -+ -+#undef SUBTARGET_EXTRA_ASM_SPEC -+#define SUBTARGET_EXTRA_ASM_SPEC \ -+ "-matpcs %{mabi=apcs-gnu|mabi=atpcs:-meabi=gnu} %{fpic|fpie:-k} %{fPIC|fPIE:-k}" -+ -+/* Default to full VFP if -mhard-float is specified. */ -+#undef SUBTARGET_ASM_FLOAT_SPEC -+#define SUBTARGET_ASM_FLOAT_SPEC \ -+ "%{mhard-float:%{!mfpu=*:-mfpu=vfp}} \ -+ %{mfloat-abi=hard:%{!mfpu=*:-mfpu=vfp}}" -+ -+#undef SUBTARGET_EXTRA_SPECS -+#define SUBTARGET_EXTRA_SPECS \ -+ { "subtarget_extra_asm_spec", SUBTARGET_EXTRA_ASM_SPEC }, \ -+ { "subtarget_asm_float_spec", SUBTARGET_ASM_FLOAT_SPEC }, \ -+ { "netbsd_link_spec", NETBSD_LINK_SPEC_ELF }, \ -+ { "linker_eabi_suffix", TARGET_LINKER_EABI_SUFFIX }, \ -+ { "linker_emulation", TARGET_LINKER_EMULATION }, \ -+ { "linker_big_emulation", TARGET_LINKER_BIG_EMULATION }, \ -+ { "linker_little_emulation", TARGET_LINKER_LITTLE_EMULATION }, \ -+ { "be8_link_spec", BE8_LINK_SPEC }, \ -+ { "target_fix_v4bx_spec", TARGET_FIX_V4BX_SPEC }, \ -+ { "netbsd_entry_point", NETBSD_ENTRY_POINT }, -+ -+#define NETBSD_ENTRY_POINT "__start" -+ -+#undef LINK_SPEC -+#define LINK_SPEC \ -+ "-X %{mbig-endian:-EB -m %(linker_big_emulation)} \ -+ %{mlittle-endian:-EL -m %(linker_liitle_emulation)} \ -+ %{!mbig-endian:%{!mlittle-endian:-m %(linker_emulation)}} \ -+ %(be8_link_spec) %(target_fix_v4bx_spec) \ -+ %(netbsd_link_spec)" -diff -rNU3 dist.orig/gcc/config/arm/netbsd-elf.h dist/gcc/config/arm/netbsd-elf.h ---- dist.orig/gcc/config/arm/netbsd-elf.h 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/config/arm/netbsd-elf.h 2015-10-18 13:19:50.000000000 +0200 -@@ -22,9 +22,20 @@ - - /* arm.h defaults to ARM6 CPU. */ - --/* This defaults us to little-endian. */ --#ifndef TARGET_ENDIAN_DEFAULT --#define TARGET_ENDIAN_DEFAULT 0 -+/* Default EABI to armv5t so that thumb shared libraries work. -+ The ARM926EH-S core is the default for armv5te, so set -+ SUBTARGET_CPU_DEFAULT to achieve this. */ -+ -+#define SUBTARGET_CPU_DEFAULT \ -+ (ARM_DEFAULT_ABI != ARM_ABI_APCS && ARM_DEFAULT_ABI != ARM_ABI_ATPCS \ -+ ? TARGET_CPU_arm926ejs : TARGET_CPU_arm6) -+ -+/* TARGET_BIG_ENDIAN_DEFAULT is set in -+ config.gcc for big endian configurations. */ -+#if TARGET_BIG_ENDIAN_DEFAULT -+#define TARGET_ENDIAN_DEFAULT MASK_BIG_END -+#else -+#define TARGET_ENDIAN_DEFAULT 0 - #endif - - #undef MULTILIB_DEFAULTS -@@ -38,6 +49,7 @@ - #undef ARM_DEFAULT_ABI - #define ARM_DEFAULT_ABI ARM_ABI_ATPCS - -+#undef TARGET_OS_CPP_BUILTINS - #define TARGET_OS_CPP_BUILTINS() \ - do \ - { \ -@@ -50,12 +62,13 @@ - - #undef SUBTARGET_EXTRA_ASM_SPEC - #define SUBTARGET_EXTRA_ASM_SPEC \ -- "-matpcs %{fpic|fpie:-k} %{fPIC|fPIE:-k}" -+ "-matpcs %{mabi=aapcs*:-meabi=5} %{fpic|fpie:-k} %{fPIC|fPIE:-k}" - - /* Default to full VFP if -mfloat-abi=hard is specified. */ - #undef SUBTARGET_ASM_FLOAT_SPEC - #define SUBTARGET_ASM_FLOAT_SPEC \ -- "%{mfloat-abi=hard:{!mfpu=*:-mfpu=vfp}}" -+ "%{mhard-float:%{!mfpu=*:-mfpu=vfp}} \ -+ %{mfloat-abi=hard:%{!mfpu=*:-mfpu=vfp}}" - - #undef SUBTARGET_EXTRA_SPECS - #define SUBTARGET_EXTRA_SPECS \ -@@ -68,7 +81,9 @@ - - #undef LINK_SPEC - #define LINK_SPEC \ -- "-X %{mbig-endian:-EB} %{mlittle-endian:-EL} \ -+ "-X \ -+ %{mbig-endian:-EB %{-mabi=aapcs*:-m armelfb_nbsd_eabi}} \ -+ %{mlittle-endian:-EL %{-mabi=aapcs*:-m armelf_nbsd_eabi}} \ - %(netbsd_link_spec)" - - /* Make GCC agree with . */ -@@ -79,6 +94,12 @@ - #undef PTRDIFF_TYPE - #define PTRDIFF_TYPE "long int" - -+#undef INTPTR_TYPE -+#define INTPTR_TYPE PTRDIFF_TYPE -+ -+#undef UINTPTR_TYPE -+#define UINTPTR_TYPE SIZE_TYPE -+ - /* We don't have any limit on the length as out debugger is GDB. */ - #undef DBX_CONTIN_LENGTH - -diff -rNU3 dist.orig/gcc/config/arm/t-arm dist/gcc/config/arm/t-arm ---- dist.orig/gcc/config/arm/t-arm 2013-03-07 00:29:08.000000000 +0100 -+++ dist/gcc/config/arm/t-arm 2015-10-18 13:19:50.000000000 +0200 -@@ -66,6 +66,8 @@ - - $(srcdir)/config/arm/arm-tune.md: $(srcdir)/config/arm/gentune.sh \ - $(srcdir)/config/arm/arm-cores.def -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_config_arm_arm-tune.md: - $(SHELL) $(srcdir)/config/arm/gentune.sh \ - $(srcdir)/config/arm/arm-cores.def > \ - $(srcdir)/config/arm/arm-tune.md -@@ -73,6 +75,8 @@ - $(srcdir)/config/arm/arm-tables.opt: $(srcdir)/config/arm/genopt.sh \ - $(srcdir)/config/arm/arm-cores.def $(srcdir)/config/arm/arm-arches.def \ - $(srcdir)/config/arm/arm-fpus.def -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_config_arm_arm-tables.opt: - $(SHELL) $(srcdir)/config/arm/genopt.sh $(srcdir)/config/arm > \ - $(srcdir)/config/arm/arm-tables.opt - -diff -rNU3 dist.orig/gcc/config/arm/t-netbsdeabi dist/gcc/config/arm/t-netbsdeabi ---- dist.orig/gcc/config/arm/t-netbsdeabi 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/arm/t-netbsdeabi 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,8 @@ -+# NetBSD has (will have) "non-native" libraries in /usr/lib/. -+ -+MULTILIB_OPTIONS = mabi=aapcs-linux/mabi=apcs-gnu -+MULTILIB_DIRNAMES = eabi oabi -+MULTILIB_OSDIRNAMES = . ../lib/oabi -+ -+LIBGCC = stmp-multilib -+INSTALL_LIBGCC = install-multilib -diff -rNU3 dist.orig/gcc/config/freebsd-spec.h dist/gcc/config/freebsd-spec.h ---- dist.orig/gcc/config/freebsd-spec.h 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/config/freebsd-spec.h 2015-10-18 13:19:50.000000000 +0200 -@@ -133,6 +133,14 @@ - #define FBSD_DYNAMIC_LINKER "/libexec/ld-elf.so.1" - #endif - -+#if defined(HAVE_LD_EH_FRAME_HDR) && !defined(LINK_EH_SPEC) -+#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} " -+#endif -+ -+/* Use --as-needed -lgcc_s for eh support. */ -+#ifdef HAVE_LD_AS_NEEDED -+#define USE_LD_AS_NEEDED 1 -+#endif - /* NOTE: The freebsd-spec.h header is included also for various - non-FreeBSD powerpc targets, thus it should never define macros - other than FBSD_* prefixed ones, or USING_CONFIG_FREEBSD_SPEC. */ -diff -rNU3 dist.orig/gcc/config/host-netbsd.c dist/gcc/config/host-netbsd.c ---- dist.orig/gcc/config/host-netbsd.c 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/host-netbsd.c 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,85 @@ -+/* NetBSD host-specific hook definitions. -+ Copyright (C) 2004-2013 Free Software Foundation, Inc. -+ -+ This file is part of GCC. -+ -+ GCC is free software; you can redistribute it and/or modify it -+ under the terms of the GNU General Public License as published -+ by the Free Software Foundation; either version 3, or (at your -+ option) any later version. -+ -+ GCC is distributed in the hope that it will be useful, but WITHOUT -+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -+ License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with GCC; see the file COPYING3. If not see -+ . */ -+ -+#include "config.h" -+#include "system.h" -+#include "coretypes.h" -+#include "hosthooks.h" -+#include "hosthooks-def.h" -+ -+ -+#undef HOST_HOOKS_GT_PCH_GET_ADDRESS -+#define HOST_HOOKS_GT_PCH_GET_ADDRESS netbsd_gt_pch_get_address -+#undef HOST_HOOKS_GT_PCH_USE_ADDRESS -+#define HOST_HOOKS_GT_PCH_USE_ADDRESS netbsd_gt_pch_use_address -+ -+/* For various ports, try to guess a fixed spot in the vm space -+ that's probably free. */ -+#if defined(__sparc64__) -+# define TRY_EMPTY_VM_SPACE 0x40000000000 -+#elif defined(_LP64) -+# define TRY_EMPTY_VM_SPACE 0x400000000000 -+#elif defined(__mips__) || defined(__vax__) || defined (__arm__) -+# define TRY_EMPTY_VM_SPACE 0x60000000 -+#else -+# define TRY_EMPTY_VM_SPACE 0xb0000000 -+#endif -+ -+/* Determine a location where we might be able to reliably allocate -+ SIZE bytes. FD is the PCH file, though we should return with the -+ file unmapped. */ -+ -+static void * -+netbsd_gt_pch_get_address (size_t size, int fd) -+{ -+ void *addr; -+ -+ addr = mmap ((void *) TRY_EMPTY_VM_SPACE, size, PROT_READ | PROT_WRITE, -+ MAP_PRIVATE | MAP_FIXED, fd, 0); -+ -+ /* If we failed the map, that means there's *no* free space. */ -+ if (addr == (void *) MAP_FAILED) -+ return NULL; -+ /* Unmap the area before returning. */ -+ munmap (addr, size); -+ -+ return addr; -+} -+ -+/* Map SIZE bytes of FD+OFFSET at BASE. Return 1 if we succeeded at -+ mapping the data at BASE, -1 if we couldn't. */ -+ -+static int -+netbsd_gt_pch_use_address (void *base, size_t size, int fd, size_t offset) -+{ -+ void *addr; -+ -+ /* We're called with size == 0 if we're not planning to load a PCH -+ file at all. This allows the hook to free any static space that -+ we might have allocated at link time. */ -+ if (size == 0) -+ return -1; -+ -+ addr = mmap (base, size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_FIXED, fd, offset); -+ -+ return addr == base ? 1 : -1; -+} -+ -+ -+const struct host_hooks host_hooks = HOST_HOOKS_INITIALIZER; -diff -rNU3 dist.orig/gcc/config/i386/i386.h dist/gcc/config/i386/i386.h ---- dist.orig/gcc/config/i386/i386.h 2014-01-08 20:54:29.000000000 +0100 -+++ dist/gcc/config/i386/i386.h 2015-10-18 13:19:50.000000000 +0200 -@@ -1071,6 +1071,7 @@ - - #define HARD_REGNO_CALLER_SAVE_MODE(REGNO, NREGS, MODE) \ - (CC_REGNO_P (REGNO) ? VOIDmode \ -+ : MMX_REGNO_P (REGNO) ? V8QImode \ - : (MODE) == VOIDmode && (NREGS) != 1 ? VOIDmode \ - : (MODE) == VOIDmode ? choose_hard_reg_mode ((REGNO), (NREGS), false) \ - : (MODE) == HImode && !TARGET_PARTIAL_REG_STALL ? SImode \ -diff -rNU3 dist.orig/gcc/config/i386/netbsd-elf.h dist/gcc/config/i386/netbsd-elf.h ---- dist.orig/gcc/config/i386/netbsd-elf.h 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/config/i386/netbsd-elf.h 2015-10-18 13:19:50.000000000 +0200 -@@ -118,4 +118,10 @@ - we don't care about compatibility with older gcc versions. */ - #define DEFAULT_PCC_STRUCT_RETURN 1 - --#define HAVE_ENABLE_EXECUTE_STACK -+#undef X87_ENABLE_ARITH -+#define X87_ENABLE_ARITH(MODE) \ -+ (flag_excess_precision == EXCESS_PRECISION_FAST || (MODE) == DFmode) -+ -+/* Preserve i386 psABI */ -+#undef PREFERRED_STACK_BOUNDARY_DEFAULT -+#define PREFERRED_STACK_BOUNDARY_DEFAULT MIN_STACK_BOUNDARY -diff -rNU3 dist.orig/gcc/config/i386/netbsd64.h dist/gcc/config/i386/netbsd64.h ---- dist.orig/gcc/config/i386/netbsd64.h 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/config/i386/netbsd64.h 2015-10-18 13:19:50.000000000 +0200 -@@ -66,4 +66,8 @@ - fprintf (FILE, "\tcall __mcount\n"); \ - } - -+/* Preserve i386 psABI */ -+#undef PREFERRED_STACK_BOUNDARY_DEFAULT -+#define PREFERRED_STACK_BOUNDARY_DEFAULT MIN_STACK_BOUNDARY -+ - #define HAVE_ENABLE_EXECUTE_STACK -diff -rNU3 dist.orig/gcc/config/i386/pmm_malloc.h dist/gcc/config/i386/pmm_malloc.h ---- dist.orig/gcc/config/i386/pmm_malloc.h 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/config/i386/pmm_malloc.h 2015-10-18 13:19:50.000000000 +0200 -@@ -31,7 +31,7 @@ - #ifndef __cplusplus - extern int posix_memalign (void **, size_t, size_t); - #else --extern "C" int posix_memalign (void **, size_t, size_t) throw (); -+extern "C" int posix_memalign (void **, size_t, size_t); - #endif - - static __inline void * -diff -rNU3 dist.orig/gcc/config/i386/t-netbsd64 dist/gcc/config/i386/t-netbsd64 ---- dist.orig/gcc/config/i386/t-netbsd64 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/i386/t-netbsd64 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,15 @@ -+# NetBSD has (will have) "non-native" libraries in /usr/lib/. -+# For NetBSD/amd64 we thus have /usr/lib and /usr/lib/i386. -+ -+MULTILIB_OPTIONS = m64/m32 -+MULTILIB_DIRNAMES = 64 32 -+MULTILIB_OSDIRNAMES = . ../lib/i386 -+ -+LIBGCC = stmp-multilib -+INSTALL_LIBGCC = install-multilib -+ -+# The pushl in CTOR initialization interferes with frame pointer elimination. -+# crtend*.o cannot be compiled without -fno-asynchronous-unwind-tables, -+# because then __FRAME_END__ might not be the last thing in .eh_frame -+# section. -+CRTSTUFF_T_CFLAGS += -fno-omit-frame-pointer -fno-asynchronous-unwind-tables -diff -rNU3 dist.orig/gcc/config/ia64/netbsd.h dist/gcc/config/ia64/netbsd.h ---- dist.orig/gcc/config/ia64/netbsd.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/ia64/netbsd.h 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,56 @@ -+/* Definitions of target machine for GNU compiler, -+ for ia64/ELF NetBSD systems. -+ Copyright (C) 2005 Free Software Foundation, Inc. -+ -+This file is part of GNU CC. -+ -+GNU CC is free software; you can redistribute it and/or modify -+it under the terms of the GNU General Public License as published by -+the Free Software Foundation; either version 2, or (at your option) -+any later version. -+ -+GNU CC is distributed in the hope that it will be useful, -+but WITHOUT ANY WARRANTY; without even the implied warranty of -+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+GNU General Public License for more details. -+ -+You should have received a copy of the GNU General Public License -+along with GNU CC; see the file COPYING. If not, write to -+the Free Software Foundation, 59 Temple Place - Suite 330, -+Boston, MA 02111-1307, USA. */ -+ -+#define TARGET_OS_CPP_BUILTINS() \ -+ do \ -+ { \ -+ NETBSD_OS_CPP_BUILTINS_ELF(); \ -+ } \ -+ while (0) -+ -+ -+/* Extra specs needed for NetBSD/ia-64 ELF. */ -+ -+#undef SUBTARGET_EXTRA_SPECS -+#define SUBTARGET_EXTRA_SPECS \ -+ { "netbsd_cpp_spec", NETBSD_CPP_SPEC }, \ -+ { "netbsd_link_spec", NETBSD_LINK_SPEC_ELF }, \ -+ { "netbsd_entry_point", NETBSD_ENTRY_POINT }, -+ -+ -+/* Provide a LINK_SPEC appropriate for a NetBSD/ia64 ELF target. */ -+ -+#undef LINK_SPEC -+#define LINK_SPEC "%(netbsd_link_spec)" -+ -+#define NETBSD_ENTRY_POINT "_start" -+ -+ -+/* Provide a CPP_SPEC appropriate for NetBSD. */ -+ -+#undef CPP_SPEC -+#define CPP_SPEC "%(netbsd_cpp_spec)" -+ -+ -+#if 0 -+/* Attempt to enable execute permissions on the stack. */ -+#define TRANSFER_FROM_TRAMPOLINE NETBSD_ENABLE_EXECUTE_STACK -+#endif -diff -rNU3 dist.orig/gcc/config/m68k/m68k.md dist/gcc/config/m68k/m68k.md ---- dist.orig/gcc/config/m68k/m68k.md 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/config/m68k/m68k.md 2015-10-18 13:19:50.000000000 +0200 -@@ -3124,16 +3124,33 @@ - ;; We need a separate DEFINE_EXPAND for u?mulsidi3 to be able to use the - ;; proper matching constraint. This is because the matching is between - ;; the high-numbered word of the DImode operand[0] and operand[1]. -+;; -+;; Note: life_analysis() does not keep track of the individual halves of the -+;; DImode register. To prevent spurious liveness before the u?mulsidi3 insn -+;; (which causes "uninitialized variable" warnings), we explicitly clobber -+;; the DImode register. - (define_expand "umulsidi3" -- [(parallel -- [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4) -- (mult:SI (match_operand:SI 1 "register_operand" "") -- (match_operand:SI 2 "register_operand" ""))) -+ [(set (match_operand:DI 0 "register_operand" "") -+ (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "")) -+ (zero_extend:DI (match_operand:SI 2 "register_operand" ""))))] -+ "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE" -+ "") -+ -+(define_insn_and_split "*umulsidi3_split" -+ [(set (match_operand:DI 0 "register_operand" "") -+ (mult:DI (zero_extend:DI (match_operand:SI 1 "register_operand" "")) -+ (zero_extend:DI (match_operand:SI 2 "register_operand" ""))))] -+ "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE" -+ "#" -+ "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE" -+ [(clobber (match_dup 0)) -+ (parallel -+ [(set (subreg:SI (match_dup 0) 4) -+ (mult:SI (match_dup 1) (match_dup 2))) - (set (subreg:SI (match_dup 0) 0) - (truncate:SI (lshiftrt:DI (mult:DI (zero_extend:DI (match_dup 1)) - (zero_extend:DI (match_dup 2))) - (const_int 32))))])] -- "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE" - "") - - (define_insn "" -@@ -3164,15 +3181,27 @@ - "mulu%.l %2,%3:%0") - - (define_expand "mulsidi3" -- [(parallel -- [(set (subreg:SI (match_operand:DI 0 "register_operand" "") 4) -- (mult:SI (match_operand:SI 1 "register_operand" "") -- (match_operand:SI 2 "register_operand" ""))) -+ [(set (match_operand:DI 0 "register_operand" "") -+ (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "")) -+ (sign_extend:DI (match_operand:SI 2 "register_operand" ""))))] -+ "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE" -+ "") -+ -+(define_insn_and_split "*mulsidi3_split" -+ [(set (match_operand:DI 0 "register_operand" "") -+ (mult:DI (sign_extend:DI (match_operand:SI 1 "register_operand" "")) -+ (sign_extend:DI (match_operand:SI 2 "register_operand" ""))))] -+ "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE" -+ "#" -+ "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE" -+ [(clobber (match_dup 0)) -+ (parallel -+ [(set (subreg:SI (match_dup 0) 4) -+ (mult:SI (match_dup 1) (match_dup 2))) - (set (subreg:SI (match_dup 0) 0) - (truncate:SI (lshiftrt:DI (mult:DI (sign_extend:DI (match_dup 1)) - (sign_extend:DI (match_dup 2))) - (const_int 32))))])] -- "TARGET_68020 && !TUNE_68060 && !TARGET_COLDFIRE" - "") - - (define_insn "" -diff -rNU3 dist.orig/gcc/config/m68k/netbsd-elf.h dist/gcc/config/m68k/netbsd-elf.h ---- dist.orig/gcc/config/m68k/netbsd-elf.h 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/config/m68k/netbsd-elf.h 2015-10-18 13:19:50.000000000 +0200 -@@ -35,19 +35,34 @@ - } \ - while (0) - --/* Don't try using XFmode on the 68010. */ -+/* Don't try using XFmode on the 68010 or coldfire. */ - #undef LONG_DOUBLE_TYPE_SIZE - #define LONG_DOUBLE_TYPE_SIZE (TARGET_68020 ? 80 : 64) - - #undef LIBGCC2_LONG_DOUBLE_TYPE_SIZE --#ifdef __mc68010__ -+#if defined(__mc68010__) || defined(__mcoldfire__) - #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 64 - #else - #define LIBGCC2_LONG_DOUBLE_TYPE_SIZE 80 - #endif - -+#undef SUBTARGET_OVERRIDE_OPTIONS -+#define SUBTARGET_OVERRIDE_OPTIONS \ -+ { \ -+ if (TARGET_COLDFIRE) \ -+ { \ -+ target_flags |= MASK_STRICT_ALIGNMENT | MASK_CF_HWDIV; \ -+ if ((target_flags_explicit & MASK_HARD_FLOAT) == 0) \ -+ { \ -+ target_flags &= ~MASK_HARD_FLOAT; \ -+ m68k_fpu = FPUTYPE_NONE; \ -+ } \ -+ } \ -+ } -+ - #undef SUBTARGET_EXTRA_SPECS - #define SUBTARGET_EXTRA_SPECS \ -+ { "netbsd_cpp_spec", NETBSD_CPP_SPEC }, \ - { "netbsd_entry_point", NETBSD_ENTRY_POINT }, - - -@@ -56,20 +71,31 @@ - whether or not use of the FPU is allowed. */ - - #undef CPP_SPEC --#define CPP_SPEC NETBSD_CPP_SPEC -+#define CPP_SPEC \ -+ "%(netbsd_cpp_spec)" - - - /* Provide an ASM_SPEC appropriate for NetBSD m68k ELF targets. We need - to pass PIC code generation options. */ - - #undef ASM_SPEC --#define ASM_SPEC "%(asm_cpu_spec) %{fpic|fpie:-k} %{fPIC|fPIE:-k -K}" -+#define ASM_SPEC \ -+ "%(asm_default_spec) \ -+ %{m68010} %{m68020} %{m68030} %{m68040} %{m68060} \ -+ %{m5200} %{m5206e} %{m528x} %{m5307} %{m5407} %{mcfv4e}\ -+ %{mcpu=*:-mcpu=%*} %{march=*:-march=%*}\ -+ %{fpic|fpie:-k} %{fPIC|fPIE:-k -K}" - - /* Provide a LINK_SPEC appropriate for a NetBSD/m68k ELF target. */ - - #undef LINK_SPEC - #define LINK_SPEC NETBSD_LINK_SPEC_ELF - -+/* NetBSD/sun2 does not support shlibs, avoid using libgcc_pic. */ -+#if TARGET_DEFAULT_CPU == 0 -+#undef REAL_LIBGCC_SPEC -+#endif -+ - #define NETBSD_ENTRY_POINT "_start" - - /* Output assembler code to FILE to increment profiler label # LABELNO -@@ -79,7 +105,13 @@ - #define FUNCTION_PROFILER(FILE, LABELNO) \ - do \ - { \ -- asm_fprintf (FILE, "\tlea (%LLP%d,%Rpc),%Ra1\n", (LABELNO)); \ -+ if (TARGET_COLDFIRE) \ -+ { \ -+ asm_fprintf (FILE, "\tmovea.l #%LLP%d-.,%Ra1\n", (LABELNO)); \ -+ asm_fprintf (FILE, "\tlea (-6,%Rpc,%Ra1),%Ra1\n", (LABELNO)); \ -+ } \ -+ else \ -+ asm_fprintf (FILE, "\tlea (%LLP%d,%Rpc),%Ra1\n", (LABELNO)); \ - if (flag_pic) \ - fprintf (FILE, "\tbsr.l __mcount@PLTPC\n"); \ - else \ -@@ -270,6 +302,8 @@ - - #undef STACK_BOUNDARY - #define STACK_BOUNDARY 32 -+#undef PREFERRED_STACK_BOUNDARY -+#define PREFERRED_STACK_BOUNDARY 32 - - - /* Alignment of field after `int : 0' in a structure. -diff -rNU3 dist.orig/gcc/config/m68k/t-m68010-netbsd dist/gcc/config/m68k/t-m68010-netbsd ---- dist.orig/gcc/config/m68k/t-m68010-netbsd 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/m68k/t-m68010-netbsd 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,4 @@ -+# Use unwind-dw2-fde-glibc -+LIB2ADDEH = $(srcdir)/unwind-dw2.c $(srcdir)/unwind-dw2-fde-glibc.c \ -+ $(srcdir)/unwind-sjlj.c $(srcdir)/gthr-gnat.c $(srcdir)/unwind-c.c -+LIB2ADDEHDEP = unwind.inc unwind-dw2-fde.h unwind-dw2-fde.c -diff -rNU3 dist.orig/gcc/config/m68k/t-opts dist/gcc/config/m68k/t-opts ---- dist.orig/gcc/config/m68k/t-opts 2011-05-02 17:42:39.000000000 +0200 -+++ dist/gcc/config/m68k/t-opts 2015-10-18 13:19:50.000000000 +0200 -@@ -1,5 +1,7 @@ - $(srcdir)/config/m68k/m68k-tables.opt: $(srcdir)/config/m68k/genopt.sh \ - $(srcdir)/config/m68k/m68k-devices.def $(srcdir)/config/m68k/m68k-isas.def \ - $(srcdir)/config/m68k/m68k-microarchs.def -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_m68k-tables.opt: - $(SHELL) $(srcdir)/config/m68k/genopt.sh $(srcdir)/config/m68k > \ - $(srcdir)/config/m68k/m68k-tables.opt -diff -rNU3 dist.orig/gcc/config/mips/netbsd.h dist/gcc/config/mips/netbsd.h ---- dist.orig/gcc/config/mips/netbsd.h 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/config/mips/netbsd.h 2015-10-18 13:19:50.000000000 +0200 -@@ -32,16 +32,63 @@ - if (TARGET_ABICALLS) \ - builtin_define ("__ABICALLS__"); \ - \ -- if (mips_abi == ABI_EABI) \ -- builtin_define ("__mips_eabi"); \ -- else if (mips_abi == ABI_N32) \ -+ /* The GNU C++ standard library requires this. */ \ -+ if (c_dialect_cxx ()) \ -+ builtin_define ("_GNU_SOURCE"); \ -+ \ -+ if (mips_abi == ABI_N32) \ -+ { \ - builtin_define ("__mips_n32"); \ -+ builtin_define ("_ABIN32=2"); \ -+ builtin_define ("_MIPS_SIM=_ABIN32"); \ -+ builtin_define ("_MIPS_SZLONG=32"); \ -+ builtin_define ("_MIPS_SZPTR=32"); \ -+ } \ - else if (mips_abi == ABI_64) \ -+ { \ - builtin_define ("__mips_n64"); \ -+ builtin_define ("_ABI64=3"); \ -+ builtin_define ("_MIPS_SIM=_ABI64"); \ -+ builtin_define ("_MIPS_SZLONG=64"); \ -+ builtin_define ("_MIPS_SZPTR=64"); \ -+ } \ - else if (mips_abi == ABI_O64) \ -+ { \ - builtin_define ("__mips_o64"); \ -+ builtin_define ("_ABIO64=4"); \ -+ builtin_define ("_MIPS_SIM=_ABIO64"); \ -+ builtin_define ("_MIPS_SZLONG=64"); \ -+ builtin_define ("_MIPS_SZPTR=64"); \ - } \ -- while (0) -+ else if (mips_abi == ABI_EABI) \ -+ { \ -+ builtin_define ("__mips_eabi"); \ -+ builtin_define ("_ABIEMB=5"); \ -+ builtin_define ("_MIPS_SIM=_ABIEMB"); \ -+ if (TARGET_LONG64) \ -+ builtin_define ("_MIPS_SZLONG=64"); \ -+ else \ -+ builtin_define ("_MIPS_SZLONG=32"); \ -+ if (TARGET_64BIT) \ -+ builtin_define ("_MIPS_SZPTR=64"); \ -+ else \ -+ builtin_define ("_MIPS_SZPTR=32"); \ -+ } \ -+ else \ -+ { \ -+ builtin_define ("__mips_o32"); \ -+ builtin_define ("_ABIO32=1"); \ -+ builtin_define ("_MIPS_SIM=_ABIO32"); \ -+ builtin_define ("_MIPS_SZLONG=32"); \ -+ builtin_define ("_MIPS_SZPTR=32"); \ -+ } \ -+ if (TARGET_FLOAT64) \ -+ builtin_define ("_MIPS_FPSET=32"); \ -+ else \ -+ builtin_define ("_MIPS_FPSET=16"); \ -+ \ -+ builtin_define ("_MIPS_SZINT=32"); \ -+ } while (0) - - /* The generic MIPS TARGET_CPU_CPP_BUILTINS are incorrect for NetBSD. - Specifically, they define too many namespace-invasive macros. Override -@@ -97,6 +144,11 @@ - builtin_define ("__mips=64"); \ - builtin_define ("__mips_isa_rev=1"); \ - } \ -+ else if (ISA_MIPS64R2) \ -+ { \ -+ builtin_define ("__mips=64"); \ -+ builtin_define ("__mips_isa_rev=2"); \ -+ } \ - \ - if (TARGET_HARD_FLOAT) \ - builtin_define ("__mips_hard_float"); \ -@@ -111,6 +163,11 @@ - else \ - builtin_define ("__MIPSEL__"); \ - \ -+ if (TARGET_OCTEON) \ -+ builtin_define ("__OCTEON__"); \ -+ \ -+ if (ISA_HAS_POP) \ -+ builtin_define ("__mips_popcount"); \ - /* No language dialect defines. */ \ - \ - /* ABIs handled in TARGET_OS_CPP_BUILTINS. */ \ -@@ -136,10 +193,12 @@ - - #undef LINK_SPEC - #define LINK_SPEC \ -- "%{EL:-m elf32lmip} \ -- %{EB:-m elf32bmip} \ -+ "%{EL:-m elf32ltsmip} \ -+ %{EB:-m elf32btsmip} \ - %(endian_spec) \ -- %{G*} %{mips1} %{mips2} %{mips3} %{mips4} %{mips32} %{mips32r2} %{mips64} \ -+ %{G*} %{mips1} %{mips2} %{mips3} %{mips4} \ -+ %{mips32} %{mips32r2} %{mips64} %{mips64r2} \ -+ %{bestGnum} %{call_shared} %{no_archive} %{exact_version} \ - %(netbsd_link_spec)" - - #define NETBSD_ENTRY_POINT "__start" -@@ -169,6 +228,20 @@ - - /* Make gcc agree with */ - -+#undef SIZE_TYPE -+#define SIZE_TYPE ((POINTER_SIZE == 64 || TARGET_NEWABI) \ -+ ? "long unsigned int" : "unsigned int") -+ -+#undef PTRDIFF_TYPE -+#define PTRDIFF_TYPE ((POINTER_SIZE == 64 || TARGET_NEWABI) \ -+ ? "long int" : "int") -+ -+#undef INTPTR_TYPE -+#define INTPTR_TYPE PTRDIFF_TYPE -+ -+#undef UINTPTR_TYPE -+#define UINTPTR_TYPE SIZE_TYPE -+ - #undef WCHAR_TYPE - #define WCHAR_TYPE "int" - -@@ -177,3 +250,6 @@ - - #undef WINT_TYPE - #define WINT_TYPE "int" -+ -+#undef TARGET_WRITABLE_EH_FRAME -+#define TARGET_WRITABLE_EH_FRAME (flag_pic && TARGET_SHARED) -diff -rNU3 dist.orig/gcc/config/mips/netbsd64.h dist/gcc/config/mips/netbsd64.h ---- dist.orig/gcc/config/mips/netbsd64.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/mips/netbsd64.h 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,47 @@ -+/* Definitions of target machine for GNU compiler, for MIPS NetBSD systems. -+ Copyright (C) 1993, 1995, 1996, 1997, 1999, 2000, 2001, 2002, 2003, 2004 -+ Free Software Foundation, Inc. -+ -+This file is part of GCC. -+ -+GCC is free software; you can redistribute it and/or modify -+it under the terms of the GNU General Public License as published by -+the Free Software Foundation; either version 2, or (at your option) -+any later version. -+ -+GCC is distributed in the hope that it will be useful, -+but WITHOUT ANY WARRANTY; without even the implied warranty of -+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+GNU General Public License for more details. -+ -+You should have received a copy of the GNU General Public License -+along with GCC; see the file COPYING. If not, write to -+the Free Software Foundation, 51 Franklin Street, Fifth Floor, -+Boston, MA 02110-1301, USA. */ -+ -+/* Force the default endianness and ABI flags onto the command line -+ in order to make the other specs easier to write. */ -+ -+#undef DRIVER_SELF_SPECS -+#define DRIVER_SELF_SPECS \ -+ BASE_DRIVER_SELF_SPECS \ -+ "%{!EB:%{!EL:%(endian_spec)}}", \ -+ "%{!mabi=*: -mabi=n32}" -+ -+/* Define default target values. */ -+ -+/* Provide a LINK_SPEC appropriate for a NetBSD/mips target. -+ This is a copy of LINK_SPEC from tweaked for -+ the MIPS target. */ -+ -+#undef LINK_SPEC -+#define LINK_SPEC \ -+ "%{mabi=64:-m elf64%{EB:b}%{EL:l}tsmip} \ -+ %{mabi=32:-m elf32%{EB:b}%{EL:l}tsmip} \ -+ %{mabi=o64:-m elf64%{EB:b}%{EL:l}tsmip} \ -+ %{mabi=n32:-m elf32%{EB:b}%{EL:l}tsmipn32} \ -+ %(endian_spec) \ -+ %{G*} %{mips1} %{mips2} %{mips3} %{mips4} \ -+ %{mips32} %{mips32r2} %{mips64} %{mips64r2} \ -+ %{bestGnum} %{call_shared} %{no_archive} %{exact_version} \ -+ %(netbsd_link_spec)" -diff -rNU3 dist.orig/gcc/config/mips/t-mips dist/gcc/config/mips/t-mips ---- dist.orig/gcc/config/mips/t-mips 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/config/mips/t-mips 2015-10-18 13:19:50.000000000 +0200 -@@ -18,5 +18,7 @@ - - $(srcdir)/config/mips/mips-tables.opt: $(srcdir)/config/mips/genopt.sh \ - $(srcdir)/config/mips/mips-cpus.def -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_config_mips_mips-tables.opt: - $(SHELL) $(srcdir)/config/mips/genopt.sh $(srcdir)/config/mips > \ - $(srcdir)/config/mips/mips-tables.opt -diff -rNU3 dist.orig/gcc/config/mips/t-netbsd64 dist/gcc/config/mips/t-netbsd64 ---- dist.orig/gcc/config/mips/t-netbsd64 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/mips/t-netbsd64 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,9 @@ -+# NetBSD has (will have) "non-native" libraries in /usr/lib/. -+# For NetBSD/mips64 we thus have /usr/lib (n32), /usr/lib/o32 and /usr/lib/64. -+ -+MULTILIB_OPTIONS = mabi=n32/mabi=64/mabi=32 -+MULTILIB_DIRNAMES = n32 n64 o32 -+MULTILIB_OSDIRNAMES = . ../lib/64 ../lib/o32 -+ -+LIBGCC = stmp-multilib -+INSTALL_LIBGCC = install-multilib -diff -rNU3 dist.orig/gcc/config/netbsd-elf.h dist/gcc/config/netbsd-elf.h ---- dist.orig/gcc/config/netbsd-elf.h 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/config/netbsd-elf.h 2015-10-18 13:19:50.000000000 +0200 -@@ -40,8 +40,11 @@ - %{!p:crt0%O%s}}} \ - %:if-exists(crti%O%s) \ - %{static:%:if-exists-else(crtbeginT%O%s crtbegin%O%s)} \ -- %{!static: \ -- %{!shared:crtbegin%O%s} %{shared:crtbeginS%O%s}}" -+ %{!static: \ -+ %{!shared: \ -+ %{!pie:crtbegin%O%s} \ -+ %{pie:crtbeginS%O%s}} \ -+ %{shared:crtbeginS%O%s}}" - - #undef STARTFILE_SPEC - #define STARTFILE_SPEC NETBSD_STARTFILE_SPEC -@@ -52,7 +55,10 @@ - C++ file-scope static objects deconstructed after exiting "main". */ - - #define NETBSD_ENDFILE_SPEC \ -- "%{!shared:crtend%O%s} %{shared:crtendS%O%s} \ -+ "%{!shared: \ -+ %{!pie:crtend%O%s} \ -+ %{pie:crtendS%O%s}} \ -+ %{shared:crtendS%O%s} \ - %:if-exists(crtn%O%s)" - - #undef ENDFILE_SPEC -@@ -70,6 +76,7 @@ - #define NETBSD_LINK_SPEC_ELF \ - "%{assert*} %{R*} %{rpath*} \ - %{shared:-shared} \ -+ %{symbolic:-Bsymbolic} \ - %{!shared: \ - -dc -dp \ - %{!nostdlib: \ -@@ -84,3 +91,11 @@ - #ifdef HAVE_LD_AS_NEEDED - #define USE_LD_AS_NEEDED 1 - #endif -+ -+#define MFLIB_SPEC " %{fmudflap: -export-dynamic -lmudflap \ -+ %{static:%(link_gcc_c_sequence) -lmudflap}} \ -+ %{fmudflapth: -export-dynamic -lmudflapth -lpthread \ -+ %{static:%(link_gcc_c_sequence) -lmudflapth}} " -+ -+#undef TARGET_UNWIND_TABLES_DEFAULT -+#define TARGET_UNWIND_TABLES_DEFAULT true -diff -rNU3 dist.orig/gcc/config/netbsd-stdint.h dist/gcc/config/netbsd-stdint.h ---- dist.orig/gcc/config/netbsd-stdint.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/netbsd-stdint.h 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,72 @@ -+/* Definitions for types for NetBSD systems. -+ Copyright (C) 2009 Free Software Foundation, Inc. -+ Contributed by Gerald Pfeifer . -+ -+This file is part of GCC. -+ -+GCC is free software; you can redistribute it and/or modify -+it under the terms of the GNU General Public License as published by -+the Free Software Foundation; either version 3, or (at your option) -+any later version. -+ -+GCC is distributed in the hope that it will be useful, -+but WITHOUT ANY WARRANTY; without even the implied warranty of -+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+GNU General Public License for more details. -+ -+Under Section 7 of GPL version 3, you are granted additional -+permissions described in the GCC Runtime Library Exception, version -+3.1, as published by the Free Software Foundation. -+ -+You should have received a copy of the GNU General Public License and -+a copy of the GCC Runtime Library Exception along with this program; -+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -+. */ -+ -+#define SIG_ATOMIC_TYPE "int" -+ -+#define INT8_TYPE "signed char" -+#define INT16_TYPE "short int" -+#define INT32_TYPE "int" -+#define INT64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int") -+#define UINT8_TYPE "unsigned char" -+#define UINT16_TYPE "short unsigned int" -+#define UINT32_TYPE "unsigned int" -+#define UINT64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int") -+ -+#define INT_LEAST8_TYPE "signed char" -+#define INT_LEAST16_TYPE "short int" -+#define INT_LEAST32_TYPE "int" -+#define INT_LEAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int") -+#define UINT_LEAST8_TYPE "unsigned char" -+#define UINT_LEAST16_TYPE "short unsigned int" -+#define UINT_LEAST32_TYPE "unsigned int" -+#define UINT_LEAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int") -+ -+#ifdef CHAR_FAST8 -+#define INT_FAST8_TYPE (LONG_TYPE_SIZE == 64 ? "int" : "signed char") -+#else -+#define INT_FAST8_TYPE "int" -+#endif -+#ifdef SHORT_FAST16 -+#define INT_FAST16_TYPE (LONG_TYPE_SIZE == 64 ? "int" : "short int") -+#else -+#define INT_FAST16_TYPE "int" -+#endif -+#define INT_FAST32_TYPE "int" -+#define INT_FAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int") -+#ifdef CHAR_FAST8 -+#define UINT_FAST8_TYPE (LONG_TYPE_SIZE == 64 ? "unsigned int" : "unsigned char") -+#else -+#define UINT_FAST8_TYPE "unsigned int" -+#endif -+#ifdef SHORT_FAST16 -+#define UINT_FAST16_TYPE (LONG_TYPE_SIZE == 64 ? "unsigned int" : "short unsigned int") -+#else -+#define UINT_FAST16_TYPE "unsigned int" -+#endif -+#define UINT_FAST32_TYPE "unsigned int" -+#define UINT_FAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int") -+ -+#define INTPTR_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "int") -+#define UINTPTR_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "unsigned int") -diff -rNU3 dist.orig/gcc/config/netbsd.h dist/gcc/config/netbsd.h ---- dist.orig/gcc/config/netbsd.h 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/config/netbsd.h 2015-10-18 13:19:50.000000000 +0200 -@@ -36,37 +36,59 @@ - - /* NETBSD_NATIVE is defined when gcc is integrated into the NetBSD - source tree so it can be configured appropriately without using -- the GNU configure/build mechanism. */ -+ the GNU configure/build mechanism. - --#ifdef NETBSD_NATIVE -+ NETBSD_TOOLS is defined when gcc is built as cross-compiler for -+ the in-tree toolchain. -+ */ -+ -+#if defined(NETBSD_NATIVE) || defined(NETBSD_TOOLS) - - /* Look for the include files in the system-defined places. */ - - #undef GPLUSPLUS_INCLUDE_DIR - #define GPLUSPLUS_INCLUDE_DIR "/usr/include/g++" - -+#undef GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT -+#define GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT 1 -+ -+#undef GPLUSPLUS_BACKWARD_INCLUDE_DIR -+#define GPLUSPLUS_BACKWARD_INCLUDE_DIR "/usr/include/g++/backward" -+ -+#undef GCC_INCLUDE_DIR_ADD_SYSROOT -+#define GCC_INCLUDE_DIR_ADD_SYSROOT 1 -+ -+/* -+ * XXX figure out a better way to do this -+ */ - #undef GCC_INCLUDE_DIR --#define GCC_INCLUDE_DIR "/usr/include" -+#define GCC_INCLUDE_DIR "/usr/include/gcc-4.8" - --#undef INCLUDE_DEFAULTS --#define INCLUDE_DEFAULTS \ -- { \ -- { GPLUSPLUS_INCLUDE_DIR, "G++", 1, 1 }, \ -- { GCC_INCLUDE_DIR, "GCC", 0, 0 }, \ -- { 0, 0, 0, 0 } \ -- } -+/* Under NetBSD, the normal location of the various *crt*.o files is the -+ /usr/lib directory. */ - -+#undef STANDARD_STARTFILE_PREFIX -+#define STANDARD_STARTFILE_PREFIX "/usr/lib/" -+#undef STANDARD_STARTFILE_PREFIX_1 -+#define STANDARD_STARTFILE_PREFIX_1 "/usr/lib/" -+ -+#endif /* NETBSD_NATIVE || NETBSD_TOOLS */ -+ -+#if defined(NETBSD_NATIVE) - /* Under NetBSD, the normal location of the compiler back ends is the - /usr/libexec directory. */ - - #undef STANDARD_EXEC_PREFIX - #define STANDARD_EXEC_PREFIX "/usr/libexec/" - --/* Under NetBSD, the normal location of the various *crt*.o files is the -- /usr/lib directory. */ -+#undef TOOLDIR_BASE_PREFIX -+#define TOOLDIR_BASE_PREFIX "../" - --#undef STANDARD_STARTFILE_PREFIX --#define STANDARD_STARTFILE_PREFIX "/usr/lib/" -+#undef STANDARD_BINDIR_PREFIX -+#define STANDARD_BINDIR_PREFIX "/usr/bin" -+ -+#undef STANDARD_LIBEXEC_PREFIX -+#define STANDARD_LIBEXEC_PREFIX STANDARD_EXEC_PREFIX - - #endif /* NETBSD_NATIVE */ - -@@ -96,6 +118,7 @@ - %{!pg:-lposix}} \ - %{p:-lposix_p} \ - %{pg:-lposix_p}} \ -+ %{shared:-lc} \ - %{!shared: \ - %{!symbolic: \ - %{!p: \ -@@ -109,6 +132,7 @@ - %{!pg:-lposix}} \ - %{p:-lposix_p} \ - %{pg:-lposix_p}} \ -+ %{shared:-lc} \ - %{!shared: \ - %{!symbolic: \ - %{!p: \ -@@ -120,24 +144,18 @@ - #undef LIB_SPEC - #define LIB_SPEC NETBSD_LIB_SPEC - --/* Provide a LIBGCC_SPEC appropriate for NetBSD. We also want to exclude -- libgcc with -symbolic. */ -+#undef STATIC_LIBASAN_LIBS -+#define STATIC_LIBASAN_LIBS "-lstdc++ -lpthread" - --#ifdef NETBSD_NATIVE --#define NETBSD_LIBGCC_SPEC \ -- "%{!symbolic: \ -- %{!shared: \ -- %{!p: \ -- %{!pg: -lgcc}}} \ -- %{shared: -lgcc_pic} \ -- %{p: -lgcc_p} \ -- %{pg: -lgcc_p}}" --#else --#define NETBSD_LIBGCC_SPEC "%{!shared:%{!symbolic: -lgcc}}" --#endif -+/* Pass -cxx-isystem to cc1/cc1plus. */ -+#define NETBSD_CC1_AND_CC1PLUS_SPEC \ -+ "%{cxx-isystem}" -+ -+#undef CC1_SPEC -+#define CC1_SPEC NETBSD_CC1_AND_CC1PLUS_SPEC - --#undef LIBGCC_SPEC --#define LIBGCC_SPEC NETBSD_LIBGCC_SPEC -+#undef CC1PLUS_SPEC -+#define CC1PLUS_SPEC NETBSD_CC1_AND_CC1PLUS_SPEC - - /* When building shared libraries, the initialization and finalization - functions for the library are .init and .fini respectively. */ -@@ -172,3 +190,10 @@ - - #undef WINT_TYPE - #define WINT_TYPE "int" -+ -+#define LINK_EH_SPEC "%{!static:--eh-frame-hdr} " -+ -+/* Use --as-needed -lgcc_s for eh support. */ -+#ifdef HAVE_LD_AS_NEEDED -+#define USE_LD_AS_NEEDED 1 -+#endif -diff -rNU3 dist.orig/gcc/config/or1k/constraints.md dist/gcc/config/or1k/constraints.md ---- dist.orig/gcc/config/or1k/constraints.md 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/or1k/constraints.md 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,59 @@ -+;; Copyright (C) 2010 Embecosm Limited -+;; -+;; Contributed by Joern Rennecke in 2010 -+;; -+;; This file is part of GCC. -+;; -+;; GCC is free software; you can redistribute it and/or modify -+;; it under the terms of the GNU General Public License as published by -+;; the Free Software Foundation; either version 3, or (at your option) -+;; any later version. -+;; -+;; GCC is distributed in the hope that it will be useful, -+;; but WITHOUT ANY WARRANTY; without even the implied warranty of -+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+;; GNU General Public License for more details. -+;; -+;; You should have received a copy of the GNU General Public License -+;; along with GCC; see the file COPYING3. If not see -+;; . -+ -+(define_constraint "I" -+ "" -+ (and (match_code "const_int") -+ (match_test "ival >= -32768 && ival <= 32767"))) -+ -+(define_constraint "J" -+ "" -+ (and (match_code "const_int") -+ (match_test "ival == 0"))) -+ -+(define_constraint "K" -+ "" -+ (and (match_code "const_int") -+ (match_test "ival >= 0 && ival <= 65535"))) -+ -+(define_constraint "L" -+ "" -+ (and (match_code "const_int") -+ (match_test "ival >= 0 && ival <= 31"))) -+ -+(define_constraint "M" -+ "" -+ (and (match_code "const_int") -+ (match_test "(ival & 0xffff) == 0"))) -+ -+(define_constraint "N" -+ "" -+ (and (match_code "const_int") -+ (match_test "ival >= -33554432 && ival <= 33554431"))) -+ -+(define_constraint "O" -+ "" -+ (and (match_code "const_int") -+ (match_test "ival == 0"))) -+ -+(define_constraint "C" -+ "" -+ (match_code "const_double")) -+ -diff -rNU3 dist.orig/gcc/config/or1k/elf.h dist/gcc/config/or1k/elf.h ---- dist.orig/gcc/config/or1k/elf.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/or1k/elf.h 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,31 @@ -+/* Definitions for rtems targeting an OpenRisc OR1K using COFF -+ ??? this is for OR1K, but the rest of the above seems bogus. -+ Copyright (C) 1996, 1997, 2005 Free Software Foundation, Inc. -+ Contributed by Joel Sherrill (joel@OARcorp.com). -+ -+This file is part of GNU CC. -+ -+GNU CC is free software; you can redistribute it and/or modify -+it under the terms of the GNU General Public License as published by -+the Free Software Foundation; either version 2, or (at your option) -+any later version. -+ -+GNU CC is distributed in the hope that it will be useful, -+but WITHOUT ANY WARRANTY; without even the implied warranty of -+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+GNU General Public License for more details. -+ -+You should have received a copy of the GNU General Public License -+along with GNU CC; see the file COPYING. If not, write to -+the Free Software Foundation, 59 Temple Place - Suite 330, -+Boston, MA 02111-1307, USA. */ -+ -+/* Use ELF */ -+#undef OBJECT_FORMAT_ELF -+#define OBJECT_FORMAT_ELF -+ -+/* or1k debug info support is controlled by tm.h header files we include: -+ dbxelf.h enables optional stabs debug info. -+ elfos.h sets PREFERRED_DEBUGGING_TYPE to DWARF2_DEBUG . */ -+ -+#define DRIVER_SELF_SPECS "%{!mno-newlib:-mnewlib}" -diff -rNU3 dist.orig/gcc/config/or1k/linux-elf.h dist/gcc/config/or1k/linux-elf.h ---- dist.orig/gcc/config/or1k/linux-elf.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/or1k/linux-elf.h 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,98 @@ -+/* Definitions for or1k running Linux-based GNU systems using ELF -+ Copyright (C) 2002, 2005 -+ Free Software Foundation, Inc. -+ Contributed by Marko Mlinar -+ -+This file is part of GNU CC. -+ -+GNU CC is free software; you can redistribute it and/or modify -+it under the terms of the GNU General Public License as published by -+the Free Software Foundation; either version 2, or (at your option) -+any later version. -+ -+GNU CC is distributed in the hope that it will be useful, -+but WITHOUT ANY WARRANTY; without even the implied warranty of -+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+GNU General Public License for more details. -+ -+You should have received a copy of the GNU General Public License -+along with this program; see the file COPYING. If not, write to -+the Free Software Foundation, 59 Temple Place - Suite 330, -+Boston, MA 02111-1307, USA. */ -+ -+/* elfos.h should have already been included. Now just override -+ any conflicting definitions and add any extras. */ -+ -+/* Do not assume anything about header files. */ -+#define NO_IMPLICIT_EXTERN_C -+ -+/* This is how we tell the assembler that two symbols have the same value. */ -+#define ASM_OUTPUT_DEF(FILE, NAME1, NAME2) \ -+ do \ -+ { \ -+ assemble_name (FILE, NAME1); \ -+ fputs (" = ", FILE); \ -+ assemble_name (FILE, NAME2); \ -+ fputc ('\n', FILE); \ -+ } \ -+ while (0) -+ -+ -+#if 0 -+/* Node: Label Output */ -+ -+#define SET_ASM_OP "\t.set\t" -+ -+#define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \ -+ (*targetm.asm_out.globalize_label) (FILE, XSTR (FUN, 0)) -+ -+#define ASM_WEAKEN_LABEL(FILE, NAME) \ -+ do \ -+ { \ -+ fputs ("\t.weak\t", (FILE)); \ -+ assemble_name ((FILE), (NAME)); \ -+ fputc ('\n', (FILE)); \ -+ } \ -+ while (0) -+ -+#endif -+ -+/* The GNU C++ standard library requires that these macros be defined. */ -+#undef CPLUSPLUS_CPP_SPEC -+#define CPLUSPLUS_CPP_SPEC "-D_GNU_SOURCE %(cpp)" -+ -+#undef DRIVER_SELF_SPECS -+#define DRIVER_SELF_SPECS "" -+ -+#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1" -+ -+/* Define a set of Linux builtins. This is copied from linux.h. We can't -+ include the whole file for now, because that causes configure to require ld -+ to support --eh-frame-header, which it currently doesn't */ -+#define LINUX_TARGET_OS_CPP_BUILTINS() \ -+ do { \ -+ builtin_define ("__gnu_linux__"); \ -+ builtin_define_std ("linux"); \ -+ builtin_define_std ("unix"); \ -+ builtin_assert ("system=linux"); \ -+ builtin_assert ("system=unix"); \ -+ builtin_assert ("system=posix"); \ -+ } while (0) -+ -+#define TARGET_OS_CPP_BUILTINS() \ -+ do { \ -+ LINUX_TARGET_OS_CPP_BUILTINS(); \ -+ if (OPTION_UCLIBC) \ -+ builtin_define ("__UCLIBC__"); \ -+ /* The GNU C++ standard library requires this. */ \ -+ if (c_dialect_cxx ()) \ -+ builtin_define ("_GNU_SOURCE"); \ -+ } while (0) -+ -+#undef LINK_SPEC -+#define LINK_SPEC "%{mnewlib:-entry 0x100} \ -+ -dynamic-linker " GNU_USER_DYNAMIC_LINKER " \ -+ %{rdynamic:-export-dynamic} \ -+ %{static:-static} \ -+ %{shared:-shared}" -+ -diff -rNU3 dist.orig/gcc/config/or1k/linux-gas.h dist/gcc/config/or1k/linux-gas.h ---- dist.orig/gcc/config/or1k/linux-gas.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/or1k/linux-gas.h 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,37 @@ -+/* Definitions of target machine for GNU compiler. -+ Or32 Linux-based GNU systems version. -+ Copyright (C) 2002, 2005 Free Software Foundation, Inc. -+ Contributed by Marko Mlinar -+ -+This file is part of GNU CC. -+ -+GNU CC is free software; you can redistribute it and/or modify -+it under the terms of the GNU General Public License as published by -+the Free Software Foundation; either version 2, or (at your option) -+any later version. -+ -+GNU CC is distributed in the hope that it will be useful, -+but WITHOUT ANY WARRANTY; without even the implied warranty of -+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+GNU General Public License for more details. -+ -+You should have received a copy of the GNU General Public License -+along with this program; see the file COPYING. If not, write to -+the Free Software Foundation, 59 Temple Place - Suite 330, -+Boston, MA 02111-1307, USA. */ -+ -+/* Unsigned chars produces much better code than signed. */ -+#undef DEFAULT_SIGNED_CHAR -+#define DEFAULT_SIGNED_CHAR 1 -+ -+/* Make gcc agree with */ -+ -+#define SIZE_TYPE "unsigned int" -+#define PTRDIFF_TYPE "int" -+#define WCHAR_TYPE "unsigned int" -+#define WCHAR_TYPE_SIZE 32 -+ -+ -+/* Clear the instruction cache from `beg' to `end'. This makes an -+ inline system call to SYS_cacheflush. */ -+#define CLEAR_INSN_CACHE(BEG, END) /* Do something here !!! */ -diff -rNU3 dist.orig/gcc/config/or1k/netbsd.h dist/gcc/config/or1k/netbsd.h ---- dist.orig/gcc/config/or1k/netbsd.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/or1k/netbsd.h 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,67 @@ -+/* Definitions for or1k running NetBSD systems using ELF -+ Copyright (C) 2014 -+ Free Software Foundation, Inc. -+ Contributed by Matt Thomas -+ -+This file is part of GNU CC. -+ -+GNU CC is free software; you can redistribute it and/or modify -+it under the terms of the GNU General Public License as published by -+the Free Software Foundation; either version 2, or (at your option) -+any later version. -+ -+GNU CC is distributed in the hope that it will be useful, -+but WITHOUT ANY WARRANTY; without even the implied warranty of -+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+GNU General Public License for more details. -+ -+You should have received a copy of the GNU General Public License -+along with this program; see the file COPYING. If not, write to -+the Free Software Foundation, 59 Temple Place - Suite 330, -+Boston, MA 02111-1307, USA. */ -+ -+/* This is how we tell the assembler that two symbols have the same value. */ -+#define ASM_OUTPUT_DEF(FILE, NAME1, NAME2) \ -+ do \ -+ { \ -+ assemble_name (FILE, NAME1); \ -+ fputs (" = ", FILE); \ -+ assemble_name (FILE, NAME2); \ -+ fputc ('\n', FILE); \ -+ } \ -+ while (0) -+ -+#undef DRIVER_SELF_SPECS -+#define DRIVER_SELF_SPECS "" -+ -+#define TARGET_OS_CPP_BUILTINS() \ -+ do { \ -+ NETBSD_OS_CPP_BUILTINS_ELF(); \ -+ /* The GNU C++ standard library requires this. */ \ -+ if (c_dialect_cxx ()) \ -+ builtin_define ("_GNU_SOURCE"); \ -+ } while (0) -+ -+#undef CPP_SPEC -+#define CPP_SPEC NETBSD_CPP_SPEC -+ -+#undef LIB_SPEC -+#define LIB_SPEC NETBSD_LIB_SPEC -+ -+#undef LINK_SPEC -+#define LINK_SPEC NETBSD_LINK_SPEC_ELF -+ -+#undef NETBSD_ENTRY_POINT -+#define NETBSD_ENTRY_POINT "_start" -+ -+#undef SUBTARGET_EXTRA_SPECS -+#define SUBTARGET_EXTRA_SPECS \ -+ { "netbsd_link_spec", NETBSD_LINK_SPEC_ELF }, \ -+ { "netbsd_entry_point", NETBSD_ENTRY_POINT }, \ -+ { "netbsd_endfile_spec", NETBSD_ENDFILE_SPEC }, -+ -+#undef TARGET_DEFAULT -+#define TARGET_DEFAULT \ -+ (/*MASK_HARD_FLOAT |*/ MASK_DOUBLE_FLOAT \ -+ | MASK_HARD_DIV | MASK_HARD_MUL \ -+ | MASK_MASK_CMOV | MASK_MASK_ROR | MASK_MASK_SEXT) -diff -rNU3 dist.orig/gcc/config/or1k/or1k-modes.def dist/gcc/config/or1k/or1k-modes.def ---- dist.orig/gcc/config/or1k/or1k-modes.def 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/or1k/or1k-modes.def 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,38 @@ -+/* Definitions of target machine for GNU compiler, for OR32. -+ Copyright (C) 2002, 2003 Free Software Foundation, Inc. -+ -+ This file is part of GCC. -+ -+ GCC is free software; you can redistribute it and/or modify it -+ under the terms of the GNU General Public License as published -+ by the Free Software Foundation; either version 2, or (at your -+ option) any later version. -+ -+ GCC is distributed in the hope that it will be useful, but WITHOUT -+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -+ License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with GCC; see the file COPYING. If not, write to the -+ Free Software Foundation, 59 Temple Place - Suite 330, Boston, -+ MA 02111-1307, USA. */ -+ -+/* Add any extra modes needed to represent the condition code. -+ */ -+ -+CC_MODE (CCEQ); -+CC_MODE (CCNE); -+ -+CC_MODE (CCLE); -+CC_MODE (CCGE); -+CC_MODE (CCLT); -+CC_MODE (CCGT); -+ -+CC_MODE (CCLEU); -+CC_MODE (CCGEU); -+CC_MODE (CCLTU); -+CC_MODE (CCGTU); -+ -+CC_MODE(CCFP); -+CC_MODE(CCUNS); -diff -rNU3 dist.orig/gcc/config/or1k/or1k-opts.h dist/gcc/config/or1k/or1k-opts.h ---- dist.orig/gcc/config/or1k/or1k-opts.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/or1k/or1k-opts.h 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,14 @@ -+#ifndef OR1K_OPTS_H -+#define OR1K_OPTS_H -+ -+enum or1k_delay { -+ OR1K_DELAY_OFF = 0, -+ OR1K_DELAY_ON = 1, -+ OR1K_DELAY_COMPAT = 2 -+}; -+ -+#define TARGET_DELAY_ON (or1k_delay_selected == OR1K_DELAY_ON) -+#define TARGET_DELAY_OFF (or1k_delay_selected == OR1K_DELAY_OFF) -+#define TARGET_DELAY_COMPAT (or1k_delay_selected == OR1K_DELAY_COMPAT) -+ -+#endif -diff -rNU3 dist.orig/gcc/config/or1k/or1k-protos.h dist/gcc/config/or1k/or1k-protos.h ---- dist.orig/gcc/config/or1k/or1k-protos.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/or1k/or1k-protos.h 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,67 @@ -+/* Definitions of target machine for GNU compiler, OR1K cpu. -+ -+ Copyright (C) 2010 Embecosm Limited -+ -+This file is part of GCC. -+ -+GCC is free software; you can redistribute it and/or modify -+it under the terms of the GNU General Public License as published by -+the Free Software Foundation; either version 3, or (at your option) -+any later version. -+ -+GCC is distributed in the hope that it will be useful, -+but WITHOUT ANY WARRANTY; without even the implied warranty of -+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+GNU General Public License for more details. -+ -+You should have received a copy of the GNU General Public License -+along with GCC; see the file COPYING3. If not see -+. */ -+ -+#ifndef GCC_OR1K_PROTOS_H -+#define GCC_OR1K_PROTOS_H -+ -+/* The following are for general support. */ -+extern int or1k_trampoline_code_size (void); -+ -+/* The following are only needed when handling the machine definition. */ -+#ifdef RTX_CODE -+extern void or1k_init_expanders (void); -+extern void or1k_expand_prologue (void); -+extern void or1k_expand_epilogue (void); -+extern bool or1k_expand_move (enum machine_mode mode, rtx operands[]); -+extern const char *or1k_output_move_double (rtx *operands); -+extern void or1k_expand_conditional_branch (rtx *operands, -+ enum machine_mode mode); -+extern int or1k_emit_cmove (rtx dest, -+ rtx op, -+ rtx true_cond, -+ rtx false_cond); -+extern enum machine_mode or1k_select_cc_mode (enum rtx_code op); -+extern const char *or1k_output_bf (rtx * operands); -+extern const char *or1k_output_cmov (rtx * operands); -+extern void or1k_emit_set_const32 (rtx op0, -+ rtx op1); -+extern bool or1k_expand_symbol_ref (enum machine_mode mode, -+ rtx operands[]); -+extern void or1k_expand_cmpxchg_qihi (rtx bval, rtx retval, -+ rtx mem, rtx oldval, rtx newval, int is_weak, -+ enum memmodel success_mode, enum memmodel failure_mode); -+extern void or1k_expand_fetch_op_qihi (rtx oldval, rtx mem, rtx operand, -+ rtx newval, rtx (*generator)(rtx, rtx, rtx, rtx, rtx)); -+#endif -+ -+#endif -+extern int or1k_struct_alignment (tree); -+extern int or1k_data_alignment (tree, int); -+ -+extern int or1k_initial_elimination_offset (int, int); -+extern bool or1k_save_reg_p_cached (int regno); -+extern void or1k_print_jump_restore (rtx jump_address); -+extern rtx or1k_eh_return_handler_rtx (void); -+extern rtx or1k_return_addr_rtx (int, rtx); -+ -+extern int or1k_legitimate_pic_operand_p (rtx x); -+ -+/* For RETURN_ADDR_RTX */ -+extern rtx get_hard_reg_initial_val (enum machine_mode, unsigned int); -diff -rNU3 dist.orig/gcc/config/or1k/or1k.c dist/gcc/config/or1k/or1k.c ---- dist.orig/gcc/config/or1k/or1k.c 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/or1k/or1k.c 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,2433 @@ -+/* Subroutines for insn-output.c for GNU compiler. OpenRISC 1000 version. -+ Copyright (C) 1987, 1992, 1997, 1999, 2000, 2001, 2002, 2003, 2004, -+ 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc -+ Copyright (C) 2010 Embecosm Limited -+ -+ Contributed by Damjan Lampret in 1999. -+ Major optimizations by Matjaz Breskvar in 2005. -+ Updated for GCC 4.5 by Jeremy Bennett -+ and Joern Rennecke in 2010. -+ -+ This file is part of GNU CC. -+ -+ This program is free software; you can redistribute it and/or modify it -+ under the terms of the GNU General Public License as published by the Free -+ Software Foundation; either version 3 of the License, or (at your option) -+ any later version. -+ -+ This program is distributed in the hope that it will be useful, but WITHOUT -+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -+ more details. -+ -+ You should have received a copy of the GNU General Public License along -+ with this program. If not, see . */ -+ -+#include "config.h" -+#include "system.h" -+#include "coretypes.h" -+#include "tm.h" -+#include "rtl.h" -+#include "tree.h" -+//#include "calls.h" -+//#include "varasm.h" -+//#include "obstack.h" -+#include "regs.h" -+#include "hard-reg-set.h" -+#include "real.h" -+#include "insn-config.h" -+#include "conditions.h" -+#include "output.h" -+#include "insn-attr.h" -+#include "flags.h" -+#include "reload.h" -+#include "function.h" -+#include "expr.h" -+#include "toplev.h" -+#include "recog.h" -+#include "ggc.h" -+#include "except.h" -+#include "tm_p.h" -+#include "target.h" -+#include "target-def.h" -+#include "debug.h" -+#include "langhooks.h" -+#include "df.h" -+#include "dwarf2.h" -+#include "ansidecl.h" -+ -+/* ========================================================================== */ -+/* Local macros */ -+ -+/* Construct a l.movhi instruction for the given reg and value */ -+#define OR1K_MOVHI(rd, k) \ -+ ((0x6 << 26) | ((rd) << 21) | (k)) -+ -+/* Construct a l.ori instruction for the given two regs and value */ -+#define OR1K_ORI(rd, ra, k) \ -+ ((0x2a << 26) | ((rd) << 21) | ((ra) << 16) | (k)) -+ -+/* Construct a l.lwz instruction for the given two registers and offset */ -+#define OR1K_LWZ(rd, ra, i) \ -+ ((0x21 << 26) | ((rd) << 21) | ((ra) << 16) | (i)) -+ -+/* Construct a l.jr instruction for the given register */ -+#define OR1K_JR(rb) \ -+ ((0x11 << 26) | ((rb) << 11)) -+ -+#define OR1K_NOP \ -+ (0x15 << 24) -+ -+/* ========================================================================== */ -+/* Static variables (i.e. global to this file only. */ -+ -+ -+/*!Stack layout we use for pushing and poping saved registers */ -+static struct -+{ -+ bool save_lr_p; -+ int lr_save_offset; -+ bool save_fp_p; -+ int fp_save_offset; -+ int gpr_size; -+ int gpr_offset; -+ int total_size; -+ int vars_size; -+ int args_size; -+ int gpr_frame; -+ int late_frame; -+ HOST_WIDE_INT mask; -+} frame_info; -+ -+ -+/* ========================================================================== */ -+/* Local (i.e. static) utility functions */ -+ -+/* -------------------------------------------------------------------------- */ -+/*!Must the current function save a register? -+ -+ @param[in] regno The register to consider. -+ -+ @return Non-zero (TRUE) if current function must save "regno", zero -+ (FALSE) otherwise. */ -+/* -------------------------------------------------------------------------- */ -+static bool -+or1k_save_reg_p (int regno) -+{ -+ /* No need to save the faked cc0 register. */ -+ if (regno == OR1K_FLAGS_REG) -+ return false; -+ -+ /* Check call-saved registers. */ -+ if (df_regs_ever_live_p(regno) && !call_used_regs[regno]) -+ return true; -+ -+ /* We need to save the old frame pointer before setting up a new -+ one. */ -+ if (regno == HARD_FRAME_POINTER_REGNUM && frame_pointer_needed) -+ return true; -+ -+ /* Save the stack pointer for DWARF2 for now. -+ * AFAIK, DWARF should be able to unwind using only the current stack -+ * register and the CFA offset, but I never got that to work. */ -+ if (regno == STACK_POINTER_REGNUM && !frame_pointer_needed) -+ return true; -+ -+ /* We need to save the incoming return address if it is ever clobbered -+ within the function. */ -+ if (regno == LINK_REGNUM -+ && (df_regs_ever_live_p(regno) || crtl->uses_pic_offset_table -+ || cfun->machine->force_lr_save)) -+ return true; -+ -+ if(crtl->calls_eh_return) -+ { -+ unsigned int i; -+ for (i = 0; EH_RETURN_DATA_REGNO (i) != INVALID_REGNUM; i++) -+ { -+ if ((unsigned int)regno == EH_RETURN_DATA_REGNO (i)) -+ return true; -+ } -+ } -+ -+ return false; -+ -+} /* or1k_save_reg_p () */ -+ -+bool -+or1k_save_reg_p_cached (int regno) -+{ -+ return (frame_info.mask & ((HOST_WIDE_INT) 1 << regno)) != 0; -+} -+ -+/* N.B. contrary to the ISA documentation, the stack includes the outgoing -+ arguments. */ -+/* -------------------------------------------------------------------------- */ -+/*!Compute full frame size and layout. -+ -+ Store information in "frame_info". -+ -+ @param[in] size The size of the function's local variables. -+ -+ @return Total size of stack frame. */ -+/* -------------------------------------------------------------------------- */ -+static HOST_WIDE_INT -+or1k_compute_frame_size (HOST_WIDE_INT size) -+{ -+ HOST_WIDE_INT args_size; -+ HOST_WIDE_INT vars_size; -+ HOST_WIDE_INT stack_offset; -+ HOST_WIDE_INT save_size; -+ bool interrupt_p = false; -+ int regno; -+ -+ args_size = crtl->outgoing_args_size; -+ vars_size = OR1K_ALIGN (size, 4); -+ -+ frame_info.args_size = args_size; -+ frame_info.vars_size = vars_size; -+ frame_info.gpr_frame = interrupt_p ? or1k_redzone : 0; -+ -+ /* If the function has local variables, we're committed to -+ allocating it anyway. Otherwise reclaim it here. */ -+ /* FIXME: Verify this. Got if from the MIPS port. */ -+ if (vars_size == 0 && crtl->is_leaf) -+ args_size = 0; -+ -+ stack_offset = 0; -+ -+ /* Save link register right at the bottom. */ -+ if (or1k_save_reg_p (LINK_REGNUM)) -+ { -+ stack_offset = stack_offset - UNITS_PER_WORD; -+ frame_info.lr_save_offset = stack_offset; -+ frame_info.save_lr_p = true; -+ } -+ else -+ frame_info.save_lr_p = false; -+ -+ /* HACK: In PIC mode we need to save the PIC reg and the link reg in -+ in case the function is doing references through the got or plt, -+ but this information is not necessarily available when the initial -+ elimination offset is calculated, so we always reserve the space even -+ if it is not used... */ -+ if (!frame_info.save_lr_p && flag_pic) -+ stack_offset = stack_offset - UNITS_PER_WORD; -+ -+ /* Save frame pointer right after possible link register. */ -+ if (frame_pointer_needed) -+ { -+ stack_offset = stack_offset - UNITS_PER_WORD; -+ frame_info.fp_save_offset = stack_offset; -+ frame_info.save_fp_p = true; -+ } -+ else -+ frame_info.save_fp_p = false; -+ -+ frame_info.gpr_size = 0; -+ frame_info.mask = 0; -+ -+ for (regno = 0; regno <= OR1K_LAST_ACTUAL_REG; regno++) -+ { -+ if (regno == LINK_REGNUM -+ || (frame_pointer_needed && regno == HARD_FRAME_POINTER_REGNUM)) -+ /* These have already been saved if so needed. */ -+ continue; -+ -+ if (or1k_save_reg_p (regno)) -+ { -+ frame_info.gpr_size += UNITS_PER_WORD; -+ frame_info.mask |= ((HOST_WIDE_INT) 1 << regno); -+ } -+ } -+ -+ if (!or1k_save_reg_p (PIC_OFFSET_TABLE_REGNUM) -+ && (crtl->uses_pic_offset_table || (flag_pic && frame_info.save_lr_p))) -+ { -+ frame_info.gpr_size += UNITS_PER_WORD; -+ frame_info.mask |= ((HOST_WIDE_INT) 1 << PIC_OFFSET_TABLE_REGNUM); -+ } -+ else if (flag_pic && !or1k_save_reg_p (PIC_OFFSET_TABLE_REGNUM)) -+ frame_info.gpr_size += UNITS_PER_WORD; -+ -+ save_size = (frame_info.gpr_size -+ + (frame_info.save_fp_p ? UNITS_PER_WORD : 0) -+ + (frame_info.save_lr_p || flag_pic ? UNITS_PER_WORD : 0)); -+ frame_info.total_size = save_size + vars_size + args_size; -+ gcc_assert (PROLOGUE_TMP != STATIC_CHAIN_REGNUM); -+ if (frame_info.total_size > 32767 && interrupt_p) -+ { -+ int n_extra -+ = (!!(~frame_info.mask && 1 << PROLOGUE_TMP) -+ + !!(~frame_info.mask & 1 << EPILOGUE_TMP)) * UNITS_PER_WORD; -+ -+ save_size += n_extra; -+ frame_info.gpr_size += n_extra; -+ frame_info.total_size += n_extra; -+ frame_info.mask |= (1 << PROLOGUE_TMP) | (1 << EPILOGUE_TMP); -+ } -+ -+ stack_offset -= frame_info.gpr_size; -+ frame_info.gpr_offset = stack_offset; -+ frame_info.late_frame = frame_info.total_size; -+ -+ if (save_size > or1k_redzone -+ || (frame_info.gpr_frame -+ && (frame_info.gpr_frame + frame_info.late_frame <= 32767))) -+ { -+ if (frame_info.gpr_frame + frame_info.late_frame <= 32767) -+ save_size = frame_info.total_size; -+ frame_info.gpr_frame += save_size; -+ frame_info.lr_save_offset += save_size; -+ frame_info.fp_save_offset += save_size; -+ frame_info.gpr_offset += save_size; -+ frame_info.late_frame -= save_size; -+ /* FIXME: check in TARGET_OVERRIDE_OPTIONS for invalid or1k_redzone. */ -+ gcc_assert (frame_info.gpr_frame <= 32767); -+ gcc_assert ((frame_info.gpr_frame & 3) == 0); -+ } -+ -+ return frame_info.total_size; -+ -+} /* or1k_compute_frame_size () */ -+ -+ -+/* -------------------------------------------------------------------------- */ -+/*!Emit a frame related insn. -+ -+ Same as emit_insn, but sets RTX_FRAME_RELATED_P to one. Getting this right -+ will matter for DWARF 2 output, if prologues are handled via the "prologue" -+ pattern rather than target hooks. -+ -+ @param[in] insn The insn to emit. -+ -+ @return The RTX for the emitted insn. */ -+/* -------------------------------------------------------------------------- */ -+static rtx -+emit_frame_insn (rtx insn) -+{ -+ insn = emit_insn (insn); -+ RTX_FRAME_RELATED_P (insn) = 1; -+ return (insn); -+ -+} /* emit_frame_insn () */ -+ -+ -+/* -------------------------------------------------------------------------- */ -+/* Generate a RTX for the indexed memory address based on stack_pointer_rtx -+ and a displacement -+ -+ @param[in] disp The displacement -+ -+ @return The RTX for the generated address. */ -+/* -------------------------------------------------------------------------- */ -+static rtx -+stack_disp_mem (HOST_WIDE_INT disp) -+{ -+ return gen_frame_mem (Pmode, plus_constant (Pmode, stack_pointer_rtx, disp)); -+} -+ -+enum machine_mode -+or1k_select_cc_mode (enum rtx_code op) -+{ -+ switch (op) { -+ case EQ: return CCEQmode; -+ case NE: return CCNEmode; -+ case GEU: return CCGEUmode; -+ case GTU: return CCGTUmode; -+ case LTU: return CCLTUmode; -+ case LEU: return CCLEUmode; -+ case GE: return CCGEmode; -+ case LT: return CCLTmode; -+ case GT: return CCGTmode; -+ case LE: return CCLEmode; -+ default: gcc_unreachable (); -+ } -+} -+ -+/* -------------------------------------------------------------------------- */ -+/*!Generate insn patterns to do an integer compare of operands. -+ -+ @param[in] code RTX for the condition code. -+ @param[in] op0 RTX for the first operand. -+ @param[in] op1 RTX for the second operand. -+ -+ @return RTX for the comparison. */ -+/* -------------------------------------------------------------------------- */ -+static rtx -+or1k_expand_int_compare (enum rtx_code code, -+ rtx op0, -+ rtx op1) -+{ -+ enum machine_mode cmpmode; -+ rtx tmp, flags; -+ -+ cmpmode = or1k_select_cc_mode (code); -+ flags = gen_rtx_REG (cmpmode, OR1K_FLAGS_REG); -+ -+ /* This is very simple, but making the interface the same as in the -+ FP case makes the rest of the code easier. */ -+ tmp = gen_rtx_COMPARE (cmpmode, op0, op1); -+ emit_insn (gen_rtx_SET (VOIDmode, flags, tmp)); -+ -+ /* Return the test that should be put into the flags user, i.e. -+ the bcc, scc, or cmov instruction. */ -+ return gen_rtx_fmt_ee (code, VOIDmode, flags, const0_rtx); -+ -+} /* or1k_expand_int_compare () */ -+ -+ -+/* -------------------------------------------------------------------------- */ -+/*!Generate insn patterns to do an integer compare of operands. -+ -+ We only deal with the case where the comparison is an integer -+ comparison. This wrapper function potentially allows reuse for non-integer -+ comparison in the future. -+ -+ @param[in] code RTX for the condition code. -+ @param[in] op0 RTX for the first operand. -+ @param[in] op1 RTX for the second operand. -+ -+ @return RTX for the comparison. */ -+/* -------------------------------------------------------------------------- */ -+static rtx -+or1k_expand_compare (enum rtx_code code, rtx op0, rtx op1) -+{ -+ return or1k_expand_int_compare (code, op0, op1); -+ -+} /* or1k_expand_compare () */ -+ -+ -+/* TODO(bluecmd): Write documentation for this function */ -+void -+or1k_expand_cmpxchg_qihi (rtx bval, rtx retval, rtx mem, rtx oldval, rtx newval, -+ int is_weak, enum memmodel success_mode, -+ enum memmodel failure_mode) -+{ -+ rtx addr1 = force_reg (Pmode, XEXP (mem, 0)); -+ rtx addr = gen_reg_rtx (Pmode); -+ rtx off = gen_reg_rtx (SImode); -+ rtx shifter = gen_reg_rtx (SImode); -+ rtx retword = gen_reg_rtx (SImode); -+ rtx mask = gen_reg_rtx (SImode); -+ rtx shifted_oldval = gen_reg_rtx (SImode); -+ rtx shifted_newval = gen_reg_rtx (SImode); -+ rtx shifted_mask = gen_reg_rtx (SImode); -+ rtx mask_const; -+ rtx memsi; -+ enum machine_mode mode = GET_MODE (mem); -+ -+ oldval = gen_lowpart_common (SImode, oldval); -+ newval = gen_lowpart_common (SImode, newval); -+ -+ mask_const = gen_rtx_CONST_INT (VOIDmode, -+ mode == QImode ? 0xff : 0xffff); -+ emit_insn (gen_rtx_SET (VOIDmode, mask, mask_const)); -+ -+ /* align address and retrieve the offset. */ -+ emit_insn (gen_rtx_SET (VOIDmode, addr, -+ gen_rtx_AND (Pmode, addr1, GEN_INT (-4)))); -+ emit_insn (gen_rtx_SET (VOIDmode, off, -+ gen_rtx_AND (SImode, addr1, GEN_INT (3)))); -+ emit_insn (gen_rtx_SET (VOIDmode, off, -+ gen_rtx_XOR (SImode, off, -+ GEN_INT (GET_MODE (mem) == QImode -+ ? 3 : 2)))); -+ -+ memsi = gen_rtx_MEM (SImode, addr); -+ -+ /* shift all arguments to be aligned to where the data we want -+ * to operate on is located. */ -+ emit_insn (gen_rtx_SET (VOIDmode, shifter, -+ gen_rtx_ASHIFT (SImode, off, GEN_INT (3)))); -+ -+ emit_insn (gen_ashlsi3 (shifted_oldval, oldval, shifter)); -+ emit_insn (gen_ashlsi3 (shifted_newval, newval, shifter)); -+ emit_insn (gen_ashlsi3 (shifted_mask, mask, shifter)); -+ -+ emit_insn (gen_cmpxchg_mask (bval, retword, memsi, shifted_oldval, -+ shifted_newval, shifted_mask)); -+ -+ /* shift the data we care about to the lower end. */ -+ emit_insn (gen_lshrsi3 (retword, retword, shifter)); -+ -+ emit_move_insn (retval, gen_lowpart (GET_MODE (retval), retword)); -+} -+ -+/* TODO(bluecmd): Write documentation for this function */ -+void -+or1k_expand_fetch_op_qihi (rtx oldval, rtx mem, rtx operand, rtx newval, -+ rtx (*generator)(rtx, rtx, rtx, rtx, rtx)) -+{ -+ rtx addr1 = force_reg (Pmode, XEXP (mem, 0)); -+ rtx addr = gen_reg_rtx (Pmode); -+ rtx off = gen_reg_rtx (SImode); -+ rtx shifter = gen_reg_rtx (SImode); -+ rtx mask = gen_reg_rtx (SImode); -+ rtx shifted_oldval = gen_reg_rtx (SImode); -+ rtx shifted_newval = gen_reg_rtx (SImode); -+ rtx shifted_operand = gen_reg_rtx (SImode); -+ rtx shifted_mask = gen_reg_rtx (SImode); -+ rtx mask_const; -+ rtx memsi; -+ enum machine_mode mode = GET_MODE (mem); -+ -+ /* TODO(bluecmd): A lot of code is shared between cmpxchg and this. We should -+ * move it to nice functions. */ -+ operand = gen_lowpart_common (SImode, operand); -+ -+ mask_const = gen_rtx_CONST_INT (VOIDmode, -+ mode == QImode ? 0xff : 0xffff); -+ emit_insn (gen_rtx_SET (VOIDmode, mask, mask_const)); -+ -+ /* align address and retrieve the offset. */ -+ emit_insn (gen_rtx_SET (VOIDmode, addr, -+ gen_rtx_AND (Pmode, addr1, GEN_INT (-4)))); -+ emit_insn (gen_rtx_SET (VOIDmode, off, -+ gen_rtx_AND (SImode, addr1, GEN_INT (3)))); -+ emit_insn (gen_rtx_SET (VOIDmode, off, -+ gen_rtx_XOR (SImode, off, -+ GEN_INT (GET_MODE (mem) == QImode -+ ? 3 : 2)))); -+ -+ memsi = gen_rtx_MEM (SImode, addr); -+ -+ /* shift all arguments to be aligned to where the data we want -+ * to operate on is located. */ -+ emit_insn (gen_rtx_SET (VOIDmode, shifter, -+ gen_rtx_ASHIFT (SImode, off, GEN_INT (3)))); -+ -+ emit_insn (gen_ashlsi3 (shifted_operand, operand, shifter)); -+ emit_insn (gen_ashlsi3 (shifted_mask, mask, shifter)); -+ -+ emit_insn (generator (shifted_oldval, memsi, shifted_operand, -+ shifted_newval, shifted_mask)); -+ -+ /* shift the data we care about to the lower end. */ -+ emit_insn (gen_lshrsi3 (shifted_oldval, shifted_oldval, shifter)); -+ emit_insn (gen_lshrsi3 (shifted_newval, shifted_newval, shifter)); -+ emit_move_insn (oldval, gen_lowpart (GET_MODE (oldval), shifted_oldval)); -+ emit_move_insn (newval, gen_lowpart (GET_MODE (newval), shifted_newval)); -+} -+ -+/* -------------------------------------------------------------------------- */ -+/*!Emit insns to use the l.cmov instruction -+ -+ Emit a compare and then cmov. Only works for integer first operand. -+ -+ @param[in] dest RTX for the destination operand. -+ @param[in] op RTX for the comparison operation -+ @param[in] true_cond RTX to move to dest if condition is TRUE. -+ @param[in] false_cond RTX to move to dest if condition is FALSE. -+ -+ @return Non-zero (TRUE) if insns were emitted, zero (FALSE) otherwise. */ -+/* -------------------------------------------------------------------------- */ -+static int -+or1k_emit_int_cmove (rtx dest, -+ rtx op, -+ rtx true_cond, -+ rtx false_cond) -+{ -+ rtx condition_rtx, cr; -+ rtx op0 = XEXP (op, 0); -+ rtx op1 = XEXP (op, 1); -+ -+ if ((GET_MODE (op0) != SImode) && -+ (GET_MODE (op0) != HImode) && -+ (GET_MODE (op0) != QImode)) -+ { -+ return 0; -+ } -+ -+ /* We still have to do the compare, because cmov doesn't do a compare, it -+ just looks at the FLAG bit set by a previous compare instruction. */ -+ condition_rtx = or1k_expand_compare (GET_CODE (op), op0, op1); -+ -+ cr = XEXP (condition_rtx, 0); -+ -+ emit_insn (gen_cmov (dest, condition_rtx, true_cond, false_cond, cr)); -+ -+ return 1; -+ -+} /* or1k_emit_int_cmove () */ -+ -+ -+static void -+or1k_print_operand_address (FILE *stream, rtx addr) -+{ -+ rtx offset; -+ -+ switch (GET_CODE (addr)) -+ { -+ case MEM: -+ if (GET_CODE (XEXP (addr, 0)) == REG) -+ fprintf (stream, "%s", reg_names[REGNO (addr)]); -+ else -+ abort (); -+ break; -+ -+ case REG: -+ fprintf (stream, "0(%s)", reg_names[REGNO (addr)]); -+ break; -+ -+ case PLUS: -+ offset = 0; -+ -+ if (GET_CODE (XEXP (addr, 0)) == REG) -+ { -+ offset = XEXP (addr, 1); -+ addr = XEXP (addr, 0); -+ } -+ else if (GET_CODE (XEXP (addr, 1)) == REG) -+ { -+ offset = XEXP (addr, 0); -+ addr = XEXP (addr, 1); -+ } -+ output_address (offset); -+ fprintf (stream, "(%s)", reg_names[REGNO (addr)]); -+ break; -+ -+ case SYMBOL_REF: -+ if (SYMBOL_REF_DECL (addr)) -+ assemble_external (SYMBOL_REF_DECL (addr)); -+ -+ if (XSTR (addr, 0)[0] == '*') -+ fputs (&XSTR (addr, 0)[1], stream); -+ else -+ { -+ asm_fprintf (stream, "%U%s", XSTR (addr, 0)); -+ } -+ break; -+ -+ default: -+ output_addr_const (stream, addr); -+ } -+} -+ -+/* -------------------------------------------------------------------------- */ -+/*!Is this a value suitable for an OR1K address displacement? -+ -+ Must be an integer (signed) which fits into 16-bits. If the result is a -+ double word, we had better also check that we can also get at the second -+ word. -+ -+ @param[in] mode Mode of the result for which this displacement will be -+ used. -+ @param[in] x RTX for an expression. -+ -+ @return Non-zero (TRUE) if this is a valid 16-bit offset, zero (FALSE) -+ otherwise. */ -+/* -------------------------------------------------------------------------- */ -+static int -+or1k_legitimate_displacement_p (enum machine_mode mode, -+ rtx x) -+{ -+ if (CONST_INT == GET_CODE(x)) -+ { -+ HOST_WIDE_INT disp = INTVAL (x); -+ -+ /* Allow for a second access 4 bytes further on if double. */ -+ if ((DFmode == mode) || (DImode == mode)) -+ { -+ return (-32768 < disp) && (disp <= 32763); -+ } -+ else -+ { -+ return (-32768 < disp) && (disp <= 32767); -+ } -+ } -+ else -+ { -+ return 0; -+ } -+} /* or1k_legitimate_displacement_p () */ -+ -+ -+/* -------------------------------------------------------------------------- */ -+/*!Can this register be used as a base register? -+ -+ We need a strict version, for which the register must either be a hard -+ register, or already renumbered to a hard register. -+ -+ For the non-strict version, any register (other than the flag register will -+ do). -+ -+ @todo The code from the old port does not allow r0 as a base when strict, -+ and does when non-strict. Surely it is always a valid register? -+ -+ @param[in] regno The register to test -+ @param[in] strict Non-zero (TRUE) if this is a strict check, zero (FALSE) -+ otherwise. -+ -+ @return Non-zero (TRUE) if this register can be used as a base register, -+ zero (FALSE) otherwise. */ -+/* -------------------------------------------------------------------------- */ -+static bool -+or1k_regnum_ok_for_base_p (HOST_WIDE_INT num, -+ bool strict) -+{ -+ if (strict) -+ { -+ return (num < FIRST_PSEUDO_REGISTER) -+ ? (num > 0) && (num <= OR1K_LAST_INT_REG) -+ : (reg_renumber[num] > 0) && (reg_renumber[num] <= OR1K_LAST_INT_REG); -+ } -+ else -+ { -+ return (num <= OR1K_LAST_INT_REG) || (num >= FIRST_PSEUDO_REGISTER); -+ } -+} /* or1k_regnum_ok_for_base_p () */ -+ -+int -+or1k_legitimate_pic_operand_p (rtx x) -+{ -+ if (GET_CODE (x) == CONST -+ && GET_CODE (XEXP (x, 0)) == PLUS -+ && ((GET_CODE (XEXP (XEXP (x, 0), 0)) == SYMBOL_REF -+ && (!SYMBOL_REF_LOCAL_P (XEXP (XEXP (x, 0), 0)) -+ || SYMBOL_REF_WEAK (XEXP (XEXP (x, 0), 0)))) -+ || GET_CODE (XEXP (XEXP (x, 0), 0)) == LABEL_REF) -+ && CONST_INT_P (XEXP (XEXP (x, 0), 1))) -+ return or1k_legitimate_displacement_p (SImode, XEXP (XEXP (x, 0), 1)); -+ -+ return 1; -+} -+ -+static bool -+or1k_expand_pic_symbol_ref (enum machine_mode mode ATTRIBUTE_UNUSED, -+ rtx operands[]) -+{ -+ if (GET_CODE (operands[1]) == LABEL_REF -+ || (GET_CODE (operands[1]) == SYMBOL_REF -+ && SYMBOL_REF_LOCAL_P (operands[1]) -+ && !SYMBOL_REF_WEAK (operands[1]))) -+ { -+ crtl->uses_pic_offset_table = 1; -+ emit_insn (gen_movsi_gotoffhi (operands[0], operands[1])); -+ emit_insn (gen_movsi_gotofflo (operands[0], operands[0], -+ operands[1])); -+ emit_insn (gen_add3_insn(operands[0], operands[0], -+ pic_offset_table_rtx)); -+ return true; -+ } -+ else if (GET_CODE (operands[1]) == SYMBOL_REF) -+ { -+ crtl->uses_pic_offset_table = 1; -+ emit_insn (gen_movsi_got (operands[0], operands[1])); -+ return true; -+ } -+ else if (GET_CODE (operands[1]) == CONST -+ && GET_CODE (XEXP (operands[1], 0)) == PLUS -+ && GET_CODE (XEXP (XEXP (operands[1], 0), 0)) == SYMBOL_REF -+ && GET_CODE (XEXP (XEXP (operands[1], 0), 1)) == CONST_INT) -+ { -+ rtx symbolref = XEXP (XEXP (operands[1], 0), 0); -+ crtl->uses_pic_offset_table = 1; -+ -+ if (SYMBOL_REF_LOCAL_P (symbolref) -+ && !SYMBOL_REF_WEAK (symbolref)) -+ { -+ emit_insn (gen_movsi_gotoffhi (operands[0], operands[1])); -+ emit_insn (gen_movsi_gotofflo (operands[0], operands[0], -+ operands[1])); -+ emit_insn (gen_add3_insn(operands[0], operands[0], -+ pic_offset_table_rtx)); -+ } -+ else -+ { -+ rtx const_int = XEXP (XEXP (operands[1], 0), 1); -+ -+ /* Expand the constant into a register if it doesn't -+ fit directly as an 16-bit immediate in the add below. -+ Note that the reg allocation is allowed here since -+ we are guarded by LEGITIMATE_PIC_OPERAND_P. */ -+ if (!or1k_legitimate_displacement_p (mode, const_int)) -+ { -+ rtx scratch = gen_reg_rtx (mode); -+ -+ or1k_emit_set_const32 (scratch, const_int); -+ const_int = scratch; -+ } -+ -+ emit_insn (gen_movsi_got (operands[0], symbolref)); -+ emit_insn (gen_add3_insn(operands[0], operands[0], const_int)); -+ } -+ return true; -+ } -+ return false; -+} -+ -+/* Return the TLS type for TLS symbols, 0 otherwise. */ -+enum tls_model -+or1k_tls_symbolic_operand (rtx op) -+{ -+ if (GET_CODE (op) == CONST) -+ { -+ rtx sym, addend; -+ split_const (op, &sym, &addend); -+ if (GET_CODE (sym) == SYMBOL_REF) -+ return SYMBOL_REF_TLS_MODEL (sym); -+ } -+ else if (GET_CODE (op) == SYMBOL_REF) -+ return SYMBOL_REF_TLS_MODEL (op); -+ -+ return TLS_MODEL_NONE; -+} -+ -+static GTY(()) rtx gen_tls_tga; -+ -+/* Get reference to the '__tls_get_addr' symbol */ -+static rtx -+gen_tls_get_addr (void) -+{ -+ if (!gen_tls_tga) -+ gen_tls_tga = init_one_libfunc ("__tls_get_addr"); -+ return gen_tls_tga; -+} -+ -+/* Emit call to '__tls_get_addr' */ -+static void -+or1k_tls_call (rtx dest, rtx arg) -+{ -+ emit_library_call_value (gen_tls_get_addr(), dest, -+ LCT_CONST, Pmode, 1, arg, Pmode); -+} -+ -+static rtx -+or1k_legitimize_tls_address (rtx dest, rtx x) -+{ -+ rtx sym; -+ rtx tp = gen_rtx_REG(Pmode, THREAD_PTR_REGNUM); -+ rtx addend = NULL_RTX; -+ rtx result = dest; -+ -+ enum tls_model tls_kind = or1k_tls_symbolic_operand (x); -+ -+ if (GET_CODE (x) == SYMBOL_REF) -+ sym = gen_rtx_SYMBOL_REF(Pmode, XSTR(x, 0)); -+ else if (GET_CODE (x) == CONST) -+ { -+ result = gen_reg_rtx (Pmode); -+ split_const (x, &sym, &addend); -+ sym = gen_rtx_SYMBOL_REF(Pmode, XSTR(sym, 0)); -+ } -+ else -+ gcc_unreachable (); -+ -+ switch (tls_kind) { -+ case TLS_MODEL_GLOBAL_DYNAMIC: -+ case TLS_MODEL_LOCAL_DYNAMIC: -+ { -+ /* TODO: For now, treat LD as GD */ -+ rtx hi = gen_reg_rtx (Pmode); -+ rtx offset = gen_reg_rtx (Pmode); -+ rtx addr = gen_reg_rtx (Pmode); -+ crtl->uses_pic_offset_table = 1; -+ /* Generate a new symbol ref that is not marked as TLS or we will recurse -+ * in or1k_legitimate_constant_p. */ -+ emit_insn (gen_movsi_tlsgdhi (hi, sym)); -+ emit_insn (gen_movsi_tlsgdlo (offset, hi, sym)); -+ emit_insn (gen_add3_insn (addr, offset, pic_offset_table_rtx)); -+ or1k_tls_call (result, addr); -+ break; -+ } -+ case TLS_MODEL_INITIAL_EXEC: -+ { -+ rtx hi = gen_reg_rtx (Pmode); -+ rtx offset = gen_reg_rtx (Pmode); -+ rtx addr = gen_reg_rtx (Pmode); -+ rtx tpoffset = gen_reg_rtx (Pmode); -+ crtl->uses_pic_offset_table = 1; -+ emit_insn (gen_movsi_gottpoffhi (hi, sym)); -+ emit_insn (gen_movsi_gottpofflo (offset, hi, sym)); -+ emit_insn (gen_add3_insn (addr, offset, pic_offset_table_rtx)); -+ emit_insn (gen_load_gottpoff (tpoffset, addr)); -+ emit_insn (gen_add3_insn (result, tpoffset, tp)); -+ break; -+ } -+ case TLS_MODEL_LOCAL_EXEC: -+ { -+ rtx hi = gen_reg_rtx (Pmode); -+ rtx addr = gen_reg_rtx (Pmode); -+ emit_insn (gen_movsi_tpoffhi (hi, sym)); -+ emit_insn (gen_movsi_tpofflo (addr, hi, sym)); -+ emit_insn (gen_add3_insn (result, addr, tp)); -+ break; -+ } -+ default: -+ gcc_unreachable (); -+ } -+ -+ if (addend != NULL_RTX) -+ emit_insn (gen_add3_insn (dest, result, addend)); -+ -+ return dest; -+} -+ -+static rtx -+or1k_legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED, -+ enum machine_mode mode ATTRIBUTE_UNUSED) -+{ -+ if (or1k_tls_symbolic_operand (x) != TLS_MODEL_NONE) -+ return or1k_legitimize_tls_address (gen_reg_rtx (Pmode), x); -+ -+ return x; -+} -+ -+static bool -+or1k_cannot_force_const_mem (enum machine_mode mode ATTRIBUTE_UNUSED, rtx x) -+{ -+ return or1k_tls_symbolic_operand (x) != TLS_MODEL_NONE; -+} -+ -+bool -+or1k_expand_symbol_ref(enum machine_mode mode, rtx operands[]) -+{ -+ if (flag_pic && or1k_expand_pic_symbol_ref(mode, operands)) -+ return true; -+ -+ return false; -+} -+ -+bool -+or1k_expand_move (enum machine_mode mode, rtx operands[]) -+{ -+ if (can_create_pseudo_p ()) -+ { -+ if (GET_CODE (operands[0]) == MEM -+ || (GET_CODE (operands[0]) == SUBREG -+ && GET_CODE (SUBREG_REG (operands[0])) == MEM)) -+ { -+ /* Source operand for store must be in a register. */ -+ operands[1] = force_reg (SImode, operands[1]); -+ } -+ } -+ -+ if (or1k_tls_symbolic_operand (operands[1]) != TLS_MODEL_NONE) -+ { -+ or1k_legitimize_tls_address (force_reg (Pmode, operands[0]), -+ operands[1]); -+ return true; -+ } -+ -+ if (or1k_expand_symbol_ref (mode, operands)) -+ return true; -+ -+ /* Working with CONST_INTs is easier, so convert -+ a double if needed. */ -+ -+ if (GET_CODE (operands[1]) == CONST_DOUBLE) { -+ operands[1] = GEN_INT (CONST_DOUBLE_LOW (operands[1])); -+ } -+ -+ /* Handle sets of MEM first. */ -+ if (GET_CODE (operands[0]) == MEM) -+ { -+ if (register_operand(operands[1], SImode) -+ || (operands[1] == const0_rtx)) -+ goto movsi_is_ok; -+ -+ if (! reload_in_progress) -+ { -+ operands[0] = validize_mem (operands[0]); -+ operands[1] = force_reg (SImode, operands[1]); -+ } -+ } -+ -+ /* This makes sure we will not get rematched due to splittage. */ -+ if (! CONSTANT_P (operands[1]) || input_operand (operands[1], SImode)) -+ ; -+ else if (CONSTANT_P (operands[1]) -+ && GET_CODE (operands[1]) != HIGH -+ && GET_CODE (operands[1]) != LO_SUM) -+ { -+ or1k_emit_set_const32 (operands[0], operands[1]); -+ return true; -+ } -+ movsi_is_ok: -+ ; -+ -+ return false; -+} -+ -+/* -------------------------------------------------------------------------- */ -+/*!Emit a move from SRC to DEST. -+ -+ Assume that the move expanders can handle all moves if !can_create_pseudo_p -+ (). The distinction is important because, unlike emit_move_insn, the move -+ expanders know how to force Pmode objects into the constant pool even when -+ the constant pool address is not itself legitimate. -+ -+ @param[in] dest Destination of the move. -+ @param[in] src Source for the move. -+ -+ @return RTX for the move. */ -+/* -------------------------------------------------------------------------- */ -+static rtx -+or1k_emit_move (rtx dest, rtx src) -+{ -+ return (can_create_pseudo_p () -+ ? emit_move_insn (dest, src) -+ : emit_move_insn_1 (dest, src)); -+ -+} /* or1k_emit_move () */ -+ -+ -+/* -------------------------------------------------------------------------- */ -+/*!Emit an instruction of the form (set TARGET (CODE OP0 OP1)). -+ -+ @param[in] code The code for the operation. -+ @param[in] target Destination for the set operation. -+ @param[in] op0 First operand. -+ @param[in] op1 Second operand. */ -+/* -------------------------------------------------------------------------- */ -+static void -+or1k_emit_binary (enum rtx_code code, -+ rtx target, -+ rtx op0, -+ rtx op1) -+{ -+ emit_insn (gen_rtx_SET (VOIDmode, target, -+ gen_rtx_fmt_ee (code, GET_MODE (target), op0, op1))); -+ -+} /* or1k_emit_binary () */ -+ -+ -+/* -------------------------------------------------------------------------- */ -+/*!Compute the result of an operation into a new register. -+ -+ Compute ("code" "op0" "op1") and store the result in a new register of mode -+ "mode". -+ -+ @param[in] mode Mode of the result -+ @parma[in] code RTX for the operation to perform -+ @param[in] op0 RTX for the first operand -+ @param[in] op1 RTX for the second operand -+ -+ @return The RTX for the new register. */ -+/* -------------------------------------------------------------------------- */ -+static rtx -+or1k_force_binary (enum machine_mode mode, -+ enum rtx_code code, -+ rtx op0, -+ rtx op1) -+{ -+ rtx reg; -+ -+ reg = gen_reg_rtx (mode); -+ or1k_emit_binary (code, reg, op0, op1); -+ -+ return reg; -+ -+} /* or1k_force_binary () */ -+ -+ -+/* ========================================================================== */ -+/* Global support functions */ -+ -+static int -+or1k_trampoline_code_words (void) -+{ -+ int words = 5; -+ -+ /* need one more word in TARGET_DELAY_COMPAT mode to hold l.nop in delay slot */ -+ if (TARGET_DELAY_COMPAT) -+ words++; -+ -+ return words; -+} -+ -+/* -------------------------------------------------------------------------- */ -+/* Return the size in bytes of the trampoline code. -+ -+ Padded to TRAMPOLINE_ALIGNMENT bits. The code sequence is documented in -+ or1k_trampoline_init (). -+ -+ This is just the code size. the static chain pointer and target function -+ address immediately follow. -+ -+ @return The size of the trampoline code in bytes. */ -+/* -------------------------------------------------------------------------- */ -+int -+or1k_trampoline_code_size (void) -+{ -+ const int TRAMP_BYTE_ALIGN = TRAMPOLINE_ALIGNMENT / 8; -+ -+ return (or1k_trampoline_code_words() * 4 + TRAMP_BYTE_ALIGN - 1) / TRAMP_BYTE_ALIGN * TRAMP_BYTE_ALIGN; -+ -+} /* or1k_trampoline_code_size () */ -+ -+ -+/* ========================================================================== */ -+/* Functions to support the Machine Description */ -+ -+ -+/* -------------------------------------------------------------------------- */ -+/*!Expand a prologue pattern. -+ -+ Called after register allocation to add any instructions needed for the -+ prologue. Using a prologue insn is favored compared to putting all of the -+ instructions in output_function_prologue(), since it allows the scheduler -+ to intermix instructions with the saves of the caller saved registers. In -+ some cases, it might be necessary to emit a barrier instruction as the last -+ insn to prevent such scheduling. */ -+/* -------------------------------------------------------------------------- */ -+void -+or1k_expand_prologue (void) -+{ -+ int total_size = or1k_compute_frame_size (get_frame_size ()); -+ rtx insn; -+ -+ if (!total_size) -+ /* No frame needed. */ -+ return; -+ -+ gcc_assert (!frame_info.save_lr_p || !frame_info.save_fp_p -+ || frame_info.lr_save_offset != frame_info.fp_save_offset); -+ -+ if (frame_info.gpr_frame) -+ emit_frame_insn (gen_add2_insn (stack_pointer_rtx, -+ GEN_INT (-frame_info.gpr_frame))); -+ if (frame_info.save_fp_p) -+ { -+ emit_frame_insn (gen_rtx_SET (Pmode, -+ stack_disp_mem (frame_info.fp_save_offset), -+ hard_frame_pointer_rtx)); -+ -+ emit_frame_insn -+ (gen_add3_insn (hard_frame_pointer_rtx, stack_pointer_rtx, const0_rtx)); -+ } -+ if (frame_info.save_lr_p) -+ { -+ emit_frame_insn -+ (gen_rtx_SET (Pmode, stack_disp_mem (frame_info.lr_save_offset), -+ gen_rtx_REG (Pmode, LINK_REGNUM))); -+ } -+ if (frame_info.gpr_size) -+ { -+ int offset = 0; -+ int regno; -+ -+ for (regno = 0; regno <= OR1K_LAST_ACTUAL_REG; regno++) -+ { -+ if (!(frame_info.mask & ((HOST_WIDE_INT) 1 << regno))) -+ continue; -+ -+ /* Check that the offsets aren't stepping on lr/fp slots */ -+ gcc_assert (!frame_info.save_lr_p -+ || ((frame_info.gpr_offset + offset) -+ != frame_info.lr_save_offset)); -+ gcc_assert (!frame_info.save_fp_p -+ || ((frame_info.gpr_offset + offset) -+ != frame_info.fp_save_offset)); -+ -+ emit_frame_insn -+ (gen_rtx_SET (Pmode, -+ stack_disp_mem (frame_info.gpr_offset + offset), -+ gen_rtx_REG (Pmode, regno))); -+ offset = offset + UNITS_PER_WORD; -+ } -+ } -+ -+ /* Update the stack pointer to reflect frame size. */ -+ total_size = frame_info.late_frame; -+ insn = gen_add2_insn (stack_pointer_rtx, GEN_INT (-total_size)); -+ if (total_size > 32768) -+ { -+ rtx note = insn; -+ rtx value_rtx = gen_rtx_REG (Pmode, PROLOGUE_TMP); -+ -+ or1k_emit_set_const32 (value_rtx, GEN_INT (-total_size)); -+ if (frame_info.save_fp_p) -+ insn = gen_frame_alloc_fp (value_rtx); -+ else -+ insn = gen_add2_insn (stack_pointer_rtx, value_rtx); -+ insn = emit_frame_insn (insn); -+ add_reg_note (insn, REG_FRAME_RELATED_EXPR, note); -+ } -+ else if (total_size) -+ { -+ if (frame_info.save_fp_p) -+ emit_frame_insn (gen_frame_alloc_fp (GEN_INT (-total_size))); -+ else -+ emit_frame_insn (insn); -+ } -+ /* Emit got pointer acquiring if there are any got references or -+ this function has calls */ -+ if (crtl->uses_pic_offset_table || (flag_pic && frame_info.save_lr_p)) -+ { -+ SET_REGNO (pic_offset_table_rtx, PIC_OFFSET_TABLE_REGNUM); -+ emit_insn (gen_set_got (pic_offset_table_rtx)); -+ } -+ -+} /* or1k_expand_prologue () */ -+ -+ -+/* -------------------------------------------------------------------------- */ -+/*!Expand an epilogue pattern. -+ -+ Called after register allocation to add any instructions needed for the -+ epilogue. Using an epilogue insn is favored compared to putting all of the -+ instructions in output_function_epilogue(), since it allows the scheduler -+ to intermix instructions with the restores of the caller saved registers. -+ In some cases, it might be necessary to emit a barrier instruction as the -+ first insn to prevent such scheduling. */ -+/* -------------------------------------------------------------------------- */ -+void -+or1k_expand_epilogue (void) -+{ -+ int total_size = or1k_compute_frame_size (get_frame_size ()); -+ -+ if (frame_info.save_fp_p) -+ { -+ emit_insn (gen_frame_dealloc_fp ()); -+ emit_insn -+ (gen_rtx_SET (Pmode, hard_frame_pointer_rtx, -+ stack_disp_mem (frame_info.fp_save_offset))); -+ } -+ else -+ { -+ rtx value_rtx; -+ -+ total_size = frame_info.late_frame; -+ if (total_size > 32767) -+ { -+ value_rtx = gen_rtx_REG (Pmode, EPILOGUE_TMP); -+ or1k_emit_set_const32 (value_rtx, GEN_INT (total_size)); -+ } -+ else if (frame_info.late_frame) -+ value_rtx = GEN_INT (total_size); -+ if (total_size) -+ emit_insn (gen_frame_dealloc_sp (value_rtx)); -+ } -+ -+ /* eh_return sets the LR, do not overwrite it */ -+ if (frame_info.save_lr_p && !crtl->calls_eh_return) -+ { -+ emit_insn -+ (gen_rtx_SET (Pmode, gen_rtx_REG (Pmode, LINK_REGNUM), -+ stack_disp_mem (frame_info.lr_save_offset))); -+ } -+ -+ if (frame_info.gpr_size) -+ { -+ int offset = 0; -+ int regno; -+ -+ for (regno = 2; regno <= OR1K_LAST_ACTUAL_REG; regno++) -+ { -+ if (!(frame_info.mask & ((HOST_WIDE_INT) 1 << regno))) -+ continue; -+ -+ if (regno != FIRST_PSEUDO_REGISTER) -+ emit_insn -+ (gen_rtx_SET (Pmode, gen_rtx_REG (Pmode, regno), -+ stack_disp_mem (frame_info.gpr_offset + offset))); -+ offset = offset + UNITS_PER_WORD; -+ } -+ } -+ -+ if (crtl->calls_eh_return) -+ emit_insn (gen_add2_insn (stack_pointer_rtx, EH_RETURN_STACKADJ_RTX)); -+ -+ if (frame_info.gpr_frame) -+ emit_insn (gen_add2_insn (stack_pointer_rtx, -+ GEN_INT (frame_info.gpr_frame))); -+ emit_jump_insn (gen_return_internal (gen_rtx_REG (Pmode, 9))); -+ -+} /* or1k_expand_epilogue () */ -+ -+ -+ -+/* -------------------------------------------------------------------------- */ -+/*!Generate assembler code for a movdi/movdf pattern -+ -+ @param[in] operands Operands to the movdx pattern. -+ -+ @return The assembler string to output (always "", since we've done the -+ output here). */ -+/* -------------------------------------------------------------------------- */ -+const char * -+or1k_output_move_double (rtx *operands) -+{ -+ rtx xoperands[3]; -+ -+ switch (GET_CODE (operands[0])) -+ { -+ case REG: -+ if (GET_CODE (operands[1]) == REG) -+ { -+ if (REGNO (operands[0]) == REGNO (operands[1]) + 1) -+ { -+ output_asm_insn ("\tl.or \t%H0, %H1, r0", operands); -+ output_asm_insn ("\tl.or \t%0, %1, r0", operands); -+ return ""; -+ } -+ else -+ { -+ output_asm_insn ("\tl.or \t%0, %1, r0", operands); -+ output_asm_insn ("\tl.or \t%H0, %H1, r0", operands); -+ return ""; -+ } -+ } -+ else if (GET_CODE (operands[1]) == MEM) -+ { -+ xoperands[1] = XEXP (operands[1], 0); -+ if (GET_CODE (xoperands[1]) == REG) -+ { -+ xoperands[0] = operands[0]; -+ if (REGNO (xoperands[0]) == REGNO (xoperands[1])) -+ { -+ output_asm_insn ("\tl.lwz \t%H0, 4(%1)", xoperands); -+ output_asm_insn ("\tl.lwz \t%0, 0(%1)", xoperands); -+ return ""; -+ } -+ else -+ { -+ output_asm_insn ("\tl.lwz \t%0, 0(%1)", xoperands); -+ output_asm_insn ("\tl.lwz \t%H0, 4(%1)", xoperands); -+ return ""; -+ } -+ } -+ else if (GET_CODE (xoperands[1]) == PLUS) -+ { -+ if (GET_CODE (xoperands[2] = XEXP (xoperands[1], 1)) == REG) -+ { -+ xoperands[0] = operands[0]; -+ xoperands[1] = XEXP (xoperands[1], 0); -+ if (REGNO (xoperands[0]) == REGNO (xoperands[2])) -+ { -+ output_asm_insn ("\tl.lwz \t%H0, %1+4(%2)", -+ xoperands); -+ output_asm_insn ("\tl.lwz \t%0, %1(%2)", xoperands); -+ return ""; -+ } -+ else -+ { -+ output_asm_insn ("\tl.lwz \t%0, %1(%2)", xoperands); -+ output_asm_insn ("\tl.lwz \t%H0, %1+4(%2)", -+ xoperands); -+ return ""; -+ } -+ } -+ else if (GET_CODE (xoperands[2] = XEXP (xoperands[1], 0)) == -+ REG) -+ { -+ xoperands[0] = operands[0]; -+ xoperands[1] = XEXP (xoperands[1], 1); -+ if (REGNO (xoperands[0]) == REGNO (xoperands[2])) -+ { -+ output_asm_insn ("\tl.lwz \t%H0, %1+4(%2)", -+ xoperands); -+ output_asm_insn ("\tl.lwz \t%0, %1(%2)", xoperands); -+ return ""; -+ } -+ else -+ { -+ output_asm_insn ("\tl.lwz \t%0, %1(%2)", xoperands); -+ output_asm_insn ("\tl.lwz \t%H0, %1+4(%2)", -+ xoperands); -+ return ""; -+ } -+ } -+ else -+ abort (); -+ } -+ else -+ abort (); -+ } -+ else -+ abort (); -+ case MEM: -+ xoperands[0] = XEXP (operands[0], 0); -+ if (GET_CODE (xoperands[0]) == REG) -+ { -+ xoperands[1] = operands[1]; -+ output_asm_insn ("\tl.sw \t0(%0), %1", xoperands); -+ output_asm_insn ("\tl.sw \t4(%0), %H1", xoperands); -+ return ""; -+ } -+ else if (GET_CODE (xoperands[0]) == PLUS) -+ { -+ if (GET_CODE (xoperands[1] = XEXP (xoperands[0], 1)) == REG) -+ { -+ xoperands[0] = XEXP (xoperands[0], 0); -+ xoperands[2] = operands[1]; -+ output_asm_insn ("\tl.sw \t%0(%1), %2", xoperands); -+ output_asm_insn ("\tl.sw \t%0+4(%1), %H2", xoperands); -+ return ""; -+ } -+ else if (GET_CODE (xoperands[1] = XEXP (xoperands[0], 0)) == REG) -+ { -+ xoperands[0] = XEXP (xoperands[0], 1); -+ xoperands[2] = operands[1]; -+ output_asm_insn ("\tl.sw \t%0(%1), %2", xoperands); -+ output_asm_insn ("\tl.sw \t%0+4(%1), %H2", xoperands); -+ return ""; -+ } -+ else -+ abort (); -+ } -+ else -+ { -+ fprintf (stderr, " O/p error %s\n", -+ GET_RTX_NAME (GET_CODE (xoperands[0]))); -+ return ""; -+ /* abort (); */ -+ } -+ default: -+ abort (); -+ } -+} /* or1k_output_move_double () */ -+ -+ -+/* -------------------------------------------------------------------------- */ -+/*!Expand a conditional branch -+ -+ @param[in] operands Operands to the branch. -+ @param[in] mode Mode of the comparison. */ -+/* -------------------------------------------------------------------------- */ -+void -+or1k_expand_conditional_branch (rtx *operands, -+ enum machine_mode mode) -+{ -+ rtx tmp; -+ enum rtx_code test_code = GET_CODE(operands[0]); -+ -+ switch (mode) -+ { -+ case SImode: -+ tmp = or1k_expand_compare (test_code, operands[1], operands[2]); -+ tmp = gen_rtx_IF_THEN_ELSE (VOIDmode, -+ tmp, -+ gen_rtx_LABEL_REF (VOIDmode, operands[3]), -+ pc_rtx); -+ emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx, tmp)); -+ return; -+ -+ case SFmode: -+ tmp = or1k_expand_compare (test_code, operands[1], operands[2]); -+ tmp = gen_rtx_IF_THEN_ELSE (VOIDmode, -+ tmp, -+ gen_rtx_LABEL_REF (VOIDmode, operands[3]), -+ pc_rtx); -+ emit_jump_insn (gen_rtx_SET (VOIDmode, pc_rtx, tmp)); -+ return; -+ -+ default: -+ abort (); -+ } -+ -+} /* or1k_expand_conditional_branch () */ -+ -+ -+/* -------------------------------------------------------------------------- */ -+/*!Emit a conditional move -+ -+ move "true_cond" to "dest" if "op" of the operands of the last comparison -+ is nonzero/true, "false_cond" if it is zero/false. -+ -+ @param[in] dest RTX for the destination operand. -+ @param[in] op RTX for the comparison operation -+ @param[in] true_cond RTX to move to dest if condition is TRUE. -+ @param[in] false_cond RTX to move to dest if condition is FALSE. -+ -+ @return Non-zero (TRUE) if the hardware supports such an operation, zero -+ (FALSE) otherwise. */ -+/* -------------------------------------------------------------------------- */ -+int -+or1k_emit_cmove (rtx dest, -+ rtx op, -+ rtx true_cond, -+ rtx false_cond) -+{ -+ enum machine_mode result_mode = GET_MODE (dest); -+ -+ if (GET_MODE (true_cond) != result_mode) -+ return 0; -+ -+ if (GET_MODE (false_cond) != result_mode) -+ return 0; -+ -+ /* First, work out if the hardware can do this at all */ -+ return or1k_emit_int_cmove (dest, op, true_cond, false_cond); -+ -+} /* or1k_emit_cmove () */ -+ -+ -+/* -------------------------------------------------------------------------- */ -+/*!Output the assembler for a branch on flag instruction. -+ -+ @param[in] operands Operands to the branch. -+ -+ @return The assembler string to use. */ -+/* -------------------------------------------------------------------------- */ -+const char * -+or1k_output_bf (rtx * operands) -+{ -+ enum rtx_code code; -+ enum machine_mode mode_calc, mode_got; -+ -+ code = GET_CODE (operands[1]); -+ mode_calc = or1k_select_cc_mode (code); -+ mode_got = GET_MODE (operands[2]); -+ -+ if (mode_calc != mode_got) -+ return "l.bnf\t%l0%("; -+ else -+ return "l.bf\t%l0%("; -+} /* or1k_output_bf () */ -+ -+ -+/* -------------------------------------------------------------------------- */ -+/*!Output the assembler for a conditional move instruction. -+ -+ @param[in] operands Operands to the conditional move. -+ -+ @return The assembler string to use. */ -+/* -------------------------------------------------------------------------- */ -+const char * -+or1k_output_cmov (rtx * operands) -+{ -+ enum rtx_code code; -+ enum machine_mode mode_calc, mode_got; -+ -+ code = GET_CODE (operands[1]); -+ mode_calc = or1k_select_cc_mode (code); -+ mode_got = GET_MODE (operands[4]); -+ -+ if (mode_calc != mode_got) -+ return "l.cmov\t%0,%3,%2"; /* reversed */ -+ else -+ return "l.cmov\t%0,%2,%3"; -+ -+} /* or1k_output_cmov () */ -+ -+/* -------------------------------------------------------------------------- */ -+/*!Load a 32-bit constant. -+ -+ We know it can't be done in one insn when we get here, the movsi expander -+ guarantees this. -+ -+ @param[in] op0 RTX for the destination. -+ @param[in] op1 RTX for the (constant) source. */ -+/* -------------------------------------------------------------------------- */ -+void -+or1k_emit_set_const32 (rtx op0, -+ rtx op1) -+{ -+ enum machine_mode mode = GET_MODE (op0); -+ rtx temp; -+ -+ /* Sanity check that we really can't do it in one instruction. I.e that we -+ don't have a 16-bit constant. */ -+ if (GET_CODE (op1) == CONST_INT) -+ { -+ HOST_WIDE_INT val = INTVAL (op1) & GET_MODE_MASK (mode); -+ -+ if ((-32768 <= val) && (val <= 32767)) -+ { -+ abort (); -+ } -+ } -+ -+ /* Full 2-insn decomposition is needed. */ -+ if (reload_in_progress || reload_completed) -+ temp = op0; -+ else -+ temp = gen_reg_rtx (mode); -+ -+ if (GET_CODE (op1) == CONST_INT) -+ { -+ /* Emit them as real moves instead of a HIGH/LO_SUM, -+ this way CSE can see everything and reuse intermediate -+ values if it wants. */ -+ emit_insn (gen_rtx_SET (VOIDmode, temp, -+ GEN_INT (INTVAL (op1) -+ & ~(HOST_WIDE_INT) 0xffff))); -+ -+ emit_insn (gen_rtx_SET (VOIDmode, -+ op0, -+ gen_rtx_IOR (mode, temp, -+ GEN_INT (INTVAL (op1) & 0xffff)))); -+ } -+ else -+ { -+ /* since or1k bfd can not deal with relocs that are not of type -+ OR1K_CONSTH_RELOC + OR1K_CONST_RELOC (ie move high must be -+ followed by exactly one lo_sum) -+ */ -+ emit_insn (gen_movsi_insn_big (op0, op1)); -+ } -+} /* or1k_emit_set_const32 () */ -+ -+ -+/* ========================================================================== */ -+/* Target hook functions. -+ -+ These are initialized at the end of this file, to avoid having to -+ predeclare all the functions. They are only needed here, so are static. */ -+ -+ -+ -+ -+/* -------------------------------------------------------------------------- */ -+/*!Define where a function returns values. -+ -+ Define this to return an RTX representing the place where a function -+ returns or receives a value of data type ret type, a tree node representing -+ a data type. "func" is a tree node representing FUNCTION_DECL or -+ FUNCTION_TYPE of a function being called. If "outgoing" is false, the hook -+ should compute the register in which the caller will see the return -+ value. Otherwise, the hook should return an RTX representing the place -+ where a function returns a value. -+ -+ On many machines, only TYPE_MODE ("ret_type") is relevant. (Actually, on -+ most machines, scalar values are returned in the same place regardless of -+ mode.) The value of the expression is usually a reg RTX for the hard -+ register where the return value is stored. The value can also be a parallel -+ RTX, if the return value is in multiple places. See FUNCTION_ARG for an -+ explanation of the parallel form. Note that the callee will populate every -+ location specified in the parallel, but if the first element of the -+ parallel contains the whole return value, callers will use that element as -+ the canonical location and ignore the others. The m68k port uses this type -+ of parallel to return pointers in both ‘%a0’ (the canonical location) and -+ ‘%d0’. -+ -+ If TARGET_PROMOTE_FUNCTION_RETURN returns true, you must apply the same -+ promotion rules specified in PROMOTE_MODE if valtype is a scalar type. -+ -+ If the precise function being called is known, "func" is a tree node -+ (FUNCTION_DECL) for it; otherwise, "func" is a null pointer. This makes it -+ possible to use a different value-returning convention for specific -+ functions when all their calls are known. -+ -+ Some target machines have "register windows" so that the register in which -+ a function returns its value is not the same as the one in which the caller -+ sees the value. For such machines, you should return different RTX -+ depending on outgoing. -+ -+ TARGET_FUNCTION_VALUE is not used for return values with aggregate data -+ types, because these are returned in another way. See -+ TARGET_STRUCT_VALUE_RTX and related macros. -+ -+ For the OR1K, we can just use the result of LIBCALL_VALUE, since all -+ functions return their result in the same place (register rv = r11). -+ -+ JPB 30-Aug-10: What about 64-bit scalar returns (long long int, double), -+ which also use rvh (=r12)? -+ -+ @param[in] ret_type The return type of the function. -+ @param[in] func Tree representing function being called. -+ @param[in] outgoing Non-zero (TRUE) if the result represents where the -+ function places the results, zero (FALSE) if the -+ result represents where the caller sees the result. -+ -+ @return A RTX representing where the result can be found. */ -+/* -------------------------------------------------------------------------- */ -+static rtx -+or1k_function_value (const_tree ret_type, -+ const_tree func ATTRIBUTE_UNUSED, -+ bool outgoing ATTRIBUTE_UNUSED) -+{ -+ return LIBCALL_VALUE (TYPE_MODE(ret_type)); -+ -+} /* or1k_function_value () */ -+ -+ -+/* -------------------------------------------------------------------------- */ -+/*!Check if a function is suitable for tail call optimization. -+ -+ True if it is OK to do sibling call optimization for the specified call -+ expression "exp". "decl" will be the called function, or NULL if this is an -+ indirect call. -+ -+ It is not uncommon for limitations of calling conventions to prevent tail -+ calls to functions outside the current unit of translation, or during PIC -+ compilation. The hook is used to enforce these restrictions, as the sibcall -+ md pattern can not fail, or fall over to a “normal” call. The criteria for -+ successful sibling call optimization may vary greatly between different -+ architectures. -+ -+ For the OR1K, we currently don't allow sibcalls. -+ -+ @param[in] decl The function for which we may optimize -+ @param[in] exp The call expression which is candidate for optimization. -+ -+ @return Non-zero (TRUE) if sibcall optimization is permitted, zero (FALSE) -+ otherwise. */ -+/* -------------------------------------------------------------------------- */ -+static bool -+or1k_function_ok_for_sibcall (tree decl ATTRIBUTE_UNUSED, -+ tree exp ATTRIBUTE_UNUSED) -+{ -+ return 0; -+} /* or1k_function_ok_for_sibcall () */ -+ -+ -+/* -------------------------------------------------------------------------- */ -+/*!Should an argument be passed by reference. -+ -+ This target hook should return true if an argument at the position -+ indicated by "cum" should be passed by reference. This predicate is queried -+ after target independent reasons for being passed by reference, such as -+ TREE_ADDRESSABLE ("type"). -+ -+ If the hook returns TRUE, a copy of that argument is made in memory and a -+ pointer to the argument is passed instead of the argument itself. The -+ pointer is passed in whatever way is appropriate for passing a pointer to -+ that type. -+ -+ For the OR1K, all aggregates and arguments greater than 8 bytes are passed -+ this way. -+ -+ @param[in] cum Position of argument under consideration. -+ @param[in[ mode Not sure what this relates to. -+ @param[in] type Type of the argument. -+ @param[in] named Not sure what this relates to. -+ -+ @return Non-zero (TRUE) if the argument should be passed by reference, -+ zero (FALSE) otherwise. */ -+/* -------------------------------------------------------------------------- */ -+static bool -+or1k_pass_by_reference (cumulative_args_t cum ATTRIBUTE_UNUSED, -+ enum machine_mode mode ATTRIBUTE_UNUSED, -+ const_tree type, -+ bool named ATTRIBUTE_UNUSED) -+{ -+ return (type && (AGGREGATE_TYPE_P (type) || int_size_in_bytes (type) > 8)); -+ -+} /* or1k_pass_by_reference () */ -+ -+ -+int -+or1k_initial_elimination_offset(int from, int to) -+{ -+ or1k_compute_frame_size (get_frame_size ()); -+ return ((from == FRAME_POINTER_REGNUM -+ ? frame_info.gpr_offset : frame_info.gpr_frame) -+ + (to == STACK_POINTER_REGNUM ? frame_info.late_frame : 0)); -+} -+ -+ -+/* -------------------------------------------------------------------------- */ -+/*!How many bytes at the beginning of an argument must be put into registers. -+ -+ This target hook returns the number of bytes at the beginning of an -+ argument that must be put in registers. The value must be zero for -+ arguments that are passed entirely in registers or that are entirely pushed -+ on the stack. -+ -+ On some machines, certain arguments must be passed partially in registers -+ and partially in memory. On these machines, typically the first few words -+ of arguments a re passed in registers, and the rest on the stack. If a -+ multi-word argument (a double or a structure) crosses that boundary, its -+ first few words must be passed in registers and the rest must be -+ pushed. This macro tells the compiler when this occurs, and how many bytes -+ should go in registers. -+ -+ FUNCTION_ARG for these arguments should return the first register to be -+ used by the caller for this argument; likewise FUNCTION_INCOMING_ARG, for -+ the called function. -+ -+ On the OR1K we never split argumetns between registers and memory. -+ -+ JPB 30-Aug-10: Is this correct? Surely we should allow this. The ABI spec -+ is incomplete on this point. -+ -+ @param[in] cum Position of argument under consideration. -+ @param[in[ mode Not sure what this relates to. -+ @param[in] type Type of the argument. -+ @param[in] named Not sure what this relates to. -+ -+ @return The number of bytes of the argument to go into registers */ -+/* -------------------------------------------------------------------------- */ -+static int -+or1k_arg_partial_bytes (cumulative_args_t cum ATTRIBUTE_UNUSED, -+ enum machine_mode mode ATTRIBUTE_UNUSED, -+ tree type ATTRIBUTE_UNUSED, -+ bool named ATTRIBUTE_UNUSED) -+{ -+ return 0; -+ -+} /* or1k_arg_partial_bytes () */ -+ -+ -+/* -------------------------------------------------------------------------- */ -+/*!Promote the mode of a function's arguments/return value. -+ -+ Like PROMOTE_MODE, but it is applied to outgoing function arguments or -+ function return values. The target hook should return the new mode and -+ possibly change "*punsignedp" if the promotion should change -+ signedness. This function is called only for scalar or pointer types. -+ -+ "for_return" allows to distinguish the promotion of arguments and return -+ values. If it is 1, a return value is being promoted and -+ TARGET_FUNCTION_VALUE must perform the same promotions done here. If it is -+ 2, the returned mode should be that of the register in which an incoming -+ parameter is copied, or the outgoing result is computed; then the hook -+ should return the same mode as PROMOTE_MODE, though the signedness may be -+ different. -+ -+ The default is to not promote arguments and return values. You can also -+ define the hook to "default_promote_function_mode_always_promote" if you -+ would like to apply the same rules given by PROMOTE_MODE. -+ -+ For the OR1K, if the size of the mode is integral and less than 4, we -+ promote to SImode, otherwise we return the mode we are supplied. -+ -+ @param[in] type Not sure. Type of the argument? -+ @param[in] mode The mode of argument/return value to consider. -+ @param[out] punsignedp Signedness of the value. -+ @param[in] fntype Not sure. Type of the function? -+ @param[in] for_return 1 if a return value, 2 if an incoming value. -+ -+ @return The new mode. */ -+/* -------------------------------------------------------------------------- */ -+static enum machine_mode -+or1k_promote_function_mode (const_tree type ATTRIBUTE_UNUSED, -+ enum machine_mode mode, -+ int *punsignedp ATTRIBUTE_UNUSED, -+ const_tree fntype ATTRIBUTE_UNUSED, -+ int for_return ATTRIBUTE_UNUSED) -+{ -+ return ( (GET_MODE_CLASS (mode) == MODE_INT) -+ && (GET_MODE_SIZE (mode) < 4)) ? SImode : mode; -+ -+} /* or1k_promote_function_mode () */ -+ -+ -+/* -------------------------------------------------------------------------- */ -+/*!Is this a legitimate address? -+ -+ A function that returns whether x (an RTX) is a legitimate memory address on -+ the target machine for a memory operand of mode mode. -+ -+ Legitimate addresses are defined in two variants: a strict variant and a -+ non-strict one. The strict parameter chooses which variant is desired by -+ the caller. -+ -+ The strict variant is used in the reload pass. It must be defined so that -+ any pseudo- register that has not been allocated a hard register is -+ considered a memory reference. This is because in contexts where some kind -+ of register is required, a pseudo-register with no hard register must be -+ rejected. For non-hard registers, the strict variant should look up the -+ reg_renumber array; it should then proceed using the hard register number in -+ the array, or treat the pseudo as a memory reference if the array holds -1. -+ -+ The non-strict variant is used in other passes. It must be defined to accept -+ all pseudo-registers in every context where some kind of register is -+ required. -+ -+ Normally, constant addresses which are the sum of a symbol_ref and an -+ integer are stored inside a const RTX to mark them as constant. Therefore, -+ there is no need to recognize such sums specifically as legitimate -+ addresses. Normally you would simply recognize any const as legitimate. -+ -+ Usually PRINT_OPERAND_ADDRESS is not prepared to handle constant sums that -+ are not marked with const. It assumes that a naked plus indicates -+ indexing. If so, then you must reject such naked constant sums as -+ illegitimate addresses, so that none of them will be given to -+ PRINT_OPERAND_ADDRESS. -+ -+ On some machines, whether a symbolic address is legitimate depends on the -+ section that the address refers to. On these machines, define the target -+ hook TARGET_ENCODE_ SECTION_INFO to store the information into the -+ symbol_ref, and then check for it here. When you see a const, you will have -+ to look inside it to find the symbol_ref in order to determine the -+ section. See the internals manual section on "Assembler Format" for more -+ info. -+ -+ Some ports are still using a deprecated legacy substitute for this hook, the -+ GO_IF_LEGITIMATE_ADDRESS macro. This macro has this syntax: -+ -+ #define GO_IF_LEGITIMATE_ADDRESS (mode, x, label ) -+ -+ and should goto label if the address x is a valid address on the target -+ machine for a memory operand of mode mode. Whether the strict or non-strict -+ variants are desired is defined by the REG_OK_STRICT macro introduced -+ earlier in this section. Using the hook is usually simpler because it limits -+ the number of files that are recompiled when changes are made. -+ -+ The OR1K only has a single addressing mode, which is a base register with -+ 16-bit displacement. We can accept just 16-bit constants as addresses (they -+ can use r0 as base address, and we can accept plain registers as addresses -+ (they can use a displacement of zero). -+ -+ @param[in] mode The mode of the address -+ @param[in] x The address (RTX) -+ @param[in] strict Non-zero (TRUE) if we are in "strict" mode, zero (FALSE) -+ otherwise. -+ -+ @return Non-zero (TRUE) if this is a legitimate address, zero (FALSE) -+ otherwise. */ -+/* -------------------------------------------------------------------------- */ -+static bool -+or1k_legitimate_address_p (enum machine_mode mode ATTRIBUTE_UNUSED, -+ rtx x, -+ bool strict) -+{ -+ /* You might think 16-bit constants are suitable. They can be built into -+ addresses using r0 as the base. However this seems to lead to defective -+ code. So for now this is a placeholder, and this code is not used. -+ -+ if (or1k_legitimate_displacement_p (mode, x)) -+ { -+ return 1; -+ } -+ */ -+ /* Addresses consisting of a register and 16-bit displacement are also -+ suitable. We need the mode, since for double words, we had better be -+ able to address the full 8 bytes. */ -+ if (GET_CODE(x) == PLUS) -+ { -+ rtx reg = XEXP(x,0); -+ -+ /* If valid register... */ -+ if ((GET_CODE(reg) == REG) -+ && or1k_regnum_ok_for_base_p (REGNO (reg), strict)) -+ { -+ rtx offset = XEXP(x,1); -+ -+ /* ...and valid offset */ -+ if (or1k_legitimate_displacement_p (mode, offset)) -+ { -+ return 1; -+ } -+ } -+ } -+ -+ /* Addresses consisting of just a register are OK. They can be built into -+ addresses using an offset of zero (and an offset of four if double -+ word). */ -+ if (GET_CODE(x) == REG -+ && or1k_regnum_ok_for_base_p(REGNO(x),strict)) { -+ return 1; -+ } -+ -+ return 0; -+} -+ -+/* -------------------------------------------------------------------------- */ -+/*!Initialize a trampoline for nested functions. -+ -+ A nested function is defined by *two* pieces of information, the address of -+ the function (like any other function) and a pointer to the frame of the -+ enclosing function. The latter is required to allow the nested function to -+ access local variables in the enclosing function's frame. -+ -+ This represents a problem, since a function in C is represented as an -+ address that can be held in a single variable as a pointer. Requiring two -+ pointers will not fit. -+ -+ The solution is documented in "Lexical Closures for C++" by Thomas -+ M. Breuel (USENIX C++ Conference Proceedings, October 17-21, 1988). The -+ nested function is represented by a small block of code and data on the -+ enclosing function's stack frame, which sets up a pointer to the enclosing -+ function's stack frame (the static chain pointer) in a register defined by -+ the ABI, and then jumps to the code of the function proper. -+ -+ The function can be represented as a single pointer to this block of code, -+ known as a trampoline, which when called generates both pointers -+ needed. The nested function (which knows it is a nested function at compile -+ time) can then generate code to access the enclosing frame via the static -+ chain register. -+ -+ There is a catch that the trampoline is set up as data, but executed as -+ instructions. The former will be via the data cache, the latter via the -+ instruction cache. There is a risk that a later trampoline will not be seen -+ by the instruction cache, so the wrong code will be executed. So the -+ instruction cache should be flushed for the trampoline address range. -+ -+ This hook is called to initialize a trampoline. "m_tramp" is an RTX for the -+ memory block for the trampoline; "fndecl" is the FUNCTION_DECL for the -+ nested function; "static_chain" is an RTX for the static chain value that -+ should be passed to the function when it is called. -+ -+ If the target defines TARGET_ASM_TRAMPOLINE_TEMPLATE, then the first thing -+ this hook should do is emit a block move into "m_tramp" from the memory -+ block returned by assemble_trampoline_template. Note that the block move -+ need only cover the constant parts of the trampoline. If the target -+ isolates the variable parts of the trampoline to the end, not all -+ TRAMPOLINE_SIZE bytes need be copied. -+ -+ If the target requires any other actions, such as flushing caches or -+ enabling stack execution, these actions should be performed after -+ initializing the trampoline proper. -+ -+ For the OR1K, no static chain register is used. We choose to use the return -+ value (rv) register. The code is based on that for MIPS. -+ The trampoline code is: -+ -+ l.movhi r11,hi(end_addr) -+ l.ori r11,lo(end_addr) -+ l.lwz r13,4(r11) -+ l.jr r13 -+ l.lwz r11,0(r11) -+ end_addr: -+ .word -+ .word -+ -+ @note For the OR1K we need to flush the instruction cache, which is a -+ privileged operation. Needs fixing. -+ -+ @param[in] m_tramp The lowest address of the trampoline on the stack. -+ @param[in] fndecl Declaration of the enclosing function. -+ @param[in] chain_value Static chain pointer to pass to the nested -+ function. */ -+/* -------------------------------------------------------------------------- */ -+static void -+or1k_trampoline_init (rtx m_tramp, -+ tree fndecl, -+ rtx chain_value) -+{ -+ rtx addr; /* Start address of the trampoline */ -+ rtx end_addr; /* End address of the code block */ -+ -+ rtx high; /* RTX for the high part of end_addr */ -+ rtx low; /* RTX for the low part of end_addr */ -+ rtx opcode; /* RTX for generated opcodes */ -+ rtx mem; /* RTX for trampoline memory */ -+ -+ rtx *trampoline; /* The trampoline code */ -+ -+ unsigned int i; /* Index into trampoline */ -+ unsigned int j; /* General counter */ -+ -+ HOST_WIDE_INT end_addr_offset; /* Offset to end of code */ -+ HOST_WIDE_INT static_chain_offset; /* Offset to stack chain word */ -+ HOST_WIDE_INT target_function_offset; /* Offset to func address word */ -+ -+ /* Work out the offsets of the pointers from the start of the trampoline -+ code. */ -+ trampoline = (rtx*) alloca (or1k_trampoline_code_words() * sizeof(rtx)); -+ end_addr_offset = or1k_trampoline_code_size (); -+ static_chain_offset = end_addr_offset; -+ target_function_offset = static_chain_offset + GET_MODE_SIZE (ptr_mode); -+ -+ /* Get pointers in registers to the beginning and end of the code block. */ -+ addr = force_reg (Pmode, XEXP (m_tramp, 0)); -+ end_addr = or1k_force_binary (Pmode, PLUS, addr, GEN_INT (end_addr_offset)); -+ -+ /* Build up the code in TRAMPOLINE. -+ -+ l.movhi r11,hi(end_addr) -+ l.ori r11,lo(end_addr) -+ l.lwz r13,4(r11) -+ l.jr r13 -+ l.lwz r11,0(r11) -+ end_addr: -+ */ -+ -+ i = 0; -+ -+ /* Break out the high and low parts of the end_addr */ -+ high = expand_simple_binop (SImode, LSHIFTRT, end_addr, GEN_INT (16), -+ NULL, false, OPTAB_WIDEN); -+ low = convert_to_mode (SImode, gen_lowpart (HImode, end_addr), true); -+ -+ /* Emit the l.movhi, adding an operation to OR in the high bits from the -+ RTX. */ -+ opcode = gen_int_mode (OR1K_MOVHI (11, 0), SImode); -+ trampoline[i++] = expand_simple_binop (SImode, IOR, opcode, high, NULL, -+ false, OPTAB_WIDEN); -+ -+ /* Emit the l.ori, adding an operations to OR in the low bits from the -+ RTX. */ -+ opcode = gen_int_mode (OR1K_ORI (11, 11, 0), SImode); -+ trampoline[i++] = expand_simple_binop (SImode, IOR, opcode, low, NULL, -+ false, OPTAB_WIDEN); -+ -+ /* Emit the l.lwz of the function address. No bits to OR in here, so we can -+ do the opcode directly. */ -+ trampoline[i++] = -+ gen_int_mode (OR1K_LWZ (13, 11, target_function_offset - end_addr_offset), -+ SImode); -+ -+ if (TARGET_DELAY_ON) { -+ /* Emit the l.jr of the function. No bits to OR in here, so we can do the -+ opcode directly. */ -+ trampoline[i++] = gen_int_mode (OR1K_JR (13), SImode); -+ -+ /* Emit the l.lwz of the static chain. No bits to OR in here, so we can -+ do the opcode directly. */ -+ trampoline[i++] = -+ gen_int_mode (OR1K_LWZ (STATIC_CHAIN_REGNUM, 11, -+ static_chain_offset - end_addr_offset), SImode); -+ } else { -+ trampoline[i++] = -+ gen_int_mode (OR1K_LWZ (STATIC_CHAIN_REGNUM, 11, -+ static_chain_offset - end_addr_offset), SImode); -+ trampoline[i++] = gen_int_mode (OR1K_JR (13), SImode); -+ if (TARGET_DELAY_COMPAT) -+ trampoline[i++] = gen_int_mode (OR1K_NOP, SImode); -+ } -+ -+ /* Copy the trampoline code. Leave any padding uninitialized. */ -+ for (j = 0; j < i; j++) -+ { -+ mem = adjust_address (m_tramp, SImode, j * GET_MODE_SIZE (SImode)); -+ or1k_emit_move (mem, trampoline[j]); -+ } -+ -+ /* Set up the static chain pointer field. */ -+ mem = adjust_address (m_tramp, ptr_mode, static_chain_offset); -+ or1k_emit_move (mem, chain_value); -+ -+ /* Set up the target function field. */ -+ mem = adjust_address (m_tramp, ptr_mode, target_function_offset); -+ or1k_emit_move (mem, XEXP (DECL_RTL (fndecl), 0)); -+ -+ /* Flushing the trampoline from the instruction cache needs to be done -+ here. */ -+ -+} /* or1k_trampoline_init () */ -+ -+ -+/* -------------------------------------------------------------------------- */ -+/*!Provide support for DW_AT_calling_convention -+ -+ Define this to enable the dwarf attribute DW_AT_calling_convention to be -+ emitted for each function. Instead of an integer return the enum value for -+ the DW_CC_ tag. -+ -+ To support optional call frame debugging information, you must also define -+ INCOMING_RETURN_ADDR_RTX and either set RTX_FRAME_RELATED_P on the prologue -+ insns if you use RTL for the prologue, or call "dwarf2out_def_cfa" and -+ "dwarf2out_reg_save" as appropriate from TARGET_ASM_FUNCTION_PROLOGUE if -+ you don’t. -+ -+ For the OR1K, it should be sufficient to return DW_CC_normal in all cases. -+ -+ @param[in] function The function requiring debug information -+ -+ @return The enum of the DW_CC tag. */ -+/* -------------------------------------------------------------------------- */ -+static int -+or1k_dwarf_calling_convention (const_tree function ATTRIBUTE_UNUSED) -+{ -+ return DW_CC_normal; -+ -+} /* or1k_dwarf_calling_convention () */ -+ -+/* ========================================================================== */ -+/* Target hook initialization. -+ -+ In most cases these use the static functions declared above. They have -+ defaults, so must be undefined first, before being redefined. -+ -+ The description of what they do is found with the function above, unless it -+ is a standard function or a constant, in which case it is defined here (as -+ with TARGET_ASM_NAMED_SECTION). -+ -+ The final declaration is of the global "targetm" structure. */ -+ -+/* Output assembly directives to switch to section name. The section should -+ have attributes as specified by flags, which is a bit mask of the SECTION_* -+ flags defined in ‘output.h’. If decl is non-NULL, it is the VAR_DECL or -+ FUNCTION_DECL with which this section is associated. -+ -+ For OR1K, we use the default ELF sectioning. */ -+#undef TARGET_ASM_NAMED_SECTION -+#define TARGET_ASM_NAMED_SECTION default_elf_asm_named_section -+ -+#undef TARGET_FUNCTION_VALUE -+#define TARGET_FUNCTION_VALUE or1k_function_value -+ -+#undef TARGET_FUNCTION_OK_FOR_SIBCALL -+#define TARGET_FUNCTION_OK_FOR_SIBCALL or1k_function_ok_for_sibcall -+ -+#undef TARGET_PASS_BY_REFERENCE -+#define TARGET_PASS_BY_REFERENCE or1k_pass_by_reference -+ -+#undef TARGET_ARG_PARTIAL_BYTES -+#define TARGET_ARG_PARTIAL_BYTES or1k_arg_partial_bytes -+ -+#undef TARGET_OPTION_OVERRIDE -+#define TARGET_OPTION_OVERRIDE or1k_option_override -+ -+#undef TARGET_ASM_FILE_START -+#define TARGET_ASM_FILE_START or1k_asm_file_start -+ -+/* This target hook returns TRUE if an argument declared in a prototype as an -+ integral type smaller than int should actually be passed as an int. In -+ addition to avoiding errors in certain cases of mismatch, it also makes for -+ better code on certain machines. -+ -+ The default is to not promote prototypes. -+ -+ For the OR1K we do require this, so use a utility hook, which always -+ returns TRUE. */ -+#undef TARGET_PROMOTE_PROTOTYPES -+#define TARGET_PROMOTE_PROTOTYPES hook_bool_const_tree_true -+ -+#undef TARGET_PROMOTE_FUNCTION_MODE -+#define TARGET_PROMOTE_FUNCTION_MODE or1k_promote_function_mode -+ -+#undef TARGET_LEGITIMATE_ADDRESS_P -+#define TARGET_LEGITIMATE_ADDRESS_P or1k_legitimate_address_p -+ -+#undef TARGET_LEGITIMIZE_ADDRESS -+#define TARGET_LEGITIMIZE_ADDRESS or1k_legitimize_address -+ -+#undef TARGET_TRAMPOLINE_INIT -+#define TARGET_TRAMPOLINE_INIT or1k_trampoline_init -+ -+#undef TARGET_CANNOT_FORCE_CONST_MEM -+#define TARGET_CANNOT_FORCE_CONST_MEM or1k_cannot_force_const_mem -+ -+#undef TARGET_DWARF_CALLING_CONVENTION -+#define TARGET_DWARF_CALLING_CONVENTION or1k_dwarf_calling_convention -+ -+/* uClibc has some instances where (non-coforming to ISO C) a non-varargs -+ prototype is in scope when calling that function which is implemented -+ as varargs. We want this to work at least where none of the anonymous -+ arguments are used. I.e. we want the last named argument to be known -+ as named so it can be passed in a register, varars funtion or not. */ -+#undef TARGET_STRICT_ARGUMENT_NAMING -+#define TARGET_STRICT_ARGUMENT_NAMING hook_bool_CUMULATIVE_ARGS_true -+ -+/* Is this suitable for an immediate operand. -+ -+ JPB 1-Sep-10: Is this correct. We can only do 16-bit immediates directly. */ -+static bool -+or1k_legitimate_constant_p (enum machine_mode mode ATTRIBUTE_UNUSED, rtx x) -+{ -+ if (or1k_tls_symbolic_operand (x) != TLS_MODEL_NONE) -+ return 0; -+ -+ return GET_CODE(x) != CONST_DOUBLE || (GET_MODE (x) == VOIDmode && !flag_pic); -+} -+#undef TARGET_LEGITIMATE_CONSTANT_P -+#define TARGET_LEGITIMATE_CONSTANT_P or1k_legitimate_constant_p -+ -+/* On the OR1K, no functions pop their arguments. -+ JPB 29-Aug-10: Is this really correct? */ -+static int -+or1k_return_pops_args (tree ARG_UNUSED(fundecl), tree ARG_UNUSED(funtype), int ARG_UNUSED(size)) -+{ -+ return 0; -+} -+#undef TARGET_RETURN_POPS_ARGS -+#define TARGET_RETURN_POPS_ARGS or1k_return_pops_args -+ -+/* Determine where to put an argument to a function. Value is zero to push -+ the argument on the stack, or a hard register in which to store the -+ argument. -+ -+ "mode" is the argument's machine mode. -+ -+ "type" is the data type of the argument (as a tree). This is null for -+ libcalls where that information may not be available. -+ -+ "cum" is a variable of type CUMULATIVE_ARGS which gives info about the -+ preceding args and about the function being called. -+ -+ "named" is nonzero if this argument is a named parameter (otherwise it is -+ an extra parameter matching an ellipsis). -+ -+ On the ARC the first MAX_ARC_PARM_REGS args are normally in registers and -+ the rest are pushed. */ -+static rtx -+or1k_function_arg (cumulative_args_t cum, enum machine_mode mode, -+ const_tree type, bool named) -+{ -+ CUMULATIVE_ARGS *cum_pnt = get_cumulative_args (cum); -+ -+ if (OR1K_PASS_IN_REG_P (*cum_pnt, mode, type, named)) -+ return gen_rtx_REG (mode, OR1K_ROUND_ADVANCE_CUM (*cum_pnt, mode, type) -+ + GP_ARG_MIN_REG); -+ else -+ return 0; -+} -+#undef TARGET_FUNCTION_ARG -+#define TARGET_FUNCTION_ARG or1k_function_arg -+/* Update the data in "cum" to advance over an argument of mode "mode" and -+ data type "type". ("type" is null for libcalls where that information may -+ not be available.) */ -+static void -+or1k_function_arg_advance (cumulative_args_t cum, enum machine_mode mode, -+ const_tree type, bool ARG_UNUSED(named)) -+{ -+ CUMULATIVE_ARGS *cum_pnt = get_cumulative_args (cum); -+ -+ *cum_pnt = OR1K_ROUND_ADVANCE_CUM (*cum_pnt, mode, type) -+ + OR1K_ROUND_ADVANCE_ARG (mode, type); -+} -+ -+#undef TARGET_FUNCTION_ARG_ADVANCE -+#define TARGET_FUNCTION_ARG_ADVANCE or1k_function_arg_advance -+ -+#undef TARGET_PRINT_OPERAND_ADDRESS -+#define TARGET_PRINT_OPERAND_ADDRESS or1k_print_operand_address -+ -+/* Trampoline stubs are yet to be written. */ -+/* #define TARGET_ASM_TRAMPOLINE_TEMPLATE */ -+/* #define TARGET_TRAMPOLINE_INIT */ -+ -+/* Lay out structs with increased alignment so that they can be accessed -+ more efficiently. But don't increase the size of one or two byte -+ structs. */ -+int -+or1k_struct_alignment (tree t) -+{ -+ unsigned HOST_WIDE_INT total = 0; -+ int default_align_fields = 0; -+ int special_align_fields = 0; -+ tree field; -+ unsigned max_align -+ = maximum_field_alignment ? maximum_field_alignment : BIGGEST_ALIGNMENT; -+ bool struct_p; -+ -+ switch (TREE_CODE (t)) -+ { -+ case RECORD_TYPE: -+ struct_p = true; break; -+ case UNION_TYPE: case QUAL_UNION_TYPE: -+ struct_p = false; break; -+ default: gcc_unreachable (); -+ } -+ /* Skip all non field decls */ -+ for (field = TYPE_FIELDS (t); field; field = TREE_CHAIN (field)) -+ { -+ unsigned HOST_WIDE_INT field_size; -+ -+ if (TREE_CODE (field) != FIELD_DECL || -+ TREE_TYPE (field) == error_mark_node) -+ continue; -+ /* If this is a field in a non-qualified union, or the sole field in -+ a struct, and the alignment was set by the user, don't change the -+ alignment. -+ If the field is a struct/union in a non-qualified union, we already -+ had sufficient opportunity to pad it - if we didn't, that'd be -+ because the alignment was set as above. -+ Likewise if the field is a struct/union and the sole field in a -+ struct. */ -+ if (DECL_USER_ALIGN (field) -+ || TYPE_USER_ALIGN (TREE_TYPE (field)) -+ || TREE_CODE (TREE_TYPE (field)) == UNION_TYPE -+ || TREE_CODE (TREE_TYPE (field)) == QUAL_UNION_TYPE -+ || TREE_CODE (TREE_TYPE (field)) == RECORD_TYPE) -+ { -+ if (TREE_CODE (t) == UNION_TYPE) -+ return 0; -+ special_align_fields++; -+ } -+ else if (DECL_PACKED (field)) -+ special_align_fields++; -+ else -+ default_align_fields++; -+ if (!host_integerp (DECL_SIZE_UNIT (field), 1)) -+ field_size = max_align; -+ else -+ field_size = tree_low_cst (DECL_SIZE_UNIT (field), 1); -+ if (field_size >= BIGGEST_ALIGNMENT) -+ total = max_align; -+ if (struct_p) -+ total += field_size; -+ else -+ total = MAX (total, field_size); -+ } -+ -+ if (!default_align_fields -+ && (TREE_CODE (t) != RECORD_TYPE || special_align_fields <= 1)) -+ return 0; -+ return total < max_align ? (1U << ceil_log2 (total)) : max_align; -+} -+ -+/* Increase the alignment of objects so that they are easier to copy. -+ Note that this can cause more struct copies to be inlined, so code -+ size might increase, but so should perfromance. */ -+int -+or1k_data_alignment (tree t, int align) -+{ -+ if (align < FASTEST_ALIGNMENT && TREE_CODE (t) == ARRAY_TYPE) -+ { -+ int size = int_size_in_bytes (t); -+ -+ return (size > 0 && size < FASTEST_ALIGNMENT / BITS_PER_UNIT -+ ? (1 << floor_log2 (size)) * BITS_PER_UNIT -+ : FASTEST_ALIGNMENT); -+ } -+ return align; -+} -+ -+static void -+or1k_option_override (void) -+{ -+ if (!TARGET_DELAY_ON) -+ flag_delayed_branch = FALSE; -+} -+ -+static void -+or1k_asm_file_start(void) -+{ -+ default_file_start(); -+ -+ if (TARGET_DELAY_OFF) { -+ fprintf(asm_out_file, "\t.nodelay\n"); -+ } -+} -+ -+/* Implement EH_RETURN_HANDLER_RTX. -+ * Make eh_return use the link register. Epilogue LR restore -+ * is suppressed for eh_return. */ -+rtx -+or1k_eh_return_handler_rtx (void) -+{ -+ return INCOMING_RETURN_ADDR_RTX; -+} -+ -+/* Implement RETURN_ADDR_RTX. -+ * We do not support moving back to a previous frame. */ -+rtx -+or1k_return_addr_rtx (int count, rtx frame ATTRIBUTE_UNUSED) -+{ -+ if (count != 0) -+ return const0_rtx; -+ -+ /* We don't know if LR is going to be saved or if we're going to -+ * be clobbering it with the GOT instruction. -+ * Therefore the safest bet is to force a save of LR and use that. -+ * Assume it's going to be first in the stack. */ -+ -+ cfun->machine->force_lr_save = true; -+ return gen_rtx_MEM (Pmode, plus_constant (Pmode, arg_pointer_rtx, -+ -UNITS_PER_WORD)); -+} -+ -+/* Implement TARGET_FRAME_POINTER_REQUIRED. -+ * We want frame pointer in eh_return and when alloca is used */ -+static bool -+or1k_frame_pointer_required (void) -+{ -+ return crtl->calls_eh_return || cfun->calls_alloca; -+} -+ -+/* Functions to save and restore machine-specific function data. */ -+static struct machine_function * -+or1k_init_machine_status (void) -+{ -+ return ggc_alloc_cleared_machine_function (); -+} -+ -+void -+or1k_init_expanders (void) -+{ -+ /* Arrange to initialize and mark the machine per-function -+ * status. */ -+ init_machine_status = or1k_init_machine_status; -+ -+ if (cfun && cfun->machine) -+ { -+ cfun->machine->force_lr_save = false; -+ } -+} -+ -+#undef TARGET_FRAME_POINTER_REQUIRED -+#define TARGET_FRAME_POINTER_REQUIRED or1k_frame_pointer_required -+ -+/* Initialize the GCC target structure. */ -+struct gcc_target targetm = TARGET_INITIALIZER; -+ -+#include "gt-or1k.h" -diff -rNU3 dist.orig/gcc/config/or1k/or1k.h dist/gcc/config/or1k/or1k.h ---- dist.orig/gcc/config/or1k/or1k.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/or1k/or1k.h 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,1202 @@ -+/* Definitions of target machine for GNU compiler. OpenRISC 1000 version. -+ Copyright (C) 1987, 1988, 1992, 1995, 1996, 1999, 2000, 2001, 2002, -+ 2003, 2004, 2005 Free Software Foundation, Inc. -+ Copyright (C) 2010 Embecosm Limited -+ Contributed by Damjan Lampret in 1999. -+ Major optimizations by Matjaz Breskvar in 2005. -+ -+This file is part of GNU CC. -+ -+GNU CC is free software; you can redistribute it and/or modify -+it under the terms of the GNU General Public License as published by -+the Free Software Foundation; either version 1, or (at your option) -+any later version. -+ -+GNU CC is distributed in the hope that it will be useful, -+but WITHOUT ANY WARRANTY; without even the implied warranty of -+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+GNU General Public License for more details. -+ -+You should have received a copy of the GNU General Public License -+along with GNU CC; see the file COPYING. If not, write to -+the Free Software Foundation, 59 Temple Place - Suite 330, -+Boston, MA 02111-1307, USA. */ -+ -+#ifndef _OR1K_H_ -+#define _OR1K_H_ -+ -+#include "config/or1k/or1k-opts.h" -+ -+/* Target CPU builtins */ -+#define TARGET_CPU_CPP_BUILTINS() \ -+ do \ -+ { \ -+ if (TARGET_DELAY_OFF) { \ -+ builtin_define ("__OR1KND__"); \ -+ builtin_define ("__or1knd__"); \ -+ builtin_assert ("cpu=or1knd"); \ -+ builtin_assert ("machine=or1knd"); \ -+ } else { \ -+ builtin_define ("__OR1K__"); \ -+ builtin_define ("__or1k__"); \ -+ builtin_assert ("cpu=or1k"); \ -+ builtin_assert ("machine=or1k"); \ -+ } \ -+ if (TARGET_DELAY_ON) { \ -+ builtin_define ("__OR1K_DELAY__"); \ -+ } else if (TARGET_DELAY_OFF) { \ -+ builtin_define ("__OR1K_NODELAY__"); \ -+ } else if (TARGET_DELAY_COMPAT) { \ -+ builtin_define ("__OR1K_DELAY_COMPAT__"); \ -+ } \ -+ } \ -+ while (0) -+ -+#undef CPP_SPEC -+#define CPP_SPEC "%{!mnewlib:%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}}" -+ -+/* Make sure we pick up the crti.o, crtbegin.o, crtend.o and crtn.o files. */ -+#undef STARTFILE_SPEC -+#define STARTFILE_SPEC \ -+ "%{!shared:%{pie:Scrt0.o%s;:crt0.o%s}} crti.o%s \ -+ %{static:crtbeginT.o%s;shared|pie:crtbeginS.o%s;:crtbegin.o%s}" -+ -+#undef ENDFILE_SPEC -+#define ENDFILE_SPEC "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s" -+ -+#undef LINK_SPEC -+#define LINK_SPEC "%{mnewlib:-entry 0x100} %{static:-static} %{shared:-shared}" -+ -+/* Override previous definitions (linux.h). Newlib doesn't have a profiling -+ version of the library, but it does have a debugging version (libg.a) */ -+#undef LIB_SPEC -+#define LIB_SPEC "%{!mnewlib:%{pthread:-lpthread} \ -+ %{!p:%{!pg:-lc}}%{p:-lc_p}%{pg:-lc_p}}" \ -+ "%{mnewlib:%{!g:-lc} %{g:-lg} -lor1k \ -+ %{mboard=*:-lboard-%*} %{!mboard=*:-lboard-or1ksim} \ -+ %{!g:-lc} %{g:-lg} \ -+ }" -+ -+#define SUBTARGET_EXTRA_SPECS -+ -+#define EXTRA_SPECS \ -+ SUBTARGET_EXTRA_SPECS -+ -+/* Target machine storage layout */ -+ -+/* Define this if most significant bit is lowest numbered -+ in instructions that operate on numbered bit-fields. -+ This is not true on the or1k. */ -+#define BITS_BIG_ENDIAN 0 -+ -+/* Define this if most significant byte of a word is the lowest numbered. */ -+#define BYTES_BIG_ENDIAN 1 -+ -+/* Define this if most significant word of a multiword number is numbered. */ -+#define WORDS_BIG_ENDIAN 1 -+ -+#define BITS_PER_WORD 32 -+#define SHORT_TYPE_SIZE 16 -+#define INT_TYPE_SIZE 32 -+#define LONG_TYPE_SIZE 32 -+#define LONG_LONG_TYPE_SIZE 64 -+#define FLOAT_TYPE_SIZE 32 -+#define DOUBLE_TYPE_SIZE 64 -+#define LONG_DOUBLE_TYPE_SIZE 64 -+ -+/* Width of a word, in units (bytes). */ -+#define UNITS_PER_WORD 4 -+ -+/* Width in bits of a pointer. -+ See also the macro `Pmode' defined below. */ -+#define POINTER_SIZE 32 -+ -+/* Allocation boundary (in *bits*) for storing pointers in memory. */ -+#define POINTER_BOUNDARY 32 -+ -+/* Allocation boundary (in *bits*) for storing arguments in argument list. */ -+#define PARM_BOUNDARY 32 -+ -+/* Boundary (in *bits*) on which stack pointer should be aligned. */ -+#define STACK_BOUNDARY 32 -+ -+/* Allocation boundary (in *bits*) for the code of a function. */ -+#define FUNCTION_BOUNDARY 32 -+ -+/* Alignment of field after `int : 0' in a structure. */ -+#define EMPTY_FIELD_BOUNDARY 8 -+ -+/* A bitfield declared as `int' forces `int' alignment for the struct. */ -+#define PCC_BITFIELD_TYPE_MATTERS 1 -+ -+/* No data type wants to be aligned rounder than this. */ -+#define BIGGEST_ALIGNMENT 32 -+ -+/* The best alignment to use in cases where we have a choice. */ -+#define FASTEST_ALIGNMENT 32 -+ -+/* Make strings word-aligned so strcpy from constants will be faster. */ -+/* -+#define CONSTANT_ALIGNMENT(EXP, ALIGN) \ -+ ((TREE_CODE (EXP) == STRING_CST || TREE_CODE (EXP) == CONSTRUCTOR) \ -+ && (ALIGN) < FASTEST_ALIGNMENT \ -+ ? FASTEST_ALIGNMENT : (ALIGN)) -+*/ -+ -+/* One use of this macro is to increase alignment of medium-size -+ data to make it all fit in fewer cache lines. Another is to -+ cause character arrays to be word-aligned so that `strcpy' calls -+ that copy constants to character arrays can be done inline. */ -+/* -+#define DATA_ALIGNMENT(TYPE, ALIGN) \ -+ ((((ALIGN) < FASTEST_ALIGNMENT) \ -+ && (TREE_CODE (TYPE) == ARRAY_TYPE \ -+ || TREE_CODE (TYPE) == UNION_TYPE \ -+ || TREE_CODE (TYPE) == RECORD_TYPE)) ? FASTEST_ALIGNMENT : (ALIGN)) -+*/ /* CHECK - btw code gets bigger with this one */ -+#define DATA_ALIGNMENT(TYPE, ALIGN) \ -+ ((ALIGN) < FASTEST_ALIGNMENT \ -+ ? or1k_data_alignment ((TYPE), (ALIGN)) : (ALIGN)) -+ -+#define LOCAL_ALIGNMENT(TYPE, ALIGN) \ -+ ((ALIGN) < FASTEST_ALIGNMENT \ -+ ? or1k_data_alignment ((TYPE), (ALIGN)) : (ALIGN)) -+ -+/* Define this if move instructions will actually fail to work -+ when given unaligned data. */ -+#define STRICT_ALIGNMENT 1 /* CHECK */ -+ -+/* Align an address */ -+#define OR1K_ALIGN(n,a) (((n) + (a) - 1) & ~((a) - 1)) -+ -+/* Define if operations between registers always perform the operation -+ on the full register even if a narrower mode is specified. */ -+#define WORD_REGISTER_OPERATIONS /* CHECK */ -+ -+ -+/* Define if loading in MODE, an integral mode narrower than BITS_PER_WORD -+ will either zero-extend or sign-extend. The value of this macro should -+ be the code that says which one of the two operations is implicitly -+ done, NIL if none. */ -+#define LOAD_EXTEND_OP(MODE) ZERO_EXTEND -+ -+/* Define this macro if it is advisable to hold scalars in registers -+ in a wider mode than that declared by the program. In such cases, -+ the value is constrained to be within the bounds of the declared -+ type, but kept valid in the wider mode. The signedness of the -+ extension may differ from that of the type. */ -+#define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \ -+ if (GET_MODE_CLASS (MODE) == MODE_INT \ -+ && GET_MODE_SIZE (MODE) < UNITS_PER_WORD) \ -+ (MODE) = SImode; -+ /* CHECK */ -+ -+ -+/* -+ * brings 0.4% improvment in static size for linux -+ * -+#define PROMOTE_FOR_CALL_ONLY -+*/ -+ -+/* Define this macro if it is as good or better to call a constant -+ function address than to call an address kept in a register. */ -+#define NO_FUNCTION_CSE 1 /* check */ -+ -+/* Standard register usage. */ -+ -+/* Number of actual hardware registers. -+ The hardware registers are assigned numbers for the compiler -+ from 0 to just below FIRST_PSEUDO_REGISTER. -+ All registers that the compiler knows about must be given numbers, -+ even those that are not normally considered general registers. */ -+ -+#define OR1K_LAST_ACTUAL_REG 31 -+#define ARG_POINTER_REGNUM (OR1K_LAST_ACTUAL_REG + 1) -+#define FRAME_POINTER_REGNUM (ARG_POINTER_REGNUM + 1) -+#define OR1K_LAST_INT_REG FRAME_POINTER_REGNUM -+#define OR1K_FLAGS_REG (OR1K_LAST_INT_REG + 1) -+#define FIRST_PSEUDO_REGISTER (OR1K_FLAGS_REG + 1) -+ -+/* 1 for registers that have pervasive standard uses -+ and are not available for the register allocator. -+ On the or1k, these are r1 as stack pointer and -+ r2 as frame/arg pointer. r9 is link register, r0 -+ is zero, r10 is linux thread and r16 is got pointer */ -+#define FIXED_REGISTERS { \ -+ 1, 1, 0, 0, 0, 0, 0, 0, \ -+ 0, 1, 1, 0, 0, 0, 0, 0, \ -+ 1, 0, 0, 0, 0, 0, 0, 0, \ -+ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1 } -+/* 1 for registers not available across function calls. -+ These must include the FIXED_REGISTERS and also any -+ registers that can be used without being saved. -+ The latter must include the registers where values are returned -+ and the register where structure-value addresses are passed. -+ Aside from that, you can include as many other registers as you like. */ -+#define CALL_USED_REGISTERS { \ -+ 1, 1, 0, 1, 1, 1, 1, 1, \ -+ 1, 1, 1, 1, 1, 1, 0, 1, \ -+ 1, 1, 0, 1, 0, 1, 0, 1, \ -+ 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1} -+ -+/* stack pointer: must be FIXED and CALL_USED */ -+/* hard frame pointer: must be call saved. */ -+/* soft frame pointer / arg pointer: must be FIXED and CALL_USED */ -+ -+/* Return number of consecutive hard regs needed starting at reg REGNO -+ to hold something of mode MODE. -+ This is ordinarily the length in words of a value of mode MODE -+ but can be less for certain modes in special long registers. -+ On the or1k, all registers are one word long. */ -+#define HARD_REGNO_NREGS(REGNO, MODE) \ -+ ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD) -+ -+/* Value is 1 if hard register REGNO can hold a value of machine-mode MODE. */ -+#define HARD_REGNO_MODE_OK(REGNO, MODE) 1 -+ -+/* Value is 1 if it is a good idea to tie two pseudo registers -+ when one has mode MODE1 and one has mode MODE2. -+ If HARD_REGNO_MODE_OK could produce different values for MODE1 and MODE2, -+ for any hard reg, then this must be 0 for correct output. */ -+#define MODES_TIEABLE_P(MODE1, MODE2) 1 -+ -+/* A C expression for the cost of moving data of mode mode from a register in -+ class "from" to one in class "to". The classes are expressed using the -+ enumeration values such as GENERAL_REGS. A value of 2 is the default; other -+ values are interpreted relative to that. -+ -+ It is not required that the cost always equal 2 when "from" is the same as -+ "to"; on some machines it is expensive to move between registers if they are -+ not general registers. -+ -+ If reload sees an insn consisting of a single set between two hard -+ registers, and if REGISTER_MOVE_COST applied to their classes returns a -+ value of 2, reload does not check to ensure that the constraints of the -+ insn are met. Setting a cost of other than 2 will allow reload to verify -+ that the constraints are met. You should do this if the "movm" pattern's -+ constraints do not allow such copying. -+ -+ JPB 31-Aug-10: This is just the default. */ -+#define REGISTER_MOVE_COST(mode, from, to) 2 -+ -+/* A C expression for the cost of moving data of mode mode between a register -+ of class "class" and memory; "in" is zero if the value is to be written to -+ memory, nonzero if it is to be read in. This cost is relative to those in -+ REGISTER_MOVE_COST. If moving between registers and memory is more -+ expensive than between two registers, you should define this macro to -+ express the relative cost. -+ -+ If you do not define this macro, GCC uses a default cost of 4 plus the cost -+ of copying via a secondary reload register, if one is needed. If your -+ machine requires a secondary reload register to copy between memory and a -+ register of class but the reload mechanism is more complex than copying via -+ an intermediate, define this macro to reflect the actual cost of the move. -+ -+ GCC defines the function "memory_move_secondary_cost" if secondary reloads -+ are needed. It computes the costs due to copying via a secondary -+ register. If your machine copies from memory using a secondary register in -+ the conventional way but the default base value of 4 is not correct for -+ your machine, define this macro to add some other value to the result of -+ that function. The arguments to that function are the same as to this -+ macro. -+ -+ JPB 31-Aug-10. Is this really correct? I suppose the OR1K only takes one -+ cycle, notionally, to access memory, but surely that will -+ often stall the pipeline. Needs more investigation. */ -+#define MEMORY_MOVE_COST(mode, class, in) 2 -+ -+/* A C expression for the cost of a branch instruction. A value of 1 is the -+ default; other values are interpreted relative to that. Parameter "speed_p" -+ is TRUE when the branch in question should be optimized for speed. When it -+ is FALSE, BRANCH_COST should be returning value optimal for code size -+ rather then performance considerations. "predictable_p" is true for well -+ predictable branches. On many architectures the BRANCH_COST can be reduced -+ then. -+ -+ JPB 31-Aug-10. The original code had the comment that "... this should -+ specify the cost of a branch insn; roughly the number of -+ extra insns that should be added to avoid a branch. -+ -+ Set this to 3 on the or1k since that is roughly the average -+ cost of an unscheduled conditional branch. -+ -+ Cost of 2 and 3 give equal and ~0.7% bigger binaries -+ respectively." -+ -+ This seems ad-hoc. Probably we need some experiments. */ -+#define BRANCH_COST(speed_p, predictable_p) 2 -+ -+/* Specify the registers used for certain standard purposes. -+ The values of these macros are register numbers. */ -+ -+/* Register to use for pushing function arguments. */ -+#define STACK_POINTER_REGNUM 1 -+ -+/* Base register for access to local variables of the function. */ -+#define HARD_FRAME_POINTER_REGNUM 2 -+ -+/* Link register. */ -+#define LINK_REGNUM 9 -+ -+/* Register in which static-chain is passed to a function. */ -+ -+#define STATIC_CHAIN_REGNUM 11 -+ -+#define PROLOGUE_TMP 13 -+#define EPILOGUE_TMP 3 -+ -+/* Register in which address to store a structure value -+ is passed to a function. */ -+/*#define STRUCT_VALUE_REGNUM 0*/ -+ -+/* Pass address of result struct to callee as "invisible" first argument */ -+#define STRUCT_VALUE 0 -+ -+/* -----------------------[ PHX start ]-------------------------------- */ -+ -+/* Define the classes of registers for register constraints in the -+ machine description. Also define ranges of constants. -+ -+ One of the classes must always be named ALL_REGS and include all hard regs. -+ If there is more than one class, another class must be named NO_REGS -+ and contain no registers. -+ -+ The name GENERAL_REGS must be the name of a class (or an alias for -+ another name such as ALL_REGS). This is the class of registers -+ that is allowed by "g" or "r" in a register constraint. -+ Also, registers outside this class are allocated only when -+ instructions express preferences for them. -+ -+ GENERAL_REGS and BASE_REGS classess are the same on or1k. -+ -+ The classes must be numbered in nondecreasing order; that is, -+ a larger-numbered class must never be contained completely -+ in a smaller-numbered class. -+ -+ For any two classes, it is very desirable that there be another -+ class that represents their union. */ -+ -+/* The or1k has only one kind of registers, so NO_REGS, GENERAL_REGS -+ and ALL_REGS are the only classes. */ -+/* JPB 26-Aug-10: Based on note from Mikhael (mirekez@gmail.com), we don't -+ need CR_REGS and it is in the wrong place for later things! */ -+enum reg_class -+{ -+ NO_REGS, -+ GENERAL_REGS, -+ ALL_REGS, -+ LIM_REG_CLASSES -+}; -+ -+#define N_REG_CLASSES (int) LIM_REG_CLASSES -+ -+/* Give names of register classes as strings for dump file. */ -+#define REG_CLASS_NAMES \ -+{ \ -+ "NO_REGS", \ -+ "GENERAL_REGS", \ -+ "ALL_REGS" \ -+} -+ -+/* Define which registers fit in which classes. This is an initializer for a -+ vector of HARD_REG_SET of length N_REG_CLASSES. -+ -+ An initializer containing the contents of the register classes, as integers -+ which are bit masks. The Nth integer specifies the contents of class N. -+ The way the integer MASK is interpreted is that register R is in the class -+ if `MASK & (1 << R)' is 1. -+ -+ When the machine has more than 32 registers, an integer does not suffice. -+ Then the integers are replaced by sub-initializers, braced groupings -+ containing several integers. Each sub-initializer must be suitable as an -+ initializer for the type `HARD_REG_SET' which is defined in -+ `hard-reg-set.h'. -+ -+ For the OR1K we have the minimal set. GENERAL_REGS is all except r0, which -+ it permanently zero. */ -+#define REG_CLASS_CONTENTS \ -+ { \ -+ { 0x00000000, 0x00000000 }, /* NO_REGS */ \ -+ { 0xffffffff, 0x00000003 }, /* GENERAL_REGS */ \ -+ { 0xffffffff, 0x00000007 } /* ALL_REGS */ \ -+ } -+ -+/* The same information, inverted: -+ -+ Return the class number of the smallest class containing reg number REGNO. -+ This could be a conditional expression or could index an array. -+ -+ ??? 0 is not really a register, but a constant. */ -+#define REGNO_REG_CLASS(regno) \ -+ ((0 == regno) ? ALL_REGS : ((1 <= regno) && (regno <= OR1K_LAST_INT_REG)) \ -+ ? GENERAL_REGS : NO_REGS) -+ -+/* The class value for index registers, and the one for base regs. */ -+#define INDEX_REG_CLASS GENERAL_REGS -+#define BASE_REG_CLASS GENERAL_REGS -+ -+/* Given an rtx X being reloaded into a reg required to be in class CLASS, -+ return the class of reg to actually use. In general this is just CLASS; -+ but on some machines in some cases it is preferable to use a more -+ restrictive class. */ -+#define PREFERRED_RELOAD_CLASS(X,CLASS) (CLASS) -+ -+/* Return the maximum number of consecutive registers needed to represent mode -+ MODE in a register of class CLASS. -+ -+ On the or1k, this is always the size of MODE in words, since all registers -+ are the same size. */ -+#define CLASS_MAX_NREGS(CLASS, MODE) \ -+ ((GET_MODE_SIZE (MODE) + UNITS_PER_WORD - 1) / UNITS_PER_WORD) -+ -+ -+/* -------------------------------------------------------------------------- */ -+/* Stack layout; function entry, exit and calling. */ -+ -+/* Define this if pushing a word on the stack makes the stack pointer a -+ smaller address. */ -+#define STACK_GROWS_DOWNWARD 1 -+ -+/* Define this if the nominal address of the stack frame is at the -+ high-address end of the local variables; that is, each additional local -+ variable allocated goes at a more negative offset in the frame. */ -+#define FRAME_GROWS_DOWNWARD 1 -+ -+/* Offset within stack frame to start allocating local variables at. If -+ FRAME_GROWS_DOWNWARD, this is the offset to the END of the first local -+ allocated. Otherwise, it is the offset to the BEGINNING of the first local -+ allocated. */ -+#define STARTING_FRAME_OFFSET 0 -+ -+/* Offset of first parameter from the argument pointer register value. */ -+#define FIRST_PARM_OFFSET(FNDECL) 0 -+ -+/* Define this if stack space is still allocated for a parameter passed -+ in a register. The value is the number of bytes allocated to this -+ area. -+ -+ No such allocation for OR1K. */ -+/* #define REG_PARM_STACK_SPACE(FNDECL) (UNITS_PER_WORD * GP_ARG_NUM_REG) */ -+ -+/* Define this if the above stack space is to be considered part of the -+ space allocated by the caller. -+ -+ N/a for OR1K. */ -+/* #define OUTGOING_REG_PARM_STACK_SPACE */ -+ -+/* Define this macro if `REG_PARM_STACK_SPACE' is defined, but the -+ stack parameters don't skip the area specified by it. -+ -+ N/a for OR1K. */ -+/* #define STACK_PARMS_IN_REG_PARM_AREA */ -+ -+/* If nonzero, the maximum amount of space required for outgoing arguments -+ will be computed and placed into the variable -+ current_function_outgoing_args_size. No space will be pushed onto the stack -+ for each call; instead, the function prologue should increase the stack -+ frame size by this amount. -+ -+ Setting both PUSH_ARGS and ACCUMULATE_OUTGOING_ARGS is not proper. -+ -+ This is the approached used by OR1K. */ -+#define ACCUMULATE_OUTGOING_ARGS 1 -+ -+#define ELIMINABLE_REGS \ -+{{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \ -+ { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \ -+ { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \ -+ { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}} -+ -+#define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \ -+ (OFFSET) = or1k_initial_elimination_offset ((FROM), (TO)) -+ -+/* Minimum and maximum general purpose registers used to hold arguments. */ -+#define GP_ARG_MIN_REG 3 -+#define GP_ARG_MAX_REG 8 -+#define GP_ARG_NUM_REG (GP_ARG_MAX_REG - GP_ARG_MIN_REG + 1) -+ -+/* Return register */ -+#define GP_ARG_RETURN 11 -+#define GP_ARG_RETURNH 12 -+ -+/* TLS thread pointer register */ -+#define THREAD_PTR_REGNUM 10 -+ -+/* Position Independent Code. */ -+ -+#define PIC_OFFSET_TABLE_REGNUM 16 -+ -+/* A C expression that is nonzero if X is a legitimate immediate -+ operand on the target machine when generating position independent code. -+ You can assume that X satisfies CONSTANT_P, so you need not -+ check this. You can also assume `flag_pic' is true, so you need not -+ check it either. You need not define this macro if all constants -+ (including SYMBOL_REF) can be immediate operands when generating -+ position independent code. */ -+#define LEGITIMATE_PIC_OPERAND_P(X) or1k_legitimate_pic_operand_p (X) -+ -+/* A C expression to create an RTX representing the place where a library -+ function returns a value of mode mode. -+ -+ Note that “library function” in this context means a compiler support -+ routine, used to perform arithmetic, whose name is known specially by the -+ compiler and was not mentioned in the C code being compiled. -+ -+ For the OR1K, return value is in R11 (GP_ARG_RETURN). */ -+#define LIBCALL_VALUE(mode) \ -+ gen_rtx_REG( \ -+ ((GET_MODE_CLASS (mode) != MODE_INT \ -+ || GET_MODE_SIZE (mode) >= 4) \ -+ ? (mode) \ -+ : SImode), \ -+ GP_ARG_RETURN) -+ -+/* Define this if PCC uses the nonreentrant convention for returning -+ structure and union values. -+ -+ Not needed for OR1K. */ -+/*#define PCC_STATIC_STRUCT_RETURN */ -+ -+/* A C expression that is nonzero if regno is the number of a hard register in -+ which the values of called function may come back. -+ -+ A register whose use for returning values is limited to serving as the -+ second of a pair (for a value of type double, say) need not be recognized -+ by this macro. So for most machines, this definition suffices: -+ -+ #define FUNCTION_VALUE_REGNO_P(N) ((N) == 0) -+ -+ If the machine has register windows, so that the caller and the called -+ function use different registers for the return value, this macro should -+ recognize only the caller's register numbers. -+ -+ For OR1K, we must check if we have the return register. -+ -+ From GCC 4.6, this will be replaced by TARGET_FUNCION_VALUE_REGNO_P target -+ hook function. */ -+#define FUNCTION_VALUE_REGNO_P(N) ((N) == GP_ARG_RETURN) -+ -+/* 1 if N is a possible register number for function argument passing. */ -+#define FUNCTION_ARG_REGNO_P(N) \ -+ ((N) >= GP_ARG_MIN_REG && (N) <= GP_ARG_MAX_REG) -+ -+/* A code distinguishing the floating point format of the target -+ machine. There are three defined values: IEEE_FLOAT_FORMAT, -+ VAX_FLOAT_FORMAT, and UNKNOWN_FLOAT_FORMAT. */ -+#define TARGET_FLOAT_FORMAT IEEE_FLOAT_FORMAT -+#define FLOAT_WORDS_BIG_ENDIAN 1 -+ -+/* A C type for declaring a variable that is used as the first argument of -+ FUNCTION_ARG and other related values. For some target machines, the type -+ int suffices and can hold the number of bytes of argument so far. -+ -+ There is no need to record in CUMULATIVE_ARGS anything about the arguments -+ that have been passed on the stack. The compiler has other variables to -+ keep track of that. For target machines on which all arguments are passed -+ on the stack, there is no need to store anything in CUMULATIVE_ARGS; -+ however, the data structure must exist and should not be empty, so use -+ int. */ -+#define CUMULATIVE_ARGS int -+ -+/* A C statement (sans semicolon) for initializing the variable "cum" for the -+ state at the beginning of the argument list. The variable has type -+ CUMULATIVE_ARGS. The value of "fntype" is the tree node for the data type -+ of the function which will receive the args, or 0 if the args are to a -+ compiler support library function. For direct calls that are not libcalls, -+ "fndecl" contain the declaration node of the function. "fndecl" is also set -+ when INIT_CUMULATIVE_ARGS is used to find arguments for the function being -+ compiled. "n_named_args" is set to the number of named arguments, -+ including a structure return address if it is passed as a parameter, when -+ making a call. When processing incoming arguments, "n_named_args" is set to -+ −1. -+ -+ When processing a call to a compiler support library function, "libname" -+ identifies which one. It is a symbol_ref rtx which contains the name of the -+ function, as a string. "libname" is 0 when an ordinary C function call is -+ being processed. Thus, each time this macro is called, either "libname" or -+ "fntype" is nonzero, but never both of them at once. -+ -+ For the OR1K, we set "cum" to zero each time. -+ JPB 29-Aug-10: Is this correct? */ -+#define INIT_CUMULATIVE_ARGS(cum, fntype, libname, fndecl, n_named_args) \ -+ (cum = 0) -+ -+/* -------------------------------------------------------------------------- */ -+/* Define intermediate macro to compute the size (in registers) of an argument -+ for the or1k. -+ -+ The OR1K_ROUND_ADVANCE* macros are local to this file. */ -+ -+/* Round "size" up to a word boundary. */ -+#define OR1K_ROUND_ADVANCE(size) \ -+ (((size) + UNITS_PER_WORD - 1) / UNITS_PER_WORD) -+ -+/* Round arg "mode"/"type" up to the next word boundary. */ -+#define OR1K_ROUND_ADVANCE_ARG(mode, type) \ -+ ((mode) == BLKmode \ -+ ? OR1K_ROUND_ADVANCE (int_size_in_bytes (type)) \ -+ : OR1K_ROUND_ADVANCE (GET_MODE_SIZE (mode))) -+ -+/* The ABI says that no rounding to even or odd words takes place. */ -+#define OR1K_ROUND_ADVANCE_CUM(cum, mode, type) (cum) -+ -+/* Return boolean indicating if arg of type "type" and mode "mode" will be -+ passed in a reg. This includes arguments that have to be passed by -+ reference as the pointer to them is passed in a reg if one is available -+ (and that is what we're given). -+ -+ When passing arguments "named" is always 1. When receiving arguments -+ "named" is 1 for each argument except the last in a stdarg/varargs -+ function. In a stdarg function we want to treat the last named arg as -+ named. In a varargs function we want to treat the last named arg (which is -+ `__builtin_va_alist') as unnamed. -+ -+ This macro is only used in this file. */ -+#define OR1K_PASS_IN_REG_P(cum, mode, type, named) \ -+ ((named) \ -+ && ((OR1K_ROUND_ADVANCE_CUM ((cum), (mode), (type)) \ -+ + OR1K_ROUND_ADVANCE_ARG ((mode), (type)) \ -+ <= GP_ARG_NUM_REG))) -+ -+/* Output assembler code to FILE to increment profiler label # LABELNO -+ for profiling a function entry. */ -+#define FUNCTION_PROFILER(FILE, LABELNO) -+ -+/* EXIT_IGNORE_STACK should be nonzero if, when returning from a function, the -+ stack pointer does not matter. The value is tested only in functions that -+ have frame pointers. No definition is equivalent to always zero. -+ -+ The default suffices for OR1K. */ -+#define EXIT_IGNORE_STACK 0 -+ -+/* A C expression whose value is RTL representing the location of the -+ incoming return address at the beginning of any function, before the -+ prologue. This RTL is either a REG, indicating that the return -+ value is saved in REG, or a MEM representing a location in -+ the stack. */ -+#define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (Pmode, LINK_REGNUM) -+ -+#define RETURN_ADDR_RTX or1k_return_addr_rtx -+ -+/* Addressing modes, and classification of registers for them. */ -+ -+/* #define HAVE_POST_INCREMENT */ -+/* #define HAVE_POST_DECREMENT */ -+ -+/* #define HAVE_PRE_DECREMENT */ -+/* #define HAVE_PRE_INCREMENT */ -+ -+/* Macros to check register numbers against specific register classes. */ -+#define MAX_REGS_PER_ADDRESS 1 -+ -+/* True if X is an rtx for a constant that is a valid address. -+ -+ JPB 29-Aug-10: Why is the default implementation not OK? */ -+#define CONSTANT_ADDRESS_P(X) \ -+ (GET_CODE (X) == LABEL_REF || GET_CODE (X) == SYMBOL_REF \ -+ || GET_CODE (X) == CONST_INT || GET_CODE (X) == CONST \ -+ || GET_CODE (X) == HIGH) -+ -+/* A C expression which is nonzero if register number num is suitable for use -+ as a base register in operand addresses. Like TARGET_LEGITIMATE_ADDRESS_P, -+ this macro should also define a strict and a non-strict variant. Both -+ variants behave the same for hard register; for pseudos, the strict variant -+ will pass only those that have been allocated to a valid hard registers, -+ while the non-strict variant will pass all pseudos. -+ -+ Compiler source files that want to use the strict variant of this and other -+ macros define the macro REG_OK_STRICT. You should use an #ifdef -+ REG_OK_STRICT conditional to define the strict variant in that case and the -+ non-strict variant otherwise. -+ -+ JPB 29-Aug-10: This has been conflated with the old REG_OK_FOR_BASE_P -+ function, which is no longer part of GCC. -+ -+ I'm not sure this is right. r0 can be a base register, just -+ it can't get set by the user. */ -+#ifdef REG_OK_STRICT -+#define REGNO_OK_FOR_BASE_P(num) \ -+ ( ((0 < (num)) && ((num) <= OR1K_LAST_INT_REG)) \ -+ || ((0 < reg_renumber[num]) && (reg_renumber[num] <= OR1K_LAST_INT_REG))) -+ -+#else -+/* Accept an int register or a pseudo reg. -+ -+ JPB 1-Sep-10: Should this allow r0, if the strict version does not? */ -+#define REGNO_OK_FOR_BASE_P(num) ((num) <= OR1K_LAST_INT_REG || \ -+ (num) >= FIRST_PSEUDO_REGISTER) -+#endif -+ -+/* OR1K doesn't have any indexed addressing. */ -+#define REG_OK_FOR_INDEX_P(X) 0 -+#define REGNO_OK_FOR_INDEX_P(X) 0 -+ -+ -+/* Specify the machine mode that this machine uses for the index in the -+ tablejump instruction. */ -+#define CASE_VECTOR_MODE SImode -+ -+/* Define as C expression which evaluates to nonzero if the tablejump -+ instruction expects the table to contain offsets from the address of the -+ table. -+ -+ Do not define this if the table should contain absolute addresses. */ -+/* #define CASE_VECTOR_PC_RELATIVE 1 */ -+ -+/* Define this as 1 if `char' should by default be signed; else as 0. */ -+#define DEFAULT_SIGNED_CHAR 1 -+ -+/* The maximum number of bytes that a single instruction can move quickly -+ between memory and registers or between two memory locations. */ -+#define MOVE_MAX 4 -+ -+/* Define this if zero-extension is slow (more than one real instruction). */ -+/* #define SLOW_ZERO_EXTEND */ -+ -+/* Nonzero if access to memory by bytes is slow and undesirable. -+ For RISC chips, it means that access to memory by bytes is no -+ better than access by words when possible, so grab a whole word -+ and maybe make use of that. */ -+#define SLOW_BYTE_ACCESS 1 -+ -+/* Define if shifts truncate the shift count -+ which implies one can omit a sign-extension or zero-extension -+ of a shift count. */ -+/* #define SHIFT_COUNT_TRUNCATED */ -+ -+/* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits -+ is done just by pretending it is already truncated. */ -+#define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) 1 -+ -+/* Specify the machine mode that pointers have. -+ After generation of rtl, the compiler makes no further distinction -+ between pointers and any other objects of this machine mode. */ -+#define Pmode SImode -+ -+/* A function address in a call instruction -+ is a byte address (for indexing purposes) -+ so give the MEM rtx a byte's mode. */ -+#define FUNCTION_MODE SImode -+ -+ -+/* -------------------------------------------------------------------------- */ -+/* Condition code stuff */ -+ -+/* Given a comparison code (EQ, NE, etc.) and the first operand of a COMPARE, -+ return the mode to be used for the comparison. */ -+#define SELECT_CC_MODE(op, x, y) or1k_select_cc_mode(op) -+ -+/* Can the condition code MODE be safely reversed? This is safe in -+ all cases on this port, because at present it doesn't use the -+ trapping FP comparisons (fcmpo). */ -+#define REVERSIBLE_CC_MODE(mode) 1 -+ -+/* Given a condition code and a mode, return the inverse condition. -+ -+ JPB 31-Aug-10: This seems like the default. Do we even need this? */ -+#define REVERSE_CONDITION(code, mode) reverse_condition (code) -+ -+ -+/* -------------------------------------------------------------------------- */ -+/* Control the assembler format that we output. */ -+ -+/* A C string constant describing how to begin a comment in the target -+ assembler language. The compiler assumes that the comment will end at -+ the end of the line. */ -+#define ASM_COMMENT_START "#" -+ -+/* Output to assembler file text saying following lines may contain character -+ constants, extra white space, comments, etc. -+ -+ JPB 29-Aug-10: Default would seem to be OK here. */ -+#define ASM_APP_ON "#APP\n" -+ -+/* Output to assembler file text saying following lines no longer contain -+ unusual constructs. -+ -+ JPB 29-Aug-10: Default would seem to be OK here. */ -+#define ASM_APP_OFF "#NO_APP\n" -+ -+/* Switch to the text or data segment. */ -+ -+/* Output before read-only data. */ -+#define TEXT_SECTION_ASM_OP "\t.section .text" -+ -+/* Output before writable data. */ -+#define DATA_SECTION_ASM_OP "\t.section .data" -+ -+/* Output before uninitialized data. */ -+#define BSS_SECTION_ASM_OP "\t.section .bss" -+ -+/* How to refer to registers in assembler output. This sequence is indexed by -+ compiler's hard-register-number (see above). */ -+#define REGISTER_NAMES \ -+ {"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", \ -+ "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15", \ -+ "r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23", \ -+ "r24", "r25", "r26", "r27", "r28", "r29", "r30", "r31", \ -+ "argp", "frame", "cc-flag"} -+ -+ -+/* -------------------------------------------------------------------------- */ -+/* Debug things for DBX (STABS) */ -+/* */ -+/* Note. Our config.gcc includes dbxelf.h, which sets up appropriate */ -+/* defaults. Choice of which debug format to use is in our elf.h */ -+/* -------------------------------------------------------------------------- */ -+ -+/* Don't try to use the type-cross-reference character in DBX data. -+ Also has the consequence of putting each struct, union or enum -+ into a separate .stabs, containing only cross-refs to the others. */ -+/* JPB 24-Aug-10: Is this really correct. Can't GDB use this info? */ -+#define DBX_NO_XREFS -+ -+/* -------------------------------------------------------------------------- */ -+/* Debug things for DWARF2 */ -+/* */ -+/* Note. Choice of which debug format to use is in our elf.h */ -+/* -------------------------------------------------------------------------- */ -+ -+/* We support frame unwind info including for exceptions handling. This needs -+ INCOMING_RETURN_ADDR_RTX to be set and OBJECT_FORMAT_ELF to be defined (in -+ elfos.h). Override any default value. */ -+#undef DWARF2_UNWIND_INFO -+#define DWARF2_UNWIND_INFO 1 -+ -+/* We want frame info produced. Note that this is superfluous if -+ DWARF2_UNWIND_INFO is non-zero, but we set so this so, we can produce frame -+ info even when it is zero. Override any default value. */ -+#undef DWARF2_FRAME_INFO -+#define DWARF2_FRAME_INFO 1 -+ -+/* Macro specifying which register holds the return address */ -+#define DWARF_FRAME_RETURN_COLUMN DWARF_FRAME_REGNUM (LINK_REGNUM) -+ -+/* Where is the start of our stack frame in relation to the end of the -+ previous stack frame at the start of a function, before the prologue */ -+#define INCOMING_FRAME_SP_OFFSET 0 -+ -+/* Use compact debug tables. Generates .file/.loc directives. */ -+#undef DWARF2_ASM_LINE_DEBUG_INFO -+#define DWARF2_ASM_LINE_DEBUG_INFO 1 -+ -+/* We don't need an alternative return address for now. */ -+/* DWARF_ALT_FRAME_RETURN_COLUMN */ -+ -+/* We always save registers in the prologue with word alignment, so don't -+ need this. */ -+/* DWARF_CIE_DATA_ALIGNMENT */ -+ -+/* This specifies the maximum number of registers we can save in a frame. We -+ could note that only SP, FP, LR, arg regs and callee saved regs come into -+ this category. However this is only an efficiency thing, so for now we -+ don't use it. */ -+/* DWARF_FRAME_REGISTERS */ -+ -+/* This specifies a mapping from register numbers in .dwarf_frame to -+ .eh_frame. However for us they are the same, so we don't need it. */ -+/* DWARF_FRAME_REGNUM */ -+ -+/* Defined if the DWARF column numbers do not match register numbers. For us -+ they do, so this is not needed. */ -+/* DWARF_REG_TO_UNWIND_COLUMN */ -+ -+/* Can be used to define a register guaranteed to be zero. Only useful if zero -+ is used to terminate backtraces, and not recommended for new ports, so we -+ don't use it. */ -+/* DWARF_ZERO_REG */ -+ -+/* This is the inverse function for DWARF_FRAME_REGNUM. Again not needed. */ -+/* DWARF2_FRAME_REG_OUT */ -+ -+ -+/* -------------------------------------------------------------------------- */ -+/* Node: Label Output */ -+ -+/* Globalizing directive for a label. */ -+#define GLOBAL_ASM_OP "\t.global " -+ -+#define SUPPORTS_WEAK 1 -+ -+/* This is how to output the definition of a user-level label named NAME, -+ such as the label on a static function or variable NAME. */ -+#define ASM_OUTPUT_LABEL(FILE,NAME) \ -+ { assemble_name (FILE, NAME); fputs (":\n", FILE); } -+ -+/* We use -fleading-underscore to add it, when necessary. -+ JPB: No prefix for global symbols */ -+#define USER_LABEL_PREFIX "" -+ -+/* Remove any previous definition (elfos.h). */ -+#define ASM_GENERATE_INTERNAL_LABEL(LABEL, PREFIX, NUM) \ -+ sprintf (LABEL, "*%s%d", PREFIX, NUM) -+ -+/* This is how to output an assembler line defining an int constant. */ -+#define ASM_OUTPUT_INT(stream, value) \ -+ { \ -+ fprintf (stream, "\t.word\t"); \ -+ output_addr_const (stream, (value)); \ -+ fprintf (stream, "\n")} -+ -+/* This is how to output an assembler line defining a float constant. */ -+#define ASM_OUTPUT_FLOAT(stream, value) \ -+ { long l; \ -+ REAL_VALUE_TO_TARGET_SINGLE (value,l); \ -+ fprintf(stream,"\t.word\t0x%08x\t\t# float %26.7e\n", l, value); } -+ -+/* This is how to output an assembler line defining a double constant. */ -+#define ASM_OUTPUT_DOUBLE(stream, value) \ -+ { long l[2]; \ -+ REAL_VALUE_TO_TARGET_DOUBLE (value,&l[0]); \ -+ fprintf(stream,"\t.word\t0x%08x,0x%08x\t# float %26.16le\n", \ -+ l[0],l[1],value); } -+ -+/* This is how to output an assembler line defining a long double constant. -+ -+ JPB 29-Aug-10: Do we really mean this. I thought long double on OR1K was -+ the same as double. */ -+#define ASM_OUTPUT_LONG_DOUBLE(stream, value) \ -+ { long l[4]; \ -+ REAL_VALUE_TO_TARGET_DOUBLE (value,&l[0]); \ -+ fprintf (stream, \ -+ "\t.word\t0x%08x,0x%08x,0x%08x,0x%08x\t# float %26.18lle\n", \ -+ l[0],l[1],l[2],l[3],value); } -+ -+/* This is how to output an assembler line defining a short constant. */ -+#define ASM_OUTPUT_SHORT(stream, value) \ -+ { fprintf (stream, "\t.half\t"); \ -+ output_addr_const (stream, (value)); \ -+ fprintf (stream, "\n"); } -+ -+/* This is how to output an assembler line defining a char constant. */ -+#define ASM_OUTPUT_CHAR(stream, value) \ -+ { fprintf (stream, "\t.byte\t"); \ -+ output_addr_const (stream, (value)); \ -+ fprintf (stream, "\n")} -+ -+/* This is how to output an assembler line for a numeric constant byte. */ -+#define ASM_OUTPUT_BYTE(stream, value) \ -+ fprintf (stream, "\t.byte\t0x%02x\n", (value)) -+ -+/* This is how to output an insn to push a register on the stack. -+ It need not be very fast code. -+ -+ JPB 29-Aug-10: This was using l.sub (since we don't have l.subi), so it -+ was potty code. Replaced by adding immediate -1. */ -+#define ASM_OUTPUT_REG_PUSH(stream, regno) \ -+ { fprintf (stream, "\tl.addi\tr1,r1,-4\n"); \ -+ fprintf (stream, "\tl.sw\t0(r1),%s\n", reg_names[regno]); } -+ -+/* This is how to output an insn to pop a register from the stack. -+ It need not be very fast code. */ -+#define ASM_OUTPUT_REG_POP(stream,REGNO) \ -+ { fprintf (stream, "\tl.lwz\t%s,0(r1)\n", reg_names[REGNO]); \ -+ fprintf (stream, "\tl.addi\tr1,r1,4\n"); } -+ -+/* This is how to output an element of a case-vector that is absolute. -+ (The Vax does not use such vectors, -+ but we must define this macro anyway.) */ -+#define ASM_OUTPUT_ADDR_VEC_ELT(stream, value) \ -+ fprintf (stream, "\t.word\t.L%d\n", value) -+ -+/* This is how to output an element of a case-vector that is relative. */ -+#define ASM_OUTPUT_ADDR_DIFF_ELT(stream, body, value, rel) \ -+ fprintf (stream, "\t.word\t.L%d-.L%d\n", value, rel) -+ -+#define JUMP_TABLES_IN_TEXT_SECTION (flag_pic) -+/* ??? If we were serious about PIC, we should also use l.jal to get -+ the table start address. */ -+ -+/* This is how to output an assembler line that says to advance the location -+ counter to a multiple of 2**log bytes. */ -+#define ASM_OUTPUT_ALIGN(stream, log) \ -+ if ((log) != 0) \ -+ { \ -+ fprintf (stream, "\t.align\t%d\n", 1 << (log)); \ -+ } -+ -+/* This is how to output an assembler line that says to advance the location -+ counter by "size" bytes. */ -+#define ASM_OUTPUT_SKIP(stream, size) \ -+ fprintf (stream, "\t.space %d\n", (size)) -+ -+/* Need to split up .ascii directives to avoid breaking -+ the linker. */ -+ -+/* This is how to output a string. */ -+#define ASM_OUTPUT_ASCII(stream, ptr, len) \ -+ output_ascii_pseudo_op (stream, (const unsigned char *) (ptr), len) -+ -+/* Invoked just before function output. */ -+#define ASM_OUTPUT_FUNCTION_PREFIX(stream, fnname) \ -+ { fputs (".proc\t", stream); assemble_name (stream, fnname); \ -+ fputs ("\n", stream); } -+ -+/* This says how to output an assembler line to define a global common -+ symbol. */ -+#define ASM_OUTPUT_COMMON(stream,name,size,rounded) \ -+ { data_section (); \ -+ fputs ("\t.global\t", stream); \ -+ assemble_name(stream, name); \ -+ fputs ("\n", stream); \ -+ assemble_name (stream, name); \ -+ fputs (":\n", stream); \ -+ fprintf (stream, "\t.space\t%d\n", rounded); } -+ -+/* This says how to output an assembler line to define a local common -+ symbol. -+ -+ JPB 29-Aug-10: I'm sure this doesn't work - we don't have a .bss directive -+ like this. */ -+#define ASM_OUTPUT_LOCAL(stream, name, size, rounded) \ -+ { fputs ("\t.bss\t", (stream)); \ -+ assemble_name ((stream), (name)); \ -+ fprintf ((stream), ",%d,%d\n", (size), (rounded)); } -+ -+/* This says how to output an assembler line to define a global common symbol -+ with size "size" (in bytes) and alignment "align" (in bits). */ -+#define ASM_OUTPUT_ALIGNED_COMMON(stream, name, size, align) \ -+ { data_section(); \ -+ if ((ALIGN) > 8) \ -+ { \ -+ fprintf(stream, "\t.align %d\n", ((align) / BITS_PER_UNIT)); \ -+ } \ -+ fputs("\t.global\t", stream); assemble_name(stream, name); \ -+ fputs("\n", stream); \ -+ assemble_name(stream, name); \ -+ fputs (":\n", stream); \ -+ fprintf(stream, "\t.space\t%d\n", size); } -+ -+/* This says how to output an assembler line to define a local common symbol -+ with size "size" (in bytes) and alignment "align" (in bits). */ -+#define ASM_OUTPUT_ALIGNED_LOCAL(stream, name, size, align) \ -+ { data_section(); \ -+ if ((align) > 8) \ -+ { \ -+ fprintf(stream, "\t.align %d\n", ((align) / BITS_PER_UNIT)); \ -+ } \ -+ assemble_name(stream, name); \ -+ fputs (":\n", stream); \ -+ fprintf(stream, "\t.space %d\n", size); } -+ -+/* Store in "output" a string (made with alloca) containing an assembler-name -+ for a local static variable named "name". "labelno" is an integer which is -+ different for each call. */ -+#define ASM_FORMAT_PRIVATE_NAME(output, name, labelno) \ -+ { (output) = (char *) alloca (strlen ((name)) + 10); \ -+ sprintf ((output), "%s.%lu", (name), (unsigned long int) (labelno)); } -+ -+/* Macro for %code validation. Returns nonzero if valid. -+ -+ The acceptance of '(' is an idea taken from SPARC; output nop for %( if not -+ optimizing or the slot is not filled. */ -+#define PRINT_OPERAND_PUNCT_VALID_P(code) (('(' == code) || ('%' == code)) -+ -+/* Print an instruction operand "x" on file "stream". "code" is the code from -+ the %-spec that requested printing this operand; if `%z3' was used to print -+ operand 3, then CODE is 'z'. */ -+#define PRINT_OPERAND(stream, x, code) \ -+{ \ -+ if (code == 'r' \ -+ && GET_CODE (x) == MEM \ -+ && GET_CODE (XEXP (x, 0)) == REG) \ -+ { \ -+ fprintf (stream, "%s", reg_names[REGNO (XEXP (x, 0))]); \ -+ } \ -+ else if (code == '(') \ -+ { \ -+ if (TARGET_DELAY_ON && dbr_sequence_length ()) \ -+ fprintf (stream, "\t# delay slot filled"); \ -+ else if (!TARGET_DELAY_OFF) \ -+ fprintf (stream, "\n\tl.nop\t\t\t# nop delay slot"); \ -+ } \ -+ else if (code == 'C') \ -+ { \ -+ switch (GET_CODE (x)) \ -+ { \ -+ case EQ: \ -+ fputs ("eq", stream); \ -+ break; \ -+ case NE: \ -+ fputs ("ne", stream); \ -+ break; \ -+ case GT: \ -+ fputs ("gts", stream); \ -+ break; \ -+ case GE: \ -+ fputs ("ges", stream); \ -+ break; \ -+ case LT: \ -+ fputs ("lts", stream); \ -+ break; \ -+ case LE: \ -+ fputs ("les", stream); \ -+ break; \ -+ case GTU: \ -+ fputs ("gtu", stream); \ -+ break; \ -+ case GEU: \ -+ fputs ("geu", stream); \ -+ break; \ -+ case LTU: \ -+ fputs ("ltu", stream); \ -+ break; \ -+ case LEU: \ -+ fputs ("leu", stream); \ -+ break; \ -+ default: \ -+ abort (); \ -+ } \ -+ } \ -+ else if (code == 'H') \ -+ { \ -+ if (GET_CODE (x) == REG) \ -+ fprintf (stream, "%s", reg_names[REGNO (x) + 1]); \ -+ else \ -+ abort (); \ -+ } \ -+ else if (GET_CODE (x) == REG) \ -+ fprintf (stream, "%s", reg_names[REGNO (x)]); \ -+ else if (GET_CODE (x) == MEM) \ -+ output_address (XEXP (x, 0)); \ -+ else \ -+ output_addr_const (stream, x); \ -+} -+ -+/* The size of the trampoline in bytes. This is a block of code followed by -+ two words specifying the function address and static chain pointer. */ -+#define TRAMPOLINE_SIZE \ -+ (or1k_trampoline_code_size () + GET_MODE_SIZE (ptr_mode) * 2) -+ -+/* Alignment required for trampolines, in bits. -+ -+ For the OR1K, there is no need for anything other than word alignment. */ -+#define TRAMPOLINE_ALIGNMENT 32 -+ -+/* Assume that if the assembler supports thread local storage -+ * the system supports it. */ -+#if !defined(TARGET_HAVE_TLS) && defined(HAVE_AS_TLS) -+#define TARGET_HAVE_TLS true -+#endif -+ -+/* Describe how we implement __builtin_eh_return. */ -+#define EH_RETURN_REGNUM 23 -+/* Use r25, r27, r29 and r31 (clobber regs) for exception data */ -+#define EH_RETURN_DATA_REGNO(N) ((N) < 4 ? (25 + ((N)<<1)) : INVALID_REGNUM) -+#define EH_RETURN_STACKADJ_RTX gen_rtx_REG (Pmode, EH_RETURN_REGNUM) -+#define EH_RETURN_HANDLER_RTX or1k_eh_return_handler_rtx () -+ -+#define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \ -+ (flag_pic ? DW_EH_PE_pcrel : DW_EH_PE_absptr) -+ -+#define INIT_EXPANDERS or1k_init_expanders () -+ -+/* A C structure for machine-specific, per-function data. This is -+ * added to the cfun structure. */ -+typedef struct GTY(()) machine_function -+{ -+ /* Force stack save of LR. Used in RETURN_ADDR_RTX. */ -+ int force_lr_save; -+} machine_function; -+ -+#endif /* _OR1K_H_ */ -diff -rNU3 dist.orig/gcc/config/or1k/or1k.md dist/gcc/config/or1k/or1k.md ---- dist.orig/gcc/config/or1k/or1k.md 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/or1k/or1k.md 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,1599 @@ -+;; Machine description for GNU compiler, OpenRISC 1000 family, OR32 ISA -+;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, -+;; 2009, 2010 Free Software Foundation, Inc. -+;; Copyright (C) 2010 Embecosm Limited -+ -+;; Contributed by Damjan Lampret in 1999. -+;; Major optimizations by Matjaz Breskvar in 2005. -+;; Floating point additions by Jungsook Yang -+;; Julius Baxter in 2010 -+;; Updated for GCC 4.5 by Jeremy Bennett -+;; and Joern Rennecke in 2010 -+ -+;; This file is part of GNU CC. -+ -+;; This program is free software; you can redistribute it and/or modify it -+;; under the terms of the GNU General Public License as published by the Free -+;; Software Foundation; either version 3 of the License, or (at your option) -+;; any later version. -+;; -+;; This program is distributed in the hope that it will be useful, but WITHOUT -+;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -+;; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -+;; more details. -+;; -+;; You should have received a copy of the GNU General Public License along -+;; with this program. If not, see . */ -+ -+(define_constants [ -+ (SP_REG 1) -+ (FP_REG 2) ; hard frame pointer -+ (CC_REG 34) -+ -+ ;; unspec values -+ (UNSPEC_FRAME 0) -+ (UNSPEC_GOT 1) -+ (UNSPEC_GOTOFFHI 2) -+ (UNSPEC_GOTOFFLO 3) -+ (UNSPEC_TPOFFLO 4) -+ (UNSPEC_TPOFFHI 5) -+ (UNSPEC_GOTTPOFFLO 6) -+ (UNSPEC_GOTTPOFFHI 7) -+ (UNSPEC_GOTTPOFFLD 8) -+ (UNSPEC_TLSGDLO 9) -+ (UNSPEC_TLSGDHI 10) -+ (UNSPEC_SET_GOT 101) -+ (UNSPEC_CMPXCHG 201) -+ (UNSPEC_FETCH_AND_OP 202) -+]) -+ -+(include "predicates.md") -+ -+(include "constraints.md") -+ -+(define_attr "type" -+ "unknown,load,store,move,extend,logic,add,mul,shift,compare,branch,jump,fp,jump_restore" -+ (const_string "unknown")) -+ -+;; Number of machine instructions required to implement an insn. -+(define_attr "length" "" (const_int 1)) -+ -+;; Single delay slot after branch or jump instructions, wich may contain any -+;; instruction but another branch or jump. -+;; If TARGET_DELAY_OFF is not true, then never use delay slots. -+;; If TARGET_DELAY_ON is not true, no instruction will be allowed to -+;; fill the slot, and so it will be filled by a nop instead. -+(define_delay -+ (and (match_test "!TARGET_DELAY_OFF") (eq_attr "type" "branch,jump")) -+ [(and (match_test "TARGET_DELAY_ON") -+ (eq_attr "type" "!branch,jump") -+ (eq_attr "length" "1")) (nil) (nil)]) -+ -+;; ALU is modelled as a single functional unit, which is reserved for varying -+;; numbers of slots. -+;; -+;; I think this is all incorrect for the OR1K. The latency says when the -+;; result will be ready, not how long the pipeline takes to execute. -+(define_cpu_unit "or1k_alu") -+(define_insn_reservation "bit_unit" 3 (eq_attr "type" "shift") "or1k_alu") -+(define_insn_reservation "lsu_load" 3 (eq_attr "type" "load") "or1k_alu*3") -+(define_insn_reservation "lsu_store" 2 (eq_attr "type" "store") "or1k_alu") -+(define_insn_reservation "alu_unit" 2 -+ (eq_attr "type" "add,logic,extend,move,compare") -+ "or1k_alu") -+(define_insn_reservation "mul_unit" 16 (eq_attr "type" "mul") "or1k_alu*16") -+ -+;; AI = Atomic Integers -+;; We do not support DI in our atomic operations. -+(define_mode_iterator AI [QI HI SI]) -+ -+;; Note: We use 'mult' here for nand since it does not have its own RTX class. -+(define_code_iterator atomic_op [plus minus and ior xor mult]) -+(define_code_attr op_name -+ [(plus "add") (minus "sub") (and "and") (ior "or") (xor "xor") (mult "nand")]) -+(define_code_attr op_insn -+ [(plus "add") (minus "sub") (and "and") (ior "or") (xor "xor") (mult "and")]) -+(define_code_attr post_op_insn -+ [(plus "") (minus "") (and "") (ior "") (xor "") -+ (mult "l.xori \t%3,%3,0xffff # fetch_nand: invert")]) -+ -+;; Called after register allocation to add any instructions needed for the -+;; prologue. Using a prologue insn is favored compared to putting all of the -+;; instructions in output_function_prologue(), since it allows the scheduler -+;; to intermix instructions with the saves of the caller saved registers. In -+;; some cases, it might be necessary to emit a barrier instruction as the last -+;; insn to prevent such scheduling. -+ -+(define_expand "prologue" -+ [(use (const_int 1))] -+ "" -+{ -+ or1k_expand_prologue (); -+ DONE; -+}) -+ -+;; Called after register allocation to add any instructions needed for the -+;; epilogue. Using an epilogue insn is favored compared to putting all of the -+;; instructions in output_function_epilogue(), since it allows the scheduler -+;; to intermix instructions with the restores of the caller saved registers. -+;; In some cases, it might be necessary to emit a barrier instruction as the -+;; first insn to prevent such scheduling. -+(define_expand "epilogue" -+ [(use (const_int 2))] -+ "" -+{ -+ or1k_expand_epilogue (); -+ DONE; -+}) -+ -+(define_insn "frame_alloc_fp" -+ [(set (reg:SI SP_REG) -+ (plus:SI (reg:SI SP_REG) -+ (match_operand:SI 0 "nonmemory_operand" "r,I"))) -+ (clobber (mem:QI (plus:SI (reg:SI FP_REG) -+ (unspec:SI [(const_int FP_REG)] UNSPEC_FRAME))))] -+ "" -+ "@ -+ l.add\tr1,r1,%0\t# allocate frame -+ l.addi\tr1,r1,%0\t# allocate frame" -+ [(set_attr "type" "add") -+ (set_attr "length" "1")]) -+ -+(define_insn "frame_dealloc_fp" -+ [(set (reg:SI SP_REG) (reg:SI FP_REG)) -+ (clobber (mem:QI (plus:SI (reg:SI FP_REG) -+ (unspec:SI [(const_int FP_REG)] UNSPEC_FRAME))))] -+ "" -+ "l.ori\tr1,r2,0\t# deallocate frame" -+ [(set_attr "type" "logic") -+ (set_attr "length" "1")]) -+ -+(define_insn "frame_dealloc_sp" -+ [(set (reg:SI SP_REG) -+ (plus:SI (reg:SI SP_REG) -+ (match_operand:SI 0 "nonmemory_operand" "r,I"))) -+ (clobber (mem:QI (plus:SI (reg:SI SP_REG) -+ (unspec:SI [(const_int SP_REG)] UNSPEC_FRAME))))] -+ "" -+ "@ -+ l.add \tr1,r1,%0 -+ l.addi \tr1,r1,%0" -+ [(set_attr "type" "add") -+ (set_attr "length" "1")]) -+ -+(define_insn "return_internal" -+ [(return) -+ (use (match_operand 0 "pmode_register_operand" ""))] -+ "" -+ "l.jr \t%0\t# return_internal%(" -+ [(set_attr "type" "jump") -+ (set_attr "length" "1")]) -+ -+ -+ -+;; -+;; movQI -+;; -+ -+(define_expand "movqi" -+ [(set (match_operand:QI 0 "general_operand" "") -+ (match_operand:QI 1 "general_operand" ""))] -+ "" -+ " -+ if (can_create_pseudo_p()) -+ { -+ if (GET_CODE (operands[1]) == CONST_INT) -+ { -+ rtx reg = gen_reg_rtx (SImode); -+ -+ emit_insn (gen_movsi (reg, operands[1])); -+ operands[1] = gen_lowpart (QImode, reg); -+ } -+ if (GET_CODE (operands[1]) == MEM && optimize > 0) -+ { -+ rtx reg = gen_reg_rtx (SImode); -+ -+ emit_insn (gen_rtx_SET (SImode, reg, -+ gen_rtx_ZERO_EXTEND (SImode, -+ operands[1]))); -+ -+ operands[1] = gen_lowpart (QImode, reg); -+ } -+ if (GET_CODE (operands[0]) != REG) -+ operands[1] = force_reg (QImode, operands[1]); -+ } -+") -+ -+(define_insn "*movqi_internal" -+ [(set (match_operand:QI 0 "nonimmediate_operand" "=m,r,r,r,r") -+ (match_operand:QI 1 "general_operand" "r,r,I,K,m"))] -+ "" -+ "@ -+ l.sb \t%0,%1\t # movqi -+ l.ori \t%0,%1,0\t # movqi: move reg to reg -+ l.addi \t%0,r0,%1\t # movqi: move immediate -+ l.ori \t%0,r0,%1\t # movqi: move immediate -+ l.lbz \t%0,%1\t # movqi" -+ [(set_attr "type" "store,add,add,logic,load")]) -+ -+ -+;; -+;; movHI -+;; -+ -+(define_expand "movhi" -+ [(set (match_operand:HI 0 "general_operand" "") -+ (match_operand:HI 1 "general_operand" ""))] -+ "" -+ " -+ if (can_create_pseudo_p()) -+ { -+ if (GET_CODE (operands[1]) == CONST_INT) -+ { -+ rtx reg = gen_reg_rtx (SImode); -+ -+ emit_insn (gen_movsi (reg, operands[1])); -+ operands[1] = gen_lowpart (HImode, reg); -+ } -+ else if (GET_CODE (operands[1]) == MEM && optimize > 0) -+ { -+ rtx reg = gen_reg_rtx (SImode); -+ -+ emit_insn (gen_rtx_SET (SImode, reg, -+ gen_rtx_ZERO_EXTEND (SImode, -+ operands[1]))); -+ operands[1] = gen_lowpart (HImode, reg); -+ } -+ if (GET_CODE (operands[0]) != REG) -+ operands[1] = force_reg (HImode, operands[1]); -+ } -+") -+ -+(define_insn "*movhi_internal" -+ [(set (match_operand:HI 0 "nonimmediate_operand" "=m,r,r,r,r") -+ (match_operand:HI 1 "general_operand" "r,r,I,K,m"))] -+ "" -+ "@ -+ l.sh \t%0,%1\t # movhi -+ l.ori \t%0,%1,0\t # movhi: move reg to reg -+ l.addi \t%0,r0,%1\t # movhi: move immediate -+ l.ori \t%0,r0,%1\t # movhi: move immediate -+ l.lhz \t%0,%1\t # movhi" -+ [(set_attr "type" "store,add,add,logic,load")]) -+ -+(define_expand "movsi" -+ [(set (match_operand:SI 0 "general_operand" "") -+ (match_operand:SI 1 "general_operand" ""))] -+ "" -+{ -+ if (or1k_expand_move (SImode, operands)) DONE; -+}) -+ -+;; -+;; movSI -+;; -+ -+(define_insn "*movsi_insn" -+ [(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,r,r,r,m") -+ (match_operand:SI 1 "input_operand" "I,K,M,r,m,r"))] -+ "(register_operand (operands[0], SImode) -+ || (register_operand (operands[1], SImode)) -+ || (operands[1] == const0_rtx))" -+ "@ -+ l.addi \t%0,r0,%1\t # move immediate I -+ l.ori \t%0,r0,%1\t # move immediate K -+ l.movhi \t%0,hi(%1)\t # move immediate M -+ l.ori \t%0,%1,0\t # move reg to reg -+ l.lwz \t%0,%1\t # SI load -+ l.sw \t%0,%1\t # SI store" -+ [(set_attr "type" "add,load,store,add,logic,move") -+ (set_attr "length" "1,1,1,1,1,1")]) -+ -+(define_insn "movsi_lo_sum" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (lo_sum:SI (match_operand:SI 1 "register_operand" "r") -+ (match_operand:SI 2 "immediate_operand" "i")))] -+ "" -+ "l.ori \t%0,%1,lo(%2) # movsi_lo_sum" -+ [(set_attr "type" "logic") -+ (set_attr "length" "1")]) -+ -+(define_insn "movsi_high" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (high:SI (match_operand:SI 1 "immediate_operand" "i")))] -+ "" -+ "l.movhi \t%0,hi(%1) # movsi_high" -+[(set_attr "type" "move") -+ (set_attr "length" "1")]) -+ -+(define_insn "movsi_gotofflo" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (unspec:SI [(lo_sum:SI (match_operand:SI 1 "register_operand" "r") -+ (match_operand 2 "" ""))] UNSPEC_GOTOFFLO))] -+ "flag_pic" -+ "l.ori \t%0,%1,gotofflo(%2) # movsi_gotofflo" -+ [(set_attr "type" "logic") -+ (set_attr "length" "1")]) -+ -+(define_insn "movsi_gotoffhi" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (unspec:SI [(match_operand 1 "" "")] UNSPEC_GOTOFFHI))] -+ "flag_pic" -+ "l.movhi \t%0,gotoffhi(%1) # movsi_gotoffhi" -+ [(set_attr "type" "move") -+ (set_attr "length" "1")]) -+ -+(define_insn "movsi_got" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (unspec:SI [(match_operand 1 "symbolic_operand" "")] UNSPEC_GOT)) -+ (use (reg:SI 16))] -+ "flag_pic" -+ "l.lwz \t%0, got(%1)(r16)" -+ [(set_attr "type" "load")] -+) -+ -+(define_insn "movsi_tlsgdlo" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (unspec:SI [(lo_sum:SI (match_operand:SI 1 "register_operand" "r") -+ (match_operand:SI 2 "immediate_operand" "i"))] UNSPEC_TLSGDLO))] -+ "" -+ "l.ori \t%0,%1,tlsgdlo(%2) # movsi_tlsgdlo" -+ [(set_attr "type" "logic") -+ (set_attr "length" "1")]) -+ -+(define_insn "movsi_tlsgdhi" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (unspec:SI [(match_operand:SI 1 "immediate_operand" "i")] UNSPEC_TLSGDHI))] -+ "" -+ "l.movhi \t%0,tlsgdhi(%1) # movsi_tlsgdhi" -+[(set_attr "type" "move") -+ (set_attr "length" "1")]) -+ -+(define_insn "movsi_gottpofflo" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (unspec:SI [(lo_sum:SI (match_operand:SI 1 "register_operand" "r") -+ (match_operand:SI 2 "immediate_operand" "i"))] UNSPEC_GOTTPOFFLO))] -+ "" -+ "l.ori \t%0,%1,gottpofflo(%2) # movsi_gottpofflo" -+ [(set_attr "type" "logic") -+ (set_attr "length" "1")]) -+ -+(define_insn "movsi_gottpoffhi" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (unspec:SI [(match_operand:SI 1 "immediate_operand" "i")] UNSPEC_GOTTPOFFHI))] -+ "" -+ "l.movhi \t%0,gottpoffhi(%1) # movsi_gottpoffhi" -+[(set_attr "type" "move") -+ (set_attr "length" "1")]) -+ -+(define_insn "load_gottpoff" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (unspec:SI [(match_operand:SI 1 "register_operand" "r")] UNSPEC_GOTTPOFFLD))] -+ "" -+ "l.lwz \t%0,0(%1) # load_gottpoff" -+[(set_attr "type" "load") -+ (set_attr "length" "1")]) -+ -+(define_insn "movsi_tpofflo" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (unspec:SI [(lo_sum:SI (match_operand:SI 1 "register_operand" "r") -+ (match_operand:SI 2 "immediate_operand" "i"))] UNSPEC_TPOFFLO))] -+ "" -+ "l.ori \t%0,%1,tpofflo(%2) # movsi_tpofflo" -+ [(set_attr "type" "logic") -+ (set_attr "length" "1")]) -+ -+(define_insn "movsi_tpoffhi" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (unspec:SI [(match_operand:SI 1 "immediate_operand" "i")] UNSPEC_TPOFFHI))] -+ "" -+ "l.movhi \t%0,tpoffhi(%1) # movsi_tpoffhi" -+[(set_attr "type" "move") -+ (set_attr "length" "1")]) -+ -+ -+(define_insn_and_split "movsi_insn_big" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (match_operand:SI 1 "immediate_operand" "i"))] -+ "GET_CODE (operands[1]) != CONST_INT" -+ ;; the switch of or1k bfd to Rela allows us to schedule insns separately. -+ "l.movhi \t%0,hi(%1)\;l.ori \t%0,%0,lo(%1)" -+ "(GET_CODE (operands[1]) != CONST_INT -+ || ! (CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[1]), 'I', \"I\") -+ || CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[1]), 'K', \"K\") -+ || CONST_OK_FOR_CONSTRAINT_P (INTVAL (operands[1]), 'M', \"M\"))) -+ && reload_completed -+ && GET_CODE (operands[1]) != HIGH && GET_CODE (operands[1]) != LO_SUM" -+ [(pc)] -+{ -+ if (!or1k_expand_symbol_ref(SImode, operands)) -+ { -+ emit_insn (gen_movsi_high (operands[0], operands[1])); -+ emit_insn (gen_movsi_lo_sum (operands[0], operands[0], operands[1])); -+ } -+ DONE; -+} -+ [(set_attr "type" "move") -+ (set_attr "length" "2")]) -+ -+ -+;; -+;; Conditional Branches & Moves -+;; -+ -+(define_expand "addsicc" -+ [(match_operand:SI 0 "register_operand" "") -+ (match_operand 1 "comparison_operator" "") -+ (match_operand:SI 2 "register_operand" "") -+ (match_operand:SI 3 "register_operand" "")] -+ "" -+ "FAIL;") -+ -+(define_expand "addhicc" -+ [(match_operand:HI 0 "register_operand" "") -+ (match_operand 1 "comparison_operator" "") -+ (match_operand:HI 2 "register_operand" "") -+ (match_operand:HI 3 "register_operand" "")] -+ "" -+ "FAIL;") -+ -+(define_expand "addqicc" -+ [(match_operand:QI 0 "register_operand" "") -+ (match_operand 1 "comparison_operator" "") -+ (match_operand:QI 2 "register_operand" "") -+ (match_operand:QI 3 "register_operand" "")] -+ "" -+ "FAIL;") -+ -+ -+;; -+;; conditional moves -+;; -+ -+(define_expand "movsicc" -+ [(set (match_operand:SI 0 "register_operand" "") -+ (if_then_else:SI (match_operand 1 "comparison_operator" "") -+ (match_operand:SI 2 "register_operand" "") -+ (match_operand:SI 3 "register_operand" "")))] -+ "TARGET_MASK_CMOV" -+ " -+{ -+ if (or1k_emit_cmove (operands[0], operands[1], operands[2], operands[3])) -+ DONE; -+}") -+ -+(define_expand "movhicc" -+ [(set (match_operand:HI 0 "register_operand" "") -+ (if_then_else:SI (match_operand 1 "comparison_operator" "") -+ (match_operand:HI 2 "register_operand" "") -+ (match_operand:HI 3 "register_operand" "")))] -+ "" -+ " -+{ -+ FAIL; -+}") -+ -+(define_expand "movqicc" -+ [(set (match_operand:QI 0 "register_operand" "") -+ (if_then_else:SI (match_operand 1 "comparison_operator" "") -+ (match_operand:QI 2 "register_operand" "") -+ (match_operand:QI 3 "register_operand" "")))] -+ "" -+ " -+{ -+ FAIL; -+}") -+ -+ -+;; We use the BASE_REGS for the cmov input operands because, if rA is -+;; 0, the value of 0 is placed in rD upon truth. Similarly for rB -+;; because we may switch the operands and rB may end up being rA. -+ -+(define_insn "cmov" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (if_then_else:SI -+ (match_operator 1 "comparison_operator" -+ [(match_operand 4 "cc_reg_operand" "") -+ (const_int 0)]) -+ (match_operand:SI 2 "register_operand" "r") -+ (match_operand:SI 3 "register_operand" "r")))] -+ "TARGET_MASK_CMOV" -+ "* -+ return or1k_output_cmov(operands); -+ ") -+ -+;; -+;; .................... -+;; -+;; COMPARISONS -+;; -+;; .................... -+ -+;; Flow here is rather complex: -+;; -+;; 1) The cmp{si,di,sf,df} routine is called. It deposits the -+;; arguments into the branch_cmp array, and the type into -+;; branch_type. No RTL is generated. -+;; -+;; 2) The appropriate branch define_expand is called, which then -+;; creates the appropriate RTL for the comparison and branch. -+;; Different CC modes are used, based on what type of branch is -+;; done, so that we can constrain things appropriately. There -+;; are assumptions in the rest of GCC that break if we fold the -+;; operands into the branches for integer operations, and use cc0 -+;; for floating point, so we use the fp status register instead. -+;; If needed, an appropriate temporary is created to hold the -+;; of the integer compare. -+ -+;; Compare insns are next. Note that the RS/6000 has two types of compares, -+;; signed & unsigned, and one type of branch. -+;; -+;; Start with the DEFINE_EXPANDs to generate the rtl for compares, scc -+;; insns, and branches. We store the operands of compares until we see -+;; how it is used. -+ -+;; JPB 31-Aug-10: cmpxx appears to be obsolete in GCC 4.5. Needs more -+;; investigation. -+ -+;;(define_expand "cmpsi" -+;; [(set (reg:CC CC_REG) -+;; (compare:CC (match_operand:SI 0 "register_operand" "") -+;; (match_operand:SI 1 "nonmemory_operand" "")))] -+;; "" -+;; { -+;; if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) -+;; operands[0] = force_reg (SImode, operands[0]); -+;; or1k_compare_op0 = operands[0]; -+;; or1k_compare_op1 = operands[1]; -+;; DONE; -+;; }) -+ -+;; (define_expand "cmpsf" -+;; [(set (reg:CC CC_REG) -+;; (compare:CC (match_operand:SF 0 "register_operand" "") -+;; (match_operand:SF 1 "register_operand" "")))] -+;; "TARGET_HARD_FLOAT" -+;; { -+;; if (GET_CODE (operands[0]) == MEM && GET_CODE (operands[1]) == MEM) -+;; operands[0] = force_reg (SFmode, operands[0]); -+;; or1k_compare_op0 = operands[0]; -+;; or1k_compare_op1 = operands[1]; -+;; DONE; -+;; }) -+ -+(define_expand "cbranchsi4" -+ [(match_operator 0 "comparison_operator" -+ [(match_operand:SI 1 "register_operand") -+ (match_operand:SI 2 "nonmemory_operand")]) -+ (match_operand 3 "")] -+ "" -+ { -+ or1k_expand_conditional_branch (operands, SImode); -+ DONE; -+ }) -+ -+(define_expand "cbranchsf4" -+ [(match_operator 0 "comparison_operator" -+ [(match_operand:SF 1 "register_operand") -+ (match_operand:SF 2 "register_operand")]) -+ (match_operand 3 "")] -+ "TARGET_HARD_FLOAT" -+ { -+ or1k_expand_conditional_branch (operands, SFmode); -+ DONE; -+ }) -+ -+;; -+;; Setting a CCxx registers from comparision -+;; -+ -+ -+ -+;; Here are the actual compare insns. -+(define_insn "*cmpsi_eq" -+ [(set (reg:CCEQ CC_REG) -+ (compare:CCEQ (match_operand:SI 0 "register_operand" "r,r") -+ (match_operand:SI 1 "nonmemory_operand" "I,r")))] -+ "" -+ "@ -+ l.sfeqi\t%0,%1 # cmpsi_eq -+ l.sfeq \t%0,%1 # cmpsi_eq" -+ [(set_attr "type" "compare") -+ (set_attr "length" "1")]) -+ -+(define_insn "*cmpsi_ne" -+ [(set (reg:CCNE CC_REG) -+ (compare:CCNE (match_operand:SI 0 "register_operand" "r,r") -+ (match_operand:SI 1 "nonmemory_operand" "I,r")))] -+ "" -+ "@ -+ l.sfnei\t%0,%1 # cmpsi_ne -+ l.sfne \t%0,%1 # cmpsi_ne" -+ [(set_attr "type" "compare") -+ (set_attr "length" "1")]) -+ -+(define_insn "*cmpsi_gt" -+ [(set (reg:CCGT CC_REG) -+ (compare:CCGT (match_operand:SI 0 "register_operand" "r,r") -+ (match_operand:SI 1 "nonmemory_operand" "I,r")))] -+ "" -+ "@ -+ l.sfgtsi\t%0,%1 # cmpsi_gt -+ l.sfgts \t%0,%1 # cmpsi_gt" -+ [(set_attr "type" "compare") -+ (set_attr "length" "1")]) -+ -+(define_insn "*cmpsi_gtu" -+ [(set (reg:CCGTU CC_REG) -+ (compare:CCGTU (match_operand:SI 0 "register_operand" "r,r") -+ (match_operand:SI 1 "nonmemory_operand" "I,r")))] -+ "" -+ "@ -+ l.sfgtui\t%0,%1 # cmpsi_gtu -+ l.sfgtu \t%0,%1 # cmpsi_gtu" -+ [(set_attr "type" "compare") -+ (set_attr "length" "1")]) -+ -+(define_insn "*cmpsi_lt" -+ [(set (reg:CCLT CC_REG) -+ (compare:CCLT (match_operand:SI 0 "register_operand" "r,r") -+ (match_operand:SI 1 "nonmemory_operand" "I,r")))] -+ "" -+ "@ -+ l.sfltsi\t%0,%1 # cmpsi_lt -+ l.sflts \t%0,%1 # cmpsi_lt" -+ [(set_attr "type" "compare") -+ (set_attr "length" "1")]) -+ -+(define_insn "*cmpsi_ltu" -+ [(set (reg:CCLTU CC_REG) -+ (compare:CCLTU (match_operand:SI 0 "register_operand" "r,r") -+ (match_operand:SI 1 "nonmemory_operand" "I,r")))] -+ "" -+ "@ -+ l.sfltui\t%0,%1 # cmpsi_ltu -+ l.sfltu \t%0,%1 # cmpsi_ltu" -+ [(set_attr "type" "compare") -+ (set_attr "length" "1")]) -+ -+(define_insn "*cmpsi_ge" -+ [(set (reg:CCGE CC_REG) -+ (compare:CCGE (match_operand:SI 0 "register_operand" "r,r") -+ (match_operand:SI 1 "nonmemory_operand" "I,r")))] -+ "" -+ "@ -+ l.sfgesi\t%0,%1 # cmpsi_ge -+ l.sfges \t%0,%1 # cmpsi_ge" -+ [(set_attr "type" "compare") -+ (set_attr "length" "1")]) -+ -+ -+(define_insn "*cmpsi_geu" -+ [(set (reg:CCGEU CC_REG) -+ (compare:CCGEU (match_operand:SI 0 "register_operand" "r,r") -+ (match_operand:SI 1 "nonmemory_operand" "I,r")))] -+ "" -+ "@ -+ l.sfgeui\t%0,%1 # cmpsi_geu -+ l.sfgeu \t%0,%1 # cmpsi_geu" -+ [(set_attr "type" "compare") -+ (set_attr "length" "1")]) -+ -+ -+(define_insn "*cmpsi_le" -+ [(set (reg:CCLE CC_REG) -+ (compare:CCLE (match_operand:SI 0 "register_operand" "r,r") -+ (match_operand:SI 1 "nonmemory_operand" "I,r")))] -+ "" -+ "@ -+ l.sflesi\t%0,%1 # cmpsi_le -+ l.sfles \t%0,%1 # cmpsi_le" -+ [(set_attr "type" "compare") -+ (set_attr "length" "1")]) -+ -+(define_insn "*cmpsi_leu" -+ [(set (reg:CCLEU CC_REG) -+ (compare:CCLEU (match_operand:SI 0 "register_operand" "r,r") -+ (match_operand:SI 1 "nonmemory_operand" "I,r")))] -+ "" -+ "@ -+ l.sfleui\t%0,%1 # cmpsi_leu -+ l.sfleu \t%0,%1 # cmpsi_leu" -+ [(set_attr "type" "compare") -+ (set_attr "length" "1")]) -+ -+;; Single precision floating point evaluation instructions -+(define_insn "*cmpsf_eq" -+ [(set (reg:CCEQ CC_REG) -+ (compare:CCEQ (match_operand:SF 0 "register_operand" "r,r") -+ (match_operand:SF 1 "register_operand" "r,r")))] -+ "TARGET_HARD_FLOAT" -+ "lf.sfeq.s\t%0,%1 # cmpsf_eq" -+ [(set_attr "type" "compare") -+ (set_attr "length" "1")]) -+ -+(define_insn "*cmpsf_ne" -+ [(set (reg:CCNE CC_REG) -+ (compare:CCNE (match_operand:SF 0 "register_operand" "r,r") -+ (match_operand:SF 1 "register_operand" "r,r")))] -+ "TARGET_HARD_FLOAT" -+ "lf.sfne.s\t%0,%1 # cmpsf_ne" -+ [(set_attr "type" "compare") -+ (set_attr "length" "1")]) -+ -+ -+(define_insn "*cmpsf_gt" -+ [(set (reg:CCGT CC_REG) -+ (compare:CCGT (match_operand:SF 0 "register_operand" "r,r") -+ (match_operand:SF 1 "register_operand" "r,r")))] -+ "TARGET_HARD_FLOAT" -+ "lf.sfgt.s\t%0,%1 # cmpsf_gt" -+ [(set_attr "type" "compare") -+ (set_attr "length" "1")]) -+ -+(define_insn "*cmpsf_ge" -+ [(set (reg:CCGE CC_REG) -+ (compare:CCGE (match_operand:SF 0 "register_operand" "r,r") -+ (match_operand:SF 1 "register_operand" "r,r")))] -+ "TARGET_HARD_FLOAT" -+ "lf.sfge.s\t%0,%1 # cmpsf_ge" -+ [(set_attr "type" "compare") -+ (set_attr "length" "1")]) -+ -+ -+(define_insn "*cmpsf_lt" -+ [(set (reg:CCLT CC_REG) -+ (compare:CCLT (match_operand:SF 0 "register_operand" "r,r") -+ (match_operand:SF 1 "register_operand" "r,r")))] -+ "TARGET_HARD_FLOAT" -+ "lf.sflt.s\t%0,%1 # cmpsf_lt" -+ [(set_attr "type" "compare") -+ (set_attr "length" "1")]) -+ -+(define_insn "*cmpsf_le" -+ [(set (reg:CCLE CC_REG) -+ (compare:CCLE (match_operand:SF 0 "register_operand" "r,r") -+ (match_operand:SF 1 "register_operand" "r,r")))] -+ "TARGET_HARD_FLOAT" -+ "lf.sfle.s\t%0,%1 # cmpsf_le" -+ [(set_attr "type" "compare") -+ (set_attr "length" "1")]) -+ -+(define_insn "*bf" -+ [(set (pc) -+ (if_then_else (match_operator 1 "comparison_operator" -+ [(match_operand 2 -+ "cc_reg_operand" "") -+ (const_int 0)]) -+ (label_ref (match_operand 0 "" "")) -+ (pc)))] -+ "" -+ "* -+ return or1k_output_bf(operands); -+ " -+ [(set_attr "type" "branch") -+ (set_attr "length" "1")]) -+ -+;; -+;; -+;; -+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -+;; -+;; -+(define_insn_and_split "movdi" -+ [(set (match_operand:DI 0 "nonimmediate_operand" "=r, r, m, r") -+ (match_operand:DI 1 "general_operand" " r, m, r, n"))] -+ "" -+ "* -+ return or1k_output_move_double (operands); -+ " -+ "&& reload_completed && CONSTANT_P (operands[1])" -+ [(set (match_dup 2) (match_dup 3)) (set (match_dup 4) (match_dup 5))] -+ "operands[2] = operand_subword (operands[0], 0, 0, DImode); -+ operands[3] = operand_subword (operands[1], 0, 0, DImode); -+ operands[4] = operand_subword (operands[0], 1, 0, DImode); -+ operands[5] = operand_subword (operands[1], 1, 0, DImode);" -+ [(set_attr "length" "2,2,2,3")]) -+ -+;; Moving double and single precision floating point values -+ -+ -+(define_insn "movdf" -+ [(set (match_operand:DF 0 "nonimmediate_operand" "=r, r, m, r") -+ (match_operand:DF 1 "general_operand" " r, m, r, i"))] -+ "" -+ "* -+ return or1k_output_move_double (operands); -+ " -+ [(set_attr "length" "2,2,2,3")]) -+ -+ -+(define_insn "movsf" -+ [(set (match_operand:SF 0 "nonimmediate_operand" "=r,r,m") -+ (match_operand:SF 1 "general_operand" "r,m,r"))] -+ "" -+ "@ -+ l.ori \t%0,%1,0\t # movsf -+ l.lwz \t%0,%1\t # movsf -+ l.sw \t%0,%1\t # movsf" -+ [(set_attr "type" "move,load,store") -+ (set_attr "length" "1,1,1")]) -+ -+ -+;; -+;; extendqisi2 -+;; -+ -+(define_expand "extendqisi2" -+ [(use (match_operand:SI 0 "register_operand" "")) -+ (use (match_operand:QI 1 "nonimmediate_operand" ""))] -+ "" -+ " -+{ -+ if (TARGET_MASK_SEXT) -+ emit_insn (gen_extendqisi2_sext(operands[0], operands[1])); -+ else { -+ if ( GET_CODE(operands[1]) == MEM ) { -+ emit_insn (gen_extendqisi2_no_sext_mem(operands[0], operands[1])); -+ } -+ else { -+ emit_insn (gen_extendqisi2_no_sext_reg(operands[0], operands[1])); -+ } -+ } -+ DONE; -+}") -+ -+(define_insn "extendqisi2_sext" -+ [(set (match_operand:SI 0 "register_operand" "=r,r") -+ (sign_extend:SI (match_operand:QI 1 "nonimmediate_operand" "r,m")))] -+ "TARGET_MASK_SEXT" -+ "@ -+ l.extbs \t%0,%1\t # extendqisi2_has_signed_extend -+ l.lbs \t%0,%1\t # extendqisi2_has_signed_extend" -+ [(set_attr "length" "1,1") -+ (set_attr "type" "extend,load")]) -+ -+(define_insn "extendqisi2_no_sext_mem" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (sign_extend:SI (match_operand:QI 1 "memory_operand" "m")))] -+ "!TARGET_MASK_SEXT" -+ "l.lbs \t%0,%1\t # extendqisi2_no_sext_mem" -+ [(set_attr "length" "1") -+ (set_attr "type" "load")]) -+ -+(define_expand "extendqisi2_no_sext_reg" -+ [(set (match_dup 2) -+ (ashift:SI (match_operand:QI 1 "register_operand" "") -+ (const_int 24))) -+ (set (match_operand:SI 0 "register_operand" "") -+ (ashiftrt:SI (match_dup 2) -+ (const_int 24)))] -+ "!TARGET_MASK_SEXT" -+ " -+{ -+ operands[1] = gen_lowpart (SImode, operands[1]); -+ operands[2] = gen_reg_rtx (SImode); }") -+ -+;; -+;; extendhisi2 -+;; -+ -+(define_expand "extendhisi2" -+ [(use (match_operand:SI 0 "register_operand" "")) -+ (use (match_operand:HI 1 "nonimmediate_operand" ""))] -+ "" -+ " -+{ -+ if (TARGET_MASK_SEXT) -+ emit_insn (gen_extendhisi2_sext(operands[0], operands[1])); -+ else { -+ if ( GET_CODE(operands[1]) == MEM ) { -+ emit_insn (gen_extendhisi2_no_sext_mem(operands[0], operands[1])); -+ } -+ else { -+ emit_insn (gen_extendhisi2_no_sext_reg(operands[0], operands[1])); -+ } -+ } -+ DONE; -+}") -+ -+(define_insn "extendhisi2_sext" -+ [(set (match_operand:SI 0 "register_operand" "=r,r") -+ (sign_extend:SI (match_operand:HI 1 "nonimmediate_operand" "r,m")))] -+ "TARGET_MASK_SEXT" -+ "@ -+ l.exths \t%0,%1\t # extendhisi2_has_signed_extend -+ l.lhs \t%0,%1\t # extendhisi2_has_signed_extend" -+ [(set_attr "length" "1,1") -+ (set_attr "type" "extend,load")]) -+ -+(define_insn "extendhisi2_no_sext_mem" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (sign_extend:SI (match_operand:HI 1 "memory_operand" "m")))] -+ "!TARGET_MASK_SEXT" -+ "l.lhs \t%0,%1\t # extendhisi2_no_sext_mem" -+ [(set_attr "length" "1") -+ (set_attr "type" "load")]) -+ -+(define_expand "extendhisi2_no_sext_reg" -+ [(set (match_dup 2) -+ (ashift:SI (match_operand:HI 1 "register_operand" "") -+ (const_int 16))) -+ (set (match_operand:SI 0 "register_operand" "") -+ (ashiftrt:SI (match_dup 2) -+ (const_int 16)))] -+ "!TARGET_MASK_SEXT" -+ " -+{ -+ operands[1] = gen_lowpart (SImode, operands[1]); -+ operands[2] = gen_reg_rtx (SImode); }") -+ -+ -+;; -+;; zero_extend2 -+;; -+ -+(define_insn "zero_extendqisi2" -+ [(set (match_operand:SI 0 "register_operand" "=r,r") -+ (zero_extend:SI (match_operand:QI 1 "nonimmediate_operand" "r,m")))] -+ "" -+ "@ -+ l.andi \t%0,%1,0xff\t # zero_extendqisi2 -+ l.lbz \t%0,%1\t # zero_extendqisi2" -+ [(set_attr "type" "logic,load") -+ (set_attr "length" "1,1")]) -+ -+ -+(define_insn "zero_extendhisi2" -+ [(set (match_operand:SI 0 "register_operand" "=r,r") -+ (zero_extend:SI (match_operand:HI 1 "nonimmediate_operand" "r,m")))] -+ "" -+ "@ -+ l.andi \t%0,%1,0xffff\t # zero_extendqisi2 -+ l.lhz \t%0,%1\t # zero_extendqisi2" -+ [(set_attr "type" "logic,load") -+ (set_attr "length" "1,1")]) -+ -+;; -+;; Shift/rotate operations -+;; -+ -+(define_insn "ashlsi3" -+ [(set (match_operand:SI 0 "register_operand" "=r,r") -+ (ashift:SI (match_operand:SI 1 "register_operand" "r,r") -+ (match_operand:SI 2 "nonmemory_operand" "r,L")))] -+ "" -+ "@ -+ l.sll \t%0,%1,%2 # ashlsi3 -+ l.slli \t%0,%1,%2 # ashlsi3" -+ [(set_attr "type" "shift,shift") -+ (set_attr "length" "1,1")]) -+ -+(define_insn "ashrsi3" -+ [(set (match_operand:SI 0 "register_operand" "=r,r") -+ (ashiftrt:SI (match_operand:SI 1 "register_operand" "r,r") -+ (match_operand:SI 2 "nonmemory_operand" "r,L")))] -+ "" -+ "@ -+ l.sra \t%0,%1,%2 # ashrsi3 -+ l.srai \t%0,%1,%2 # ashrsi3" -+ [(set_attr "type" "shift,shift") -+ (set_attr "length" "1,1")]) -+ -+(define_insn "lshrsi3" -+ [(set (match_operand:SI 0 "register_operand" "=r,r") -+ (lshiftrt:SI (match_operand:SI 1 "register_operand" "r,r") -+ (match_operand:SI 2 "nonmemory_operand" "r,L")))] -+ "" -+ "@ -+ l.srl \t%0,%1,%2 # lshrsi3 -+ l.srli \t%0,%1,%2 # lshrsi3" -+ [(set_attr "type" "shift,shift") -+ (set_attr "length" "1,1")]) -+ -+(define_insn "rotrsi3" -+ [(set (match_operand:SI 0 "register_operand" "=r,r") -+ (rotatert:SI (match_operand:SI 1 "register_operand" "r,r") -+ (match_operand:SI 2 "nonmemory_operand" "r,L")))] -+ "TARGET_MASK_ROR" -+ "@ -+ l.ror \t%0,%1,%2 # rotrsi3 -+ l.rori \t%0,%1,%2 # rotrsi3" -+ [(set_attr "type" "shift,shift") -+ (set_attr "length" "1,1")]) -+ -+;; -+;; Logical bitwise operations -+;; -+ -+(define_insn "andsi3" -+ [(set (match_operand:SI 0 "register_operand" "=r,r") -+ (and:SI (match_operand:SI 1 "register_operand" "%r,r") -+ (match_operand:SI 2 "nonmemory_operand" "r,K")))] -+ "" -+ "@ -+ l.and \t%0,%1,%2 # andsi3 -+ l.andi \t%0,%1,%2 # andsi3" -+ [(set_attr "type" "logic,logic") -+ (set_attr "length" "1,1")]) -+ -+(define_insn "iorsi3" -+ [(set (match_operand:SI 0 "register_operand" "=r,r") -+ (ior:SI (match_operand:SI 1 "register_operand" "%r,r") -+ (match_operand:SI 2 "nonmemory_operand" "r,K")))] -+ "" -+ "@ -+ l.or \t%0,%1,%2 # iorsi3 -+ l.ori \t%0,%1,%2 # iorsi3" -+ [(set_attr "type" "logic,logic") -+ (set_attr "length" "1,1")]) -+ -+(define_insn "xorsi3" -+ [(set (match_operand:SI 0 "register_operand" "=r,r") -+ (xor:SI (match_operand:SI 1 "register_operand" "%r,r") -+ (match_operand:SI 2 "nonmemory_operand" "r,I")))] -+ "" -+ "@ -+ l.xor \t%0,%1,%2 # xorsi3 -+ l.xori \t%0,%1,%2 # xorsi3" -+ [(set_attr "type" "logic,logic") -+ (set_attr "length" "1,1")]) -+ -+(define_insn "one_cmplqi2" -+ [(set (match_operand:QI 0 "register_operand" "=r") -+ (not:QI (match_operand:QI 1 "register_operand" "r")))] -+ "" -+ "l.xori \t%0,%1,0x00ff # one_cmplqi2" -+ [(set_attr "type" "logic") -+ (set_attr "length" "1")]) -+ -+(define_insn "one_cmplsi2" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (not:SI (match_operand:SI 1 "register_operand" "r")))] -+ "" -+ "l.xori \t%0,%1,0xffff # one_cmplsi2" -+ [(set_attr "type" "logic") -+ (set_attr "length" "1")]) -+ -+;; -+;; Arithmetic operations -+;; -+ -+(define_insn "negsi2" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (neg:SI (match_operand:SI 1 "register_operand" "r")))] -+ "" -+ "l.sub \t%0,r0,%1 # negsi2" -+ [(set_attr "type" "add") -+ (set_attr "length" "1")]) -+ -+(define_insn "addsi3" -+ [(set (match_operand:SI 0 "register_operand" "=r,r") -+ (plus:SI (match_operand:SI 1 "register_operand" "%r,r") -+ (match_operand:SI 2 "nonmemory_operand" "r,I")))] -+ "" -+ "@ -+ l.add \t%0,%1,%2 # addsi3 -+ l.addi \t%0,%1,%2 # addsi3" -+ [(set_attr "type" "add,add") -+ (set_attr "length" "1,1")]) -+ -+(define_insn "subsi3" -+ [(set (match_operand:SI 0 "register_operand" "=r,r") -+ (minus:SI (match_operand:SI 1 "register_operand" "r,r") -+ (match_operand:SI 2 "nonmemory_operand" "r,I")))] -+ "" -+ "@ -+ l.sub \t%0,%1,%2 # subsi3 -+ l.addi \t%0,%1,%n2 # subsi3" -+ [(set_attr "type" "add,add")] -+) -+ -+;; -+;; mul and div -+;; -+ -+(define_insn "mulsi3" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (mult:SI (match_operand:SI 1 "register_operand" "r") -+ (match_operand:SI 2 "register_operand" "r")))] -+ "TARGET_HARD_MUL" -+ "l.mul \t%0,%1,%2 # mulsi3" -+ [(set_attr "type" "mul") -+ (set_attr "length" "1")]) -+ -+(define_insn "divsi3" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (div:SI (match_operand:SI 1 "register_operand" "r") -+ (match_operand:SI 2 "register_operand" "r")))] -+ "TARGET_HARD_DIV" -+ "l.div \t%0,%1,%2 # divsi3" -+ [(set_attr "type" "mul") -+ (set_attr "length" "1")]) -+ -+(define_insn "udivsi3" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (udiv:SI (match_operand:SI 1 "register_operand" "r") -+ (match_operand:SI 2 "register_operand" "r")))] -+ "TARGET_HARD_DIV" -+ "l.divu \t%0,%1,%2 # udivsi3" -+ [(set_attr "type" "mul") -+ (set_attr "length" "1")]) -+ -+;; -+;; jumps -+;; -+ -+;; jump -+ -+(define_expand "jump" -+ [(set (pc) -+ (label_ref (match_operand 0 "" "")))] -+ "" -+ " -+{ -+ emit_jump_insn (gen_jump_internal (operands[0])); -+ DONE; -+}") -+ -+(define_insn "jump_internal" -+ [(set (pc) -+ (label_ref (match_operand 0 "" "")))] -+ "" -+ "l.j \t%l0 # jump_internal%(" -+ [(set_attr "type" "jump") -+ (set_attr "length" "1")]) -+ -+;; indirect jump -+ -+(define_expand "indirect_jump" -+ [(set (pc) (match_operand:SI 0 "register_operand" "r"))] -+ "" -+ " -+{ -+ emit_jump_insn (gen_indirect_jump_internal (operands[0])); -+ DONE; -+ -+}") -+ -+(define_insn "indirect_jump_internal" -+ [(set (pc) (match_operand:SI 0 "register_operand" "r"))] -+ "" -+ "l.jr \t%0 # indirect_jump_internal%(" -+ [(set_attr "type" "jump") -+ (set_attr "length" "1")]) -+ -+;; -+;; calls -+;; -+ -+;; call -+ -+(define_expand "call" -+ [(parallel [(call (match_operand:SI 0 "sym_ref_mem_operand" "") -+ (match_operand 1 "" "i")) -+ (clobber (reg:SI 9)) -+ (use (reg:SI 16))])] -+ "" -+ " -+{ -+ emit_call_insn (gen_call_internal (operands[0], operands[1])); -+ DONE; -+}") -+ -+(define_insn "call_internal" -+[(parallel [(call (match_operand:SI 0 "sym_ref_mem_operand" "") -+ (match_operand 1 "" "i")) -+ (clobber (reg:SI 9)) -+ (use (reg:SI 16))])] -+ "" -+ { -+ if (flag_pic) -+ { -+ crtl->uses_pic_offset_table = 1; -+ return "l.jal \tplt(%S0)# call_internal%("; -+ } -+ -+ return "l.jal \t%S0# call_internal%("; -+ } -+ [(set_attr "type" "jump") -+ (set_attr "length" "1")]) -+ -+;; call value -+ -+(define_expand "call_value" -+ [(parallel [(set (match_operand 0 "register_operand" "=r") -+ (call (match_operand:SI 1 "sym_ref_mem_operand" "") -+ (match_operand 2 "" "i"))) -+ (clobber (reg:SI 9)) -+ (use (reg:SI 16))])] -+ "" -+ " -+{ -+ emit_call_insn (gen_call_value_internal (operands[0], operands[1], operands[2])); -+ DONE; -+}") -+ -+(define_insn "call_value_internal" -+[(parallel [(set (match_operand 0 "register_operand" "=r") -+ (call (match_operand:SI 1 "sym_ref_mem_operand" "") -+ (match_operand 2 "" "i"))) -+ (clobber (reg:SI 9)) -+ (use (reg:SI 16))])] -+ "" -+ { -+ if (flag_pic) -+ { -+ crtl->uses_pic_offset_table = 1; -+ return "l.jal \tplt(%S1) # call_value_internal%("; -+ } -+ return "l.jal \t%S1 # call_value_internal%("; -+ } -+ [(set_attr "type" "jump") -+ (set_attr "length" "1")]) -+ -+;; indirect call value -+ -+(define_expand "call_value_indirect" -+ [(parallel [(set (match_operand 0 "register_operand" "=r") -+ (call (mem:SI (match_operand:SI 1 "register_operand" "r")) -+ (match_operand 2 "" "i"))) -+ (clobber (reg:SI 9)) -+ (use (reg:SI 16))])] -+ "" -+ " -+{ -+ emit_call_insn (gen_call_value_indirect_internal (operands[0], operands[1], operands[2])); -+ DONE; -+}") -+ -+(define_insn "call_value_indirect_internal" -+ [(parallel [(set (match_operand 0 "register_operand" "=r") -+ (call (mem:SI (match_operand:SI 1 "register_operand" "r")) -+ (match_operand 2 "" "i"))) -+ (clobber (reg:SI 9)) -+ (use (reg:SI 16))])] -+ "" -+ "l.jalr \t%1 # call_value_indirect_internal%(" -+ [(set_attr "type" "jump") -+ (set_attr "length" "1")]) -+ -+;; indirect call -+ -+(define_expand "call_indirect" -+ [(parallel [(call (mem:SI (match_operand:SI 0 "register_operand" "r")) -+ (match_operand 1 "" "i")) -+ (clobber (reg:SI 9)) -+ (use (reg:SI 16))])] -+ "" -+ " -+{ -+ emit_call_insn (gen_call_indirect_internal (operands[0], operands[1])); -+ DONE; -+}") -+ -+(define_insn "call_indirect_internal" -+[(parallel [(call (mem:SI (match_operand:SI 0 "register_operand" "r")) -+ (match_operand 1 "" "i")) -+ (clobber (reg:SI 9)) -+ (use (reg:SI 16))])] -+ "" -+ "l.jalr \t%0 # call_indirect_internal%(" -+ [(set_attr "type" "jump") -+ (set_attr "length" "1")]) -+ -+;; table jump -+ -+(define_expand "tablejump" -+ [(set (pc) (match_operand:SI 0 "register_operand" "r")) -+ (use (label_ref (match_operand 1 "" "")))] -+ "" -+ " -+{ -+ if (CASE_VECTOR_PC_RELATIVE || flag_pic) -+ operands[0] -+ = force_reg (Pmode, -+ gen_rtx_PLUS (Pmode, operands[0], -+ gen_rtx_LABEL_REF (Pmode, operands[1]))); -+ emit_jump_insn (gen_tablejump_internal (operands[0], operands[1])); -+ DONE; -+}") -+ -+(define_insn "tablejump_internal" -+ [(set (pc) (match_operand:SI 0 "register_operand" "r")) -+ (use (label_ref (match_operand 1 "" "")))] -+ "" -+ "l.jr \t%0 # tablejump_internal%(" -+ [(set_attr "type" "jump") -+ (set_attr "length" "1")]) -+ -+ -+;; no-op -+ -+(define_insn "nop" -+ [(const_int 0)] -+ "" -+ "l.nop" -+ [(set_attr "type" "logic") -+ (set_attr "length" "1")]) -+ -+;; -+;; floating point -+;; -+ -+;; floating point arithmetic -+ -+(define_insn "addsf3" -+ [(set (match_operand:SF 0 "register_operand" "=r") -+ (plus:SF (match_operand:SF 1 "register_operand" "r") -+ (match_operand:SF 2 "register_operand" "r")))] -+ "TARGET_HARD_FLOAT" -+ "lf.add.s\t%0,%1,%2 # addsf3" -+ [(set_attr "type" "fp") -+ (set_attr "length" "1")]) -+ -+(define_insn "adddf3" -+ [(set (match_operand:DF 0 "register_operand" "=r") -+ (plus:DF (match_operand:DF 1 "register_operand" "r") -+ (match_operand:DF 2 "register_operand" "r")))] -+ "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT" -+ "lf.add.d\t%0,%1,%2 # adddf3" -+ [(set_attr "type" "fp") -+ (set_attr "length" "1")]) -+ -+(define_insn "subsf3" -+ [(set (match_operand:SF 0 "register_operand" "=r") -+ (minus:SF (match_operand:SF 1 "register_operand" "r") -+ (match_operand:SF 2 "register_operand" "r")))] -+ "TARGET_HARD_FLOAT" -+ "lf.sub.s\t%0,%1,%2 # subsf3" -+ [(set_attr "type" "fp") -+ (set_attr "length" "1")]) -+ -+(define_insn "subdf3" -+ [(set (match_operand:DF 0 "register_operand" "=r") -+ (minus:DF (match_operand:DF 1 "register_operand" "r") -+ (match_operand:DF 2 "register_operand" "r")))] -+ "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT" -+ "lf.sub.d\t%0,%1,%2 # subdf3" -+ [(set_attr "type" "fp") -+ (set_attr "length" "1")]) -+ -+(define_insn "mulsf3" -+ [(set (match_operand:SF 0 "register_operand" "=r") -+ (mult:SF (match_operand:SF 1 "register_operand" "r") -+ (match_operand:SF 2 "register_operand" "r")))] -+ "TARGET_HARD_FLOAT" -+ "lf.mul.s\t%0,%1,%2 # mulsf3" -+ [(set_attr "type" "fp") -+ (set_attr "length" "1")]) -+ -+(define_insn "muldf3" -+ [(set (match_operand:DF 0 "register_operand" "=r") -+ (mult:DF (match_operand:DF 1 "register_operand" "r") -+ (match_operand:DF 2 "register_operand" "r")))] -+ "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT" -+ "lf.mul.d\t%0,%1,%2 # muldf3" -+ [(set_attr "type" "fp") -+ (set_attr "length" "1")]) -+ -+(define_insn "divsf3" -+ [(set (match_operand:SF 0 "register_operand" "=r") -+ (div:SF (match_operand:SF 1 "register_operand" "r") -+ (match_operand:SF 2 "register_operand" "r")))] -+ "TARGET_HARD_FLOAT" -+ "lf.div.s\t%0,%1,%2 # divsf3" -+ [(set_attr "type" "fp") -+ (set_attr "length" "1")]) -+ -+(define_insn "divdf3" -+ [(set (match_operand:DF 0 "register_operand" "=r") -+ (div:DF (match_operand:DF 1 "register_operand" "r") -+ (match_operand:DF 2 "register_operand" "r")))] -+ "TARGET_HARD_FLOAT && TARGET_DOUBLE_FLOAT" -+ "lf.div.d\t%0,%1,%2 # divdf3" -+ [(set_attr "type" "fp") -+ (set_attr "length" "1")]) -+ -+;; Conversion between fixed point and floating point. -+ -+ -+(define_insn "floatsisf2" -+ [(set (match_operand:SF 0 "register_operand" "=r") -+ (float:SF (match_operand:SI 1 "register_operand" "r")))] -+ "TARGET_HARD_FLOAT" -+ "lf.itof.s\t%0, %1 # floatsisf2" -+ [(set_attr "type" "fp") -+ (set_attr "length" "1")]) -+ -+;; not working -+(define_insn "fixunssfsi2" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (fix:SI (match_operand:SF 1 "register_operand" "r")))] -+ "TARGET_HARD_FLOAT" -+ "lf.ftoi.s\t%0, %1 # fixunssfsi2" -+ [(set_attr "type" "fp") -+ (set_attr "length" "1")]) -+ -+;; The insn to set GOT. -+;; TODO: support for no-delay target -+(define_insn "set_got" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (unspec:SI [(const_int 0)] UNSPEC_SET_GOT)) -+ (clobber (reg:SI 9)) -+ (clobber (reg:SI 16))] -+ "" -+ "l.jal \t8 -+ \tl.movhi \tr16,gotpchi(_GLOBAL_OFFSET_TABLE_-4) -+ \tl.ori \tr16,r16,gotpclo(_GLOBAL_OFFSET_TABLE_+0) -+ \tl.add \tr16,r16,r9" -+ [(set_attr "length" "16")]) -+ -+(define_expand "atomic_compare_and_swap" -+ [(match_operand:SI 0 "register_operand") ;; bool output -+ (match_operand:AI 1 "register_operand") ;; val output -+ (match_operand:AI 2 "memory_operand") ;; memory -+ (match_operand:AI 3 "register_operand") ;; expected -+ (match_operand:AI 4 "register_operand") ;; desired -+ (match_operand:SI 5 "const_int_operand") ;; is_weak -+ (match_operand:SI 6 "const_int_operand") ;; mod_s -+ (match_operand:SI 7 "const_int_operand")] ;; mod_f -+ "0" -+{ -+ if (mode == SImode) -+ emit_insn (gen_cmpxchg (operands[0], operands[1], operands[2], operands[3], -+ operands[4])); -+ else -+ or1k_expand_cmpxchg_qihi (operands[0], operands[1], operands[2], -+ operands[3], operands[4], INTVAL (operands[5]), -+ (enum memmodel) INTVAL (operands[6]), -+ (enum memmodel) INTVAL (operands[7])); -+ DONE; -+}) -+ -+(define_insn "cmpxchg" -+ [(set (match_operand:SI 0 "register_operand" "=&r") -+ (unspec_volatile:SI [(match_operand:SI 2 "memory_operand" "+m")] -+ UNSPEC_CMPXCHG)) -+ (set (match_dup 2) -+ (unspec_volatile:SI [(match_operand:SI 3 "register_operand" "r")] -+ UNSPEC_CMPXCHG)) -+ (set (match_operand:SI 1 "register_operand" "=&r") -+ (unspec_volatile:SI [(match_dup 2) (match_dup 3) -+ (match_operand:SI 4 "register_operand" "r")] -+ UNSPEC_CMPXCHG))] -+ "" -+ " -+ l.lwa \t%1,%2 # cmpxchg: load -+ l.sfeq \t%1,%3 # cmpxchg: cmp -+ l.bnf \t1f # cmpxchg: not expected -+ l.ori \t%0,r0,0 # cmpxchg: result = 0 -+ l.swa \t%2,%4 # cmpxchg: store new -+ l.bnf \t1f # cmpxchg: done -+ l.nop -+ l.ori \t%0,r0,1 # cmpxchg: result = 1 -+1:") -+ -+(define_insn "cmpxchg_mask" -+ [(set (match_operand:SI 0 "register_operand" "=&r") -+ (unspec_volatile:SI [(match_operand:SI 2 "memory_operand" "+m")] -+ UNSPEC_CMPXCHG)) -+ (set (match_dup 2) -+ (unspec_volatile:SI [(match_operand:SI 3 "register_operand" "r")] -+ UNSPEC_CMPXCHG)) -+ (set (match_operand:SI 1 "register_operand" "=&r") -+ (unspec_volatile:SI [(match_dup 2) (match_dup 3) -+ (match_operand:SI 4 "register_operand" "r") -+ (match_operand:SI 5 "register_operand" "r")] -+ UNSPEC_CMPXCHG)) -+ (clobber (match_scratch:SI 6 "=&r"))] -+ "" -+ " -+ l.lwa \t%6,%2 # cmpxchg: load -+ l.and \t%1,%6,%5 # cmpxchg: mask -+ l.sfeq \t%1,%3 # cmpxchg: cmp -+ l.bnf \t1f # cmpxchg: not expected -+ l.ori \t%0,r0,0 # cmpxchg: result = 0 -+ l.xor \t%6,%6,%1 # cmpxchg: clear -+ l.or \t%6,%6,%4 # cmpxchg: set -+ l.swa \t%2,%6 # cmpxchg: store new -+ l.bnf \t1f # cmpxchg: done -+ l.nop -+ l.ori \t%0,r0,1 # cmpxchg: result = 1 -+1: -+ ") -+ -+(define_expand "atomic_fetch_" -+ [(match_operand:AI 0 "register_operand") -+ (match_operand:AI 1 "memory_operand") -+ (match_operand:AI 2 "register_operand") -+ (match_operand:SI 3 "const_int_operand") -+ (atomic_op:AI (match_dup 0) (match_dup 1))] -+ "" -+{ -+ rtx ret = gen_reg_rtx (mode); -+ if (mode != SImode) -+ or1k_expand_fetch_op_qihi (operands[0], operands[1], operands[2], ret, -+ gen_fetch_and__mask); -+ else -+ emit_insn (gen_fetch_and_ (operands[0], operands[1], operands[2], -+ ret)); -+ DONE; -+}) -+ -+(define_expand "atomic__fetch" -+ [(match_operand:AI 0 "register_operand") -+ (match_operand:AI 1 "memory_operand") -+ (match_operand:AI 2 "register_operand") -+ (match_operand:SI 3 "const_int_operand") -+ (atomic_op:AI (match_dup 0) (match_dup 1))] -+ "" -+{ -+ rtx ret = gen_reg_rtx (mode); -+ if (mode != SImode) -+ or1k_expand_fetch_op_qihi (ret, operands[1], operands[2], operands[0], -+ gen_fetch_and__mask); -+ else -+ emit_insn (gen_fetch_and_ (ret, operands[1], operands[2], -+ operands[0])); -+ DONE; -+}) -+ -+(define_insn "fetch_and_" -+ [(set (match_operand:SI 0 "register_operand" "=&r") -+ (match_operand:SI 1 "memory_operand" "+m")) -+ (set (match_operand:SI 3 "register_operand" "=&r") -+ (unspec_volatile:SI [(match_dup 1) -+ (match_operand:SI 2 "register_operand" "r")] -+ UNSPEC_FETCH_AND_OP)) -+ (set (match_dup 1) -+ (match_dup 3)) -+ (atomic_op:SI (match_dup 0) (match_dup 1))] -+ "" -+ " -+1: -+ l.lwa \t%0,%1 # fetch_: load -+ l.\t\t%3,%0,%2 # fetch_: logic -+ -+ l.swa \t%1,%3 # fetch_: store new -+ l.bnf \t1b # fetch_: done -+ l.nop -+ ") -+ -+(define_insn "fetch_and__mask" -+ [(set (match_operand:SI 0 "register_operand" "=&r") -+ (match_operand:SI 1 "memory_operand" "+m")) -+ (set (match_operand:SI 3 "register_operand" "=&r") -+ (unspec_volatile:SI [(match_dup 1) -+ (match_operand:SI 2 "register_operand" "r") -+ (match_operand:SI 4 "register_operand" "r")] -+ UNSPEC_FETCH_AND_OP)) -+ (set (match_dup 1) -+ (unspec_volatile:SI [(match_dup 3) (match_dup 4)] UNSPEC_FETCH_AND_OP)) -+ (clobber (match_scratch:SI 5 "=&r")) -+ (atomic_op:SI (match_dup 0) (match_dup 1))] -+ "" -+ " -+1: -+ l.lwa \t%0,%1 # fetch_: load -+ l.and \t%5,%0,%4 # fetch_: mask -+ l.xor \t%5,%0,%5 # fetch_: clear -+ l.\t\t%3,%0,%2 # fetch_: logic -+ -+ l.and \t%3,%3,%4 # fetch_: mask result -+ l.or \t%3,%5,%3 # fetch_: set -+ l.swa \t%1,%3 # fetch_: store new -+ l.bnf \t1b # fetch_: done -+ l.nop -+ ") -+ -+;; Local variables: -+;; mode:emacs-lisp -+;; comment-start: ";; " -+;; eval: (set-syntax-table (copy-sequence (syntax-table))) -+;; eval: (modify-syntax-entry ?[ "(]") -+;; eval: (modify-syntax-entry ?] ")[") -+;; eval: (modify-syntax-entry ?{ "(}") -+;; eval: (modify-syntax-entry ?} "){") -+;; eval: (setq indent-tabs-mode t) -+;; End: -diff -rNU3 dist.orig/gcc/config/or1k/or1k.opt dist/gcc/config/or1k/or1k.opt ---- dist.orig/gcc/config/or1k/or1k.opt 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/or1k/or1k.opt 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,96 @@ -+; Options for the OR1K port of the compiler -+; This file is part of GCC. -+; -+; Copyright (C) 2010 Embecosm Limited -+; -+; GCC is free software; you can redistribute it and/or modify it under -+; the terms of the GNU General Public License as published by the Free -+; Software Foundation; either version 3, or (at your option) any later -+; version. -+; -+; GCC is distributed in the hope that it will be useful, but WITHOUT ANY -+; WARRANTY; without even the implied warranty of MERCHANTABILITY or -+; FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -+; for more details. -+; -+; You should have received a copy of the GNU General Public License -+; along with GCC; see the file COPYING3. If not see -+; . -+ -+HeaderInclude -+config/or1k/or1k-opts.h -+ -+Variable -+enum or1k_delay or1k_delay_selected = OR1K_DELAY_DEFAULT -+ -+mdelay -+Target RejectNegative Negative(mno-delay) Var(or1k_delay_selected, OR1K_DELAY_ON) -+Assume branches and jumps have a delay slot -+ -+mno-delay -+Target RejectNegative Negative(mcompat-delay) Var(or1k_delay_selected, OR1K_DELAY_OFF) -+Assume branches and jumps do not have a delay slot -+ -+mcompat-delay -+Target RejectNegative Negative(mdelay) Var(or1k_delay_selected, OR1K_DELAY_COMPAT) -+Assume branches and jumps have a delay slot, but fill them with nops -+ -+mhard-float -+Target RejectNegative Mask(HARD_FLOAT) -+Use hardware floating point -+ -+msoft-float -+Target RejectNegative InverseMask(HARD_FLOAT) -+Do not use hardware floating point -+ -+mdouble-float -+Target Report RejectNegative Mask(DOUBLE_FLOAT) -+Allow hardware floating-point instructions to cover both 32-bit and 64-bit operations -+ -+mhard-div -+Target RejectNegative Mask(HARD_DIV) -+Use hardware division -+ -+msoft-div -+Target RejectNegative InverseMask(HARD_DIV) -+Do not use hardware division -+ -+mhard-mul -+Target RejectNegative Mask(HARD_MUL) -+Use hardware multiplication -+ -+msoft-mul -+Target RejectNegative InverseMask(HARD_MUL) -+Do not use hardware multiplication -+ -+msext -+Target Mask(MASK_SEXT) -+Use sign-extending instructions -+ -+mcmov -+Target Mask(MASK_CMOV) -+Use conditional move instructions -+ -+mror -+Target Mask(MASK_ROR) -+Emit ROR instructions -+ -+mboard= -+Target RejectNegative Joined -+Link with libgloss configuration suitable for this board -+ -+mnewlib -+Target Report RejectNegative -+Compile for the Linux/Gnu/newlib based toolchain -+ -+;; provide struct padding as in previous releases. -+;; Note that this will only affect STRUCTURE_SIZE_BOUNDARY, in particular -+;; make 2 byte structs 4-byte alignned and sized. -+;; We still use ROUND_TYPE_ALIGN to increase alignment of larger structs. -+mpadstruct -+Target Report RejectNegative Mask(PADSTRUCT) -+Make structs a multiple of 4 bytes (warning: ABI altered) -+ -+mredzone= -+Target RejectNegative Joined UInteger Var(or1k_redzone) Init(128) -+Set the size of the stack below sp that is assumed to be safe from interrupts. -diff -rNU3 dist.orig/gcc/config/or1k/predicates.md dist/gcc/config/or1k/predicates.md ---- dist.orig/gcc/config/or1k/predicates.md 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/or1k/predicates.md 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,121 @@ -+;; Predicate definitions for OR32 -+;; -+;; Copyright (C) 2010 Embecosm Limited -+;; -+;; This file is part of GCC. -+;; -+;; GCC is free software; you can redistribute it and/or modify -+;; it under the terms of the GNU General Public License as published by -+;; the Free Software Foundation; either version 3, or (at your option) -+;; any later version. -+;; -+;; GCC is distributed in the hope that it will be useful, -+;; but WITHOUT ANY WARRANTY; without even the implied warranty of -+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+;; GNU General Public License for more details. -+;; -+;; You should have received a copy of the GNU General Public License -+;; along with GCC; see the file COPYING3. If not see -+;; . -+ -+(define_predicate "cc_reg_operand" -+ (match_code "subreg,reg") -+{ -+ register_operand (op, mode); -+ -+ if (GET_CODE (op) == REG && REGNO (op) == CC_REG) -+ return 1; -+ -+ return 0; -+}) -+ -+(define_predicate "input_operand" -+ (match_code "subreg,reg,const_int,mem,const") -+{ -+ /* If both modes are non-void they must be the same. */ -+ if (mode != VOIDmode && GET_MODE (op) != VOIDmode && mode != GET_MODE (op)) -+ return 0; -+ -+ /* Allow any one instruction integer constant, and all CONST_INT -+ variants when we are working in DImode and !arch64. */ -+ if (GET_MODE_CLASS (mode) == MODE_INT -+ && ((GET_CODE (op) == CONST_INT) -+ && (satisfies_constraint_K (op) -+ || satisfies_constraint_M (op) -+ || satisfies_constraint_I (op)))) -+ return 1; -+ -+ if (register_operand (op, mode)) -+ return 1; -+ -+ /* If this is a SUBREG, look inside so that we handle -+ paradoxical ones. */ -+ if (GET_CODE (op) == SUBREG) -+ op = SUBREG_REG (op); -+ -+ -+ /* Check for valid MEM forms. */ -+ if (GET_CODE (op) == MEM) -+ return memory_address_p (mode, XEXP (op, 0)); -+ -+ return 0; -+}) -+ -+(define_predicate "sym_ref_mem_operand" -+ (match_code "mem") -+{ -+ if (GET_CODE (op) == MEM) -+ { -+ rtx t1 = XEXP (op, 0); -+ if (GET_CODE (t1) == SYMBOL_REF) -+ return 1; -+ } -+ return 0; -+}) -+ -+;; True iff OP is a symbolic operand. -+ -+(define_predicate "symbolic_operand" -+ (match_code "symbol_ref,label_ref,const") -+{ -+ switch (GET_CODE (op)) -+ { -+ case SYMBOL_REF: -+ return !SYMBOL_REF_TLS_MODEL (op); -+ case LABEL_REF: -+ return true; -+ case CONST: -+ op = XEXP (op, 0); -+ return (GET_CODE (op) == PLUS -+ && ((GET_CODE (XEXP (op, 0)) == SYMBOL_REF -+ && !SYMBOL_REF_TLS_MODEL (XEXP (op, 0))) -+ || GET_CODE (XEXP (op, 0)) == LABEL_REF) -+ && GET_CODE (XEXP (op, 1)) == CONST_INT); -+ default: -+ break; -+ } -+ return false; -+}) -+ -+;; Return true if OP is a symbolic operand for the TLS Global Dynamic model. -+(define_predicate "tgd_symbolic_operand" -+ (and (match_code "symbol_ref") -+ (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_GLOBAL_DYNAMIC"))) -+ -+;; Return true if OP is a symbolic operand for the TLS Local Dynamic model. -+ -+(define_predicate "tld_symbolic_operand" -+ (and (match_code "symbol_ref") -+ (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_DYNAMIC"))) -+ -+;; Return true if OP is a symbolic operand for the TLS Initial Exec model. -+ -+(define_predicate "tie_symbolic_operand" -+ (and (match_code "symbol_ref") -+ (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_INITIAL_EXEC"))) -+ -+;; Return true if OP is a symbolic operand for the TLS Local Exec model. -+ -+(define_predicate "tle_symbolic_operand" -+ (and (match_code "symbol_ref") -+ (match_test "SYMBOL_REF_TLS_MODEL (op) == TLS_MODEL_LOCAL_EXEC"))) -diff -rNU3 dist.orig/gcc/config/or1k/t-linux dist/gcc/config/or1k/t-linux ---- dist.orig/gcc/config/or1k/t-linux 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/or1k/t-linux 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,12 @@ -+MULTILIB_DIRNAMES = -+EXTRA_MULTILIB_PARTS = crti.o crtbegin.o crtend.o crtn.o -+ -+# hack: -+# the non-shared uclibc-0.9.31/libc/misc/internals/__uClibc_main.c -+# already defines __dso_handle. To avoid a duplicate definition, -+# we rename the crtbegin one. -+# JPB 18-Nov-10: Commented out, since uClibc no longer defines. -+# amend gcc Makefile CLFAGS variable -+# $(T)crtbegin.o: CRTSTUFF_CFLAGS += '-D__dso_handle=__dso_handle_dummy' -+# amend libgcc Makefile CLFAGS variable -+# crtbegin$(objext): CRTSTUFF_T_CFLAGS += '-D__dso_handle=__dso_handle_dummy' -diff -rNU3 dist.orig/gcc/config/or1k/t-or1k dist/gcc/config/or1k/t-or1k ---- dist.orig/gcc/config/or1k/t-or1k 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/or1k/t-or1k 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,28 @@ -+# t-or1k is a Makefile fragment to be included when -+# building gcc for the or1k target -+ -+# Copyright (C) 2010 Embecosm Limited -+ -+# This file is part of GCC. -+# -+# GCC is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3, or (at your option) -+# any later version. -+# -+# GCC is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with GCC; see the file COPYING3. If not see -+# . -+ -+# we don't support -g so don't use it -+LIBGCC2_DEBUG_CFLAGS = -+ -+# Build the libraries for both hard and soft floating point -+MULTILIB_OPTIONS = mno-delay/mcompat-delay msoft-float -+MULTILIB_DIRNAMES = no-delay compat-delay soft-float -+MULTILIB_MATCHES = -diff -rNU3 dist.orig/gcc/config/or1k/t-or1knd dist/gcc/config/or1k/t-or1knd ---- dist.orig/gcc/config/or1k/t-or1knd 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/or1k/t-or1knd 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,28 @@ -+# t-or1knd is a Makefile fragment to be included when -+# building gcc for the or1k target -+ -+# Copyright (C) 2010 Embecosm Limited -+ -+# This file is part of GCC. -+# -+# GCC is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3, or (at your option) -+# any later version. -+# -+# GCC is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with GCC; see the file COPYING3. If not see -+# . -+ -+# we don't support -g so don't use it -+LIBGCC2_DEBUG_CFLAGS = -+ -+# Build the libraries for both hard and soft floating point -+MULTILIB_OPTIONS = mdelay/mcompat-delay msoft-float -+MULTILIB_DIRNAMES = delay compat-delay soft-float -+MULTILIB_MATCHES = -diff -rNU3 dist.orig/gcc/config/pa/pa-netbsd.h dist/gcc/config/pa/pa-netbsd.h ---- dist.orig/gcc/config/pa/pa-netbsd.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/pa/pa-netbsd.h 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,148 @@ -+/* Definitions for PA_RISC with ELF format -+ Copyright (C) 1999-2013 Free Software Foundation, Inc. -+ -+This file is part of GCC. -+ -+GCC is free software; you can redistribute it and/or modify -+it under the terms of the GNU General Public License as published by -+the Free Software Foundation; either version 3, or (at your option) -+any later version. -+ -+GCC is distributed in the hope that it will be useful, -+but WITHOUT ANY WARRANTY; without even the implied warranty of -+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+GNU General Public License for more details. -+ -+You should have received a copy of the GNU General Public License -+along with GCC; see the file COPYING3. If not see -+. */ -+ -+ -+#undef TARGET_OS_CPP_BUILTINS -+#define TARGET_OS_CPP_BUILTINS() \ -+ do \ -+ { \ -+ NETBSD_OS_CPP_BUILTINS_ELF(); \ -+ builtin_assert ("machine=bigendian"); \ -+ } \ -+ while (0) -+ -+#undef CPP_SPEC -+#define CPP_SPEC NETBSD_CPP_SPEC -+ -+#undef ASM_SPEC -+#define ASM_SPEC \ -+ "%{v:-V} %{n} %{T} %{Ym,*} %{Yd,*} %{Wa,*:%*}" -+ -+#undef EXTRA_SPECS -+#define EXTRA_SPECS \ -+ { "netbsd_entry_point", NETBSD_ENTRY_POINT }, -+ -+#define NETBSD_ENTRY_POINT "__start" -+ -+#undef LINK_SPEC -+#define LINK_SPEC NETBSD_LINK_SPEC_ELF -+ -+/* NetBSD profiling functions don't need gcc to allocate counters. */ -+#define NO_DEFERRED_PROFILE_COUNTERS 1 -+ -+/* Define the strings used for the special svr4 .type and .size directives. -+ These strings generally do not vary from one system running svr4 to -+ another, but if a given system (e.g. m88k running svr) needs to use -+ different pseudo-op names for these, they may be overridden in the -+ file which includes this one. */ -+ -+#undef STRING_ASM_OP -+#define STRING_ASM_OP "\t.stringz\t" -+ -+#define TEXT_SECTION_ASM_OP "\t.text" -+#define DATA_SECTION_ASM_OP "\t.data" -+#define BSS_SECTION_ASM_OP "\t.section\t.bss" -+ -+#define TARGET_ASM_FILE_START pa_linux_file_start -+ -+/* We want local labels to start with period if made with asm_fprintf. */ -+#undef LOCAL_LABEL_PREFIX -+#define LOCAL_LABEL_PREFIX "." -+ -+/* Define these to generate the Linux/ELF/SysV style of internal -+ labels all the time - i.e. to be compatible with -+ ASM_GENERATE_INTERNAL_LABEL in . Compare these with the -+ ones in pa.h and note the lack of dollar signs in these. FIXME: -+ shouldn't we fix pa.h to use ASM_GENERATE_INTERNAL_LABEL instead? */ -+ -+#undef ASM_OUTPUT_ADDR_VEC_ELT -+#define ASM_OUTPUT_ADDR_VEC_ELT(FILE, VALUE) \ -+ if (TARGET_BIG_SWITCH) \ -+ fprintf (FILE, "\t.word .L%d\n", VALUE); \ -+ else \ -+ fprintf (FILE, "\tb .L%d\n\tnop\n", VALUE) -+ -+#undef ASM_OUTPUT_ADDR_DIFF_ELT -+#define ASM_OUTPUT_ADDR_DIFF_ELT(FILE, BODY, VALUE, REL) \ -+ if (TARGET_BIG_SWITCH) \ -+ fprintf (FILE, "\t.word .L%d-.L%d\n", VALUE, REL); \ -+ else \ -+ fprintf (FILE, "\tb .L%d\n\tnop\n", VALUE) -+ -+/* Use the default. */ -+#undef ASM_OUTPUT_LABEL -+ -+/* NOTE: (*targetm.asm_out.internal_label)() is defined for us by elfos.h, and -+ does what we want (i.e. uses colons). It must be compatible with -+ ASM_GENERATE_INTERNAL_LABEL(), so do not define it here. */ -+ -+/* Use the default. */ -+#undef ASM_OUTPUT_INTERNAL_LABEL -+ -+/* Use the default. */ -+#undef TARGET_ASM_GLOBALIZE_LABEL -+/* Globalizing directive for a label. */ -+#define GLOBAL_ASM_OP ".globl " -+ -+/* FIXME: Hacked from the one so that we avoid multiple -+ labels in a function declaration (since pa.c seems determined to do -+ it differently) */ -+ -+#undef ASM_DECLARE_FUNCTION_NAME -+#define ASM_DECLARE_FUNCTION_NAME(FILE, NAME, DECL) \ -+ do \ -+ { \ -+ ASM_OUTPUT_TYPE_DIRECTIVE (FILE, NAME, "function"); \ -+ ASM_DECLARE_RESULT (FILE, DECL_RESULT (DECL)); \ -+ } \ -+ while (0) -+ -+/* As well as globalizing the label, we need to encode the label -+ to ensure a plabel is generated in an indirect call. */ -+ -+#undef ASM_OUTPUT_EXTERNAL_LIBCALL -+#define ASM_OUTPUT_EXTERNAL_LIBCALL(FILE, FUN) \ -+ do \ -+ { \ -+ if (!FUNCTION_NAME_P (XSTR (FUN, 0))) \ -+ pa_encode_label (FUN); \ -+ (*targetm.asm_out.globalize_label) (FILE, XSTR (FUN, 0)); \ -+ } \ -+ while (0) -+ -+/* NetBSD always uses gas. */ -+#undef TARGET_GAS -+#define TARGET_GAS 1 -+ -+/* Use long int for these type to make hppa64 compatibility easier. */ -+#undef SIZE_TYPE -+#define SIZE_TYPE "long unsigned int" -+ -+#undef PTRDIFF_TYPE -+#define PTRDIFF_TYPE "long int" -+ -+#if 0 -+#undef TARGET_SYNC_LIBCALL -+#define TARGET_SYNC_LIBCALL 1 -+#endif -+ -+#if 0 -+#undef TARGET_SYNC_LIBCALL -+#define TARGET_SYNC_LIBCALL 1 -+#endif -diff -rNU3 dist.orig/gcc/config/pa/pa.c dist/gcc/config/pa/pa.c ---- dist.orig/gcc/config/pa/pa.c 2015-06-12 01:26:24.000000000 +0200 -+++ dist/gcc/config/pa/pa.c 2015-10-18 13:19:50.000000000 +0200 -@@ -1066,9 +1066,9 @@ - || GET_CODE (XEXP (x, 0)) == REG)) - { - rtx int_part, ptr_reg; -- int newoffset; -- int offset = INTVAL (XEXP (x, 1)); -- int mask; -+ HOST_WIDE_INT newoffset; -+ HOST_WIDE_INT offset = INTVAL (XEXP (x, 1)); -+ HOST_WIDE_INT mask; - - mask = (GET_MODE_CLASS (mode) == MODE_FLOAT - && !INT14_OK_STRICT ? 0x1f : 0x3fff); -@@ -1122,7 +1122,7 @@ - || GET_CODE (XEXP (x, 1)) == SUBREG) - && GET_CODE (XEXP (x, 1)) != CONST) - { -- int val = INTVAL (XEXP (XEXP (x, 0), 1)); -+ HOST_WIDE_INT val = INTVAL (XEXP (XEXP (x, 0), 1)); - rtx reg1, reg2; - - reg1 = XEXP (x, 1); -@@ -1199,7 +1199,7 @@ - && INTVAL (XEXP (idx, 1)) % INTVAL (XEXP (XEXP (idx, 0), 1)) == 0) - { - /* Divide the CONST_INT by the scale factor, then add it to A. */ -- int val = INTVAL (XEXP (idx, 1)); -+ HOST_WIDE_INT val = INTVAL (XEXP (idx, 1)); - - val /= INTVAL (XEXP (XEXP (idx, 0), 1)); - reg1 = XEXP (XEXP (idx, 0), 0); -@@ -1222,7 +1222,7 @@ - && INTVAL (XEXP (idx, 1)) <= 4096 - && INTVAL (XEXP (idx, 1)) >= -4096) - { -- int val = INTVAL (XEXP (XEXP (idx, 0), 1)); -+ HOST_WIDE_INT val = INTVAL (XEXP (XEXP (idx, 0), 1)); - rtx reg1, reg2; - - reg1 = force_reg (Pmode, gen_rtx_PLUS (Pmode, base, XEXP (idx, 1))); -@@ -1306,7 +1306,7 @@ - && GET_CODE (XEXP (XEXP (x, 0), 1)) == CONST_INT - && pa_shadd_constant_p (INTVAL (XEXP (XEXP (x, 0), 1)))) - { -- int val = INTVAL (XEXP (XEXP (x, 0), 1)); -+ HOST_WIDE_INT val = INTVAL (XEXP (XEXP (x, 0), 1)); - rtx reg1, reg2; - - reg1 = XEXP (x, 1); -@@ -2779,8 +2779,8 @@ - const char * - pa_output_block_move (rtx *operands, int size_is_constant ATTRIBUTE_UNUSED) - { -- int align = INTVAL (operands[5]); -- unsigned long n_bytes = INTVAL (operands[4]); -+ HOST_WIDE_INT align = INTVAL (operands[5]); -+ unsigned HOST_WIDE_INT n_bytes = INTVAL (operands[4]); - - /* We can't move more than a word at a time because the PA - has no longer integer move insns. (Could use fp mem ops?) */ -@@ -2907,8 +2907,8 @@ - compute_movmem_length (rtx insn) - { - rtx pat = PATTERN (insn); -- unsigned int align = INTVAL (XEXP (XVECEXP (pat, 0, 7), 0)); -- unsigned long n_bytes = INTVAL (XEXP (XVECEXP (pat, 0, 6), 0)); -+ unsigned HOST_WIDE_INT align = INTVAL (XEXP (XVECEXP (pat, 0, 7), 0)); -+ unsigned HOST_WIDE_INT n_bytes = INTVAL (XEXP (XVECEXP (pat, 0, 6), 0)); - unsigned int n_insns = 0; - - /* We can't move more than four bytes at a time because the PA -@@ -2943,8 +2943,8 @@ - const char * - pa_output_block_clear (rtx *operands, int size_is_constant ATTRIBUTE_UNUSED) - { -- int align = INTVAL (operands[3]); -- unsigned long n_bytes = INTVAL (operands[2]); -+ HOST_WIDE_INT align = INTVAL (operands[3]); -+ unsigned HOST_WIDE_INT n_bytes = INTVAL (operands[2]); - - /* We can't clear more than a word at a time because the PA - has no longer integer move insns. */ -@@ -3049,8 +3049,8 @@ - compute_clrmem_length (rtx insn) - { - rtx pat = PATTERN (insn); -- unsigned int align = INTVAL (XEXP (XVECEXP (pat, 0, 4), 0)); -- unsigned long n_bytes = INTVAL (XEXP (XVECEXP (pat, 0, 3), 0)); -+ unsigned HOST_WIDE_INT align = INTVAL (XEXP (XVECEXP (pat, 0, 4), 0)); -+ unsigned HOST_WIDE_INT n_bytes = INTVAL (XEXP (XVECEXP (pat, 0, 3), 0)); - unsigned int n_insns = 0; - - /* We can't clear more than a word at a time because the PA -@@ -5562,7 +5562,7 @@ - static void - pa_linux_file_start (void) - { -- pa_file_start_file (1); -+ pa_file_start_file (0); - pa_file_start_level (); - pa_file_start_mcount ("CODE"); - } -@@ -5787,7 +5787,7 @@ - const char * - pa_output_div_insn (rtx *operands, int unsignedp, rtx insn) - { -- int divisor; -+ HOST_WIDE_INT divisor; - - /* If the divisor is a constant, try to use one of the special - opcodes .*/ -diff -rNU3 dist.orig/gcc/config/pa/pa32-netbsd.h dist/gcc/config/pa/pa32-netbsd.h ---- dist.orig/gcc/config/pa/pa32-netbsd.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/pa/pa32-netbsd.h 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,37 @@ -+/* Definitions for PA_RISC with ELF-32 format -+ Copyright (C) 2000, 2002 Free Software Foundation, Inc. -+ -+This file is part of GCC. -+ -+GCC is free software; you can redistribute it and/or modify -+it under the terms of the GNU General Public License as published by -+the Free Software Foundation; either version 2, or (at your option) -+any later version. -+ -+GCC is distributed in the hope that it will be useful, -+but WITHOUT ANY WARRANTY; without even the implied warranty of -+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+GNU General Public License for more details. -+ -+You should have received a copy of the GNU General Public License -+along with GCC; see the file COPYING. If not, write to -+the Free Software Foundation, 59 Temple Place - Suite 330, -+Boston, MA 02111-1307, USA. */ -+ -+/* Turn off various SOM crap we don't want. */ -+#undef TARGET_ELF32 -+#define TARGET_ELF32 1 -+ -+/* The libcall __canonicalize_funcptr_for_compare is referenced in -+ crtend.o and the reference isn't resolved in objects that don't -+ compare function pointers. Thus, we need to play games to provide -+ a reference in crtbegin.o. The rest of the define is the same -+ as that in crtstuff.c */ -+#define CTOR_LIST_BEGIN \ -+ asm (".type __canonicalize_funcptr_for_compare,@function\n" \ -+" .text\n" \ -+" .word __canonicalize_funcptr_for_compare-$PIC_pcrel$0"); \ -+ STATIC func_ptr __CTOR_LIST__[1] \ -+ __attribute__ ((__unused__, section(".ctors"), \ -+ aligned(sizeof(func_ptr)))) \ -+ = { (func_ptr) (-1) } -diff -rNU3 dist.orig/gcc/config/pa/t-netbsd dist/gcc/config/pa/t-netbsd ---- dist.orig/gcc/config/pa/t-netbsd 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/pa/t-netbsd 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1 @@ -+#MULTIARCH_DIRNAME = $(call if_multiarch,hppa-linux-gnu) -diff -rNU3 dist.orig/gcc/config/riscv/constraints.md dist/gcc/config/riscv/constraints.md ---- dist.orig/gcc/config/riscv/constraints.md 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/riscv/constraints.md 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,90 @@ -+;; Constraint definitions for RISC-V target. -+;; Copyright (C) 2011-2014 Free Software Foundation, Inc. -+;; Contributed by Andrew Waterman (waterman@cs.berkeley.edu) at UC Berkeley. -+;; Based on MIPS target for GNU compiler. -+;; -+;; This file is part of GCC. -+;; -+;; GCC is free software; you can redistribute it and/or modify -+;; it under the terms of the GNU General Public License as published by -+;; the Free Software Foundation; either version 3, or (at your option) -+;; any later version. -+;; -+;; GCC is distributed in the hope that it will be useful, -+;; but WITHOUT ANY WARRANTY; without even the implied warranty of -+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+;; GNU General Public License for more details. -+;; -+;; You should have received a copy of the GNU General Public License -+;; along with GCC; see the file COPYING3. If not see -+;; . -+ -+;; Register constraints -+ -+(define_register_constraint "f" "TARGET_HARD_FLOAT ? FP_REGS : NO_REGS" -+ "A floating-point register (if available).") -+ -+(define_register_constraint "b" "ALL_REGS" -+ "@internal") -+ -+(define_register_constraint "j" "T_REGS" -+ "@internal") -+ -+;; Integer constraints -+ -+(define_constraint "Z" -+ "@internal" -+ (and (match_code "const_int") -+ (match_test "1"))) -+ -+(define_constraint "I" -+ "An I-type 12-bit signed immediate." -+ (and (match_code "const_int") -+ (match_test "SMALL_OPERAND (ival)"))) -+ -+(define_constraint "J" -+ "Integer zero." -+ (and (match_code "const_int") -+ (match_test "ival == 0"))) -+ -+;; Floating-point constraints -+ -+(define_constraint "G" -+ "Floating-point zero." -+ (and (match_code "const_double") -+ (match_test "op == CONST0_RTX (mode)"))) -+ -+;; General constraints -+ -+(define_constraint "Q" -+ "@internal" -+ (match_operand 0 "const_arith_operand")) -+ -+(define_memory_constraint "A" -+ "An address that is held in a general-purpose register." -+ (and (match_code "mem") -+ (match_test "GET_CODE(XEXP(op,0)) == REG"))) -+ -+(define_constraint "S" -+ "@internal -+ A constant call address." -+ (and (match_operand 0 "call_insn_operand") -+ (match_test "CONSTANT_P (op)"))) -+ -+(define_constraint "T" -+ "@internal -+ A constant @code{move_operand}." -+ (and (match_operand 0 "move_operand") -+ (match_test "CONSTANT_P (op)"))) -+ -+(define_memory_constraint "W" -+ "@internal -+ A memory address based on a member of @code{BASE_REG_CLASS}." -+ (and (match_code "mem") -+ (match_operand 0 "memory_operand"))) -+ -+(define_constraint "YG" -+ "@internal -+ A vector zero." -+ (and (match_code "const_vector") -+ (match_test "op == CONST0_RTX (mode)"))) -diff -rNU3 dist.orig/gcc/config/riscv/default-32.h dist/gcc/config/riscv/default-32.h ---- dist.orig/gcc/config/riscv/default-32.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/riscv/default-32.h 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,22 @@ -+/* Definitions of target machine for GCC, for RISC-V, -+ defaulting to 32-bit code generation. -+ -+ Copyright (C) 1999-2014 Free Software Foundation, Inc. -+ -+This file is part of GCC. -+ -+GCC is free software; you can redistribute it and/or modify -+it under the terms of the GNU General Public License as published by -+the Free Software Foundation; either version 3, or (at your option) -+any later version. -+ -+GCC is distributed in the hope that it will be useful, -+but WITHOUT ANY WARRANTY; without even the implied warranty of -+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+GNU General Public License for more details. -+ -+You should have received a copy of the GNU General Public License -+along with GCC; see the file COPYING3. If not see -+. */ -+ -+#define TARGET_64BIT_DEFAULT 0 -diff -rNU3 dist.orig/gcc/config/riscv/elf.h dist/gcc/config/riscv/elf.h ---- dist.orig/gcc/config/riscv/elf.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/riscv/elf.h 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,31 @@ -+/* Target macros for riscv*-elf targets. -+ Copyright (C) 1994, 1997, 1999, 2000, 2002, 2003, 2004, 2007, 2010 -+ Free Software Foundation, Inc. -+ -+This file is part of GCC. -+ -+GCC is free software; you can redistribute it and/or modify -+it under the terms of the GNU General Public License as published by -+the Free Software Foundation; either version 3, or (at your option) -+any later version. -+ -+GCC is distributed in the hope that it will be useful, -+but WITHOUT ANY WARRANTY; without even the implied warranty of -+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+GNU General Public License for more details. -+ -+You should have received a copy of the GNU General Public License -+along with GCC; see the file COPYING3. If not see -+. */ -+ -+/* Leave the linker script to choose the appropriate libraries. */ -+#undef LIB_SPEC -+#define LIB_SPEC "" -+ -+#undef STARTFILE_SPEC -+#define STARTFILE_SPEC "crt0%O%s crtbegin%O%s" -+ -+#undef ENDFILE_SPEC -+#define ENDFILE_SPEC "crtend%O%s" -+ -+#define NO_IMPLICIT_EXTERN_C 1 -diff -rNU3 dist.orig/gcc/config/riscv/generic.md dist/gcc/config/riscv/generic.md ---- dist.orig/gcc/config/riscv/generic.md 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/riscv/generic.md 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,98 @@ -+;; Generic DFA-based pipeline description for RISC-V targets. -+;; Copyright (C) 2011-2014 Free Software Foundation, Inc. -+;; Contributed by Andrew Waterman (waterman@cs.berkeley.edu) at UC Berkeley. -+;; Based on MIPS target for GNU compiler. -+ -+;; This file is part of GCC. -+ -+;; GCC is free software; you can redistribute it and/or modify it -+;; under the terms of the GNU General Public License as published -+;; by the Free Software Foundation; either version 3, or (at your -+;; option) any later version. -+ -+;; GCC is distributed in the hope that it will be useful, but WITHOUT -+;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -+;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -+;; License for more details. -+ -+;; You should have received a copy of the GNU General Public License -+;; along with GCC; see the file COPYING3. If not see -+;; . -+ -+ -+;; This file is derived from the old define_function_unit description. -+;; Each reservation can be overridden on a processor-by-processor basis. -+ -+(define_insn_reservation "generic_alu" 1 -+ (eq_attr "type" "unknown,const,arith,shift,slt,multi,nop,logical,move") -+ "alu") -+ -+(define_insn_reservation "generic_load" 3 -+ (eq_attr "type" "load,fpload,fpidxload") -+ "alu") -+ -+(define_insn_reservation "generic_store" 1 -+ (eq_attr "type" "store,fpstore,fpidxstore") -+ "alu") -+ -+(define_insn_reservation "generic_xfer" 2 -+ (eq_attr "type" "mfc,mtc") -+ "alu") -+ -+(define_insn_reservation "generic_branch" 1 -+ (eq_attr "type" "branch,jump,call") -+ "alu") -+ -+(define_insn_reservation "generic_imul" 17 -+ (eq_attr "type" "imul") -+ "imuldiv*17") -+ -+(define_insn_reservation "generic_idiv" 38 -+ (eq_attr "type" "idiv") -+ "imuldiv*38") -+ -+(define_insn_reservation "generic_fcvt" 1 -+ (eq_attr "type" "fcvt") -+ "alu") -+ -+(define_insn_reservation "generic_fmove" 2 -+ (eq_attr "type" "fmove") -+ "alu") -+ -+(define_insn_reservation "generic_fcmp" 3 -+ (eq_attr "type" "fcmp") -+ "alu") -+ -+(define_insn_reservation "generic_fadd" 4 -+ (eq_attr "type" "fadd") -+ "alu") -+ -+(define_insn_reservation "generic_fmul_single" 7 -+ (and (eq_attr "type" "fmul,fmadd") -+ (eq_attr "mode" "SF")) -+ "alu") -+ -+(define_insn_reservation "generic_fmul_double" 8 -+ (and (eq_attr "type" "fmul,fmadd") -+ (eq_attr "mode" "DF")) -+ "alu") -+ -+(define_insn_reservation "generic_fdiv_single" 23 -+ (and (eq_attr "type" "fdiv") -+ (eq_attr "mode" "SF")) -+ "alu") -+ -+(define_insn_reservation "generic_fdiv_double" 36 -+ (and (eq_attr "type" "fdiv") -+ (eq_attr "mode" "DF")) -+ "alu") -+ -+(define_insn_reservation "generic_fsqrt_single" 54 -+ (and (eq_attr "type" "fsqrt") -+ (eq_attr "mode" "SF")) -+ "alu") -+ -+(define_insn_reservation "generic_fsqrt_double" 112 -+ (and (eq_attr "type" "fsqrt") -+ (eq_attr "mode" "DF")) -+ "alu") -diff -rNU3 dist.orig/gcc/config/riscv/linux-unwind.h dist/gcc/config/riscv/linux-unwind.h ---- dist.orig/gcc/config/riscv/linux-unwind.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/riscv/linux-unwind.h 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,50 @@ -+/* DWARF2 EH unwinding support for RISC-V Linux. -+ Copyright (C) 2014 Free Software Foundation, Inc. -+ -+This file is part of GCC. -+ -+GCC is free software; you can redistribute it and/or modify -+it under the terms of the GNU General Public License as published by -+the Free Software Foundation; either version 3, or (at your option) -+any later version. -+ -+GCC is distributed in the hope that it will be useful, -+but WITHOUT ANY WARRANTY; without even the implied warranty of -+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+GNU General Public License for more details. -+ -+Under Section 7 of GPL version 3, you are granted additional -+permissions described in the GCC Runtime Library Exception, version -+3.1, as published by the Free Software Foundation. -+ -+You should have received a copy of the GNU General Public License and -+a copy of the GCC Runtime Library Exception along with this program; -+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -+. */ -+ -+#ifndef inhibit_libc -+/* Examine the code and attempt to identify a signal frame. */ -+ -+#include -+#include -+ -+#define MD_FALLBACK_FRAME_STATE_FOR riscv_fallback_frame_state -+ -+static _Unwind_Reason_Code -+riscv_fallback_frame_state (struct _Unwind_Context *context, -+ _Unwind_FrameState *fs) -+{ -+ unsigned int *pc = (unsigned int *) context->ra; -+ -+ /* Signal frames begin with the following code sequence: -+ li v0, __NR_rt_sigreturn -+ scall */ -+ if (((unsigned long)pc & 0x3) != 0 -+ || pc[0] != RISCV_ITYPE (ADDI, GP_RETURN, 0, __NR_rt_sigreturn) -+ || pc[1] != RISCV_ITYPE (SCALL, 0, 0, 0)) -+ return _URC_END_OF_STACK; -+ -+ /* TODO: Actually implement this. */ -+ abort(); -+} -+#endif -diff -rNU3 dist.orig/gcc/config/riscv/linux.h dist/gcc/config/riscv/linux.h ---- dist.orig/gcc/config/riscv/linux.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/riscv/linux.h 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,60 @@ -+/* Definitions for RISC-V GNU/Linux systems with ELF format. -+ Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, -+ 2007, 2008, 2010, 2011 Free Software Foundation, Inc. -+ -+This file is part of GCC. -+ -+GCC is free software; you can redistribute it and/or modify -+it under the terms of the GNU General Public License as published by -+the Free Software Foundation; either version 3, or (at your option) -+any later version. -+ -+GCC is distributed in the hope that it will be useful, -+but WITHOUT ANY WARRANTY; without even the implied warranty of -+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+GNU General Public License for more details. -+ -+You should have received a copy of the GNU General Public License -+along with GCC; see the file COPYING3. If not see -+. */ -+ -+#undef WCHAR_TYPE -+#define WCHAR_TYPE "int" -+ -+#undef WCHAR_TYPE_SIZE -+#define WCHAR_TYPE_SIZE 32 -+ -+#define TARGET_OS_CPP_BUILTINS() \ -+ do { \ -+ GNU_USER_TARGET_OS_CPP_BUILTINS(); \ -+ /* The GNU C++ standard library requires this. */ \ -+ if (c_dialect_cxx ()) \ -+ builtin_define ("_GNU_SOURCE"); \ -+ } while (0) -+ -+#undef SUBTARGET_CPP_SPEC -+#define SUBTARGET_CPP_SPEC "%{posix:-D_POSIX_SOURCE} %{pthread:-D_REENTRANT}" -+ -+#define GLIBC_DYNAMIC_LINKER "/lib/ld.so.1" -+ -+/* Borrowed from sparc/linux.h */ -+#undef LINK_SPEC -+#define LINK_SPEC \ -+ "%{shared:-shared} \ -+ %{!shared: \ -+ %{!static: \ -+ %{rdynamic:-export-dynamic} \ -+ -dynamic-linker " GNU_USER_DYNAMIC_LINKER "} \ -+ %{static:-static}}" -+ -+#undef LIB_SPEC -+#define LIB_SPEC "\ -+%{pthread:-lpthread} \ -+%{shared:-lc} \ -+%{!shared: \ -+ %{profile:-lc_p} %{!profile:-lc}}" -+ -+/* Similar to standard Linux, but adding -ffast-math support. */ -+#undef ENDFILE_SPEC -+#define ENDFILE_SPEC \ -+ "%{shared|pie:crtendS.o%s;:crtend.o%s} crtn.o%s" -diff -rNU3 dist.orig/gcc/config/riscv/linux64.h dist/gcc/config/riscv/linux64.h ---- dist.orig/gcc/config/riscv/linux64.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/riscv/linux64.h 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,43 @@ -+/* Definitions for 64-bit RISC-V GNU/Linux systems with ELF format. -+ Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2010, 2011 -+ Free Software Foundation, Inc. -+ -+This file is part of GCC. -+ -+GCC is free software; you can redistribute it and/or modify -+it under the terms of the GNU General Public License as published by -+the Free Software Foundation; either version 3, or (at your option) -+any later version. -+ -+GCC is distributed in the hope that it will be useful, -+but WITHOUT ANY WARRANTY; without even the implied warranty of -+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+GNU General Public License for more details. -+ -+You should have received a copy of the GNU General Public License -+along with GCC; see the file COPYING3. If not see -+. */ -+ -+/* Force the default ABI flags onto the command line -+ in order to make the other specs easier to write. */ -+#undef LIB_SPEC -+#define LIB_SPEC "\ -+%{pthread:-lpthread} \ -+%{shared:-lc} \ -+%{!shared: \ -+ %{profile:-lc_p} %{!profile:-lc}}" -+ -+#define GLIBC_DYNAMIC_LINKER32 "/lib32/ld.so.1" -+#define GLIBC_DYNAMIC_LINKER64 "/lib/ld.so.1" -+ -+#undef LINK_SPEC -+#define LINK_SPEC "\ -+%{shared} \ -+ %{!shared: \ -+ %{!static: \ -+ %{rdynamic:-export-dynamic} \ -+ %{" OPT_ARCH64 ": -dynamic-linker " GNU_USER_DYNAMIC_LINKER64 "} \ -+ %{" OPT_ARCH32 ": -dynamic-linker " GNU_USER_DYNAMIC_LINKER32 "}} \ -+ %{static:-static}} \ -+%{" OPT_ARCH64 ":-melf64lriscv} \ -+%{" OPT_ARCH32 ":-melf32lriscv}" -diff -rNU3 dist.orig/gcc/config/riscv/netbsd.h dist/gcc/config/riscv/netbsd.h ---- dist.orig/gcc/config/riscv/netbsd.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/riscv/netbsd.h 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,114 @@ -+/* Definitions for RISCV running NetBSD systems using ELF -+ Copyright (C) 2014 -+ Free Software Foundation, Inc. -+ Contributed by Matt Thomas -+ -+This file is part of GNU CC. -+ -+GNU CC is free software; you can redistribute it and/or modify -+it under the terms of the GNU General Public License as published by -+the Free Software Foundation; either version 2, or (at your option) -+any later version. -+ -+GNU CC is distributed in the hope that it will be useful, -+but WITHOUT ANY WARRANTY; without even the implied warranty of -+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+GNU General Public License for more details. -+ -+You should have received a copy of the GNU General Public License -+along with this program; see the file COPYING. If not, write to -+the Free Software Foundation, 59 Temple Place - Suite 330, -+Boston, MA 02111-1307, USA. */ -+ -+#undef TARGET_USE_GP -+#define TARGET_USE_GP 0 -+ -+#undef DRIVER_SELF_SPECS -+#define DRIVER_SELF_SPECS "" -+ -+#undef TARGET_DEFAULT -+#define TARGET_DEFAULT (MASK_FDIV) -+ -+#undef TARGET_DEFAULT_CMODEL -+#define TARGET_DEFAULT_CMODEL CM_MEDANY -+ -+#define TARGET_OS_CPP_BUILTINS() \ -+ do { \ -+ NETBSD_OS_CPP_BUILTINS_ELF(); \ -+ /* The GNU C++ standard library requires this. */ \ -+ if (c_dialect_cxx ()) \ -+ builtin_define ("_GNU_SOURCE"); \ -+ if (!TARGET_HARD_FLOAT_ABI) \ -+ builtin_define ("_SOFT_FLOAT"); \ -+ } while (0) -+ -+#undef CPP_SPEC -+#define CPP_SPEC NETBSD_CPP_SPEC -+ -+#undef LIB_SPEC -+#define LIB_SPEC NETBSD_LIB_SPEC -+ -+#undef LINK_SPEC -+#define LINK_SPEC NETBSD_LINK_SPEC_ELF -+/* Provide a LINK_SPEC appropriate for a NetBSD/mips target. -+ This is a copy of LINK_SPEC from tweaked for -+ the MIPS target. */ -+ -+#undef LINK_SPEC -+#define LINK_SPEC \ -+ "%{m64:-m elf64lriscv} \ -+ %{m32:-m elf32lriscv} \ -+ %(netbsd_link_spec)" -+ -+#undef NETBSD_ENTRY_POINT -+#define NETBSD_ENTRY_POINT "_start" -+ -+#undef SUBTARGET_EXTRA_SPECS -+#define SUBTARGET_EXTRA_SPECS \ -+ { "netbsd_link_spec", NETBSD_LINK_SPEC_ELF }, \ -+ { "netbsd_entry_point", NETBSD_ENTRY_POINT }, \ -+ { "netbsd_endfile_spec", NETBSD_ENDFILE_SPEC }, -+ -+#define SIG_ATOMIC_TYPE "int" -+ -+#define INT8_TYPE "signed char" -+#define INT16_TYPE "short int" -+#define INT32_TYPE "int" -+#define INT64_TYPE "long long int" -+#define UINT8_TYPE "unsigned char" -+#define UINT16_TYPE "short unsigned int" -+#define UINT32_TYPE "unsigned int" -+#define UINT64_TYPE "long long unsigned int" -+ -+#define INT_LEAST8_TYPE "signed char" -+#define INT_LEAST16_TYPE "short int" -+#define INT_LEAST32_TYPE "int" -+#define INT_LEAST64_TYPE "long long int" -+#define UINT_LEAST8_TYPE "unsigned char" -+#define UINT_LEAST16_TYPE "short unsigned int" -+#define UINT_LEAST32_TYPE "unsigned int" -+#define UINT_LEAST64_TYPE "long long unsigned int" -+ -+#define INT_FAST8_TYPE "signed char" -+#define INT_FAST16_TYPE "short int" -+#define INT_FAST32_TYPE "int" -+#define INT_FAST64_TYPE "long long int" -+#define UINT_FAST8_TYPE "unsigned char" -+#define UINT_FAST16_TYPE "short unsigned int" -+#define UINT_FAST32_TYPE "unsigned int" -+#define UINT_FAST64_TYPE "long long unsigned int" -+ -+#undef PTRDIFF_TYPE -+#define PTRDIFF_TYPE "long int" -+ -+#undef SIZE_TYPE -+#define SIZE_TYPE "long unsigned int" -+ -+#define INTPTR_TYPE PTRDIFF_TYPE -+#define UINTPTR_TYPE SIZE_TYPE -+ -+#undef INTMAX_TYPE -+#define INTMAX_TYPE "long long int" -+ -+#undef UINTMAX_TYPE -+#define UINTMAX_TYPE "long long unsigned int" -diff -rNU3 dist.orig/gcc/config/riscv/opcode-riscv.h dist/gcc/config/riscv/opcode-riscv.h ---- dist.orig/gcc/config/riscv/opcode-riscv.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/riscv/opcode-riscv.h 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,149 @@ -+/* RISC-V ISA encoding. -+ Copyright (C) 2011-2014 Free Software Foundation, Inc. -+ Contributed by Andrew Waterman (waterman@cs.berkeley.edu) at UC Berkeley. -+ Based on MIPS target for GNU compiler. -+ -+This file is part of GDB, GAS, and the GNU binutils. -+ -+GDB, GAS, and the GNU binutils are free software; you can redistribute -+them and/or modify them under the terms of the GNU General Public -+License as published by the Free Software Foundation; either version -+1, or (at your option) any later version. -+ -+GDB, GAS, and the GNU binutils are distributed in the hope that they -+will be useful, but WITHOUT ANY WARRANTY; without even the implied -+warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See -+the GNU General Public License for more details. -+ -+You should have received a copy of the GNU General Public License -+along with this file; see the file COPYING. If not, write to the Free -+Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ -+ -+#ifndef _RISCV_H_ -+#define _RISCV_H_ -+ -+#define RV_X(x, s, n) (((x) >> (s)) & ((1<<(n))-1)) -+#define RV_IMM_SIGN(x) (-(((x) >> 31) & 1)) -+ -+#define EXTRACT_ITYPE_IMM(x) \ -+ (RV_X(x, 20, 12) | (RV_IMM_SIGN(x) << 12)) -+#define EXTRACT_STYPE_IMM(x) \ -+ (RV_X(x, 7, 5) | (RV_X(x, 25, 7) << 5) | (RV_IMM_SIGN(x) << 12)) -+#define EXTRACT_SBTYPE_IMM(x) \ -+ ((RV_X(x, 8, 4) << 1) | (RV_X(x, 25, 6) << 5) | (RV_X(x, 7, 1) << 11) | (RV_IMM_SIGN(x) << 12)) -+#define EXTRACT_UTYPE_IMM(x) \ -+ ((RV_X(x, 12, 20) << 20) | (RV_IMM_SIGN(x) << 32)) -+#define EXTRACT_UJTYPE_IMM(x) \ -+ ((RV_X(x, 21, 10) << 1) | (RV_X(x, 20, 1) << 11) | (RV_X(x, 12, 8) << 12) | (RV_IMM_SIGN(x) << 20)) -+ -+#define ENCODE_ITYPE_IMM(x) \ -+ (RV_X(x, 0, 12) << 20) -+#define ENCODE_STYPE_IMM(x) \ -+ ((RV_X(x, 0, 5) << 7) | (RV_X(x, 5, 7) << 25)) -+#define ENCODE_SBTYPE_IMM(x) \ -+ ((RV_X(x, 1, 4) << 8) | (RV_X(x, 5, 6) << 25) | (RV_X(x, 11, 1) << 7) | (RV_X(x, 12, 1) << 31)) -+#define ENCODE_UTYPE_IMM(x) \ -+ (RV_X(x, 12, 20) << 12) -+#define ENCODE_UJTYPE_IMM(x) \ -+ ((RV_X(x, 1, 10) << 21) | (RV_X(x, 11, 1) << 20) | (RV_X(x, 12, 8) << 12) | (RV_X(x, 20, 1) << 31)) -+ -+#define VALID_ITYPE_IMM(x) (EXTRACT_ITYPE_IMM(ENCODE_ITYPE_IMM(x)) == (x)) -+#define VALID_STYPE_IMM(x) (EXTRACT_STYPE_IMM(ENCODE_STYPE_IMM(x)) == (x)) -+#define VALID_SBTYPE_IMM(x) (EXTRACT_SBTYPE_IMM(ENCODE_SBTYPE_IMM(x)) == (x)) -+#define VALID_UTYPE_IMM(x) (EXTRACT_UTYPE_IMM(ENCODE_UTYPE_IMM(x)) == (x)) -+#define VALID_UJTYPE_IMM(x) (EXTRACT_UJTYPE_IMM(ENCODE_UJTYPE_IMM(x)) == (x)) -+ -+#define RISCV_RTYPE(insn, rd, rs1, rs2) \ -+ ((MATCH_ ## insn) | ((rd) << OP_SH_RD) | ((rs1) << OP_SH_RS1) | ((rs2) << OP_SH_RS2)) -+#define RISCV_ITYPE(insn, rd, rs1, imm) \ -+ ((MATCH_ ## insn) | ((rd) << OP_SH_RD) | ((rs1) << OP_SH_RS1) | ENCODE_ITYPE_IMM(imm)) -+#define RISCV_STYPE(insn, rs1, rs2, imm) \ -+ ((MATCH_ ## insn) | ((rs1) << OP_SH_RS1) | ((rs2) << OP_SH_RS2) | ENCODE_STYPE_IMM(imm)) -+#define RISCV_SBTYPE(insn, rs1, rs2, target) \ -+ ((MATCH_ ## insn) | ((rs1) << OP_SH_RS1) | ((rs2) << OP_SH_RS2) | ENCODE_SBTYPE_IMM(target)) -+#define RISCV_UTYPE(insn, rd, bigimm) \ -+ ((MATCH_ ## insn) | ((rd) << OP_SH_RD) | ENCODE_UTYPE_IMM(bigimm)) -+#define RISCV_UJTYPE(insn, rd, target) \ -+ ((MATCH_ ## insn) | ((rd) << OP_SH_RD) | ENCODE_UJTYPE_IMM(target)) -+ -+#define RISCV_NOP RISCV_ITYPE(ADDI, 0, 0, 0) -+ -+#define RISCV_CONST_HIGH_PART(VALUE) \ -+ (((VALUE) + (RISCV_IMM_REACH/2)) & ~(RISCV_IMM_REACH-1)) -+#define RISCV_CONST_LOW_PART(VALUE) ((VALUE) - RISCV_CONST_HIGH_PART (VALUE)) -+ -+/* RV fields */ -+ -+#define OP_MASK_OP 0x7f -+#define OP_SH_OP 0 -+#define OP_MASK_RS2 0x1f -+#define OP_SH_RS2 20 -+#define OP_MASK_RS1 0x1f -+#define OP_SH_RS1 15 -+#define OP_MASK_RS3 0x1f -+#define OP_SH_RS3 27 -+#define OP_MASK_RD 0x1f -+#define OP_SH_RD 7 -+#define OP_MASK_SHAMT 0x3f -+#define OP_SH_SHAMT 20 -+#define OP_MASK_SHAMTW 0x1f -+#define OP_SH_SHAMTW 20 -+#define OP_MASK_RM 0x7 -+#define OP_SH_RM 12 -+#define OP_MASK_PRED 0xf -+#define OP_SH_PRED 24 -+#define OP_MASK_SUCC 0xf -+#define OP_SH_SUCC 20 -+#define OP_MASK_AQ 0x1 -+#define OP_SH_AQ 26 -+#define OP_MASK_RL 0x1 -+#define OP_SH_RL 25 -+ -+#define OP_MASK_VRD 0x1f -+#define OP_SH_VRD 7 -+#define OP_MASK_VRS 0x1f -+#define OP_SH_VRS 15 -+#define OP_MASK_VRT 0x1f -+#define OP_SH_VRT 20 -+#define OP_MASK_VRR 0x1f -+#define OP_SH_VRR 25 -+ -+#define OP_MASK_VFD 0x1f -+#define OP_SH_VFD 7 -+#define OP_MASK_VFS 0x1f -+#define OP_SH_VFS 15 -+#define OP_MASK_VFT 0x1f -+#define OP_SH_VFT 20 -+#define OP_MASK_VFR 0x1f -+#define OP_SH_VFR 25 -+ -+#define OP_MASK_IMMNGPR 0x3f -+#define OP_SH_IMMNGPR 20 -+#define OP_MASK_IMMNFPR 0x3f -+#define OP_SH_IMMNFPR 26 -+#define OP_MASK_IMMSEGNELM 0x1f -+#define OP_SH_IMMSEGNELM 17 -+#define OP_MASK_IMMSEGSTNELM 0x1f -+#define OP_SH_IMMSEGSTNELM 12 -+#define OP_MASK_CUSTOM_IMM 0x7f -+#define OP_SH_CUSTOM_IMM 25 -+ -+#define LINK_REG 1 -+ -+#define RISCV_JUMP_BITS RISCV_BIGIMM_BITS -+#define RISCV_JUMP_ALIGN_BITS 1 -+#define RISCV_JUMP_ALIGN (1 << RISCV_JUMP_ALIGN_BITS) -+#define RISCV_JUMP_REACH ((1ULL< SI optimizations -+;;........................ -+ -+;; Simplify (int)(a + 1), etc. -+(define_peephole2 -+ [(set (match_operand:DI 0 "register_operand") -+ (match_operator:DI 4 "modular_operator" -+ [(match_operand:DI 1 "register_operand") -+ (match_operand:DI 2 "arith_operand")])) -+ (set (match_operand:SI 3 "register_operand") -+ (truncate:SI (match_dup 0)))] -+ "TARGET_64BIT && (REGNO (operands[0]) == REGNO (operands[3]) || peep2_reg_dead_p (2, operands[0])) -+ && (GET_CODE (operands[4]) != ASHIFT || (CONST_INT_P (operands[2]) && INTVAL (operands[2]) < 32))" -+ [(set (match_dup 3) -+ (truncate:SI -+ (match_op_dup:DI 4 -+ [(match_operand:DI 1 "register_operand") -+ (match_operand:DI 2 "arith_operand")])))]) -+ -+;; Simplify (int)a + 1, etc. -+(define_peephole2 -+ [(set (match_operand:SI 0 "register_operand") -+ (truncate:SI (match_operand:DI 1 "register_operand"))) -+ (set (match_operand:SI 3 "register_operand") -+ (match_operator:SI 4 "modular_operator" -+ [(match_dup 0) -+ (match_operand:SI 2 "arith_operand")]))] -+ "TARGET_64BIT && (REGNO (operands[0]) == REGNO (operands[3]) || peep2_reg_dead_p (2, operands[0]))" -+ [(set (match_dup 3) -+ (match_op_dup:SI 4 [(match_dup 1) (match_dup 2)]))]) -+ -+;; Simplify -(int)a, etc. -+(define_peephole2 -+ [(set (match_operand:SI 0 "register_operand") -+ (truncate:SI (match_operand:DI 2 "register_operand"))) -+ (set (match_operand:SI 3 "register_operand") -+ (match_operator:SI 4 "modular_operator" -+ [(match_operand:SI 1 "reg_or_0_operand") -+ (match_dup 0)]))] -+ "TARGET_64BIT && (REGNO (operands[0]) == REGNO (operands[3]) || peep2_reg_dead_p (2, operands[0]))" -+ [(set (match_dup 3) -+ (match_op_dup:SI 4 [(match_dup 1) (match_dup 2)]))]) -+ -+;; Simplify PIC loads to static variables. -+;; These will go away once we figure out how to emit auipc discretely. -+(define_insn "*local_pic_load" -+ [(set (match_operand:ANYI 0 "register_operand" "=r") -+ (mem:ANYI (match_operand 1 "absolute_symbolic_operand" "")))] -+ "flag_pic && SYMBOL_REF_LOCAL_P (operands[1])" -+ "\t%0,%1" -+ [(set (attr "length") (const_int 8))]) -+(define_insn "*local_pic_load" -+ [(set (match_operand:ANYF 0 "register_operand" "=f") -+ (mem:ANYF (match_operand 1 "absolute_symbolic_operand" ""))) -+ (clobber (match_scratch:DI 2 "=&r"))] -+ "TARGET_HARD_FLOAT && TARGET_64BIT && flag_pic && SYMBOL_REF_LOCAL_P (operands[1])" -+ "\t%0,%1,%2" -+ [(set (attr "length") (const_int 8))]) -+(define_insn "*local_pic_load" -+ [(set (match_operand:ANYF 0 "register_operand" "=f") -+ (mem:ANYF (match_operand 1 "absolute_symbolic_operand" ""))) -+ (clobber (match_scratch:SI 2 "=&r"))] -+ "TARGET_HARD_FLOAT && !TARGET_64BIT && flag_pic && SYMBOL_REF_LOCAL_P (operands[1])" -+ "\t%0,%1,%2" -+ [(set (attr "length") (const_int 8))]) -+(define_insn "*local_pic_loadu" -+ [(set (match_operand:SUPERQI 0 "register_operand" "=r") -+ (zero_extend:SUPERQI (mem:SUBDI (match_operand 1 "absolute_symbolic_operand" ""))))] -+ "flag_pic && SYMBOL_REF_LOCAL_P (operands[1])" -+ "u\t%0,%1" -+ [(set (attr "length") (const_int 8))]) -+(define_insn "*local_pic_storedi" -+ [(set (mem:ANYI (match_operand 0 "absolute_symbolic_operand" "")) -+ (match_operand:ANYI 1 "reg_or_0_operand" "rJ")) -+ (clobber (match_scratch:DI 2 "=&r"))] -+ "TARGET_64BIT && (flag_pic && SYMBOL_REF_LOCAL_P (operands[0]))" -+ "\t%z1,%0,%2" -+ [(set (attr "length") (const_int 8))]) -+(define_insn "*local_pic_storesi" -+ [(set (mem:ANYI (match_operand 0 "absolute_symbolic_operand" "")) -+ (match_operand:ANYI 1 "reg_or_0_operand" "rJ")) -+ (clobber (match_scratch:SI 2 "=&r"))] -+ "!TARGET_64BIT && (flag_pic && SYMBOL_REF_LOCAL_P (operands[0]))" -+ "\t%z1,%0,%2" -+ [(set (attr "length") (const_int 8))]) -+(define_insn "*local_pic_storedi" -+ [(set (mem:ANYF (match_operand 0 "absolute_symbolic_operand" "")) -+ (match_operand:ANYF 1 "register_operand" "f")) -+ (clobber (match_scratch:DI 2 "=&r"))] -+ "TARGET_HARD_FLOAT && TARGET_64BIT && (flag_pic && SYMBOL_REF_LOCAL_P (operands[0]))" -+ "\t%1,%0,%2" -+ [(set (attr "length") (const_int 8))]) -+(define_insn "*local_pic_storesi" -+ [(set (mem:ANYF (match_operand 0 "absolute_symbolic_operand" "")) -+ (match_operand:ANYF 1 "register_operand" "f")) -+ (clobber (match_scratch:SI 2 "=&r"))] -+ "TARGET_HARD_FLOAT && !TARGET_64BIT && (flag_pic && SYMBOL_REF_LOCAL_P (operands[0]))" -+ "\t%1,%0,%2" -+ [(set (attr "length") (const_int 8))]) -diff -rNU3 dist.orig/gcc/config/riscv/predicates.md dist/gcc/config/riscv/predicates.md ---- dist.orig/gcc/config/riscv/predicates.md 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/riscv/predicates.md 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,182 @@ -+;; Predicate description for RISC-V target. -+;; Copyright (C) 2011-2014 Free Software Foundation, Inc. -+;; Contributed by Andrew Waterman (waterman@cs.berkeley.edu) at UC Berkeley. -+;; Based on MIPS target for GNU compiler. -+;; -+;; This file is part of GCC. -+;; -+;; GCC is free software; you can redistribute it and/or modify -+;; it under the terms of the GNU General Public License as published by -+;; the Free Software Foundation; either version 3, or (at your option) -+;; any later version. -+;; -+;; GCC is distributed in the hope that it will be useful, -+;; but WITHOUT ANY WARRANTY; without even the implied warranty of -+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+;; GNU General Public License for more details. -+;; -+;; You should have received a copy of the GNU General Public License -+;; along with GCC; see the file COPYING3. If not see -+;; . -+ -+(define_predicate "const_arith_operand" -+ (and (match_code "const_int") -+ (match_test "SMALL_OPERAND (INTVAL (op))"))) -+ -+(define_predicate "arith_operand" -+ (ior (match_operand 0 "const_arith_operand") -+ (match_operand 0 "register_operand"))) -+ -+(define_predicate "sle_operand" -+ (and (match_code "const_int") -+ (match_test "SMALL_OPERAND (INTVAL (op) + 1)"))) -+ -+(define_predicate "sleu_operand" -+ (and (match_operand 0 "sle_operand") -+ (match_test "INTVAL (op) + 1 != 0"))) -+ -+(define_predicate "const_0_operand" -+ (and (match_code "const_int,const_double,const_vector") -+ (match_test "op == CONST0_RTX (GET_MODE (op))"))) -+ -+(define_predicate "reg_or_0_operand" -+ (ior (match_operand 0 "const_0_operand") -+ (match_operand 0 "register_operand"))) -+ -+(define_predicate "const_1_operand" -+ (and (match_code "const_int,const_double,const_vector") -+ (match_test "op == CONST1_RTX (GET_MODE (op))"))) -+ -+(define_predicate "reg_or_1_operand" -+ (ior (match_operand 0 "const_1_operand") -+ (match_operand 0 "register_operand"))) -+ -+;; This is used for indexing into vectors, and hence only accepts const_int. -+(define_predicate "const_0_or_1_operand" -+ (and (match_code "const_int") -+ (ior (match_test "op == CONST0_RTX (GET_MODE (op))") -+ (match_test "op == CONST1_RTX (GET_MODE (op))")))) -+ -+(define_special_predicate "pc_or_label_operand" -+ (match_code "pc,label_ref")) -+ -+;; A legitimate CONST_INT operand that takes more than one instruction -+;; to load. -+(define_predicate "splittable_const_int_operand" -+ (match_code "const_int") -+{ -+ /* Don't handle multi-word moves this way; we don't want to introduce -+ the individual word-mode moves until after reload. */ -+ if (GET_MODE_SIZE (mode) > UNITS_PER_WORD) -+ return false; -+ -+ /* Otherwise check whether the constant can be loaded in a single -+ instruction. */ -+ return !LUI_INT (op) && !SMALL_INT (op); -+}) -+ -+(define_predicate "move_operand" -+ (match_operand 0 "general_operand") -+{ -+ enum riscv_symbol_type symbol_type; -+ -+ /* The thinking here is as follows: -+ -+ (1) The move expanders should split complex load sequences into -+ individual instructions. Those individual instructions can -+ then be optimized by all rtl passes. -+ -+ (2) The target of pre-reload load sequences should not be used -+ to store temporary results. If the target register is only -+ assigned one value, reload can rematerialize that value -+ on demand, rather than spill it to the stack. -+ -+ (3) If we allowed pre-reload passes like combine and cse to recreate -+ complex load sequences, we would want to be able to split the -+ sequences before reload as well, so that the pre-reload scheduler -+ can see the individual instructions. This falls foul of (2); -+ the splitter would be forced to reuse the target register for -+ intermediate results. -+ -+ (4) We want to define complex load splitters for combine. These -+ splitters can request a temporary scratch register, which avoids -+ the problem in (2). They allow things like: -+ -+ (set (reg T1) (high SYM)) -+ (set (reg T2) (low (reg T1) SYM)) -+ (set (reg X) (plus (reg T2) (const_int OFFSET))) -+ -+ to be combined into: -+ -+ (set (reg T3) (high SYM+OFFSET)) -+ (set (reg X) (lo_sum (reg T3) SYM+OFFSET)) -+ -+ if T2 is only used this once. */ -+ switch (GET_CODE (op)) -+ { -+ case CONST_INT: -+ return !splittable_const_int_operand (op, mode); -+ -+ case CONST: -+ case SYMBOL_REF: -+ case LABEL_REF: -+ return (riscv_symbolic_constant_p (op, &symbol_type) -+ && !riscv_hi_relocs[symbol_type]); -+ -+ case HIGH: -+ op = XEXP (op, 0); -+ return riscv_symbolic_constant_p (op, &symbol_type); -+ -+ default: -+ return true; -+ } -+}) -+ -+(define_predicate "consttable_operand" -+ (match_test "CONSTANT_P (op)")) -+ -+(define_predicate "symbolic_operand" -+ (match_code "const,symbol_ref,label_ref") -+{ -+ enum riscv_symbol_type type; -+ return riscv_symbolic_constant_p (op, &type); -+}) -+ -+(define_predicate "absolute_symbolic_operand" -+ (match_code "const,symbol_ref,label_ref") -+{ -+ enum riscv_symbol_type type; -+ return (riscv_symbolic_constant_p (op, &type) -+ && type == SYMBOL_ABSOLUTE); -+}) -+ -+(define_predicate "plt_symbolic_operand" -+ (match_code "const,symbol_ref,label_ref") -+{ -+ enum riscv_symbol_type type; -+ return (riscv_symbolic_constant_p (op, &type) -+ && type == SYMBOL_GOT_DISP && !SYMBOL_REF_WEAK (op) && TARGET_PLT); -+}) -+ -+(define_predicate "call_insn_operand" -+ (ior (match_operand 0 "absolute_symbolic_operand") -+ (match_operand 0 "plt_symbolic_operand") -+ (match_operand 0 "register_operand"))) -+ -+(define_predicate "symbol_ref_operand" -+ (match_code "symbol_ref")) -+ -+(define_predicate "modular_operator" -+ (match_code "plus,minus,mult,ashift")) -+ -+(define_predicate "equality_operator" -+ (match_code "eq,ne")) -+ -+(define_predicate "order_operator" -+ (match_code "eq,ne,lt,ltu,le,leu,ge,geu,gt,gtu")) -+ -+(define_predicate "fp_order_operator" -+ (match_code "eq,lt,le,gt,ge")) -+ -+(define_predicate "fp_unorder_operator" -+ (match_code "ordered,unordered")) -diff -rNU3 dist.orig/gcc/config/riscv/riscv-ftypes.def dist/gcc/config/riscv/riscv-ftypes.def ---- dist.orig/gcc/config/riscv/riscv-ftypes.def 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/riscv/riscv-ftypes.def 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,39 @@ -+/* Definitions of prototypes for RISC-V built-in functions. -+ Copyright (C) 2011-2014 Free Software Foundation, Inc. -+ Contributed by Andrew Waterman (waterman@cs.berkeley.edu) at UC Berkeley. -+ Based on MIPS target for GNU compiler. -+ -+This file is part of GCC. -+ -+GCC is free software; you can redistribute it and/or modify -+it under the terms of the GNU General Public License as published by -+the Free Software Foundation; either version 3, or (at your option) -+any later version. -+ -+GCC is distributed in the hope that it will be useful, -+but WITHOUT ANY WARRANTY; without even the implied warranty of -+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+GNU General Public License for more details. -+ -+You should have received a copy of the GNU General Public License -+along with GCC; see the file COPYING3. If not see -+. */ -+ -+/* Invoke DEF_RISCV_FTYPE (NARGS, LIST) for each prototype used by -+ MIPS built-in functions, where: -+ -+ NARGS is the number of arguments. -+ LIST contains the return-type code followed by the codes for each -+ argument type. -+ -+ Argument- and return-type codes are either modes or one of the following: -+ -+ VOID for void_type_node -+ INT for integer_type_node -+ POINTER for ptr_type_node -+ -+ (we don't use PTR because that's a ANSI-compatibillity macro). -+ -+ Please keep this list lexicographically sorted by the LIST argument. */ -+ -+DEF_RISCV_FTYPE (1, (VOID, VOID)) -diff -rNU3 dist.orig/gcc/config/riscv/riscv-modes.def dist/gcc/config/riscv/riscv-modes.def ---- dist.orig/gcc/config/riscv/riscv-modes.def 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/riscv/riscv-modes.def 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,26 @@ -+/* Extra machine modes for RISC-V target. -+ Copyright (C) 2011-2014 Free Software Foundation, Inc. -+ Contributed by Andrew Waterman (waterman@cs.berkeley.edu) at UC Berkeley. -+ Based on MIPS target for GNU compiler. -+ -+This file is part of GCC. -+ -+GCC is free software; you can redistribute it and/or modify -+it under the terms of the GNU General Public License as published by -+the Free Software Foundation; either version 3, or (at your option) -+any later version. -+ -+GCC is distributed in the hope that it will be useful, -+but WITHOUT ANY WARRANTY; without even the implied warranty of -+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+GNU General Public License for more details. -+ -+You should have received a copy of the GNU General Public License -+along with GCC; see the file COPYING3. If not see -+. */ -+ -+FLOAT_MODE (TF, 16, ieee_quad_format); -+ -+/* Vector modes. */ -+VECTOR_MODES (INT, 4); /* V8QI V4HI V2SI */ -+VECTOR_MODES (FLOAT, 4); /* V4HF V2SF */ -diff -rNU3 dist.orig/gcc/config/riscv/riscv-opc.h dist/gcc/config/riscv/riscv-opc.h ---- dist.orig/gcc/config/riscv/riscv-opc.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/riscv/riscv-opc.h 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,1195 @@ -+/* Automatically generated by parse-opcodes */ -+#ifndef RISCV_ENCODING_H -+#define RISCV_ENCODING_H -+#define MATCH_ADD 0x33 -+#define MASK_ADD 0xfe00707f -+#define MATCH_ADDI 0x13 -+#define MASK_ADDI 0x707f -+#define MATCH_ADDIW 0x1b -+#define MASK_ADDIW 0x707f -+#define MATCH_ADDW 0x3b -+#define MASK_ADDW 0xfe00707f -+#define MATCH_AMOADD_D 0x302f -+#define MASK_AMOADD_D 0xf800707f -+#define MATCH_AMOADD_W 0x202f -+#define MASK_AMOADD_W 0xf800707f -+#define MATCH_AMOAND_D 0x6000302f -+#define MASK_AMOAND_D 0xf800707f -+#define MATCH_AMOAND_W 0x6000202f -+#define MASK_AMOAND_W 0xf800707f -+#define MATCH_AMOMAX_D 0xa000302f -+#define MASK_AMOMAX_D 0xf800707f -+#define MATCH_AMOMAX_W 0xa000202f -+#define MASK_AMOMAX_W 0xf800707f -+#define MATCH_AMOMAXU_D 0xe000302f -+#define MASK_AMOMAXU_D 0xf800707f -+#define MATCH_AMOMAXU_W 0xe000202f -+#define MASK_AMOMAXU_W 0xf800707f -+#define MATCH_AMOMIN_D 0x8000302f -+#define MASK_AMOMIN_D 0xf800707f -+#define MATCH_AMOMIN_W 0x8000202f -+#define MASK_AMOMIN_W 0xf800707f -+#define MATCH_AMOMINU_D 0xc000302f -+#define MASK_AMOMINU_D 0xf800707f -+#define MATCH_AMOMINU_W 0xc000202f -+#define MASK_AMOMINU_W 0xf800707f -+#define MATCH_AMOOR_D 0x4000302f -+#define MASK_AMOOR_D 0xf800707f -+#define MATCH_AMOOR_W 0x4000202f -+#define MASK_AMOOR_W 0xf800707f -+#define MATCH_AMOSWAP_D 0x800302f -+#define MASK_AMOSWAP_D 0xf800707f -+#define MATCH_AMOSWAP_W 0x800202f -+#define MASK_AMOSWAP_W 0xf800707f -+#define MATCH_AMOXOR_D 0x2000302f -+#define MASK_AMOXOR_D 0xf800707f -+#define MATCH_AMOXOR_W 0x2000202f -+#define MASK_AMOXOR_W 0xf800707f -+#define MATCH_AND 0x7033 -+#define MASK_AND 0xfe00707f -+#define MATCH_ANDI 0x7013 -+#define MASK_ANDI 0x707f -+#define MATCH_AUIPC 0x17 -+#define MASK_AUIPC 0x7f -+#define MATCH_BEQ 0x63 -+#define MASK_BEQ 0x707f -+#define MATCH_BGE 0x5063 -+#define MASK_BGE 0x707f -+#define MATCH_BGEU 0x7063 -+#define MASK_BGEU 0x707f -+#define MATCH_BLT 0x4063 -+#define MASK_BLT 0x707f -+#define MATCH_BLTU 0x6063 -+#define MASK_BLTU 0x707f -+#define MATCH_BNE 0x1063 -+#define MASK_BNE 0x707f -+#define MATCH_C_ADD 0x6000 -+#define MASK_C_ADD 0xf003 -+#define MATCH_C_ADDI 0x8000 -+#define MASK_C_ADDI 0xe003 -+#define MATCH_C_ADDI4 0xa000 -+#define MASK_C_ADDI4 0xe003 -+#define MATCH_C_ADDIW 0xe000 -+#define MASK_C_ADDIW 0xe003 -+#define MATCH_C_ADDW 0x7000 -+#define MASK_C_ADDW 0xf003 -+#define MATCH_C_BEQZ 0x2002 -+#define MASK_C_BEQZ 0xe003 -+#define MATCH_C_BNEZ 0x6002 -+#define MASK_C_BNEZ 0xe003 -+#define MATCH_C_J 0xa002 -+#define MASK_C_J 0xe003 -+#define MATCH_C_JALR 0x5000 -+#define MASK_C_JALR 0xf003 -+#define MATCH_C_LD 0x2001 -+#define MASK_C_LD 0xe003 -+#define MATCH_C_LDSP 0xc001 -+#define MASK_C_LDSP 0xe003 -+#define MATCH_C_LI 0x0 -+#define MASK_C_LI 0xe003 -+#define MATCH_C_LUI 0x2000 -+#define MASK_C_LUI 0xe003 -+#define MATCH_C_LW 0x1 -+#define MASK_C_LW 0xe003 -+#define MATCH_C_LWSP 0x8001 -+#define MASK_C_LWSP 0xe003 -+#define MATCH_C_MV 0x4000 -+#define MASK_C_MV 0xf003 -+#define MATCH_C_SD 0x6001 -+#define MASK_C_SD 0xe003 -+#define MATCH_C_SDSP 0xe001 -+#define MASK_C_SDSP 0xe003 -+#define MATCH_C_SLLI 0xc000 -+#define MASK_C_SLLI 0xe003 -+#define MATCH_C_SW 0x4001 -+#define MASK_C_SW 0xe003 -+#define MATCH_C_SWSP 0xa001 -+#define MASK_C_SWSP 0xe003 -+#define MATCH_CSRRC 0x3073 -+#define MASK_CSRRC 0x707f -+#define MATCH_CSRRCI 0x7073 -+#define MASK_CSRRCI 0x707f -+#define MATCH_CSRRS 0x2073 -+#define MASK_CSRRS 0x707f -+#define MATCH_CSRRSI 0x6073 -+#define MASK_CSRRSI 0x707f -+#define MATCH_CSRRW 0x1073 -+#define MASK_CSRRW 0x707f -+#define MATCH_CSRRWI 0x5073 -+#define MASK_CSRRWI 0x707f -+#define MATCH_CUSTOM0 0xb -+#define MASK_CUSTOM0 0x707f -+#define MATCH_CUSTOM0_RD 0x400b -+#define MASK_CUSTOM0_RD 0x707f -+#define MATCH_CUSTOM0_RD_RS1 0x600b -+#define MASK_CUSTOM0_RD_RS1 0x707f -+#define MATCH_CUSTOM0_RD_RS1_RS2 0x700b -+#define MASK_CUSTOM0_RD_RS1_RS2 0x707f -+#define MATCH_CUSTOM0_RS1 0x200b -+#define MASK_CUSTOM0_RS1 0x707f -+#define MATCH_CUSTOM0_RS1_RS2 0x300b -+#define MASK_CUSTOM0_RS1_RS2 0x707f -+#define MATCH_CUSTOM1 0x2b -+#define MASK_CUSTOM1 0x707f -+#define MATCH_CUSTOM1_RD 0x402b -+#define MASK_CUSTOM1_RD 0x707f -+#define MATCH_CUSTOM1_RD_RS1 0x602b -+#define MASK_CUSTOM1_RD_RS1 0x707f -+#define MATCH_CUSTOM1_RD_RS1_RS2 0x702b -+#define MASK_CUSTOM1_RD_RS1_RS2 0x707f -+#define MATCH_CUSTOM1_RS1 0x202b -+#define MASK_CUSTOM1_RS1 0x707f -+#define MATCH_CUSTOM1_RS1_RS2 0x302b -+#define MASK_CUSTOM1_RS1_RS2 0x707f -+#define MATCH_CUSTOM2 0x5b -+#define MASK_CUSTOM2 0x707f -+#define MATCH_CUSTOM2_RD 0x405b -+#define MASK_CUSTOM2_RD 0x707f -+#define MATCH_CUSTOM2_RD_RS1 0x605b -+#define MASK_CUSTOM2_RD_RS1 0x707f -+#define MATCH_CUSTOM2_RD_RS1_RS2 0x705b -+#define MASK_CUSTOM2_RD_RS1_RS2 0x707f -+#define MATCH_CUSTOM2_RS1 0x205b -+#define MASK_CUSTOM2_RS1 0x707f -+#define MATCH_CUSTOM2_RS1_RS2 0x305b -+#define MASK_CUSTOM2_RS1_RS2 0x707f -+#define MATCH_CUSTOM3 0x7b -+#define MASK_CUSTOM3 0x707f -+#define MATCH_CUSTOM3_RD 0x407b -+#define MASK_CUSTOM3_RD 0x707f -+#define MATCH_CUSTOM3_RD_RS1 0x607b -+#define MASK_CUSTOM3_RD_RS1 0x707f -+#define MATCH_CUSTOM3_RD_RS1_RS2 0x707b -+#define MASK_CUSTOM3_RD_RS1_RS2 0x707f -+#define MATCH_CUSTOM3_RS1 0x207b -+#define MASK_CUSTOM3_RS1 0x707f -+#define MATCH_CUSTOM3_RS1_RS2 0x307b -+#define MASK_CUSTOM3_RS1_RS2 0x707f -+#define MATCH_DIV 0x2004033 -+#define MASK_DIV 0xfe00707f -+#define MATCH_DIVU 0x2005033 -+#define MASK_DIVU 0xfe00707f -+#define MATCH_DIVUW 0x200503b -+#define MASK_DIVUW 0xfe00707f -+#define MATCH_DIVW 0x200403b -+#define MASK_DIVW 0xfe00707f -+#define MATCH_FADD_D 0x2000053 -+#define MASK_FADD_D 0xfe00007f -+#define MATCH_FADD_H 0x4000053 -+#define MASK_FADD_H 0xfe00007f -+#define MATCH_FADD_S 0x53 -+#define MASK_FADD_S 0xfe00007f -+#define MATCH_FCLASS_D 0xe2001053 -+#define MASK_FCLASS_D 0xfff0707f -+#define MATCH_FCLASS_S 0xe0001053 -+#define MASK_FCLASS_S 0xfff0707f -+#define MATCH_FCVT_D_H 0x8c000053 -+#define MASK_FCVT_D_H 0xfff0007f -+#define MATCH_FCVT_D_L 0xd2200053 -+#define MASK_FCVT_D_L 0xfff0007f -+#define MATCH_FCVT_D_LU 0xd2300053 -+#define MASK_FCVT_D_LU 0xfff0007f -+#define MATCH_FCVT_D_S 0x42000053 -+#define MASK_FCVT_D_S 0xfff0007f -+#define MATCH_FCVT_D_W 0xd2000053 -+#define MASK_FCVT_D_W 0xfff0007f -+#define MATCH_FCVT_D_WU 0xd2100053 -+#define MASK_FCVT_D_WU 0xfff0007f -+#define MATCH_FCVT_H_D 0x92000053 -+#define MASK_FCVT_H_D 0xfff0007f -+#define MATCH_FCVT_H_L 0x64000053 -+#define MASK_FCVT_H_L 0xfff0007f -+#define MATCH_FCVT_H_LU 0x6c000053 -+#define MASK_FCVT_H_LU 0xfff0007f -+#define MATCH_FCVT_H_S 0x90000053 -+#define MASK_FCVT_H_S 0xfff0007f -+#define MATCH_FCVT_H_W 0x74000053 -+#define MASK_FCVT_H_W 0xfff0007f -+#define MATCH_FCVT_H_WU 0x7c000053 -+#define MASK_FCVT_H_WU 0xfff0007f -+#define MATCH_FCVT_L_D 0xc2200053 -+#define MASK_FCVT_L_D 0xfff0007f -+#define MATCH_FCVT_L_H 0x44000053 -+#define MASK_FCVT_L_H 0xfff0007f -+#define MATCH_FCVT_L_S 0xc0200053 -+#define MASK_FCVT_L_S 0xfff0007f -+#define MATCH_FCVT_LU_D 0xc2300053 -+#define MASK_FCVT_LU_D 0xfff0007f -+#define MATCH_FCVT_LU_H 0x4c000053 -+#define MASK_FCVT_LU_H 0xfff0007f -+#define MATCH_FCVT_LU_S 0xc0300053 -+#define MASK_FCVT_LU_S 0xfff0007f -+#define MATCH_FCVT_S_D 0x40100053 -+#define MASK_FCVT_S_D 0xfff0007f -+#define MATCH_FCVT_S_H 0x84000053 -+#define MASK_FCVT_S_H 0xfff0007f -+#define MATCH_FCVT_S_L 0xd0200053 -+#define MASK_FCVT_S_L 0xfff0007f -+#define MATCH_FCVT_S_LU 0xd0300053 -+#define MASK_FCVT_S_LU 0xfff0007f -+#define MATCH_FCVT_S_W 0xd0000053 -+#define MASK_FCVT_S_W 0xfff0007f -+#define MATCH_FCVT_S_WU 0xd0100053 -+#define MASK_FCVT_S_WU 0xfff0007f -+#define MATCH_FCVT_W_D 0xc2000053 -+#define MASK_FCVT_W_D 0xfff0007f -+#define MATCH_FCVT_W_H 0x54000053 -+#define MASK_FCVT_W_H 0xfff0007f -+#define MATCH_FCVT_W_S 0xc0000053 -+#define MASK_FCVT_W_S 0xfff0007f -+#define MATCH_FCVT_WU_D 0xc2100053 -+#define MASK_FCVT_WU_D 0xfff0007f -+#define MATCH_FCVT_WU_H 0x5c000053 -+#define MASK_FCVT_WU_H 0xfff0007f -+#define MATCH_FCVT_WU_S 0xc0100053 -+#define MASK_FCVT_WU_S 0xfff0007f -+#define MATCH_FDIV_D 0x1a000053 -+#define MASK_FDIV_D 0xfe00007f -+#define MATCH_FDIV_H 0x1c000053 -+#define MASK_FDIV_H 0xfe00007f -+#define MATCH_FDIV_S 0x18000053 -+#define MASK_FDIV_S 0xfe00007f -+#define MATCH_FENCE 0xf -+#define MASK_FENCE 0x707f -+#define MATCH_FENCE_I 0x100f -+#define MASK_FENCE_I 0x707f -+#define MATCH_FEQ_D 0xa2002053 -+#define MASK_FEQ_D 0xfe00707f -+#define MATCH_FEQ_H 0xac000053 -+#define MASK_FEQ_H 0xfe00707f -+#define MATCH_FEQ_S 0xa0002053 -+#define MASK_FEQ_S 0xfe00707f -+#define MATCH_FLD 0x3007 -+#define MASK_FLD 0x707f -+#define MATCH_FLE_D 0xa2000053 -+#define MASK_FLE_D 0xfe00707f -+#define MATCH_FLE_H 0xbc000053 -+#define MASK_FLE_H 0xfe00707f -+#define MATCH_FLE_S 0xa0000053 -+#define MASK_FLE_S 0xfe00707f -+#define MATCH_FLH 0x1007 -+#define MASK_FLH 0x707f -+#define MATCH_FLT_D 0xa2001053 -+#define MASK_FLT_D 0xfe00707f -+#define MATCH_FLT_H 0xb4000053 -+#define MASK_FLT_H 0xfe00707f -+#define MATCH_FLT_S 0xa0001053 -+#define MASK_FLT_S 0xfe00707f -+#define MATCH_FLW 0x2007 -+#define MASK_FLW 0x707f -+#define MATCH_FMADD_D 0x2000043 -+#define MASK_FMADD_D 0x600007f -+#define MATCH_FMADD_H 0x4000043 -+#define MASK_FMADD_H 0x600007f -+#define MATCH_FMADD_S 0x43 -+#define MASK_FMADD_S 0x600007f -+#define MATCH_FMAX_D 0x2a001053 -+#define MASK_FMAX_D 0xfe00707f -+#define MATCH_FMAX_H 0xcc000053 -+#define MASK_FMAX_H 0xfe00707f -+#define MATCH_FMAX_S 0x28001053 -+#define MASK_FMAX_S 0xfe00707f -+#define MATCH_FMIN_D 0x2a000053 -+#define MASK_FMIN_D 0xfe00707f -+#define MATCH_FMIN_H 0xc4000053 -+#define MASK_FMIN_H 0xfe00707f -+#define MATCH_FMIN_S 0x28000053 -+#define MASK_FMIN_S 0xfe00707f -+#define MATCH_FMOVN 0x6007077 -+#define MASK_FMOVN 0xfe00707f -+#define MATCH_FMOVZ 0x4007077 -+#define MASK_FMOVZ 0xfe00707f -+#define MATCH_FMSUB_D 0x2000047 -+#define MASK_FMSUB_D 0x600007f -+#define MATCH_FMSUB_H 0x4000047 -+#define MASK_FMSUB_H 0x600007f -+#define MATCH_FMSUB_S 0x47 -+#define MASK_FMSUB_S 0x600007f -+#define MATCH_FMUL_D 0x12000053 -+#define MASK_FMUL_D 0xfe00007f -+#define MATCH_FMUL_H 0x14000053 -+#define MASK_FMUL_H 0xfe00007f -+#define MATCH_FMUL_S 0x10000053 -+#define MASK_FMUL_S 0xfe00007f -+#define MATCH_FMV_D_X 0xf2000053 -+#define MASK_FMV_D_X 0xfff0707f -+#define MATCH_FMV_H_X 0xf4000053 -+#define MASK_FMV_H_X 0xfff0707f -+#define MATCH_FMV_S_X 0xf0000053 -+#define MASK_FMV_S_X 0xfff0707f -+#define MATCH_FMV_X_D 0xe2000053 -+#define MASK_FMV_X_D 0xfff0707f -+#define MATCH_FMV_X_H 0xe4000053 -+#define MASK_FMV_X_H 0xfff0707f -+#define MATCH_FMV_X_S 0xe0000053 -+#define MASK_FMV_X_S 0xfff0707f -+#define MATCH_FNMADD_D 0x200004f -+#define MASK_FNMADD_D 0x600007f -+#define MATCH_FNMADD_H 0x400004f -+#define MASK_FNMADD_H 0x600007f -+#define MATCH_FNMADD_S 0x4f -+#define MASK_FNMADD_S 0x600007f -+#define MATCH_FNMSUB_D 0x200004b -+#define MASK_FNMSUB_D 0x600007f -+#define MATCH_FNMSUB_H 0x400004b -+#define MASK_FNMSUB_H 0x600007f -+#define MATCH_FNMSUB_S 0x4b -+#define MASK_FNMSUB_S 0x600007f -+#define MATCH_FRCSR 0x302073 -+#define MASK_FRCSR 0xfffff07f -+#define MATCH_FRFLAGS 0x102073 -+#define MASK_FRFLAGS 0xfffff07f -+#define MATCH_FRRM 0x202073 -+#define MASK_FRRM 0xfffff07f -+#define MATCH_FSCSR 0x301073 -+#define MASK_FSCSR 0xfff0707f -+#define MATCH_FSD 0x3027 -+#define MASK_FSD 0x707f -+#define MATCH_FSFLAGS 0x101073 -+#define MASK_FSFLAGS 0xfff0707f -+#define MATCH_FSFLAGSI 0x105073 -+#define MASK_FSFLAGSI 0xfff0707f -+#define MATCH_FSGNJ_D 0x22000053 -+#define MASK_FSGNJ_D 0xfe00707f -+#define MATCH_FSGNJ_H 0x2c000053 -+#define MASK_FSGNJ_H 0xfe00707f -+#define MATCH_FSGNJ_S 0x20000053 -+#define MASK_FSGNJ_S 0xfe00707f -+#define MATCH_FSGNJN_D 0x22001053 -+#define MASK_FSGNJN_D 0xfe00707f -+#define MATCH_FSGNJN_H 0x34000053 -+#define MASK_FSGNJN_H 0xfe00707f -+#define MATCH_FSGNJN_S 0x20001053 -+#define MASK_FSGNJN_S 0xfe00707f -+#define MATCH_FSGNJX_D 0x22002053 -+#define MASK_FSGNJX_D 0xfe00707f -+#define MATCH_FSGNJX_H 0x3c000053 -+#define MASK_FSGNJX_H 0xfe00707f -+#define MATCH_FSGNJX_S 0x20002053 -+#define MASK_FSGNJX_S 0xfe00707f -+#define MATCH_FSH 0x1027 -+#define MASK_FSH 0x707f -+#define MATCH_FSQRT_D 0x5a000053 -+#define MASK_FSQRT_D 0xfff0007f -+#define MATCH_FSQRT_H 0x24000053 -+#define MASK_FSQRT_H 0xfff0007f -+#define MATCH_FSQRT_S 0x58000053 -+#define MASK_FSQRT_S 0xfff0007f -+#define MATCH_FSRM 0x201073 -+#define MASK_FSRM 0xfff0707f -+#define MATCH_FSRMI 0x205073 -+#define MASK_FSRMI 0xfff0707f -+#define MATCH_FSUB_D 0xa000053 -+#define MASK_FSUB_D 0xfe00007f -+#define MATCH_FSUB_H 0xc000053 -+#define MASK_FSUB_H 0xfe00007f -+#define MATCH_FSUB_S 0x8000053 -+#define MASK_FSUB_S 0xfe00007f -+#define MATCH_FSW 0x2027 -+#define MASK_FSW 0x707f -+#define MATCH_JAL 0x6f -+#define MASK_JAL 0x7f -+#define MATCH_JALR 0x67 -+#define MASK_JALR 0x707f -+#define MATCH_LB 0x3 -+#define MASK_LB 0x707f -+#define MATCH_LBU 0x4003 -+#define MASK_LBU 0x707f -+#define MATCH_LD 0x3003 -+#define MASK_LD 0x707f -+#define MATCH_LH 0x1003 -+#define MASK_LH 0x707f -+#define MATCH_LHU 0x5003 -+#define MASK_LHU 0x707f -+#define MATCH_LR_D 0x1000302f -+#define MASK_LR_D 0xf9f0707f -+#define MATCH_LR_W 0x1000202f -+#define MASK_LR_W 0xf9f0707f -+#define MATCH_LUI 0x37 -+#define MASK_LUI 0x7f -+#define MATCH_LW 0x2003 -+#define MASK_LW 0x707f -+#define MATCH_LWU 0x6003 -+#define MASK_LWU 0x707f -+#define MATCH_MOVN 0x2007077 -+#define MASK_MOVN 0xfe00707f -+#define MATCH_MOVZ 0x7077 -+#define MASK_MOVZ 0xfe00707f -+#define MATCH_MRTS 0x30500073 -+#define MASK_MRTS 0xffffffff -+#define MATCH_MUL 0x2000033 -+#define MASK_MUL 0xfe00707f -+#define MATCH_MULH 0x2001033 -+#define MASK_MULH 0xfe00707f -+#define MATCH_MULHSU 0x2002033 -+#define MASK_MULHSU 0xfe00707f -+#define MATCH_MULHU 0x2003033 -+#define MASK_MULHU 0xfe00707f -+#define MATCH_MULW 0x200003b -+#define MASK_MULW 0xfe00707f -+#define MATCH_OR 0x6033 -+#define MASK_OR 0xfe00707f -+#define MATCH_ORI 0x6013 -+#define MASK_ORI 0x707f -+#define MATCH_RDCYCLE 0xc0002073 -+#define MASK_RDCYCLE 0xfffff07f -+#define MATCH_RDCYCLEH 0xc8002073 -+#define MASK_RDCYCLEH 0xfffff07f -+#define MATCH_RDINSTRET 0xc0202073 -+#define MASK_RDINSTRET 0xfffff07f -+#define MATCH_RDINSTRETH 0xc8202073 -+#define MASK_RDINSTRETH 0xfffff07f -+#define MATCH_RDTIME 0xc0102073 -+#define MASK_RDTIME 0xfffff07f -+#define MATCH_RDTIMEH 0xc8102073 -+#define MASK_RDTIMEH 0xfffff07f -+#define MATCH_REM 0x2006033 -+#define MASK_REM 0xfe00707f -+#define MATCH_REMU 0x2007033 -+#define MASK_REMU 0xfe00707f -+#define MATCH_REMUW 0x200703b -+#define MASK_REMUW 0xfe00707f -+#define MATCH_REMW 0x200603b -+#define MASK_REMW 0xfe00707f -+#define MATCH_SB 0x23 -+#define MASK_SB 0x707f -+#define MATCH_SBREAK 0x100073 -+#define MASK_SBREAK 0xffffffff -+#define MATCH_SC_D 0x1800302f -+#define MASK_SC_D 0xf800707f -+#define MATCH_SC_W 0x1800202f -+#define MASK_SC_W 0xf800707f -+#define MATCH_SCALL 0x73 -+#define MASK_SCALL 0xffffffff -+#define MATCH_SD 0x3023 -+#define MASK_SD 0x707f -+#define MATCH_SFENCE_VM 0x10100073 -+#define MASK_SFENCE_VM 0xfff07fff -+#define MATCH_SH 0x1023 -+#define MASK_SH 0x707f -+#define MATCH_SLL 0x1033 -+#define MASK_SLL 0xfe00707f -+#define MATCH_SLLI 0x1013 -+#define MASK_SLLI 0xfc00707f -+#define MATCH_SLLI_RV32 0x1013 -+#define MASK_SLLI_RV32 0xfe00707f -+#define MATCH_SLLIW 0x101b -+#define MASK_SLLIW 0xfe00707f -+#define MATCH_SLLW 0x103b -+#define MASK_SLLW 0xfe00707f -+#define MATCH_SLT 0x2033 -+#define MASK_SLT 0xfe00707f -+#define MATCH_SLTI 0x2013 -+#define MASK_SLTI 0x707f -+#define MATCH_SLTIU 0x3013 -+#define MASK_SLTIU 0x707f -+#define MATCH_SLTU 0x3033 -+#define MASK_SLTU 0xfe00707f -+#define MATCH_SRA 0x40005033 -+#define MASK_SRA 0xfe00707f -+#define MATCH_SRAI 0x40005013 -+#define MASK_SRAI 0xfc00707f -+#define MATCH_SRAI_RV32 0x40005013 -+#define MASK_SRAI_RV32 0xfe00707f -+#define MATCH_SRAIW 0x4000501b -+#define MASK_SRAIW 0xfe00707f -+#define MATCH_SRAW 0x4000503b -+#define MASK_SRAW 0xfe00707f -+#define MATCH_SRET 0x10000073 -+#define MASK_SRET 0xffffffff -+#define MATCH_SRL 0x5033 -+#define MASK_SRL 0xfe00707f -+#define MATCH_SRLI 0x5013 -+#define MASK_SRLI 0xfc00707f -+#define MATCH_SRLI_RV32 0x5013 -+#define MASK_SRLI_RV32 0xfe00707f -+#define MATCH_SRLIW 0x501b -+#define MASK_SRLIW 0xfe00707f -+#define MATCH_SRLW 0x503b -+#define MASK_SRLW 0xfe00707f -+#define MATCH_STOP 0x5077 -+#define MASK_STOP 0xffffffff -+#define MATCH_SUB 0x40000033 -+#define MASK_SUB 0xfe00707f -+#define MATCH_SUBW 0x4000003b -+#define MASK_SUBW 0xfe00707f -+#define MATCH_SW 0x2023 -+#define MASK_SW 0x707f -+#define MATCH_UTIDX 0x6077 -+#define MASK_UTIDX 0xfffff07f -+#define MATCH_VENQCMD 0xa00302b -+#define MASK_VENQCMD 0xfe007fff -+#define MATCH_VENQCNT 0x1000302b -+#define MASK_VENQCNT 0xfe007fff -+#define MATCH_VENQIMM1 0xc00302b -+#define MASK_VENQIMM1 0xfe007fff -+#define MATCH_VENQIMM2 0xe00302b -+#define MASK_VENQIMM2 0xfe007fff -+#define MATCH_VF 0x10202b -+#define MASK_VF 0x1f0707f -+#define MATCH_VFLD 0x1600205b -+#define MASK_VFLD 0xfff0707f -+#define MATCH_VFLSEGD 0x1600205b -+#define MASK_VFLSEGD 0x1ff0707f -+#define MATCH_VFLSEGSTD 0x1600305b -+#define MASK_VFLSEGSTD 0x1e00707f -+#define MATCH_VFLSEGSTW 0x1400305b -+#define MASK_VFLSEGSTW 0x1e00707f -+#define MATCH_VFLSEGW 0x1400205b -+#define MASK_VFLSEGW 0x1ff0707f -+#define MATCH_VFLSTD 0x1600305b -+#define MASK_VFLSTD 0xfe00707f -+#define MATCH_VFLSTW 0x1400305b -+#define MASK_VFLSTW 0xfe00707f -+#define MATCH_VFLW 0x1400205b -+#define MASK_VFLW 0xfff0707f -+#define MATCH_VFMSV_D 0x1200202b -+#define MASK_VFMSV_D 0xfff0707f -+#define MATCH_VFMSV_S 0x1000202b -+#define MASK_VFMSV_S 0xfff0707f -+#define MATCH_VFMVV 0x1000002b -+#define MASK_VFMVV 0xfff0707f -+#define MATCH_VFSD 0x1600207b -+#define MASK_VFSD 0xfff0707f -+#define MATCH_VFSSEGD 0x1600207b -+#define MASK_VFSSEGD 0x1ff0707f -+#define MATCH_VFSSEGSTD 0x1600307b -+#define MASK_VFSSEGSTD 0x1e00707f -+#define MATCH_VFSSEGSTW 0x1400307b -+#define MASK_VFSSEGSTW 0x1e00707f -+#define MATCH_VFSSEGW 0x1400207b -+#define MASK_VFSSEGW 0x1ff0707f -+#define MATCH_VFSSTD 0x1600307b -+#define MASK_VFSSTD 0xfe00707f -+#define MATCH_VFSSTW 0x1400307b -+#define MASK_VFSSTW 0xfe00707f -+#define MATCH_VFSW 0x1400207b -+#define MASK_VFSW 0xfff0707f -+#define MATCH_VGETCFG 0x400b -+#define MASK_VGETCFG 0xfffff07f -+#define MATCH_VGETVL 0x200400b -+#define MASK_VGETVL 0xfffff07f -+#define MATCH_VLB 0x205b -+#define MASK_VLB 0xfff0707f -+#define MATCH_VLBU 0x800205b -+#define MASK_VLBU 0xfff0707f -+#define MATCH_VLD 0x600205b -+#define MASK_VLD 0xfff0707f -+#define MATCH_VLH 0x200205b -+#define MASK_VLH 0xfff0707f -+#define MATCH_VLHU 0xa00205b -+#define MASK_VLHU 0xfff0707f -+#define MATCH_VLSEGB 0x205b -+#define MASK_VLSEGB 0x1ff0707f -+#define MATCH_VLSEGBU 0x800205b -+#define MASK_VLSEGBU 0x1ff0707f -+#define MATCH_VLSEGD 0x600205b -+#define MASK_VLSEGD 0x1ff0707f -+#define MATCH_VLSEGH 0x200205b -+#define MASK_VLSEGH 0x1ff0707f -+#define MATCH_VLSEGHU 0xa00205b -+#define MASK_VLSEGHU 0x1ff0707f -+#define MATCH_VLSEGSTB 0x305b -+#define MASK_VLSEGSTB 0x1e00707f -+#define MATCH_VLSEGSTBU 0x800305b -+#define MASK_VLSEGSTBU 0x1e00707f -+#define MATCH_VLSEGSTD 0x600305b -+#define MASK_VLSEGSTD 0x1e00707f -+#define MATCH_VLSEGSTH 0x200305b -+#define MASK_VLSEGSTH 0x1e00707f -+#define MATCH_VLSEGSTHU 0xa00305b -+#define MASK_VLSEGSTHU 0x1e00707f -+#define MATCH_VLSEGSTW 0x400305b -+#define MASK_VLSEGSTW 0x1e00707f -+#define MATCH_VLSEGSTWU 0xc00305b -+#define MASK_VLSEGSTWU 0x1e00707f -+#define MATCH_VLSEGW 0x400205b -+#define MASK_VLSEGW 0x1ff0707f -+#define MATCH_VLSEGWU 0xc00205b -+#define MASK_VLSEGWU 0x1ff0707f -+#define MATCH_VLSTB 0x305b -+#define MASK_VLSTB 0xfe00707f -+#define MATCH_VLSTBU 0x800305b -+#define MASK_VLSTBU 0xfe00707f -+#define MATCH_VLSTD 0x600305b -+#define MASK_VLSTD 0xfe00707f -+#define MATCH_VLSTH 0x200305b -+#define MASK_VLSTH 0xfe00707f -+#define MATCH_VLSTHU 0xa00305b -+#define MASK_VLSTHU 0xfe00707f -+#define MATCH_VLSTW 0x400305b -+#define MASK_VLSTW 0xfe00707f -+#define MATCH_VLSTWU 0xc00305b -+#define MASK_VLSTWU 0xfe00707f -+#define MATCH_VLW 0x400205b -+#define MASK_VLW 0xfff0707f -+#define MATCH_VLWU 0xc00205b -+#define MASK_VLWU 0xfff0707f -+#define MATCH_VMSV 0x200202b -+#define MASK_VMSV 0xfff0707f -+#define MATCH_VMVV 0x200002b -+#define MASK_VMVV 0xfff0707f -+#define MATCH_VSB 0x207b -+#define MASK_VSB 0xfff0707f -+#define MATCH_VSD 0x600207b -+#define MASK_VSD 0xfff0707f -+#define MATCH_VSETCFG 0x200b -+#define MASK_VSETCFG 0x7fff -+#define MATCH_VSETVL 0x600b -+#define MASK_VSETVL 0xfff0707f -+#define MATCH_VSH 0x200207b -+#define MASK_VSH 0xfff0707f -+#define MATCH_VSSEGB 0x207b -+#define MASK_VSSEGB 0x1ff0707f -+#define MATCH_VSSEGD 0x600207b -+#define MASK_VSSEGD 0x1ff0707f -+#define MATCH_VSSEGH 0x200207b -+#define MASK_VSSEGH 0x1ff0707f -+#define MATCH_VSSEGSTB 0x307b -+#define MASK_VSSEGSTB 0x1e00707f -+#define MATCH_VSSEGSTD 0x600307b -+#define MASK_VSSEGSTD 0x1e00707f -+#define MATCH_VSSEGSTH 0x200307b -+#define MASK_VSSEGSTH 0x1e00707f -+#define MATCH_VSSEGSTW 0x400307b -+#define MASK_VSSEGSTW 0x1e00707f -+#define MATCH_VSSEGW 0x400207b -+#define MASK_VSSEGW 0x1ff0707f -+#define MATCH_VSSTB 0x307b -+#define MASK_VSSTB 0xfe00707f -+#define MATCH_VSSTD 0x600307b -+#define MASK_VSSTD 0xfe00707f -+#define MATCH_VSSTH 0x200307b -+#define MASK_VSSTH 0xfe00707f -+#define MATCH_VSSTW 0x400307b -+#define MASK_VSSTW 0xfe00707f -+#define MATCH_VSW 0x400207b -+#define MASK_VSW 0xfff0707f -+#define MATCH_VXCPTAUX 0x200402b -+#define MASK_VXCPTAUX 0xfffff07f -+#define MATCH_VXCPTCAUSE 0x402b -+#define MASK_VXCPTCAUSE 0xfffff07f -+#define MATCH_VXCPTEVAC 0x600302b -+#define MASK_VXCPTEVAC 0xfff07fff -+#define MATCH_VXCPTHOLD 0x800302b -+#define MASK_VXCPTHOLD 0xfff07fff -+#define MATCH_VXCPTKILL 0x400302b -+#define MASK_VXCPTKILL 0xffffffff -+#define MATCH_VXCPTRESTORE 0x200302b -+#define MASK_VXCPTRESTORE 0xfff07fff -+#define MATCH_VXCPTSAVE 0x302b -+#define MASK_VXCPTSAVE 0xfff07fff -+#define MATCH_XOR 0x4033 -+#define MASK_XOR 0xfe00707f -+#define MATCH_XORI 0x4013 -+#define MASK_XORI 0x707f -+#define CSR_FFLAGS 0x1 -+#define CSR_FRM 0x2 -+#define CSR_FCSR 0x3 -+#define CSR_CYCLE 0xc00 -+#define CSR_TIME 0xc01 -+#define CSR_INSTRET 0xc02 -+#define CSR_STATS 0xc0 -+#define CSR_UARCH0 0xcc0 -+#define CSR_UARCH1 0xcc1 -+#define CSR_UARCH2 0xcc2 -+#define CSR_UARCH3 0xcc3 -+#define CSR_UARCH4 0xcc4 -+#define CSR_UARCH5 0xcc5 -+#define CSR_UARCH6 0xcc6 -+#define CSR_UARCH7 0xcc7 -+#define CSR_UARCH8 0xcc8 -+#define CSR_UARCH9 0xcc9 -+#define CSR_UARCH10 0xcca -+#define CSR_UARCH11 0xccb -+#define CSR_UARCH12 0xccc -+#define CSR_UARCH13 0xccd -+#define CSR_UARCH14 0xcce -+#define CSR_UARCH15 0xccf -+#define CSR_SSTATUS 0x100 -+#define CSR_STVEC 0x101 -+#define CSR_STIMECMP 0x121 -+#define CSR_SSCRATCH 0x140 -+#define CSR_SEPC 0x141 -+#define CSR_SPTBR 0x188 -+#define CSR_SASID 0x189 -+#define CSR_SCYCLE 0x900 -+#define CSR_STIME 0x901 -+#define CSR_SINSTRET 0x902 -+#define CSR_SCAUSE 0xd40 -+#define CSR_SBADADDR 0xd41 -+#define CSR_MSTATUS 0x300 -+#define CSR_MSCRATCH 0x340 -+#define CSR_MEPC 0x341 -+#define CSR_MCAUSE 0x342 -+#define CSR_MBADADDR 0x343 -+#define CSR_RESET 0x780 -+#define CSR_TOHOST 0x781 -+#define CSR_FROMHOST 0x782 -+#define CSR_SEND_IPI 0x783 -+#define CSR_HARTID 0xfc0 -+#define CSR_CYCLEH 0xc80 -+#define CSR_TIMEH 0xc81 -+#define CSR_INSTRETH 0xc82 -+#define CSR_SCYCLEH 0x980 -+#define CSR_STIMEH 0x981 -+#define CSR_SINSTRETH 0x982 -+#define CAUSE_MISALIGNED_FETCH 0x0 -+#define CAUSE_FAULT_FETCH 0x1 -+#define CAUSE_ILLEGAL_INSTRUCTION 0x2 -+#define CAUSE_MISALIGNED_LOAD 0x4 -+#define CAUSE_FAULT_LOAD 0x5 -+#define CAUSE_MISALIGNED_STORE 0x6 -+#define CAUSE_FAULT_STORE 0x7 -+#define CAUSE_ECALL 0x8 -+#define CAUSE_BREAKPOINT 0x9 -+#endif -+#ifdef DECLARE_INSN -+DECLARE_INSN(add, MATCH_ADD, MASK_ADD) -+DECLARE_INSN(addi, MATCH_ADDI, MASK_ADDI) -+DECLARE_INSN(addiw, MATCH_ADDIW, MASK_ADDIW) -+DECLARE_INSN(addw, MATCH_ADDW, MASK_ADDW) -+DECLARE_INSN(amoadd_d, MATCH_AMOADD_D, MASK_AMOADD_D) -+DECLARE_INSN(amoadd_w, MATCH_AMOADD_W, MASK_AMOADD_W) -+DECLARE_INSN(amoand_d, MATCH_AMOAND_D, MASK_AMOAND_D) -+DECLARE_INSN(amoand_w, MATCH_AMOAND_W, MASK_AMOAND_W) -+DECLARE_INSN(amomax_d, MATCH_AMOMAX_D, MASK_AMOMAX_D) -+DECLARE_INSN(amomax_w, MATCH_AMOMAX_W, MASK_AMOMAX_W) -+DECLARE_INSN(amomaxu_d, MATCH_AMOMAXU_D, MASK_AMOMAXU_D) -+DECLARE_INSN(amomaxu_w, MATCH_AMOMAXU_W, MASK_AMOMAXU_W) -+DECLARE_INSN(amomin_d, MATCH_AMOMIN_D, MASK_AMOMIN_D) -+DECLARE_INSN(amomin_w, MATCH_AMOMIN_W, MASK_AMOMIN_W) -+DECLARE_INSN(amominu_d, MATCH_AMOMINU_D, MASK_AMOMINU_D) -+DECLARE_INSN(amominu_w, MATCH_AMOMINU_W, MASK_AMOMINU_W) -+DECLARE_INSN(amoor_d, MATCH_AMOOR_D, MASK_AMOOR_D) -+DECLARE_INSN(amoor_w, MATCH_AMOOR_W, MASK_AMOOR_W) -+DECLARE_INSN(amoswap_d, MATCH_AMOSWAP_D, MASK_AMOSWAP_D) -+DECLARE_INSN(amoswap_w, MATCH_AMOSWAP_W, MASK_AMOSWAP_W) -+DECLARE_INSN(amoxor_d, MATCH_AMOXOR_D, MASK_AMOXOR_D) -+DECLARE_INSN(amoxor_w, MATCH_AMOXOR_W, MASK_AMOXOR_W) -+DECLARE_INSN(and, MATCH_AND, MASK_AND) -+DECLARE_INSN(andi, MATCH_ANDI, MASK_ANDI) -+DECLARE_INSN(auipc, MATCH_AUIPC, MASK_AUIPC) -+DECLARE_INSN(beq, MATCH_BEQ, MASK_BEQ) -+DECLARE_INSN(bge, MATCH_BGE, MASK_BGE) -+DECLARE_INSN(bgeu, MATCH_BGEU, MASK_BGEU) -+DECLARE_INSN(blt, MATCH_BLT, MASK_BLT) -+DECLARE_INSN(bltu, MATCH_BLTU, MASK_BLTU) -+DECLARE_INSN(bne, MATCH_BNE, MASK_BNE) -+DECLARE_INSN(c_add, MATCH_C_ADD, MASK_C_ADD) -+DECLARE_INSN(c_addi, MATCH_C_ADDI, MASK_C_ADDI) -+DECLARE_INSN(c_addi4, MATCH_C_ADDI4, MASK_C_ADDI4) -+DECLARE_INSN(c_addiw, MATCH_C_ADDIW, MASK_C_ADDIW) -+DECLARE_INSN(c_addw, MATCH_C_ADDW, MASK_C_ADDW) -+DECLARE_INSN(c_beqz, MATCH_C_BEQZ, MASK_C_BEQZ) -+DECLARE_INSN(c_bnez, MATCH_C_BNEZ, MASK_C_BNEZ) -+DECLARE_INSN(c_j, MATCH_C_J, MASK_C_J) -+DECLARE_INSN(c_jalr, MATCH_C_JALR, MASK_C_JALR) -+DECLARE_INSN(c_ld, MATCH_C_LD, MASK_C_LD) -+DECLARE_INSN(c_ldsp, MATCH_C_LDSP, MASK_C_LDSP) -+DECLARE_INSN(c_li, MATCH_C_LI, MASK_C_LI) -+DECLARE_INSN(c_lui, MATCH_C_LUI, MASK_C_LUI) -+DECLARE_INSN(c_lw, MATCH_C_LW, MASK_C_LW) -+DECLARE_INSN(c_lwsp, MATCH_C_LWSP, MASK_C_LWSP) -+DECLARE_INSN(c_mv, MATCH_C_MV, MASK_C_MV) -+DECLARE_INSN(c_sd, MATCH_C_SD, MASK_C_SD) -+DECLARE_INSN(c_sdsp, MATCH_C_SDSP, MASK_C_SDSP) -+DECLARE_INSN(c_slli, MATCH_C_SLLI, MASK_C_SLLI) -+DECLARE_INSN(c_sw, MATCH_C_SW, MASK_C_SW) -+DECLARE_INSN(c_swsp, MATCH_C_SWSP, MASK_C_SWSP) -+DECLARE_INSN(csrrc, MATCH_CSRRC, MASK_CSRRC) -+DECLARE_INSN(csrrci, MATCH_CSRRCI, MASK_CSRRCI) -+DECLARE_INSN(csrrs, MATCH_CSRRS, MASK_CSRRS) -+DECLARE_INSN(csrrsi, MATCH_CSRRSI, MASK_CSRRSI) -+DECLARE_INSN(csrrw, MATCH_CSRRW, MASK_CSRRW) -+DECLARE_INSN(csrrwi, MATCH_CSRRWI, MASK_CSRRWI) -+DECLARE_INSN(custom0, MATCH_CUSTOM0, MASK_CUSTOM0) -+DECLARE_INSN(custom0_rd, MATCH_CUSTOM0_RD, MASK_CUSTOM0_RD) -+DECLARE_INSN(custom0_rd_rs1, MATCH_CUSTOM0_RD_RS1, MASK_CUSTOM0_RD_RS1) -+DECLARE_INSN(custom0_rd_rs1_rs2, MATCH_CUSTOM0_RD_RS1_RS2, MASK_CUSTOM0_RD_RS1_RS2) -+DECLARE_INSN(custom0_rs1, MATCH_CUSTOM0_RS1, MASK_CUSTOM0_RS1) -+DECLARE_INSN(custom0_rs1_rs2, MATCH_CUSTOM0_RS1_RS2, MASK_CUSTOM0_RS1_RS2) -+DECLARE_INSN(custom1, MATCH_CUSTOM1, MASK_CUSTOM1) -+DECLARE_INSN(custom1_rd, MATCH_CUSTOM1_RD, MASK_CUSTOM1_RD) -+DECLARE_INSN(custom1_rd_rs1, MATCH_CUSTOM1_RD_RS1, MASK_CUSTOM1_RD_RS1) -+DECLARE_INSN(custom1_rd_rs1_rs2, MATCH_CUSTOM1_RD_RS1_RS2, MASK_CUSTOM1_RD_RS1_RS2) -+DECLARE_INSN(custom1_rs1, MATCH_CUSTOM1_RS1, MASK_CUSTOM1_RS1) -+DECLARE_INSN(custom1_rs1_rs2, MATCH_CUSTOM1_RS1_RS2, MASK_CUSTOM1_RS1_RS2) -+DECLARE_INSN(custom2, MATCH_CUSTOM2, MASK_CUSTOM2) -+DECLARE_INSN(custom2_rd, MATCH_CUSTOM2_RD, MASK_CUSTOM2_RD) -+DECLARE_INSN(custom2_rd_rs1, MATCH_CUSTOM2_RD_RS1, MASK_CUSTOM2_RD_RS1) -+DECLARE_INSN(custom2_rd_rs1_rs2, MATCH_CUSTOM2_RD_RS1_RS2, MASK_CUSTOM2_RD_RS1_RS2) -+DECLARE_INSN(custom2_rs1, MATCH_CUSTOM2_RS1, MASK_CUSTOM2_RS1) -+DECLARE_INSN(custom2_rs1_rs2, MATCH_CUSTOM2_RS1_RS2, MASK_CUSTOM2_RS1_RS2) -+DECLARE_INSN(custom3, MATCH_CUSTOM3, MASK_CUSTOM3) -+DECLARE_INSN(custom3_rd, MATCH_CUSTOM3_RD, MASK_CUSTOM3_RD) -+DECLARE_INSN(custom3_rd_rs1, MATCH_CUSTOM3_RD_RS1, MASK_CUSTOM3_RD_RS1) -+DECLARE_INSN(custom3_rd_rs1_rs2, MATCH_CUSTOM3_RD_RS1_RS2, MASK_CUSTOM3_RD_RS1_RS2) -+DECLARE_INSN(custom3_rs1, MATCH_CUSTOM3_RS1, MASK_CUSTOM3_RS1) -+DECLARE_INSN(custom3_rs1_rs2, MATCH_CUSTOM3_RS1_RS2, MASK_CUSTOM3_RS1_RS2) -+DECLARE_INSN(div, MATCH_DIV, MASK_DIV) -+DECLARE_INSN(divu, MATCH_DIVU, MASK_DIVU) -+DECLARE_INSN(divuw, MATCH_DIVUW, MASK_DIVUW) -+DECLARE_INSN(divw, MATCH_DIVW, MASK_DIVW) -+DECLARE_INSN(fadd_d, MATCH_FADD_D, MASK_FADD_D) -+DECLARE_INSN(fadd_h, MATCH_FADD_H, MASK_FADD_H) -+DECLARE_INSN(fadd_s, MATCH_FADD_S, MASK_FADD_S) -+DECLARE_INSN(fclass_d, MATCH_FCLASS_D, MASK_FCLASS_D) -+DECLARE_INSN(fclass_s, MATCH_FCLASS_S, MASK_FCLASS_S) -+DECLARE_INSN(fcvt_d_h, MATCH_FCVT_D_H, MASK_FCVT_D_H) -+DECLARE_INSN(fcvt_d_l, MATCH_FCVT_D_L, MASK_FCVT_D_L) -+DECLARE_INSN(fcvt_d_lu, MATCH_FCVT_D_LU, MASK_FCVT_D_LU) -+DECLARE_INSN(fcvt_d_s, MATCH_FCVT_D_S, MASK_FCVT_D_S) -+DECLARE_INSN(fcvt_d_w, MATCH_FCVT_D_W, MASK_FCVT_D_W) -+DECLARE_INSN(fcvt_d_wu, MATCH_FCVT_D_WU, MASK_FCVT_D_WU) -+DECLARE_INSN(fcvt_h_d, MATCH_FCVT_H_D, MASK_FCVT_H_D) -+DECLARE_INSN(fcvt_h_l, MATCH_FCVT_H_L, MASK_FCVT_H_L) -+DECLARE_INSN(fcvt_h_lu, MATCH_FCVT_H_LU, MASK_FCVT_H_LU) -+DECLARE_INSN(fcvt_h_s, MATCH_FCVT_H_S, MASK_FCVT_H_S) -+DECLARE_INSN(fcvt_h_w, MATCH_FCVT_H_W, MASK_FCVT_H_W) -+DECLARE_INSN(fcvt_h_wu, MATCH_FCVT_H_WU, MASK_FCVT_H_WU) -+DECLARE_INSN(fcvt_l_d, MATCH_FCVT_L_D, MASK_FCVT_L_D) -+DECLARE_INSN(fcvt_l_h, MATCH_FCVT_L_H, MASK_FCVT_L_H) -+DECLARE_INSN(fcvt_l_s, MATCH_FCVT_L_S, MASK_FCVT_L_S) -+DECLARE_INSN(fcvt_lu_d, MATCH_FCVT_LU_D, MASK_FCVT_LU_D) -+DECLARE_INSN(fcvt_lu_h, MATCH_FCVT_LU_H, MASK_FCVT_LU_H) -+DECLARE_INSN(fcvt_lu_s, MATCH_FCVT_LU_S, MASK_FCVT_LU_S) -+DECLARE_INSN(fcvt_s_d, MATCH_FCVT_S_D, MASK_FCVT_S_D) -+DECLARE_INSN(fcvt_s_h, MATCH_FCVT_S_H, MASK_FCVT_S_H) -+DECLARE_INSN(fcvt_s_l, MATCH_FCVT_S_L, MASK_FCVT_S_L) -+DECLARE_INSN(fcvt_s_lu, MATCH_FCVT_S_LU, MASK_FCVT_S_LU) -+DECLARE_INSN(fcvt_s_w, MATCH_FCVT_S_W, MASK_FCVT_S_W) -+DECLARE_INSN(fcvt_s_wu, MATCH_FCVT_S_WU, MASK_FCVT_S_WU) -+DECLARE_INSN(fcvt_w_d, MATCH_FCVT_W_D, MASK_FCVT_W_D) -+DECLARE_INSN(fcvt_w_h, MATCH_FCVT_W_H, MASK_FCVT_W_H) -+DECLARE_INSN(fcvt_w_s, MATCH_FCVT_W_S, MASK_FCVT_W_S) -+DECLARE_INSN(fcvt_wu_d, MATCH_FCVT_WU_D, MASK_FCVT_WU_D) -+DECLARE_INSN(fcvt_wu_h, MATCH_FCVT_WU_H, MASK_FCVT_WU_H) -+DECLARE_INSN(fcvt_wu_s, MATCH_FCVT_WU_S, MASK_FCVT_WU_S) -+DECLARE_INSN(fdiv_d, MATCH_FDIV_D, MASK_FDIV_D) -+DECLARE_INSN(fdiv_h, MATCH_FDIV_H, MASK_FDIV_H) -+DECLARE_INSN(fdiv_s, MATCH_FDIV_S, MASK_FDIV_S) -+DECLARE_INSN(fence, MATCH_FENCE, MASK_FENCE) -+DECLARE_INSN(fence_i, MATCH_FENCE_I, MASK_FENCE_I) -+DECLARE_INSN(feq_d, MATCH_FEQ_D, MASK_FEQ_D) -+DECLARE_INSN(feq_h, MATCH_FEQ_H, MASK_FEQ_H) -+DECLARE_INSN(feq_s, MATCH_FEQ_S, MASK_FEQ_S) -+DECLARE_INSN(fld, MATCH_FLD, MASK_FLD) -+DECLARE_INSN(fle_d, MATCH_FLE_D, MASK_FLE_D) -+DECLARE_INSN(fle_h, MATCH_FLE_H, MASK_FLE_H) -+DECLARE_INSN(fle_s, MATCH_FLE_S, MASK_FLE_S) -+DECLARE_INSN(flh, MATCH_FLH, MASK_FLH) -+DECLARE_INSN(flt_d, MATCH_FLT_D, MASK_FLT_D) -+DECLARE_INSN(flt_h, MATCH_FLT_H, MASK_FLT_H) -+DECLARE_INSN(flt_s, MATCH_FLT_S, MASK_FLT_S) -+DECLARE_INSN(flw, MATCH_FLW, MASK_FLW) -+DECLARE_INSN(fmadd_d, MATCH_FMADD_D, MASK_FMADD_D) -+DECLARE_INSN(fmadd_h, MATCH_FMADD_H, MASK_FMADD_H) -+DECLARE_INSN(fmadd_s, MATCH_FMADD_S, MASK_FMADD_S) -+DECLARE_INSN(fmax_d, MATCH_FMAX_D, MASK_FMAX_D) -+DECLARE_INSN(fmax_h, MATCH_FMAX_H, MASK_FMAX_H) -+DECLARE_INSN(fmax_s, MATCH_FMAX_S, MASK_FMAX_S) -+DECLARE_INSN(fmin_d, MATCH_FMIN_D, MASK_FMIN_D) -+DECLARE_INSN(fmin_h, MATCH_FMIN_H, MASK_FMIN_H) -+DECLARE_INSN(fmin_s, MATCH_FMIN_S, MASK_FMIN_S) -+DECLARE_INSN(fmovn, MATCH_FMOVN, MASK_FMOVN) -+DECLARE_INSN(fmovz, MATCH_FMOVZ, MASK_FMOVZ) -+DECLARE_INSN(fmsub_d, MATCH_FMSUB_D, MASK_FMSUB_D) -+DECLARE_INSN(fmsub_h, MATCH_FMSUB_H, MASK_FMSUB_H) -+DECLARE_INSN(fmsub_s, MATCH_FMSUB_S, MASK_FMSUB_S) -+DECLARE_INSN(fmul_d, MATCH_FMUL_D, MASK_FMUL_D) -+DECLARE_INSN(fmul_h, MATCH_FMUL_H, MASK_FMUL_H) -+DECLARE_INSN(fmul_s, MATCH_FMUL_S, MASK_FMUL_S) -+DECLARE_INSN(fmv_d_x, MATCH_FMV_D_X, MASK_FMV_D_X) -+DECLARE_INSN(fmv_h_x, MATCH_FMV_H_X, MASK_FMV_H_X) -+DECLARE_INSN(fmv_s_x, MATCH_FMV_S_X, MASK_FMV_S_X) -+DECLARE_INSN(fmv_x_d, MATCH_FMV_X_D, MASK_FMV_X_D) -+DECLARE_INSN(fmv_x_h, MATCH_FMV_X_H, MASK_FMV_X_H) -+DECLARE_INSN(fmv_x_s, MATCH_FMV_X_S, MASK_FMV_X_S) -+DECLARE_INSN(fnmadd_d, MATCH_FNMADD_D, MASK_FNMADD_D) -+DECLARE_INSN(fnmadd_h, MATCH_FNMADD_H, MASK_FNMADD_H) -+DECLARE_INSN(fnmadd_s, MATCH_FNMADD_S, MASK_FNMADD_S) -+DECLARE_INSN(fnmsub_d, MATCH_FNMSUB_D, MASK_FNMSUB_D) -+DECLARE_INSN(fnmsub_h, MATCH_FNMSUB_H, MASK_FNMSUB_H) -+DECLARE_INSN(fnmsub_s, MATCH_FNMSUB_S, MASK_FNMSUB_S) -+DECLARE_INSN(frcsr, MATCH_FRCSR, MASK_FRCSR) -+DECLARE_INSN(frflags, MATCH_FRFLAGS, MASK_FRFLAGS) -+DECLARE_INSN(frrm, MATCH_FRRM, MASK_FRRM) -+DECLARE_INSN(fscsr, MATCH_FSCSR, MASK_FSCSR) -+DECLARE_INSN(fsd, MATCH_FSD, MASK_FSD) -+DECLARE_INSN(fsflags, MATCH_FSFLAGS, MASK_FSFLAGS) -+DECLARE_INSN(fsflagsi, MATCH_FSFLAGSI, MASK_FSFLAGSI) -+DECLARE_INSN(fsgnj_d, MATCH_FSGNJ_D, MASK_FSGNJ_D) -+DECLARE_INSN(fsgnj_h, MATCH_FSGNJ_H, MASK_FSGNJ_H) -+DECLARE_INSN(fsgnj_s, MATCH_FSGNJ_S, MASK_FSGNJ_S) -+DECLARE_INSN(fsgnjn_d, MATCH_FSGNJN_D, MASK_FSGNJN_D) -+DECLARE_INSN(fsgnjn_h, MATCH_FSGNJN_H, MASK_FSGNJN_H) -+DECLARE_INSN(fsgnjn_s, MATCH_FSGNJN_S, MASK_FSGNJN_S) -+DECLARE_INSN(fsgnjx_d, MATCH_FSGNJX_D, MASK_FSGNJX_D) -+DECLARE_INSN(fsgnjx_h, MATCH_FSGNJX_H, MASK_FSGNJX_H) -+DECLARE_INSN(fsgnjx_s, MATCH_FSGNJX_S, MASK_FSGNJX_S) -+DECLARE_INSN(fsh, MATCH_FSH, MASK_FSH) -+DECLARE_INSN(fsqrt_d, MATCH_FSQRT_D, MASK_FSQRT_D) -+DECLARE_INSN(fsqrt_h, MATCH_FSQRT_H, MASK_FSQRT_H) -+DECLARE_INSN(fsqrt_s, MATCH_FSQRT_S, MASK_FSQRT_S) -+DECLARE_INSN(fsrm, MATCH_FSRM, MASK_FSRM) -+DECLARE_INSN(fsrmi, MATCH_FSRMI, MASK_FSRMI) -+DECLARE_INSN(fsub_d, MATCH_FSUB_D, MASK_FSUB_D) -+DECLARE_INSN(fsub_h, MATCH_FSUB_H, MASK_FSUB_H) -+DECLARE_INSN(fsub_s, MATCH_FSUB_S, MASK_FSUB_S) -+DECLARE_INSN(fsw, MATCH_FSW, MASK_FSW) -+DECLARE_INSN(jal, MATCH_JAL, MASK_JAL) -+DECLARE_INSN(jalr, MATCH_JALR, MASK_JALR) -+DECLARE_INSN(lb, MATCH_LB, MASK_LB) -+DECLARE_INSN(lbu, MATCH_LBU, MASK_LBU) -+DECLARE_INSN(ld, MATCH_LD, MASK_LD) -+DECLARE_INSN(lh, MATCH_LH, MASK_LH) -+DECLARE_INSN(lhu, MATCH_LHU, MASK_LHU) -+DECLARE_INSN(lr_d, MATCH_LR_D, MASK_LR_D) -+DECLARE_INSN(lr_w, MATCH_LR_W, MASK_LR_W) -+DECLARE_INSN(lui, MATCH_LUI, MASK_LUI) -+DECLARE_INSN(lw, MATCH_LW, MASK_LW) -+DECLARE_INSN(lwu, MATCH_LWU, MASK_LWU) -+DECLARE_INSN(movn, MATCH_MOVN, MASK_MOVN) -+DECLARE_INSN(movz, MATCH_MOVZ, MASK_MOVZ) -+DECLARE_INSN(mrts, MATCH_MRTS, MASK_MRTS) -+DECLARE_INSN(mul, MATCH_MUL, MASK_MUL) -+DECLARE_INSN(mulh, MATCH_MULH, MASK_MULH) -+DECLARE_INSN(mulhsu, MATCH_MULHSU, MASK_MULHSU) -+DECLARE_INSN(mulhu, MATCH_MULHU, MASK_MULHU) -+DECLARE_INSN(mulw, MATCH_MULW, MASK_MULW) -+DECLARE_INSN(or, MATCH_OR, MASK_OR) -+DECLARE_INSN(ori, MATCH_ORI, MASK_ORI) -+DECLARE_INSN(rdcycle, MATCH_RDCYCLE, MASK_RDCYCLE) -+DECLARE_INSN(rdcycleh, MATCH_RDCYCLEH, MASK_RDCYCLEH) -+DECLARE_INSN(rdinstret, MATCH_RDINSTRET, MASK_RDINSTRET) -+DECLARE_INSN(rdinstreth, MATCH_RDINSTRETH, MASK_RDINSTRETH) -+DECLARE_INSN(rdtime, MATCH_RDTIME, MASK_RDTIME) -+DECLARE_INSN(rdtimeh, MATCH_RDTIMEH, MASK_RDTIMEH) -+DECLARE_INSN(rem, MATCH_REM, MASK_REM) -+DECLARE_INSN(remu, MATCH_REMU, MASK_REMU) -+DECLARE_INSN(remuw, MATCH_REMUW, MASK_REMUW) -+DECLARE_INSN(remw, MATCH_REMW, MASK_REMW) -+DECLARE_INSN(sb, MATCH_SB, MASK_SB) -+DECLARE_INSN(sbreak, MATCH_SBREAK, MASK_SBREAK) -+DECLARE_INSN(sc_d, MATCH_SC_D, MASK_SC_D) -+DECLARE_INSN(sc_w, MATCH_SC_W, MASK_SC_W) -+DECLARE_INSN(scall, MATCH_SCALL, MASK_SCALL) -+DECLARE_INSN(sd, MATCH_SD, MASK_SD) -+DECLARE_INSN(sfence_vm, MATCH_SFENCE_VM, MASK_SFENCE_VM) -+DECLARE_INSN(sh, MATCH_SH, MASK_SH) -+DECLARE_INSN(sll, MATCH_SLL, MASK_SLL) -+DECLARE_INSN(slli, MATCH_SLLI, MASK_SLLI) -+DECLARE_INSN(slli_rv32, MATCH_SLLI_RV32, MASK_SLLI_RV32) -+DECLARE_INSN(slliw, MATCH_SLLIW, MASK_SLLIW) -+DECLARE_INSN(sllw, MATCH_SLLW, MASK_SLLW) -+DECLARE_INSN(slt, MATCH_SLT, MASK_SLT) -+DECLARE_INSN(slti, MATCH_SLTI, MASK_SLTI) -+DECLARE_INSN(sltiu, MATCH_SLTIU, MASK_SLTIU) -+DECLARE_INSN(sltu, MATCH_SLTU, MASK_SLTU) -+DECLARE_INSN(sra, MATCH_SRA, MASK_SRA) -+DECLARE_INSN(srai, MATCH_SRAI, MASK_SRAI) -+DECLARE_INSN(srai_rv32, MATCH_SRAI_RV32, MASK_SRAI_RV32) -+DECLARE_INSN(sraiw, MATCH_SRAIW, MASK_SRAIW) -+DECLARE_INSN(sraw, MATCH_SRAW, MASK_SRAW) -+DECLARE_INSN(sret, MATCH_SRET, MASK_SRET) -+DECLARE_INSN(srl, MATCH_SRL, MASK_SRL) -+DECLARE_INSN(srli, MATCH_SRLI, MASK_SRLI) -+DECLARE_INSN(srli_rv32, MATCH_SRLI_RV32, MASK_SRLI_RV32) -+DECLARE_INSN(srliw, MATCH_SRLIW, MASK_SRLIW) -+DECLARE_INSN(srlw, MATCH_SRLW, MASK_SRLW) -+DECLARE_INSN(stop, MATCH_STOP, MASK_STOP) -+DECLARE_INSN(sub, MATCH_SUB, MASK_SUB) -+DECLARE_INSN(subw, MATCH_SUBW, MASK_SUBW) -+DECLARE_INSN(sw, MATCH_SW, MASK_SW) -+DECLARE_INSN(utidx, MATCH_UTIDX, MASK_UTIDX) -+DECLARE_INSN(venqcmd, MATCH_VENQCMD, MASK_VENQCMD) -+DECLARE_INSN(venqcnt, MATCH_VENQCNT, MASK_VENQCNT) -+DECLARE_INSN(venqimm1, MATCH_VENQIMM1, MASK_VENQIMM1) -+DECLARE_INSN(venqimm2, MATCH_VENQIMM2, MASK_VENQIMM2) -+DECLARE_INSN(vf, MATCH_VF, MASK_VF) -+DECLARE_INSN(vfld, MATCH_VFLD, MASK_VFLD) -+DECLARE_INSN(vflsegd, MATCH_VFLSEGD, MASK_VFLSEGD) -+DECLARE_INSN(vflsegstd, MATCH_VFLSEGSTD, MASK_VFLSEGSTD) -+DECLARE_INSN(vflsegstw, MATCH_VFLSEGSTW, MASK_VFLSEGSTW) -+DECLARE_INSN(vflsegw, MATCH_VFLSEGW, MASK_VFLSEGW) -+DECLARE_INSN(vflstd, MATCH_VFLSTD, MASK_VFLSTD) -+DECLARE_INSN(vflstw, MATCH_VFLSTW, MASK_VFLSTW) -+DECLARE_INSN(vflw, MATCH_VFLW, MASK_VFLW) -+DECLARE_INSN(vfmsv_d, MATCH_VFMSV_D, MASK_VFMSV_D) -+DECLARE_INSN(vfmsv_s, MATCH_VFMSV_S, MASK_VFMSV_S) -+DECLARE_INSN(vfmvv, MATCH_VFMVV, MASK_VFMVV) -+DECLARE_INSN(vfsd, MATCH_VFSD, MASK_VFSD) -+DECLARE_INSN(vfssegd, MATCH_VFSSEGD, MASK_VFSSEGD) -+DECLARE_INSN(vfssegstd, MATCH_VFSSEGSTD, MASK_VFSSEGSTD) -+DECLARE_INSN(vfssegstw, MATCH_VFSSEGSTW, MASK_VFSSEGSTW) -+DECLARE_INSN(vfssegw, MATCH_VFSSEGW, MASK_VFSSEGW) -+DECLARE_INSN(vfsstd, MATCH_VFSSTD, MASK_VFSSTD) -+DECLARE_INSN(vfsstw, MATCH_VFSSTW, MASK_VFSSTW) -+DECLARE_INSN(vfsw, MATCH_VFSW, MASK_VFSW) -+DECLARE_INSN(vgetcfg, MATCH_VGETCFG, MASK_VGETCFG) -+DECLARE_INSN(vgetvl, MATCH_VGETVL, MASK_VGETVL) -+DECLARE_INSN(vlb, MATCH_VLB, MASK_VLB) -+DECLARE_INSN(vlbu, MATCH_VLBU, MASK_VLBU) -+DECLARE_INSN(vld, MATCH_VLD, MASK_VLD) -+DECLARE_INSN(vlh, MATCH_VLH, MASK_VLH) -+DECLARE_INSN(vlhu, MATCH_VLHU, MASK_VLHU) -+DECLARE_INSN(vlsegb, MATCH_VLSEGB, MASK_VLSEGB) -+DECLARE_INSN(vlsegbu, MATCH_VLSEGBU, MASK_VLSEGBU) -+DECLARE_INSN(vlsegd, MATCH_VLSEGD, MASK_VLSEGD) -+DECLARE_INSN(vlsegh, MATCH_VLSEGH, MASK_VLSEGH) -+DECLARE_INSN(vlseghu, MATCH_VLSEGHU, MASK_VLSEGHU) -+DECLARE_INSN(vlsegstb, MATCH_VLSEGSTB, MASK_VLSEGSTB) -+DECLARE_INSN(vlsegstbu, MATCH_VLSEGSTBU, MASK_VLSEGSTBU) -+DECLARE_INSN(vlsegstd, MATCH_VLSEGSTD, MASK_VLSEGSTD) -+DECLARE_INSN(vlsegsth, MATCH_VLSEGSTH, MASK_VLSEGSTH) -+DECLARE_INSN(vlsegsthu, MATCH_VLSEGSTHU, MASK_VLSEGSTHU) -+DECLARE_INSN(vlsegstw, MATCH_VLSEGSTW, MASK_VLSEGSTW) -+DECLARE_INSN(vlsegstwu, MATCH_VLSEGSTWU, MASK_VLSEGSTWU) -+DECLARE_INSN(vlsegw, MATCH_VLSEGW, MASK_VLSEGW) -+DECLARE_INSN(vlsegwu, MATCH_VLSEGWU, MASK_VLSEGWU) -+DECLARE_INSN(vlstb, MATCH_VLSTB, MASK_VLSTB) -+DECLARE_INSN(vlstbu, MATCH_VLSTBU, MASK_VLSTBU) -+DECLARE_INSN(vlstd, MATCH_VLSTD, MASK_VLSTD) -+DECLARE_INSN(vlsth, MATCH_VLSTH, MASK_VLSTH) -+DECLARE_INSN(vlsthu, MATCH_VLSTHU, MASK_VLSTHU) -+DECLARE_INSN(vlstw, MATCH_VLSTW, MASK_VLSTW) -+DECLARE_INSN(vlstwu, MATCH_VLSTWU, MASK_VLSTWU) -+DECLARE_INSN(vlw, MATCH_VLW, MASK_VLW) -+DECLARE_INSN(vlwu, MATCH_VLWU, MASK_VLWU) -+DECLARE_INSN(vmsv, MATCH_VMSV, MASK_VMSV) -+DECLARE_INSN(vmvv, MATCH_VMVV, MASK_VMVV) -+DECLARE_INSN(vsb, MATCH_VSB, MASK_VSB) -+DECLARE_INSN(vsd, MATCH_VSD, MASK_VSD) -+DECLARE_INSN(vsetcfg, MATCH_VSETCFG, MASK_VSETCFG) -+DECLARE_INSN(vsetvl, MATCH_VSETVL, MASK_VSETVL) -+DECLARE_INSN(vsh, MATCH_VSH, MASK_VSH) -+DECLARE_INSN(vssegb, MATCH_VSSEGB, MASK_VSSEGB) -+DECLARE_INSN(vssegd, MATCH_VSSEGD, MASK_VSSEGD) -+DECLARE_INSN(vssegh, MATCH_VSSEGH, MASK_VSSEGH) -+DECLARE_INSN(vssegstb, MATCH_VSSEGSTB, MASK_VSSEGSTB) -+DECLARE_INSN(vssegstd, MATCH_VSSEGSTD, MASK_VSSEGSTD) -+DECLARE_INSN(vssegsth, MATCH_VSSEGSTH, MASK_VSSEGSTH) -+DECLARE_INSN(vssegstw, MATCH_VSSEGSTW, MASK_VSSEGSTW) -+DECLARE_INSN(vssegw, MATCH_VSSEGW, MASK_VSSEGW) -+DECLARE_INSN(vsstb, MATCH_VSSTB, MASK_VSSTB) -+DECLARE_INSN(vsstd, MATCH_VSSTD, MASK_VSSTD) -+DECLARE_INSN(vssth, MATCH_VSSTH, MASK_VSSTH) -+DECLARE_INSN(vsstw, MATCH_VSSTW, MASK_VSSTW) -+DECLARE_INSN(vsw, MATCH_VSW, MASK_VSW) -+DECLARE_INSN(vxcptaux, MATCH_VXCPTAUX, MASK_VXCPTAUX) -+DECLARE_INSN(vxcptcause, MATCH_VXCPTCAUSE, MASK_VXCPTCAUSE) -+DECLARE_INSN(vxcptevac, MATCH_VXCPTEVAC, MASK_VXCPTEVAC) -+DECLARE_INSN(vxcpthold, MATCH_VXCPTHOLD, MASK_VXCPTHOLD) -+DECLARE_INSN(vxcptkill, MATCH_VXCPTKILL, MASK_VXCPTKILL) -+DECLARE_INSN(vxcptrestore, MATCH_VXCPTRESTORE, MASK_VXCPTRESTORE) -+DECLARE_INSN(vxcptsave, MATCH_VXCPTSAVE, MASK_VXCPTSAVE) -+DECLARE_INSN(xor, MATCH_XOR, MASK_XOR) -+DECLARE_INSN(xori, MATCH_XORI, MASK_XORI) -+#endif -+#ifdef DECLARE_CSR -+DECLARE_CSR(fflags, CSR_FFLAGS) -+DECLARE_CSR(frm, CSR_FRM) -+DECLARE_CSR(fcsr, CSR_FCSR) -+DECLARE_CSR(cycle, CSR_CYCLE) -+DECLARE_CSR(time, CSR_TIME) -+DECLARE_CSR(instret, CSR_INSTRET) -+DECLARE_CSR(stats, CSR_STATS) -+DECLARE_CSR(uarch0, CSR_UARCH0) -+DECLARE_CSR(uarch1, CSR_UARCH1) -+DECLARE_CSR(uarch2, CSR_UARCH2) -+DECLARE_CSR(uarch3, CSR_UARCH3) -+DECLARE_CSR(uarch4, CSR_UARCH4) -+DECLARE_CSR(uarch5, CSR_UARCH5) -+DECLARE_CSR(uarch6, CSR_UARCH6) -+DECLARE_CSR(uarch7, CSR_UARCH7) -+DECLARE_CSR(uarch8, CSR_UARCH8) -+DECLARE_CSR(uarch9, CSR_UARCH9) -+DECLARE_CSR(uarch10, CSR_UARCH10) -+DECLARE_CSR(uarch11, CSR_UARCH11) -+DECLARE_CSR(uarch12, CSR_UARCH12) -+DECLARE_CSR(uarch13, CSR_UARCH13) -+DECLARE_CSR(uarch14, CSR_UARCH14) -+DECLARE_CSR(uarch15, CSR_UARCH15) -+DECLARE_CSR(sstatus, CSR_SSTATUS) -+DECLARE_CSR(stvec, CSR_STVEC) -+DECLARE_CSR(stimecmp, CSR_STIMECMP) -+DECLARE_CSR(sscratch, CSR_SSCRATCH) -+DECLARE_CSR(sepc, CSR_SEPC) -+DECLARE_CSR(sptbr, CSR_SPTBR) -+DECLARE_CSR(sasid, CSR_SASID) -+DECLARE_CSR(scycle, CSR_SCYCLE) -+DECLARE_CSR(stime, CSR_STIME) -+DECLARE_CSR(sinstret, CSR_SINSTRET) -+DECLARE_CSR(scause, CSR_SCAUSE) -+DECLARE_CSR(sbadaddr, CSR_SBADADDR) -+DECLARE_CSR(mstatus, CSR_MSTATUS) -+DECLARE_CSR(mscratch, CSR_MSCRATCH) -+DECLARE_CSR(mepc, CSR_MEPC) -+DECLARE_CSR(mcause, CSR_MCAUSE) -+DECLARE_CSR(mbadaddr, CSR_MBADADDR) -+DECLARE_CSR(reset, CSR_RESET) -+DECLARE_CSR(tohost, CSR_TOHOST) -+DECLARE_CSR(fromhost, CSR_FROMHOST) -+DECLARE_CSR(send_ipi, CSR_SEND_IPI) -+DECLARE_CSR(hartid, CSR_HARTID) -+DECLARE_CSR(cycleh, CSR_CYCLEH) -+DECLARE_CSR(timeh, CSR_TIMEH) -+DECLARE_CSR(instreth, CSR_INSTRETH) -+DECLARE_CSR(scycleh, CSR_SCYCLEH) -+DECLARE_CSR(stimeh, CSR_STIMEH) -+DECLARE_CSR(sinstreth, CSR_SINSTRETH) -+#endif -+#ifdef DECLARE_CAUSE -+DECLARE_CAUSE("fflags", CAUSE_FFLAGS) -+DECLARE_CAUSE("frm", CAUSE_FRM) -+DECLARE_CAUSE("fcsr", CAUSE_FCSR) -+DECLARE_CAUSE("cycle", CAUSE_CYCLE) -+DECLARE_CAUSE("time", CAUSE_TIME) -+DECLARE_CAUSE("instret", CAUSE_INSTRET) -+DECLARE_CAUSE("stats", CAUSE_STATS) -+DECLARE_CAUSE("uarch0", CAUSE_UARCH0) -+DECLARE_CAUSE("uarch1", CAUSE_UARCH1) -+DECLARE_CAUSE("uarch2", CAUSE_UARCH2) -+DECLARE_CAUSE("uarch3", CAUSE_UARCH3) -+DECLARE_CAUSE("uarch4", CAUSE_UARCH4) -+DECLARE_CAUSE("uarch5", CAUSE_UARCH5) -+DECLARE_CAUSE("uarch6", CAUSE_UARCH6) -+DECLARE_CAUSE("uarch7", CAUSE_UARCH7) -+DECLARE_CAUSE("uarch8", CAUSE_UARCH8) -+DECLARE_CAUSE("uarch9", CAUSE_UARCH9) -+DECLARE_CAUSE("uarch10", CAUSE_UARCH10) -+DECLARE_CAUSE("uarch11", CAUSE_UARCH11) -+DECLARE_CAUSE("uarch12", CAUSE_UARCH12) -+DECLARE_CAUSE("uarch13", CAUSE_UARCH13) -+DECLARE_CAUSE("uarch14", CAUSE_UARCH14) -+DECLARE_CAUSE("uarch15", CAUSE_UARCH15) -+DECLARE_CAUSE("sstatus", CAUSE_SSTATUS) -+DECLARE_CAUSE("stvec", CAUSE_STVEC) -+DECLARE_CAUSE("stimecmp", CAUSE_STIMECMP) -+DECLARE_CAUSE("sscratch", CAUSE_SSCRATCH) -+DECLARE_CAUSE("sepc", CAUSE_SEPC) -+DECLARE_CAUSE("sptbr", CAUSE_SPTBR) -+DECLARE_CAUSE("sasid", CAUSE_SASID) -+DECLARE_CAUSE("scycle", CAUSE_SCYCLE) -+DECLARE_CAUSE("stime", CAUSE_STIME) -+DECLARE_CAUSE("sinstret", CAUSE_SINSTRET) -+DECLARE_CAUSE("scause", CAUSE_SCAUSE) -+DECLARE_CAUSE("sbadaddr", CAUSE_SBADADDR) -+DECLARE_CAUSE("mstatus", CAUSE_MSTATUS) -+DECLARE_CAUSE("mscratch", CAUSE_MSCRATCH) -+DECLARE_CAUSE("mepc", CAUSE_MEPC) -+DECLARE_CAUSE("mcause", CAUSE_MCAUSE) -+DECLARE_CAUSE("mbadaddr", CAUSE_MBADADDR) -+DECLARE_CAUSE("reset", CAUSE_RESET) -+DECLARE_CAUSE("tohost", CAUSE_TOHOST) -+DECLARE_CAUSE("fromhost", CAUSE_FROMHOST) -+DECLARE_CAUSE("send_ipi", CAUSE_SEND_IPI) -+DECLARE_CAUSE("hartid", CAUSE_HARTID) -+DECLARE_CAUSE("cycleh", CAUSE_CYCLEH) -+DECLARE_CAUSE("timeh", CAUSE_TIMEH) -+DECLARE_CAUSE("instreth", CAUSE_INSTRETH) -+DECLARE_CAUSE("scycleh", CAUSE_SCYCLEH) -+DECLARE_CAUSE("stimeh", CAUSE_STIMEH) -+DECLARE_CAUSE("sinstreth", CAUSE_SINSTRETH) -+#endif -diff -rNU3 dist.orig/gcc/config/riscv/riscv-protos.h dist/gcc/config/riscv/riscv-protos.h ---- dist.orig/gcc/config/riscv/riscv-protos.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/riscv/riscv-protos.h 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,96 @@ -+/* Definition of RISC-V target for GNU compiler. -+ Copyright (C) 2011-2014 Free Software Foundation, Inc. -+ Contributed by Andrew Waterman (waterman@cs.berkeley.edu) at UC Berkeley. -+ Based on MIPS target for GNU compiler. -+ -+This file is part of GCC. -+ -+GCC is free software; you can redistribute it and/or modify -+it under the terms of the GNU General Public License as published by -+the Free Software Foundation; either version 3, or (at your option) -+any later version. -+ -+GCC is distributed in the hope that it will be useful, -+but WITHOUT ANY WARRANTY; without even the implied warranty of -+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+GNU General Public License for more details. -+ -+You should have received a copy of the GNU General Public License -+along with GCC; see the file COPYING3. If not see -+. */ -+ -+#ifndef GCC_RISCV_PROTOS_H -+#define GCC_RISCV_PROTOS_H -+ -+enum riscv_symbol_type { -+ SYMBOL_ABSOLUTE, -+ SYMBOL_GOT_DISP, -+ SYMBOL_TLS, -+ SYMBOL_TLS_LE, -+ SYMBOL_TLS_IE, -+ SYMBOL_TLS_GD -+}; -+#define NUM_SYMBOL_TYPES (SYMBOL_TLS_GD + 1) -+ -+enum riscv_code_model { -+ CM_MEDLOW, -+ CM_MEDANY, -+ CM_PIC -+}; -+extern enum riscv_code_model riscv_cmodel; -+ -+extern bool riscv_symbolic_constant_p (rtx, enum riscv_symbol_type *); -+extern int riscv_regno_mode_ok_for_base_p (int, enum machine_mode, bool); -+extern int riscv_address_insns (rtx, enum machine_mode, bool); -+extern int riscv_const_insns (rtx); -+extern int riscv_split_const_insns (rtx); -+extern int riscv_load_store_insns (rtx, rtx); -+extern rtx riscv_emit_move (rtx, rtx); -+extern bool riscv_split_symbol (rtx, rtx, enum machine_mode, rtx *); -+extern rtx riscv_unspec_address (rtx, enum riscv_symbol_type); -+extern void riscv_move_integer (rtx, rtx, HOST_WIDE_INT); -+extern bool riscv_legitimize_move (enum machine_mode, rtx, rtx); -+extern bool riscv_legitimize_vector_move (enum machine_mode, rtx, rtx); -+ -+extern rtx riscv_subword (rtx, bool); -+extern bool riscv_split_64bit_move_p (rtx, rtx); -+extern void riscv_split_doubleword_move (rtx, rtx); -+extern const char *riscv_output_move (rtx, rtx); -+extern const char *riscv_riscv_output_vector_move (enum machine_mode, rtx, rtx); -+#ifdef RTX_CODE -+extern void riscv_expand_scc (rtx *); -+extern void riscv_expand_conditional_branch (rtx *); -+#endif -+extern rtx riscv_expand_call (bool, rtx, rtx, rtx); -+extern void riscv_expand_fcc_reload (rtx, rtx, rtx); -+extern void riscv_set_return_address (rtx, rtx); -+extern bool riscv_expand_block_move (rtx, rtx, rtx); -+extern void riscv_expand_synci_loop (rtx, rtx); -+ -+extern bool riscv_expand_ext_as_unaligned_load (rtx, rtx, HOST_WIDE_INT, -+ HOST_WIDE_INT); -+extern bool riscv_expand_ins_as_unaligned_store (rtx, rtx, HOST_WIDE_INT, -+ HOST_WIDE_INT); -+extern void riscv_order_regs_for_local_alloc (void); -+ -+extern rtx riscv_return_addr (int, rtx); -+extern HOST_WIDE_INT riscv_initial_elimination_offset (int, int); -+extern void riscv_expand_prologue (void); -+extern void riscv_expand_epilogue (bool); -+extern bool riscv_can_use_return_insn (void); -+extern rtx riscv_function_value (const_tree, const_tree, enum machine_mode); -+ -+extern enum reg_class riscv_secondary_reload_class (enum reg_class, -+ enum machine_mode, -+ rtx, bool); -+extern int riscv_class_max_nregs (enum reg_class, enum machine_mode); -+ -+extern unsigned int riscv_hard_regno_nregs (int, enum machine_mode); -+ -+extern void irix_asm_output_align (FILE *, unsigned); -+extern const char *current_section_name (void); -+extern unsigned int current_section_flags (void); -+ -+extern void riscv_expand_vector_init (rtx, rtx); -+ -+#endif /* ! GCC_RISCV_PROTOS_H */ -diff -rNU3 dist.orig/gcc/config/riscv/riscv.c dist/gcc/config/riscv/riscv.c ---- dist.orig/gcc/config/riscv/riscv.c 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/riscv/riscv.c 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,4309 @@ -+/* Subroutines used for code generation for RISC-V. -+ Copyright (C) 2011-2014 Free Software Foundation, Inc. -+ Contributed by Andrew Waterman (waterman@cs.berkeley.edu) at UC Berkeley. -+ Based on MIPS target for GNU compiler. -+ -+This file is part of GCC. -+ -+GCC is free software; you can redistribute it and/or modify -+it under the terms of the GNU General Public License as published by -+the Free Software Foundation; either version 3, or (at your option) -+any later version. -+ -+GCC is distributed in the hope that it will be useful, -+but WITHOUT ANY WARRANTY; without even the implied warranty of -+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+GNU General Public License for more details. -+ -+You should have received a copy of the GNU General Public License -+along with GCC; see the file COPYING3. If not see -+. */ -+ -+#include "config.h" -+#include "system.h" -+#include "coretypes.h" -+#include "tm.h" -+#include "rtl.h" -+#include "regs.h" -+#include "hard-reg-set.h" -+#include "insn-config.h" -+#include "conditions.h" -+#include "insn-attr.h" -+#include "recog.h" -+#include "output.h" -+#include "tree.h" -+//#include "varasm.h" -+//#include "stor-layout.h" -+//#include "calls.h" -+#include "function.h" -+#include "expr.h" -+#include "optabs.h" -+#include "libfuncs.h" -+#include "flags.h" -+#include "reload.h" -+#include "tm_p.h" -+#include "ggc.h" -+#include "gstab.h" -+#include "hashtab.h" -+#include "debug.h" -+#include "target.h" -+#include "target-def.h" -+#include "langhooks.h" -+#include "sched-int.h" -+#include "bitmap.h" -+#include "diagnostic.h" -+#include "target-globals.h" -+#include "symcat.h" -+#include -+ -+/* True if X is an UNSPEC wrapper around a SYMBOL_REF or LABEL_REF. */ -+#define UNSPEC_ADDRESS_P(X) \ -+ (GET_CODE (X) == UNSPEC \ -+ && XINT (X, 1) >= UNSPEC_ADDRESS_FIRST \ -+ && XINT (X, 1) < UNSPEC_ADDRESS_FIRST + NUM_SYMBOL_TYPES) -+ -+/* Extract the symbol or label from UNSPEC wrapper X. */ -+#define UNSPEC_ADDRESS(X) \ -+ XVECEXP (X, 0, 0) -+ -+/* Extract the symbol type from UNSPEC wrapper X. */ -+#define UNSPEC_ADDRESS_TYPE(X) \ -+ ((enum riscv_symbol_type) (XINT (X, 1) - UNSPEC_ADDRESS_FIRST)) -+ -+/* The maximum distance between the top of the stack frame and the -+ value sp has when we save and restore registers. This is set by the -+ range of load/store offsets and must also preserve stack alignment. */ -+#define RISCV_MAX_FIRST_STACK_STEP (RISCV_IMM_REACH/2 - 16) -+ -+/* True if INSN is a riscv.md pattern or asm statement. */ -+#define USEFUL_INSN_P(INSN) \ -+ (NONDEBUG_INSN_P (INSN) \ -+ && GET_CODE (PATTERN (INSN)) != USE \ -+ && GET_CODE (PATTERN (INSN)) != CLOBBER \ -+ && GET_CODE (PATTERN (INSN)) != ADDR_VEC \ -+ && GET_CODE (PATTERN (INSN)) != ADDR_DIFF_VEC) -+ -+/* True if bit BIT is set in VALUE. */ -+#define BITSET_P(VALUE, BIT) (((VALUE) & (1 << (BIT))) != 0) -+ -+/* Classifies an address. -+ -+ ADDRESS_REG -+ A natural register + offset address. The register satisfies -+ riscv_valid_base_register_p and the offset is a const_arith_operand. -+ -+ ADDRESS_LO_SUM -+ A LO_SUM rtx. The first operand is a valid base register and -+ the second operand is a symbolic address. -+ -+ ADDRESS_CONST_INT -+ A signed 16-bit constant address. -+ -+ ADDRESS_SYMBOLIC: -+ A constant symbolic address. */ -+enum riscv_address_type { -+ ADDRESS_REG, -+ ADDRESS_LO_SUM, -+ ADDRESS_CONST_INT, -+ ADDRESS_SYMBOLIC -+}; -+ -+enum riscv_code_model riscv_cmodel = TARGET_DEFAULT_CMODEL; -+ -+/* Macros to create an enumeration identifier for a function prototype. */ -+#define RISCV_FTYPE_NAME1(A, B) RISCV_##A##_FTYPE_##B -+#define RISCV_FTYPE_NAME2(A, B, C) RISCV_##A##_FTYPE_##B##_##C -+#define RISCV_FTYPE_NAME3(A, B, C, D) RISCV_##A##_FTYPE_##B##_##C##_##D -+#define RISCV_FTYPE_NAME4(A, B, C, D, E) RISCV_##A##_FTYPE_##B##_##C##_##D##_##E -+ -+/* Classifies the prototype of a built-in function. */ -+enum riscv_function_type { -+#define DEF_RISCV_FTYPE(NARGS, LIST) RISCV_FTYPE_NAME##NARGS LIST, -+#include "config/riscv/riscv-ftypes.def" -+#undef DEF_RISCV_FTYPE -+ RISCV_MAX_FTYPE_MAX -+}; -+ -+/* Specifies how a built-in function should be converted into rtl. */ -+enum riscv_builtin_type { -+ /* The function corresponds directly to an .md pattern. The return -+ value is mapped to operand 0 and the arguments are mapped to -+ operands 1 and above. */ -+ RISCV_BUILTIN_DIRECT, -+ -+ /* The function corresponds directly to an .md pattern. There is no return -+ value and the arguments are mapped to operands 0 and above. */ -+ RISCV_BUILTIN_DIRECT_NO_TARGET -+}; -+ -+/* Information about a function's frame layout. */ -+struct GTY(()) riscv_frame_info { -+ /* The size of the frame in bytes. */ -+ HOST_WIDE_INT total_size; -+ -+ /* Bit X is set if the function saves or restores GPR X. */ -+ unsigned int mask; -+ -+ /* Likewise FPR X. */ -+ unsigned int fmask; -+ -+ /* Offsets of fixed-point and floating-point save areas from frame bottom */ -+ HOST_WIDE_INT gp_sp_offset; -+ HOST_WIDE_INT fp_sp_offset; -+ -+ /* Offset of virtual frame pointer from stack pointer/frame bottom */ -+ HOST_WIDE_INT frame_pointer_offset; -+ -+ /* Offset of hard frame pointer from stack pointer/frame bottom */ -+ HOST_WIDE_INT hard_frame_pointer_offset; -+ -+ /* The offset of arg_pointer_rtx from the bottom of the frame. */ -+ HOST_WIDE_INT arg_pointer_offset; -+}; -+ -+struct GTY(()) machine_function { -+ /* The number of extra stack bytes taken up by register varargs. -+ This area is allocated by the callee at the very top of the frame. */ -+ int varargs_size; -+ -+ /* The current frame information, calculated by riscv_compute_frame_info. */ -+ struct riscv_frame_info frame; -+}; -+ -+/* Information about a single argument. */ -+struct riscv_arg_info { -+ /* True if the argument is passed in a floating-point register, or -+ would have been if we hadn't run out of registers. */ -+ bool fpr_p; -+ -+ /* The number of words passed in registers, rounded up. */ -+ unsigned int reg_words; -+ -+ /* For EABI, the offset of the first register from GP_ARG_FIRST or -+ FP_ARG_FIRST. For other ABIs, the offset of the first register from -+ the start of the ABI's argument structure (see the CUMULATIVE_ARGS -+ comment for details). -+ -+ The value is MAX_ARGS_IN_REGISTERS if the argument is passed entirely -+ on the stack. */ -+ unsigned int reg_offset; -+ -+ /* The number of words that must be passed on the stack, rounded up. */ -+ unsigned int stack_words; -+ -+ /* The offset from the start of the stack overflow area of the argument's -+ first stack word. Only meaningful when STACK_WORDS is nonzero. */ -+ unsigned int stack_offset; -+}; -+ -+/* Information about an address described by riscv_address_type. -+ -+ ADDRESS_CONST_INT -+ No fields are used. -+ -+ ADDRESS_REG -+ REG is the base register and OFFSET is the constant offset. -+ -+ ADDRESS_LO_SUM -+ REG and OFFSET are the operands to the LO_SUM and SYMBOL_TYPE -+ is the type of symbol it references. -+ -+ ADDRESS_SYMBOLIC -+ SYMBOL_TYPE is the type of symbol that the address references. */ -+struct riscv_address_info { -+ enum riscv_address_type type; -+ rtx reg; -+ rtx offset; -+ enum riscv_symbol_type symbol_type; -+}; -+ -+/* One stage in a constant building sequence. These sequences have -+ the form: -+ -+ A = VALUE[0] -+ A = A CODE[1] VALUE[1] -+ A = A CODE[2] VALUE[2] -+ ... -+ -+ where A is an accumulator, each CODE[i] is a binary rtl operation -+ and each VALUE[i] is a constant integer. CODE[0] is undefined. */ -+struct riscv_integer_op { -+ enum rtx_code code; -+ unsigned HOST_WIDE_INT value; -+}; -+ -+/* The largest number of operations needed to load an integer constant. -+ The worst case is LUI, ADDI, SLLI, ADDI, SLLI, ADDI, SLLI, ADDI, -+ but we may attempt and reject even worse sequences. */ -+#define RISCV_MAX_INTEGER_OPS 32 -+ -+/* Costs of various operations on the different architectures. */ -+ -+struct riscv_tune_info -+{ -+ unsigned short fp_add[2]; -+ unsigned short fp_mul[2]; -+ unsigned short fp_div[2]; -+ unsigned short int_mul[2]; -+ unsigned short int_div[2]; -+ unsigned short issue_rate; -+ unsigned short branch_cost; -+ unsigned short fp_to_int_cost; -+ unsigned short memory_cost; -+}; -+ -+/* Information about one CPU we know about. */ -+struct riscv_cpu_info { -+ /* This CPU's canonical name. */ -+ const char *name; -+ -+ /* The RISC-V ISA and extensions supported by this CPU. */ -+ const char *isa; -+ -+ /* Tuning parameters for this CPU. */ -+ const struct riscv_tune_info *tune_info; -+}; -+ -+/* Global variables for machine-dependent things. */ -+ -+/* Which tuning parameters to use. */ -+static const struct riscv_tune_info *tune_info; -+ -+/* Index [M][R] is true if register R is allowed to hold a value of mode M. */ -+bool riscv_hard_regno_mode_ok[(int) MAX_MACHINE_MODE][FIRST_PSEUDO_REGISTER]; -+ -+/* riscv_lo_relocs[X] is the relocation to use when a symbol of type X -+ appears in a LO_SUM. It can be null if such LO_SUMs aren't valid or -+ if they are matched by a special .md file pattern. */ -+const char *riscv_lo_relocs[NUM_SYMBOL_TYPES]; -+ -+/* Likewise for HIGHs. */ -+const char *riscv_hi_relocs[NUM_SYMBOL_TYPES]; -+ -+/* Index R is the smallest register class that contains register R. */ -+const enum reg_class riscv_regno_to_class[FIRST_PSEUDO_REGISTER] = { -+ GR_REGS, GR_REGS, GR_REGS, GR_REGS, -+ GR_REGS, T_REGS, T_REGS, T_REGS, -+ GR_REGS, GR_REGS, GR_REGS, GR_REGS, -+ GR_REGS, GR_REGS, GR_REGS, GR_REGS, -+ GR_REGS, GR_REGS, GR_REGS, GR_REGS, -+ GR_REGS, GR_REGS, GR_REGS, GR_REGS, -+ GR_REGS, GR_REGS, GR_REGS, GR_REGS, -+ T_REGS, T_REGS, T_REGS, T_REGS, -+ FP_REGS, FP_REGS, FP_REGS, FP_REGS, -+ FP_REGS, FP_REGS, FP_REGS, FP_REGS, -+ FP_REGS, FP_REGS, FP_REGS, FP_REGS, -+ FP_REGS, FP_REGS, FP_REGS, FP_REGS, -+ FP_REGS, FP_REGS, FP_REGS, FP_REGS, -+ FP_REGS, FP_REGS, FP_REGS, FP_REGS, -+ FP_REGS, FP_REGS, FP_REGS, FP_REGS, -+ FP_REGS, FP_REGS, FP_REGS, FP_REGS, -+ FRAME_REGS, FRAME_REGS, -+}; -+ -+/* Costs to use when optimizing for size. */ -+static const struct riscv_tune_info rocket_tune_info = { -+ {COSTS_N_INSNS (4), COSTS_N_INSNS (5)}, /* fp_add */ -+ {COSTS_N_INSNS (4), COSTS_N_INSNS (5)}, /* fp_mul */ -+ {COSTS_N_INSNS (20), COSTS_N_INSNS (20)}, /* fp_div */ -+ {COSTS_N_INSNS (4), COSTS_N_INSNS (4)}, /* int_mul */ -+ {COSTS_N_INSNS (6), COSTS_N_INSNS (6)}, /* int_div */ -+ 1, /* issue_rate */ -+ 3, /* branch_cost */ -+ COSTS_N_INSNS (2), /* fp_to_int_cost */ -+ 5 /* memory_cost */ -+}; -+ -+/* Costs to use when optimizing for size. */ -+static const struct riscv_tune_info optimize_size_tune_info = { -+ {COSTS_N_INSNS (1), COSTS_N_INSNS (1)}, /* fp_add */ -+ {COSTS_N_INSNS (1), COSTS_N_INSNS (1)}, /* fp_mul */ -+ {COSTS_N_INSNS (1), COSTS_N_INSNS (1)}, /* fp_div */ -+ {COSTS_N_INSNS (1), COSTS_N_INSNS (1)}, /* int_mul */ -+ {COSTS_N_INSNS (1), COSTS_N_INSNS (1)}, /* int_div */ -+ 1, /* issue_rate */ -+ 1, /* branch_cost */ -+ COSTS_N_INSNS (1), /* fp_to_int_cost */ -+ 1 /* memory_cost */ -+}; -+ -+/* A table describing all the processors GCC knows about. */ -+static const struct riscv_cpu_info riscv_cpu_info_table[] = { -+ /* Entries for generic ISAs. */ -+ { "rocket", "IMAFD", &rocket_tune_info }, -+}; -+ -+/* Return the riscv_cpu_info entry for the given name string. */ -+ -+static const struct riscv_cpu_info * -+riscv_parse_cpu (const char *cpu_string) -+{ -+ unsigned int i; -+ -+ for (i = 0; i < ARRAY_SIZE (riscv_cpu_info_table); i++) -+ if (strcmp (riscv_cpu_info_table[i].name, cpu_string) == 0) -+ return riscv_cpu_info_table + i; -+ -+ error ("unknown cpu `%s'", cpu_string); -+ return riscv_cpu_info_table; -+} -+ -+/* Fill CODES with a sequence of rtl operations to load VALUE. -+ Return the number of operations needed. */ -+ -+static int -+riscv_build_integer_1 (struct riscv_integer_op *codes, HOST_WIDE_INT value, -+ enum machine_mode mode) -+{ -+ HOST_WIDE_INT low_part = RISCV_CONST_LOW_PART (value); -+ int cost = INT_MAX, alt_cost; -+ struct riscv_integer_op alt_codes[RISCV_MAX_INTEGER_OPS]; -+ -+ if (SMALL_OPERAND (value) || LUI_OPERAND (value)) -+ { -+ /* Simply ADDI or LUI */ -+ codes[0].code = UNKNOWN; -+ codes[0].value = value; -+ return 1; -+ } -+ -+ /* End with ADDI */ -+ if (low_part != 0 -+ && !(mode == HImode && (int16_t)(value - low_part) != (value - low_part))) -+ { -+ cost = 1 + riscv_build_integer_1 (codes, value - low_part, mode); -+ codes[cost-1].code = PLUS; -+ codes[cost-1].value = low_part; -+ } -+ -+ /* End with XORI */ -+ if (cost > 2 && (low_part < 0 || mode == HImode)) -+ { -+ alt_cost = 1 + riscv_build_integer_1 (alt_codes, value ^ low_part, mode); -+ alt_codes[alt_cost-1].code = XOR; -+ alt_codes[alt_cost-1].value = low_part; -+ if (alt_cost < cost) -+ cost = alt_cost, memcpy (codes, alt_codes, sizeof(alt_codes)); -+ } -+ -+ /* Eliminate trailing zeros and end with SLLI */ -+ if (cost > 2 && (value & 1) == 0) -+ { -+ int shift = 0; -+ while ((value & 1) == 0) -+ shift++, value >>= 1; -+ alt_cost = 1 + riscv_build_integer_1 (alt_codes, value, mode); -+ alt_codes[alt_cost-1].code = ASHIFT; -+ alt_codes[alt_cost-1].value = shift; -+ if (alt_cost < cost) -+ cost = alt_cost, memcpy (codes, alt_codes, sizeof(alt_codes)); -+ } -+ -+ gcc_assert (cost <= RISCV_MAX_INTEGER_OPS); -+ return cost; -+} -+ -+static int -+riscv_build_integer (struct riscv_integer_op *codes, HOST_WIDE_INT value, -+ enum machine_mode mode) -+{ -+ int cost = riscv_build_integer_1 (codes, value, mode); -+ -+ /* Eliminate leading zeros and end with SRLI */ -+ if (value > 0 && cost > 2) -+ { -+ struct riscv_integer_op alt_codes[RISCV_MAX_INTEGER_OPS]; -+ int alt_cost, shift = 0; -+ HOST_WIDE_INT shifted_val; -+ -+ /* Try filling trailing bits with 1s */ -+ while ((value << shift) >= 0) -+ shift++; -+ shifted_val = (value << shift) | ((((HOST_WIDE_INT) 1) << shift) - 1); -+ alt_cost = 1 + riscv_build_integer_1 (alt_codes, shifted_val, mode); -+ alt_codes[alt_cost-1].code = LSHIFTRT; -+ alt_codes[alt_cost-1].value = shift; -+ if (alt_cost < cost) -+ cost = alt_cost, memcpy (codes, alt_codes, sizeof (alt_codes)); -+ -+ /* Try filling trailing bits with 0s */ -+ shifted_val = value << shift; -+ alt_cost = 1 + riscv_build_integer_1 (alt_codes, shifted_val, mode); -+ alt_codes[alt_cost-1].code = LSHIFTRT; -+ alt_codes[alt_cost-1].value = shift; -+ if (alt_cost < cost) -+ cost = alt_cost, memcpy (codes, alt_codes, sizeof (alt_codes)); -+ } -+ -+ return cost; -+} -+ -+static int -+riscv_split_integer_cost (HOST_WIDE_INT val) -+{ -+ int cost; -+ int32_t loval = val, hival = (val - (int32_t)val) >> 32; -+ struct riscv_integer_op codes[RISCV_MAX_INTEGER_OPS]; -+ -+ cost = 2 + riscv_build_integer (codes, loval, VOIDmode); -+ if (loval != hival) -+ cost += riscv_build_integer (codes, hival, VOIDmode); -+ -+ return cost; -+} -+ -+static int -+riscv_integer_cost (HOST_WIDE_INT val) -+{ -+ struct riscv_integer_op codes[RISCV_MAX_INTEGER_OPS]; -+ return MIN (riscv_build_integer (codes, val, VOIDmode), -+ riscv_split_integer_cost (val)); -+} -+ -+/* Try to split a 64b integer into 32b parts, then reassemble. */ -+ -+static rtx -+riscv_split_integer (HOST_WIDE_INT val, enum machine_mode mode) -+{ -+ int32_t loval = val, hival = (val - (int32_t)val) >> 32; -+ rtx hi = gen_reg_rtx (mode), lo = gen_reg_rtx (mode); -+ -+ riscv_move_integer (hi, hi, hival); -+ riscv_move_integer (lo, lo, loval); -+ -+ hi = gen_rtx_fmt_ee (ASHIFT, mode, hi, GEN_INT (32)); -+ hi = force_reg (mode, hi); -+ -+ return gen_rtx_fmt_ee (PLUS, mode, hi, lo); -+} -+ -+/* Return true if X is a thread-local symbol. */ -+ -+static bool -+riscv_tls_symbol_p (const_rtx x) -+{ -+ return GET_CODE (x) == SYMBOL_REF && SYMBOL_REF_TLS_MODEL (x) != 0; -+} -+ -+static bool -+riscv_symbol_binds_local_p (const_rtx x) -+{ -+ return (SYMBOL_REF_DECL (x) -+ ? targetm.binds_local_p (SYMBOL_REF_DECL (x)) -+ : SYMBOL_REF_LOCAL_P (x)); -+} -+ -+/* Return the method that should be used to access SYMBOL_REF or -+ LABEL_REF X in context CONTEXT. */ -+ -+static enum riscv_symbol_type -+riscv_classify_symbol (const_rtx x) -+{ -+ if (riscv_tls_symbol_p (x)) -+ return SYMBOL_TLS; -+ -+ if (GET_CODE (x) == LABEL_REF) -+ { -+ if (LABEL_REF_NONLOCAL_P (x)) -+ return SYMBOL_GOT_DISP; -+ return SYMBOL_ABSOLUTE; -+ } -+ -+ gcc_assert (GET_CODE (x) == SYMBOL_REF); -+ -+ if (flag_pic && !riscv_symbol_binds_local_p (x)) -+ return SYMBOL_GOT_DISP; -+ -+ return SYMBOL_ABSOLUTE; -+} -+ -+/* Classify the base of symbolic expression X, given that X appears in -+ context CONTEXT. */ -+ -+static enum riscv_symbol_type -+riscv_classify_symbolic_expression (rtx x) -+{ -+ rtx offset; -+ -+ split_const (x, &x, &offset); -+ if (UNSPEC_ADDRESS_P (x)) -+ return UNSPEC_ADDRESS_TYPE (x); -+ -+ return riscv_classify_symbol (x); -+} -+ -+/* Return true if X is a symbolic constant that can be used in context -+ CONTEXT. If it is, store the type of the symbol in *SYMBOL_TYPE. */ -+ -+bool -+riscv_symbolic_constant_p (rtx x, enum riscv_symbol_type *symbol_type) -+{ -+ rtx offset; -+ -+ split_const (x, &x, &offset); -+ if (UNSPEC_ADDRESS_P (x)) -+ { -+ *symbol_type = UNSPEC_ADDRESS_TYPE (x); -+ x = UNSPEC_ADDRESS (x); -+ } -+ else if (GET_CODE (x) == SYMBOL_REF || GET_CODE (x) == LABEL_REF) -+ *symbol_type = riscv_classify_symbol (x); -+ else -+ return false; -+ -+ if (offset == const0_rtx) -+ return true; -+ -+ /* Check whether a nonzero offset is valid for the underlying -+ relocations. */ -+ switch (*symbol_type) -+ { -+ case SYMBOL_ABSOLUTE: -+ case SYMBOL_TLS_LE: -+ return (int32_t) INTVAL (offset) == INTVAL (offset); -+ -+ default: -+ return false; -+ } -+ gcc_unreachable (); -+} -+ -+/* Returns the number of instructions necessary to reference a symbol. */ -+ -+static int riscv_symbol_insns (enum riscv_symbol_type type) -+{ -+ switch (type) -+ { -+ case SYMBOL_TLS: return 0; /* Depends on the TLS model. */ -+ case SYMBOL_ABSOLUTE: return 2; /* LUI + the reference itself */ -+ case SYMBOL_TLS_LE: return 3; /* LUI + ADD TP + the reference itself */ -+ case SYMBOL_GOT_DISP: return 3; /* AUIPC + LD GOT + the reference itself */ -+ default: gcc_unreachable(); -+ } -+} -+ -+/* A for_each_rtx callback. Stop the search if *X references a -+ thread-local symbol. */ -+ -+static int -+riscv_tls_symbol_ref_1 (rtx *x, void *data ATTRIBUTE_UNUSED) -+{ -+ return riscv_tls_symbol_p (*x); -+} -+ -+/* Implement TARGET_LEGITIMATE_CONSTANT_P. */ -+ -+static bool -+riscv_legitimate_constant_p (enum machine_mode mode ATTRIBUTE_UNUSED, rtx x) -+{ -+ return riscv_const_insns (x) > 0; -+} -+ -+/* Implement TARGET_CANNOT_FORCE_CONST_MEM. */ -+ -+static bool -+riscv_cannot_force_const_mem (enum machine_mode mode, rtx x) -+{ -+ enum riscv_symbol_type type; -+ rtx base, offset; -+ -+ /* There is no assembler syntax for expressing an address-sized -+ high part. */ -+ if (GET_CODE (x) == HIGH) -+ return true; -+ -+ /* As an optimization, reject constants that riscv_legitimize_move -+ can expand inline. -+ -+ Suppose we have a multi-instruction sequence that loads constant C -+ into register R. If R does not get allocated a hard register, and -+ R is used in an operand that allows both registers and memory -+ references, reload will consider forcing C into memory and using -+ one of the instruction's memory alternatives. Returning false -+ here will force it to use an input reload instead. */ -+ if (CONST_INT_P (x) && riscv_legitimate_constant_p (mode, x)) -+ return true; -+ -+ split_const (x, &base, &offset); -+ if (riscv_symbolic_constant_p (base, &type)) -+ { -+ /* The same optimization as for CONST_INT. */ -+ if (SMALL_INT (offset) && riscv_symbol_insns (type) > 0) -+ return true; -+ -+ /* It's not worth creating additional dynamic relocations. */ -+ if (flag_pic) -+ return true; -+ } -+ -+ /* TLS symbols must be computed by riscv_legitimize_move. */ -+ if (for_each_rtx (&x, &riscv_tls_symbol_ref_1, NULL)) -+ return true; -+ -+ return false; -+} -+ -+/* Return true if register REGNO is a valid base register for mode MODE. -+ STRICT_P is true if REG_OK_STRICT is in effect. */ -+ -+int -+riscv_regno_mode_ok_for_base_p (int regno, enum machine_mode mode ATTRIBUTE_UNUSED, -+ bool strict_p) -+{ -+ if (!HARD_REGISTER_NUM_P (regno)) -+ { -+ if (!strict_p) -+ return true; -+ regno = reg_renumber[regno]; -+ } -+ -+ /* These fake registers will be eliminated to either the stack or -+ hard frame pointer, both of which are usually valid base registers. -+ Reload deals with the cases where the eliminated form isn't valid. */ -+ if (regno == ARG_POINTER_REGNUM || regno == FRAME_POINTER_REGNUM) -+ return true; -+ -+ return GP_REG_P (regno); -+} -+ -+/* Return true if X is a valid base register for mode MODE. -+ STRICT_P is true if REG_OK_STRICT is in effect. */ -+ -+static bool -+riscv_valid_base_register_p (rtx x, enum machine_mode mode, bool strict_p) -+{ -+ if (!strict_p && GET_CODE (x) == SUBREG) -+ x = SUBREG_REG (x); -+ -+ return (REG_P (x) -+ && riscv_regno_mode_ok_for_base_p (REGNO (x), mode, strict_p)); -+} -+ -+/* Return true if, for every base register BASE_REG, (plus BASE_REG X) -+ can address a value of mode MODE. */ -+ -+static bool -+riscv_valid_offset_p (rtx x, enum machine_mode mode) -+{ -+ /* Check that X is a signed 12-bit number. */ -+ if (!const_arith_operand (x, Pmode)) -+ return false; -+ -+ /* We may need to split multiword moves, so make sure that every word -+ is accessible. */ -+ if (GET_MODE_SIZE (mode) > UNITS_PER_WORD -+ && !SMALL_OPERAND (INTVAL (x) + GET_MODE_SIZE (mode) - UNITS_PER_WORD)) -+ return false; -+ -+ return true; -+} -+ -+/* Return true if a LO_SUM can address a value of mode MODE when the -+ LO_SUM symbol has type SYMBOL_TYPE. */ -+ -+static bool -+riscv_valid_lo_sum_p (enum riscv_symbol_type symbol_type, enum machine_mode mode) -+{ -+ /* Check that symbols of type SYMBOL_TYPE can be used to access values -+ of mode MODE. */ -+ if (riscv_symbol_insns (symbol_type) == 0) -+ return false; -+ -+ /* Check that there is a known low-part relocation. */ -+ if (riscv_lo_relocs[symbol_type] == NULL) -+ return false; -+ -+ /* We may need to split multiword moves, so make sure that each word -+ can be accessed without inducing a carry. This is mainly needed -+ for o64, which has historically only guaranteed 64-bit alignment -+ for 128-bit types. */ -+ if (GET_MODE_SIZE (mode) > UNITS_PER_WORD -+ && GET_MODE_BITSIZE (mode) > GET_MODE_ALIGNMENT (mode)) -+ return false; -+ -+ return true; -+} -+ -+/* Return true if X is a valid address for machine mode MODE. If it is, -+ fill in INFO appropriately. STRICT_P is true if REG_OK_STRICT is in -+ effect. */ -+ -+static bool -+riscv_classify_address (struct riscv_address_info *info, rtx x, -+ enum machine_mode mode, bool strict_p) -+{ -+ switch (GET_CODE (x)) -+ { -+ case REG: -+ case SUBREG: -+ info->type = ADDRESS_REG; -+ info->reg = x; -+ info->offset = const0_rtx; -+ return riscv_valid_base_register_p (info->reg, mode, strict_p); -+ -+ case PLUS: -+ info->type = ADDRESS_REG; -+ info->reg = XEXP (x, 0); -+ info->offset = XEXP (x, 1); -+ return (riscv_valid_base_register_p (info->reg, mode, strict_p) -+ && riscv_valid_offset_p (info->offset, mode)); -+ -+ case LO_SUM: -+ info->type = ADDRESS_LO_SUM; -+ info->reg = XEXP (x, 0); -+ info->offset = XEXP (x, 1); -+ /* We have to trust the creator of the LO_SUM to do something vaguely -+ sane. Target-independent code that creates a LO_SUM should also -+ create and verify the matching HIGH. Target-independent code that -+ adds an offset to a LO_SUM must prove that the offset will not -+ induce a carry. Failure to do either of these things would be -+ a bug, and we are not required to check for it here. The RISCV -+ backend itself should only create LO_SUMs for valid symbolic -+ constants, with the high part being either a HIGH or a copy -+ of _gp. */ -+ info->symbol_type -+ = riscv_classify_symbolic_expression (info->offset); -+ return (riscv_valid_base_register_p (info->reg, mode, strict_p) -+ && riscv_valid_lo_sum_p (info->symbol_type, mode)); -+ -+ case CONST_INT: -+ /* Small-integer addresses don't occur very often, but they -+ are legitimate if $0 is a valid base register. */ -+ info->type = ADDRESS_CONST_INT; -+ return SMALL_INT (x); -+ -+ default: -+ return false; -+ } -+} -+ -+/* Implement TARGET_LEGITIMATE_ADDRESS_P. */ -+ -+static bool -+riscv_legitimate_address_p (enum machine_mode mode, rtx x, bool strict_p) -+{ -+ struct riscv_address_info addr; -+ -+ return riscv_classify_address (&addr, x, mode, strict_p); -+} -+ -+/* Return the number of instructions needed to load or store a value -+ of mode MODE at address X. Return 0 if X isn't valid for MODE. -+ Assume that multiword moves may need to be split into word moves -+ if MIGHT_SPLIT_P, otherwise assume that a single load or store is -+ enough. */ -+ -+int -+riscv_address_insns (rtx x, enum machine_mode mode, bool might_split_p) -+{ -+ struct riscv_address_info addr; -+ int n = 1; -+ -+ if (!riscv_classify_address (&addr, x, mode, false)) -+ return 0; -+ -+ /* BLKmode is used for single unaligned loads and stores and should -+ not count as a multiword mode. */ -+ if (mode != BLKmode && might_split_p) -+ n += (GET_MODE_SIZE (mode) + UNITS_PER_WORD - 1) / UNITS_PER_WORD; -+ -+ if (addr.type == ADDRESS_LO_SUM) -+ n += riscv_symbol_insns (addr.symbol_type) - 1; -+ -+ return n; -+} -+ -+/* Return the number of instructions needed to load constant X. -+ Return 0 if X isn't a valid constant. */ -+ -+int -+riscv_const_insns (rtx x) -+{ -+ enum riscv_symbol_type symbol_type; -+ rtx offset; -+ -+ switch (GET_CODE (x)) -+ { -+ case HIGH: -+ if (!riscv_symbolic_constant_p (XEXP (x, 0), &symbol_type) -+ || !riscv_hi_relocs[symbol_type]) -+ return 0; -+ -+ /* This is simply an LUI. */ -+ return 1; -+ -+ case CONST_INT: -+ { -+ int cost = riscv_integer_cost (INTVAL (x)); -+ /* Force complicated constants to memory. */ -+ return cost < 4 ? cost : 0; -+ } -+ -+ case CONST_DOUBLE: -+ case CONST_VECTOR: -+ /* Allow zeros for normal mode, where we can use x0. */ -+ return x == CONST0_RTX (GET_MODE (x)) ? 1 : 0; -+ -+ case CONST: -+ /* See if we can refer to X directly. */ -+ if (riscv_symbolic_constant_p (x, &symbol_type)) -+ return riscv_symbol_insns (symbol_type); -+ -+ /* Otherwise try splitting the constant into a base and offset. -+ If the offset is a 16-bit value, we can load the base address -+ into a register and then use (D)ADDIU to add in the offset. -+ If the offset is larger, we can load the base and offset -+ into separate registers and add them together with (D)ADDU. -+ However, the latter is only possible before reload; during -+ and after reload, we must have the option of forcing the -+ constant into the pool instead. */ -+ split_const (x, &x, &offset); -+ if (offset != 0) -+ { -+ int n = riscv_const_insns (x); -+ if (n != 0) -+ { -+ if (SMALL_INT (offset)) -+ return n + 1; -+ else if (!targetm.cannot_force_const_mem (GET_MODE (x), x)) -+ return n + 1 + riscv_integer_cost (INTVAL (offset)); -+ } -+ } -+ return 0; -+ -+ case SYMBOL_REF: -+ case LABEL_REF: -+ return riscv_symbol_insns (riscv_classify_symbol (x)); -+ -+ default: -+ return 0; -+ } -+} -+ -+/* X is a doubleword constant that can be handled by splitting it into -+ two words and loading each word separately. Return the number of -+ instructions required to do this. */ -+ -+int -+riscv_split_const_insns (rtx x) -+{ -+ unsigned int low, high; -+ -+ low = riscv_const_insns (riscv_subword (x, false)); -+ high = riscv_const_insns (riscv_subword (x, true)); -+ gcc_assert (low > 0 && high > 0); -+ return low + high; -+} -+ -+/* Return the number of instructions needed to implement INSN, -+ given that it loads from or stores to MEM. */ -+ -+int -+riscv_load_store_insns (rtx mem, rtx insn) -+{ -+ enum machine_mode mode; -+ bool might_split_p; -+ rtx set; -+ -+ gcc_assert (MEM_P (mem)); -+ mode = GET_MODE (mem); -+ -+ /* Try to prove that INSN does not need to be split. */ -+ might_split_p = true; -+ if (GET_MODE_BITSIZE (mode) == 64) -+ { -+ set = single_set (insn); -+ if (set && !riscv_split_64bit_move_p (SET_DEST (set), SET_SRC (set))) -+ might_split_p = false; -+ } -+ -+ return riscv_address_insns (XEXP (mem, 0), mode, might_split_p); -+} -+ -+/* Emit a move from SRC to DEST. Assume that the move expanders can -+ handle all moves if !can_create_pseudo_p (). The distinction is -+ important because, unlike emit_move_insn, the move expanders know -+ how to force Pmode objects into the constant pool even when the -+ constant pool address is not itself legitimate. */ -+ -+rtx -+riscv_emit_move (rtx dest, rtx src) -+{ -+ return (can_create_pseudo_p () -+ ? emit_move_insn (dest, src) -+ : emit_move_insn_1 (dest, src)); -+} -+ -+/* Emit an instruction of the form (set TARGET (CODE OP0 OP1)). */ -+ -+static void -+riscv_emit_binary (enum rtx_code code, rtx target, rtx op0, rtx op1) -+{ -+ emit_insn (gen_rtx_SET (VOIDmode, target, -+ gen_rtx_fmt_ee (code, GET_MODE (target), op0, op1))); -+} -+ -+/* Compute (CODE OP0 OP1) and store the result in a new register -+ of mode MODE. Return that new register. */ -+ -+static rtx -+riscv_force_binary (enum machine_mode mode, enum rtx_code code, rtx op0, rtx op1) -+{ -+ rtx reg; -+ -+ reg = gen_reg_rtx (mode); -+ riscv_emit_binary (code, reg, op0, op1); -+ return reg; -+} -+ -+/* Copy VALUE to a register and return that register. If new pseudos -+ are allowed, copy it into a new register, otherwise use DEST. */ -+ -+static rtx -+riscv_force_temporary (rtx dest, rtx value) -+{ -+ if (can_create_pseudo_p ()) -+ return force_reg (Pmode, value); -+ else -+ { -+ riscv_emit_move (dest, value); -+ return dest; -+ } -+} -+ -+/* Wrap symbol or label BASE in an UNSPEC address of type SYMBOL_TYPE, -+ then add CONST_INT OFFSET to the result. */ -+ -+static rtx -+riscv_unspec_address_offset (rtx base, rtx offset, -+ enum riscv_symbol_type symbol_type) -+{ -+ base = gen_rtx_UNSPEC (Pmode, gen_rtvec (1, base), -+ UNSPEC_ADDRESS_FIRST + symbol_type); -+ if (offset != const0_rtx) -+ base = gen_rtx_PLUS (Pmode, base, offset); -+ return gen_rtx_CONST (Pmode, base); -+} -+ -+/* Return an UNSPEC address with underlying address ADDRESS and symbol -+ type SYMBOL_TYPE. */ -+ -+rtx -+riscv_unspec_address (rtx address, enum riscv_symbol_type symbol_type) -+{ -+ rtx base, offset; -+ -+ split_const (address, &base, &offset); -+ return riscv_unspec_address_offset (base, offset, symbol_type); -+} -+ -+/* If OP is an UNSPEC address, return the address to which it refers, -+ otherwise return OP itself. */ -+ -+static rtx -+riscv_strip_unspec_address (rtx op) -+{ -+ rtx base, offset; -+ -+ split_const (op, &base, &offset); -+ if (UNSPEC_ADDRESS_P (base)) -+ op = plus_constant (Pmode, UNSPEC_ADDRESS (base), INTVAL (offset)); -+ return op; -+} -+ -+/* If riscv_unspec_address (ADDR, SYMBOL_TYPE) is a 32-bit value, add the -+ high part to BASE and return the result. Just return BASE otherwise. -+ TEMP is as for riscv_force_temporary. -+ -+ The returned expression can be used as the first operand to a LO_SUM. */ -+ -+static rtx -+riscv_unspec_offset_high (rtx temp, rtx addr, enum riscv_symbol_type symbol_type) -+{ -+ addr = gen_rtx_HIGH (Pmode, riscv_unspec_address (addr, symbol_type)); -+ return riscv_force_temporary (temp, addr); -+} -+ -+/* Load an entry from the GOT. */ -+static rtx riscv_got_load_tls_gd(rtx dest, rtx sym) -+{ -+ return (Pmode == DImode ? gen_got_load_tls_gddi(dest, sym) : gen_got_load_tls_gdsi(dest, sym)); -+} -+ -+static rtx riscv_got_load_tls_ie(rtx dest, rtx sym) -+{ -+ return (Pmode == DImode ? gen_got_load_tls_iedi(dest, sym) : gen_got_load_tls_iesi(dest, sym)); -+} -+ -+static rtx riscv_tls_add_tp_le(rtx dest, rtx base, rtx sym) -+{ -+ rtx tp = gen_rtx_REG (Pmode, THREAD_POINTER_REGNUM); -+ return (Pmode == DImode ? gen_tls_add_tp_ledi(dest, base, tp, sym) : gen_tls_add_tp_lesi(dest, base, tp, sym)); -+} -+ -+/* If MODE is MAX_MACHINE_MODE, ADDR appears as a move operand, otherwise -+ it appears in a MEM of that mode. Return true if ADDR is a legitimate -+ constant in that context and can be split into high and low parts. -+ If so, and if LOW_OUT is nonnull, emit the high part and store the -+ low part in *LOW_OUT. Leave *LOW_OUT unchanged otherwise. -+ -+ TEMP is as for riscv_force_temporary and is used to load the high -+ part into a register. -+ -+ When MODE is MAX_MACHINE_MODE, the low part is guaranteed to be -+ a legitimize SET_SRC for an .md pattern, otherwise the low part -+ is guaranteed to be a legitimate address for mode MODE. */ -+ -+bool -+riscv_split_symbol (rtx temp, rtx addr, enum machine_mode mode, rtx *low_out) -+{ -+ enum riscv_symbol_type symbol_type; -+ rtx high; -+ -+ if ((GET_CODE (addr) == HIGH && mode == MAX_MACHINE_MODE) -+ || !riscv_symbolic_constant_p (addr, &symbol_type) -+ || riscv_symbol_insns (symbol_type) == 0 -+ || !riscv_hi_relocs[symbol_type]) -+ return false; -+ -+ if (low_out) -+ { -+ switch (symbol_type) -+ { -+ case SYMBOL_ABSOLUTE: -+ high = gen_rtx_HIGH (Pmode, copy_rtx (addr)); -+ high = riscv_force_temporary (temp, high); -+ *low_out = gen_rtx_LO_SUM (Pmode, high, addr); -+ break; -+ -+ default: -+ gcc_unreachable (); -+ } -+ } -+ -+ return true; -+} -+ -+/* Return a legitimate address for REG + OFFSET. TEMP is as for -+ riscv_force_temporary; it is only needed when OFFSET is not a -+ SMALL_OPERAND. */ -+ -+static rtx -+riscv_add_offset (rtx temp, rtx reg, HOST_WIDE_INT offset) -+{ -+ if (!SMALL_OPERAND (offset)) -+ { -+ rtx high; -+ -+ /* Leave OFFSET as a 16-bit offset and put the excess in HIGH. -+ The addition inside the macro CONST_HIGH_PART may cause an -+ overflow, so we need to force a sign-extension check. */ -+ high = gen_int_mode (RISCV_CONST_HIGH_PART (offset), Pmode); -+ offset = RISCV_CONST_LOW_PART (offset); -+ high = riscv_force_temporary (temp, high); -+ reg = riscv_force_temporary (temp, gen_rtx_PLUS (Pmode, high, reg)); -+ } -+ return plus_constant (Pmode, reg, offset); -+} -+ -+/* The __tls_get_attr symbol. */ -+static GTY(()) rtx riscv_tls_symbol; -+ -+/* Return an instruction sequence that calls __tls_get_addr. SYM is -+ the TLS symbol we are referencing and TYPE is the symbol type to use -+ (either global dynamic or local dynamic). RESULT is an RTX for the -+ return value location. */ -+ -+static rtx -+riscv_call_tls_get_addr (rtx sym, rtx result) -+{ -+ rtx insn, a0 = gen_rtx_REG (Pmode, GP_ARG_FIRST); -+ -+ if (!riscv_tls_symbol) -+ riscv_tls_symbol = init_one_libfunc ("__tls_get_addr"); -+ -+ start_sequence (); -+ -+ emit_insn (riscv_got_load_tls_gd (a0, sym)); -+ insn = riscv_expand_call (false, result, riscv_tls_symbol, const0_rtx); -+ RTL_CONST_CALL_P (insn) = 1; -+ use_reg (&CALL_INSN_FUNCTION_USAGE (insn), a0); -+ insn = get_insns (); -+ -+ end_sequence (); -+ -+ return insn; -+} -+ -+/* Generate the code to access LOC, a thread-local SYMBOL_REF, and return -+ its address. The return value will be both a valid address and a valid -+ SET_SRC (either a REG or a LO_SUM). */ -+ -+static rtx -+riscv_legitimize_tls_address (rtx loc) -+{ -+ rtx dest, insn, tp, tmp1; -+ enum tls_model model = SYMBOL_REF_TLS_MODEL (loc); -+ -+ /* Since we support TLS copy relocs, non-PIC TLS accesses may all use LE. */ -+ if (!flag_pic) -+ model = TLS_MODEL_LOCAL_EXEC; -+ -+ switch (model) -+ { -+ case TLS_MODEL_LOCAL_DYNAMIC: -+ /* Rely on section anchors for the optimization that LDM TLS -+ provides. The anchor's address is loaded with GD TLS. */ -+ case TLS_MODEL_GLOBAL_DYNAMIC: -+ tmp1 = gen_rtx_REG (Pmode, GP_RETURN); -+ insn = riscv_call_tls_get_addr (loc, tmp1); -+ dest = gen_reg_rtx (Pmode); -+ emit_libcall_block (insn, dest, tmp1, loc); -+ break; -+ -+ case TLS_MODEL_INITIAL_EXEC: -+ /* la.tls.ie; tp-relative add */ -+ tp = gen_rtx_REG (Pmode, THREAD_POINTER_REGNUM); -+ tmp1 = gen_reg_rtx (Pmode); -+ emit_insn (riscv_got_load_tls_ie (tmp1, loc)); -+ dest = gen_reg_rtx (Pmode); -+ emit_insn (gen_add3_insn (dest, tmp1, tp)); -+ break; -+ -+ case TLS_MODEL_LOCAL_EXEC: -+ tmp1 = riscv_unspec_offset_high (NULL, loc, SYMBOL_TLS_LE); -+ dest = gen_reg_rtx (Pmode); -+ emit_insn (riscv_tls_add_tp_le (dest, tmp1, loc)); -+ dest = gen_rtx_LO_SUM (Pmode, dest, -+ riscv_unspec_address (loc, SYMBOL_TLS_LE)); -+ break; -+ -+ default: -+ gcc_unreachable (); -+ } -+ return dest; -+} -+ -+/* If X is not a valid address for mode MODE, force it into a register. */ -+ -+static rtx -+riscv_force_address (rtx x, enum machine_mode mode) -+{ -+ if (!riscv_legitimate_address_p (mode, x, false)) -+ x = force_reg (Pmode, x); -+ return x; -+} -+ -+/* This function is used to implement LEGITIMIZE_ADDRESS. If X can -+ be legitimized in a way that the generic machinery might not expect, -+ return a new address, otherwise return NULL. MODE is the mode of -+ the memory being accessed. */ -+ -+static rtx -+riscv_legitimize_address (rtx x, rtx oldx ATTRIBUTE_UNUSED, -+ enum machine_mode mode) -+{ -+ rtx addr; -+ -+ if (riscv_tls_symbol_p (x)) -+ return riscv_legitimize_tls_address (x); -+ -+ /* See if the address can split into a high part and a LO_SUM. */ -+ if (riscv_split_symbol (NULL, x, mode, &addr)) -+ return riscv_force_address (addr, mode); -+ -+ /* Handle BASE + OFFSET using riscv_add_offset. */ -+ if (GET_CODE (x) == PLUS && CONST_INT_P (XEXP (x, 1)) -+ && INTVAL (XEXP (x, 1)) != 0) -+ { -+ rtx base = XEXP (x, 0); -+ HOST_WIDE_INT offset = INTVAL (XEXP (x, 1)); -+ -+ if (!riscv_valid_base_register_p (base, mode, false)) -+ base = copy_to_mode_reg (Pmode, base); -+ addr = riscv_add_offset (NULL, base, offset); -+ return riscv_force_address (addr, mode); -+ } -+ -+ return x; -+} -+ -+/* Load VALUE into DEST. TEMP is as for riscv_force_temporary. */ -+ -+void -+riscv_move_integer (rtx temp, rtx dest, HOST_WIDE_INT value) -+{ -+ struct riscv_integer_op codes[RISCV_MAX_INTEGER_OPS]; -+ enum machine_mode mode; -+ int i, num_ops; -+ rtx x; -+ -+ mode = GET_MODE (dest); -+ num_ops = riscv_build_integer (codes, value, mode); -+ -+ if (can_create_pseudo_p () && num_ops > 2 /* not a simple constant */ -+ && num_ops >= riscv_split_integer_cost (value)) -+ x = riscv_split_integer (value, mode); -+ else -+ { -+ /* Apply each binary operation to X. */ -+ x = GEN_INT (codes[0].value); -+ -+ for (i = 1; i < num_ops; i++) -+ { -+ if (!can_create_pseudo_p ()) -+ { -+ emit_insn (gen_rtx_SET (VOIDmode, temp, x)); -+ x = temp; -+ } -+ else -+ x = force_reg (mode, x); -+ -+ x = gen_rtx_fmt_ee (codes[i].code, mode, x, GEN_INT (codes[i].value)); -+ } -+ } -+ -+ emit_insn (gen_rtx_SET (VOIDmode, dest, x)); -+} -+ -+/* Subroutine of riscv_legitimize_move. Move constant SRC into register -+ DEST given that SRC satisfies immediate_operand but doesn't satisfy -+ move_operand. */ -+ -+static void -+riscv_legitimize_const_move (enum machine_mode mode, rtx dest, rtx src) -+{ -+ rtx base, offset; -+ -+ /* Split moves of big integers into smaller pieces. */ -+ if (splittable_const_int_operand (src, mode)) -+ { -+ riscv_move_integer (dest, dest, INTVAL (src)); -+ return; -+ } -+ -+ /* Split moves of symbolic constants into high/low pairs. */ -+ if (riscv_split_symbol (dest, src, MAX_MACHINE_MODE, &src)) -+ { -+ emit_insn (gen_rtx_SET (VOIDmode, dest, src)); -+ return; -+ } -+ -+ /* Generate the appropriate access sequences for TLS symbols. */ -+ if (riscv_tls_symbol_p (src)) -+ { -+ riscv_emit_move (dest, riscv_legitimize_tls_address (src)); -+ return; -+ } -+ -+ /* If we have (const (plus symbol offset)), and that expression cannot -+ be forced into memory, load the symbol first and add in the offset. Also -+ prefer to do this even if the constant _can_ be forced into memory, as it -+ usually produces better code. */ -+ split_const (src, &base, &offset); -+ if (offset != const0_rtx -+ && (targetm.cannot_force_const_mem (mode, src) || can_create_pseudo_p ())) -+ { -+ base = riscv_force_temporary (dest, base); -+ riscv_emit_move (dest, riscv_add_offset (NULL, base, INTVAL (offset))); -+ return; -+ } -+ -+ src = force_const_mem (mode, src); -+ -+ /* When using explicit relocs, constant pool references are sometimes -+ not legitimate addresses. */ -+ riscv_split_symbol (dest, XEXP (src, 0), mode, &XEXP (src, 0)); -+ riscv_emit_move (dest, src); -+} -+ -+/* If (set DEST SRC) is not a valid move instruction, emit an equivalent -+ sequence that is valid. */ -+ -+bool -+riscv_legitimize_move (enum machine_mode mode, rtx dest, rtx src) -+{ -+ if (!register_operand (dest, mode) && !reg_or_0_operand (src, mode)) -+ { -+ riscv_emit_move (dest, force_reg (mode, src)); -+ return true; -+ } -+ -+ /* We need to deal with constants that would be legitimate -+ immediate_operands but aren't legitimate move_operands. */ -+ if (CONSTANT_P (src) && !move_operand (src, mode)) -+ { -+ riscv_legitimize_const_move (mode, dest, src); -+ set_unique_reg_note (get_last_insn (), REG_EQUAL, copy_rtx (src)); -+ return true; -+ } -+ return false; -+} -+ -+/* Return true if there is an instruction that implements CODE and accepts -+ X as an immediate operand. */ -+ -+static int -+riscv_immediate_operand_p (int code, HOST_WIDE_INT x) -+{ -+ switch (code) -+ { -+ case ASHIFT: -+ case ASHIFTRT: -+ case LSHIFTRT: -+ /* All shift counts are truncated to a valid constant. */ -+ return true; -+ -+ case AND: -+ case IOR: -+ case XOR: -+ case PLUS: -+ case LT: -+ case LTU: -+ /* These instructions take 12-bit signed immediates. */ -+ return SMALL_OPERAND (x); -+ -+ case LE: -+ /* We add 1 to the immediate and use SLT. */ -+ return SMALL_OPERAND (x + 1); -+ -+ case LEU: -+ /* Likewise SLTU, but reject the always-true case. */ -+ return SMALL_OPERAND (x + 1) && x + 1 != 0; -+ -+ case GE: -+ case GEU: -+ /* We can emulate an immediate of 1 by using GT/GTU against x0. */ -+ return x == 1; -+ -+ default: -+ /* By default assume that x0 can be used for 0. */ -+ return x == 0; -+ } -+} -+ -+/* Return the cost of binary operation X, given that the instruction -+ sequence for a word-sized or smaller operation takes SIGNLE_INSNS -+ instructions and that the sequence of a double-word operation takes -+ DOUBLE_INSNS instructions. */ -+ -+static int -+riscv_binary_cost (rtx x, int single_insns, int double_insns) -+{ -+ if (GET_MODE_SIZE (GET_MODE (x)) == UNITS_PER_WORD * 2) -+ return COSTS_N_INSNS (double_insns); -+ return COSTS_N_INSNS (single_insns); -+} -+ -+/* Return the cost of sign-extending OP to mode MODE, not including the -+ cost of OP itself. */ -+ -+static int -+riscv_sign_extend_cost (enum machine_mode mode, rtx op) -+{ -+ if (MEM_P (op)) -+ /* Extended loads are as cheap as unextended ones. */ -+ return 0; -+ -+ if (TARGET_64BIT && mode == DImode && GET_MODE (op) == SImode) -+ /* A sign extension from SImode to DImode in 64-bit mode is free. */ -+ return 0; -+ -+ /* We need to use a shift left and a shift right. */ -+ return COSTS_N_INSNS (2); -+} -+ -+/* Return the cost of zero-extending OP to mode MODE, not including the -+ cost of OP itself. */ -+ -+static int -+riscv_zero_extend_cost (enum machine_mode mode, rtx op) -+{ -+ if (MEM_P (op)) -+ /* Extended loads are as cheap as unextended ones. */ -+ return 0; -+ -+ if ((TARGET_64BIT && mode == DImode && GET_MODE (op) == SImode) || -+ ((mode == DImode || mode == SImode) && GET_MODE (op) == HImode)) -+ /* We need a shift left by 32 bits and a shift right by 32 bits. */ -+ return COSTS_N_INSNS (2); -+ -+ /* We can use ANDI. */ -+ return COSTS_N_INSNS (1); -+} -+ -+/* Implement TARGET_RTX_COSTS. */ -+ -+static bool -+riscv_rtx_costs (rtx x, int code, int outer_code, int opno ATTRIBUTE_UNUSED, -+ int *total, bool speed) -+{ -+ enum machine_mode mode = GET_MODE (x); -+ bool float_mode_p = FLOAT_MODE_P (mode); -+ int cost; -+ -+ switch (code) -+ { -+ case CONST_INT: -+ if (riscv_immediate_operand_p (outer_code, INTVAL (x))) -+ { -+ *total = 0; -+ return true; -+ } -+ /* Fall through. */ -+ -+ case SYMBOL_REF: -+ case LABEL_REF: -+ case CONST_DOUBLE: -+ case CONST: -+ if (speed) -+ *total = 1; -+ else if ((cost = riscv_const_insns (x)) > 0) -+ *total = COSTS_N_INSNS (cost); -+ else /* The instruction will be fetched from the constant pool. */ -+ *total = COSTS_N_INSNS (riscv_symbol_insns (SYMBOL_ABSOLUTE)); -+ return true; -+ -+ case MEM: -+ /* If the address is legitimate, return the number of -+ instructions it needs. */ -+ if ((cost = riscv_address_insns (XEXP (x, 0), mode, true)) > 0) -+ { -+ *total = COSTS_N_INSNS (cost + tune_info->memory_cost); -+ return true; -+ } -+ /* Otherwise use the default handling. */ -+ return false; -+ -+ case NOT: -+ *total = COSTS_N_INSNS (GET_MODE_SIZE (mode) > UNITS_PER_WORD ? 2 : 1); -+ return false; -+ -+ case AND: -+ case IOR: -+ case XOR: -+ /* Double-word operations use two single-word operations. */ -+ *total = riscv_binary_cost (x, 1, 2); -+ return false; -+ -+ case ASHIFT: -+ case ASHIFTRT: -+ case LSHIFTRT: -+ *total = riscv_binary_cost (x, 1, CONSTANT_P (XEXP (x, 1)) ? 4 : 9); -+ return false; -+ -+ case ABS: -+ *total = COSTS_N_INSNS (float_mode_p ? 1 : 3); -+ return false; -+ -+ case LO_SUM: -+ *total = set_src_cost (XEXP (x, 0), speed); -+ return true; -+ -+ case LT: -+ case LTU: -+ case LE: -+ case LEU: -+ case GT: -+ case GTU: -+ case GE: -+ case GEU: -+ case EQ: -+ case NE: -+ case UNORDERED: -+ case LTGT: -+ /* Branch comparisons have VOIDmode, so use the first operand's -+ mode instead. */ -+ mode = GET_MODE (XEXP (x, 0)); -+ if (float_mode_p) -+ *total = tune_info->fp_add[mode == DFmode]; -+ else -+ *total = riscv_binary_cost (x, 1, 3); -+ return false; -+ -+ case MINUS: -+ if (float_mode_p -+ && !HONOR_NANS (mode) -+ && !HONOR_SIGNED_ZEROS (mode)) -+ { -+ /* See if we can use NMADD or NMSUB. See riscv.md for the -+ associated patterns. */ -+ rtx op0 = XEXP (x, 0); -+ rtx op1 = XEXP (x, 1); -+ if (GET_CODE (op0) == MULT && GET_CODE (XEXP (op0, 0)) == NEG) -+ { -+ *total = (tune_info->fp_mul[mode == DFmode] -+ + set_src_cost (XEXP (XEXP (op0, 0), 0), speed) -+ + set_src_cost (XEXP (op0, 1), speed) -+ + set_src_cost (op1, speed)); -+ return true; -+ } -+ if (GET_CODE (op1) == MULT) -+ { -+ *total = (tune_info->fp_mul[mode == DFmode] -+ + set_src_cost (op0, speed) -+ + set_src_cost (XEXP (op1, 0), speed) -+ + set_src_cost (XEXP (op1, 1), speed)); -+ return true; -+ } -+ } -+ /* Fall through. */ -+ -+ case PLUS: -+ if (float_mode_p) -+ *total = tune_info->fp_add[mode == DFmode]; -+ else -+ *total = riscv_binary_cost (x, 1, 4); -+ return false; -+ -+ case NEG: -+ if (float_mode_p -+ && !HONOR_NANS (mode) -+ && HONOR_SIGNED_ZEROS (mode)) -+ { -+ /* See if we can use NMADD or NMSUB. See riscv.md for the -+ associated patterns. */ -+ rtx op = XEXP (x, 0); -+ if ((GET_CODE (op) == PLUS || GET_CODE (op) == MINUS) -+ && GET_CODE (XEXP (op, 0)) == MULT) -+ { -+ *total = (tune_info->fp_mul[mode == DFmode] -+ + set_src_cost (XEXP (XEXP (op, 0), 0), speed) -+ + set_src_cost (XEXP (XEXP (op, 0), 1), speed) -+ + set_src_cost (XEXP (op, 1), speed)); -+ return true; -+ } -+ } -+ -+ if (float_mode_p) -+ *total = tune_info->fp_add[mode == DFmode]; -+ else -+ *total = COSTS_N_INSNS (GET_MODE_SIZE (mode) > UNITS_PER_WORD ? 4 : 1); -+ return false; -+ -+ case MULT: -+ if (float_mode_p) -+ *total = tune_info->fp_mul[mode == DFmode]; -+ else if (GET_MODE_SIZE (mode) > UNITS_PER_WORD) -+ *total = 3 * tune_info->int_mul[0] + COSTS_N_INSNS (2); -+ else if (!speed) -+ *total = COSTS_N_INSNS (1); -+ else -+ *total = tune_info->int_mul[mode == DImode]; -+ return false; -+ -+ case DIV: -+ case SQRT: -+ case MOD: -+ if (float_mode_p) -+ { -+ *total = tune_info->fp_div[mode == DFmode]; -+ return false; -+ } -+ /* Fall through. */ -+ -+ case UDIV: -+ case UMOD: -+ if (speed) -+ *total = tune_info->int_div[mode == DImode]; -+ else -+ *total = COSTS_N_INSNS (1); -+ return false; -+ -+ case SIGN_EXTEND: -+ *total = riscv_sign_extend_cost (mode, XEXP (x, 0)); -+ return false; -+ -+ case ZERO_EXTEND: -+ *total = riscv_zero_extend_cost (mode, XEXP (x, 0)); -+ return false; -+ -+ case FLOAT: -+ case UNSIGNED_FLOAT: -+ case FIX: -+ case FLOAT_EXTEND: -+ case FLOAT_TRUNCATE: -+ *total = tune_info->fp_add[mode == DFmode]; -+ return false; -+ -+ default: -+ return false; -+ } -+} -+ -+/* Implement TARGET_ADDRESS_COST. */ -+ -+static int -+riscv_address_cost (rtx addr, enum machine_mode mode, -+ addr_space_t as ATTRIBUTE_UNUSED, -+ bool speed ATTRIBUTE_UNUSED) -+{ -+ return riscv_address_insns (addr, mode, false); -+} -+ -+/* Return one word of double-word value OP. HIGH_P is true to select the -+ high part or false to select the low part. */ -+ -+rtx -+riscv_subword (rtx op, bool high_p) -+{ -+ unsigned int byte; -+ enum machine_mode mode; -+ -+ mode = GET_MODE (op); -+ if (mode == VOIDmode) -+ mode = TARGET_64BIT ? TImode : DImode; -+ -+ byte = high_p ? UNITS_PER_WORD : 0; -+ -+ if (FP_REG_RTX_P (op)) -+ return gen_rtx_REG (word_mode, REGNO (op) + high_p); -+ -+ if (MEM_P (op)) -+ return adjust_address (op, word_mode, byte); -+ -+ return simplify_gen_subreg (word_mode, op, mode, byte); -+} -+ -+/* Return true if a 64-bit move from SRC to DEST should be split into two. */ -+ -+bool -+riscv_split_64bit_move_p (rtx dest, rtx src) -+{ -+ /* All 64b moves are legal in 64b mode. All 64b FPR <-> FPR and -+ FPR <-> MEM moves are legal in 32b mode, too. Although -+ FPR <-> GPR moves are not available in general in 32b mode, -+ we can at least load 0 into an FPR with fcvt.d.w fpr, x0. */ -+ return !(TARGET_64BIT -+ || (FP_REG_RTX_P (src) && FP_REG_RTX_P (dest)) -+ || (FP_REG_RTX_P (dest) && MEM_P (src)) -+ || (FP_REG_RTX_P (src) && MEM_P (dest)) -+ || (FP_REG_RTX_P(dest) && src == CONST0_RTX(GET_MODE(src)))); -+} -+ -+/* Split a doubleword move from SRC to DEST. On 32-bit targets, -+ this function handles 64-bit moves for which riscv_split_64bit_move_p -+ holds. For 64-bit targets, this function handles 128-bit moves. */ -+ -+void -+riscv_split_doubleword_move (rtx dest, rtx src) -+{ -+ rtx low_dest; -+ -+ /* The operation can be split into two normal moves. Decide in -+ which order to do them. */ -+ low_dest = riscv_subword (dest, false); -+ if (REG_P (low_dest) && reg_overlap_mentioned_p (low_dest, src)) -+ { -+ riscv_emit_move (riscv_subword (dest, true), riscv_subword (src, true)); -+ riscv_emit_move (low_dest, riscv_subword (src, false)); -+ } -+ else -+ { -+ riscv_emit_move (low_dest, riscv_subword (src, false)); -+ riscv_emit_move (riscv_subword (dest, true), riscv_subword (src, true)); -+ } -+} -+ -+/* Return the appropriate instructions to move SRC into DEST. Assume -+ that SRC is operand 1 and DEST is operand 0. */ -+ -+const char * -+riscv_output_move (rtx dest, rtx src) -+{ -+ enum rtx_code dest_code, src_code; -+ enum machine_mode mode; -+ bool dbl_p; -+ -+ dest_code = GET_CODE (dest); -+ src_code = GET_CODE (src); -+ mode = GET_MODE (dest); -+ dbl_p = (GET_MODE_SIZE (mode) == 8); -+ -+ if (dbl_p && riscv_split_64bit_move_p (dest, src)) -+ return "#"; -+ -+ if ((src_code == REG && GP_REG_P (REGNO (src))) -+ || (src == CONST0_RTX (mode))) -+ { -+ if (dest_code == REG) -+ { -+ if (GP_REG_P (REGNO (dest))) -+ return "mv\t%0,%z1"; -+ -+ if (FP_REG_P (REGNO (dest))) -+ { -+ if (!dbl_p) -+ return "fmv.s.x\t%0,%z1"; -+ if (TARGET_64BIT) -+ return "fmv.d.x\t%0,%z1"; -+ /* in RV32, we can emulate fmv.d.x %0, x0 using fcvt.d.w */ -+ gcc_assert (src == CONST0_RTX (mode)); -+ return "fcvt.d.w\t%0,x0"; -+ } -+ } -+ if (dest_code == MEM) -+ switch (GET_MODE_SIZE (mode)) -+ { -+ case 1: return "sb\t%z1,%0"; -+ case 2: return "sh\t%z1,%0"; -+ case 4: return "sw\t%z1,%0"; -+ case 8: return "sd\t%z1,%0"; -+ } -+ } -+ if (dest_code == REG && GP_REG_P (REGNO (dest))) -+ { -+ if (src_code == REG) -+ { -+ if (FP_REG_P (REGNO (src))) -+ return dbl_p ? "fmv.x.d\t%0,%1" : "fmv.x.s\t%0,%1"; -+ } -+ -+ if (src_code == MEM) -+ switch (GET_MODE_SIZE (mode)) -+ { -+ case 1: return "lbu\t%0,%1"; -+ case 2: return "lhu\t%0,%1"; -+ case 4: return "lw\t%0,%1"; -+ case 8: return "ld\t%0,%1"; -+ } -+ -+ if (src_code == CONST_INT) -+ return "li\t%0,%1"; -+ -+ if (src_code == HIGH) -+ return "lui\t%0,%h1"; -+ -+ if (symbolic_operand (src, VOIDmode)) -+ switch (riscv_classify_symbolic_expression (src)) -+ { -+ case SYMBOL_GOT_DISP: return "la\t%0,%1"; -+ case SYMBOL_ABSOLUTE: return "lla\t%0,%1"; -+ default: gcc_unreachable(); -+ } -+ } -+ if (src_code == REG && FP_REG_P (REGNO (src))) -+ { -+ if (dest_code == REG && FP_REG_P (REGNO (dest))) -+ return dbl_p ? "fmv.d\t%0,%1" : "fmv.s\t%0,%1"; -+ -+ if (dest_code == MEM) -+ return dbl_p ? "fsd\t%1,%0" : "fsw\t%1,%0"; -+ } -+ if (dest_code == REG && FP_REG_P (REGNO (dest))) -+ { -+ if (src_code == MEM) -+ return dbl_p ? "fld\t%0,%1" : "flw\t%0,%1"; -+ } -+ gcc_unreachable (); -+} -+ -+/* Return true if CMP1 is a suitable second operand for integer ordering -+ test CODE. See also the *sCC patterns in riscv.md. */ -+ -+static bool -+riscv_int_order_operand_ok_p (enum rtx_code code, rtx cmp1) -+{ -+ switch (code) -+ { -+ case GT: -+ case GTU: -+ return reg_or_0_operand (cmp1, VOIDmode); -+ -+ case GE: -+ case GEU: -+ return cmp1 == const1_rtx; -+ -+ case LT: -+ case LTU: -+ return arith_operand (cmp1, VOIDmode); -+ -+ case LE: -+ return sle_operand (cmp1, VOIDmode); -+ -+ case LEU: -+ return sleu_operand (cmp1, VOIDmode); -+ -+ default: -+ gcc_unreachable (); -+ } -+} -+ -+/* Return true if *CMP1 (of mode MODE) is a valid second operand for -+ integer ordering test *CODE, or if an equivalent combination can -+ be formed by adjusting *CODE and *CMP1. When returning true, update -+ *CODE and *CMP1 with the chosen code and operand, otherwise leave -+ them alone. */ -+ -+static bool -+riscv_canonicalize_int_order_test (enum rtx_code *code, rtx *cmp1, -+ enum machine_mode mode) -+{ -+ HOST_WIDE_INT plus_one; -+ -+ if (riscv_int_order_operand_ok_p (*code, *cmp1)) -+ return true; -+ -+ if (CONST_INT_P (*cmp1)) -+ switch (*code) -+ { -+ case LE: -+ plus_one = trunc_int_for_mode (UINTVAL (*cmp1) + 1, mode); -+ if (INTVAL (*cmp1) < plus_one) -+ { -+ *code = LT; -+ *cmp1 = force_reg (mode, GEN_INT (plus_one)); -+ return true; -+ } -+ break; -+ -+ case LEU: -+ plus_one = trunc_int_for_mode (UINTVAL (*cmp1) + 1, mode); -+ if (plus_one != 0) -+ { -+ *code = LTU; -+ *cmp1 = force_reg (mode, GEN_INT (plus_one)); -+ return true; -+ } -+ break; -+ -+ default: -+ break; -+ } -+ return false; -+} -+ -+/* Compare CMP0 and CMP1 using ordering test CODE and store the result -+ in TARGET. CMP0 and TARGET are register_operands. If INVERT_PTR -+ is nonnull, it's OK to set TARGET to the inverse of the result and -+ flip *INVERT_PTR instead. */ -+ -+static void -+riscv_emit_int_order_test (enum rtx_code code, bool *invert_ptr, -+ rtx target, rtx cmp0, rtx cmp1) -+{ -+ enum machine_mode mode; -+ -+ /* First see if there is a RISCV instruction that can do this operation. -+ If not, try doing the same for the inverse operation. If that also -+ fails, force CMP1 into a register and try again. */ -+ mode = GET_MODE (cmp0); -+ if (riscv_canonicalize_int_order_test (&code, &cmp1, mode)) -+ riscv_emit_binary (code, target, cmp0, cmp1); -+ else -+ { -+ enum rtx_code inv_code = reverse_condition (code); -+ if (!riscv_canonicalize_int_order_test (&inv_code, &cmp1, mode)) -+ { -+ cmp1 = force_reg (mode, cmp1); -+ riscv_emit_int_order_test (code, invert_ptr, target, cmp0, cmp1); -+ } -+ else if (invert_ptr == 0) -+ { -+ rtx inv_target; -+ -+ inv_target = riscv_force_binary (GET_MODE (target), -+ inv_code, cmp0, cmp1); -+ riscv_emit_binary (XOR, target, inv_target, const1_rtx); -+ } -+ else -+ { -+ *invert_ptr = !*invert_ptr; -+ riscv_emit_binary (inv_code, target, cmp0, cmp1); -+ } -+ } -+} -+ -+/* Return a register that is zero iff CMP0 and CMP1 are equal. -+ The register will have the same mode as CMP0. */ -+ -+static rtx -+riscv_zero_if_equal (rtx cmp0, rtx cmp1) -+{ -+ if (cmp1 == const0_rtx) -+ return cmp0; -+ -+ return expand_binop (GET_MODE (cmp0), sub_optab, -+ cmp0, cmp1, 0, 0, OPTAB_DIRECT); -+} -+ -+/* Return false if we can easily emit code for the FP comparison specified -+ by *CODE. If not, set *CODE to its inverse and return true. */ -+ -+static bool -+riscv_reversed_fp_cond (enum rtx_code *code) -+{ -+ switch (*code) -+ { -+ case EQ: -+ case LT: -+ case LE: -+ case GT: -+ case GE: -+ case LTGT: -+ case ORDERED: -+ /* We know how to emit code for these cases... */ -+ return false; -+ -+ default: -+ /* ...but we must invert these and rely on the others. */ -+ *code = reverse_condition_maybe_unordered (*code); -+ return true; -+ } -+} -+ -+/* Convert a comparison into something that can be used in a branch or -+ conditional move. On entry, *OP0 and *OP1 are the values being -+ compared and *CODE is the code used to compare them. -+ -+ Update *CODE, *OP0 and *OP1 so that they describe the final comparison. */ -+ -+static void -+riscv_emit_compare (enum rtx_code *code, rtx *op0, rtx *op1) -+{ -+ rtx cmp_op0 = *op0; -+ rtx cmp_op1 = *op1; -+ -+ if (GET_MODE_CLASS (GET_MODE (*op0)) == MODE_INT) -+ { -+ if (splittable_const_int_operand (cmp_op1, VOIDmode)) -+ { -+ HOST_WIDE_INT rhs = INTVAL (cmp_op1), new_rhs; -+ enum rtx_code new_code; -+ -+ switch (*code) -+ { -+ case LTU: new_rhs = rhs - 1; new_code = LEU; goto try_new_rhs; -+ case LEU: new_rhs = rhs + 1; new_code = LTU; goto try_new_rhs; -+ case GTU: new_rhs = rhs + 1; new_code = GEU; goto try_new_rhs; -+ case GEU: new_rhs = rhs - 1; new_code = GTU; goto try_new_rhs; -+ case LT: new_rhs = rhs - 1; new_code = LE; goto try_new_rhs; -+ case LE: new_rhs = rhs + 1; new_code = LT; goto try_new_rhs; -+ case GT: new_rhs = rhs + 1; new_code = GE; goto try_new_rhs; -+ case GE: new_rhs = rhs - 1; new_code = GT; -+ try_new_rhs: -+ /* Convert e.g. OP0 > 4095 into OP0 >= 4096. */ -+ if ((rhs < 0) == (new_rhs < 0) -+ && riscv_integer_cost (new_rhs) < riscv_integer_cost (rhs)) -+ { -+ *op1 = GEN_INT (new_rhs); -+ *code = new_code; -+ } -+ break; -+ -+ case EQ: -+ case NE: -+ /* Convert e.g. OP0 == 2048 into OP0 - 2048 == 0. */ -+ if (SMALL_OPERAND (-rhs)) -+ { -+ *op0 = gen_reg_rtx (GET_MODE (cmp_op0)); -+ riscv_emit_binary (PLUS, *op0, cmp_op0, GEN_INT (-rhs)); -+ *op1 = const0_rtx; -+ } -+ default: -+ break; -+ } -+ } -+ -+ if (*op1 != const0_rtx) -+ *op1 = force_reg (GET_MODE (cmp_op0), *op1); -+ } -+ else -+ { -+ /* For FP comparisons, set an integer register with the result of the -+ comparison, then branch on it. */ -+ rtx tmp0, tmp1, final_op; -+ enum rtx_code fp_code = *code; -+ *code = riscv_reversed_fp_cond (&fp_code) ? EQ : NE; -+ -+ switch (fp_code) -+ { -+ case ORDERED: -+ /* a == a && b == b */ -+ tmp0 = gen_reg_rtx (SImode); -+ riscv_emit_binary (EQ, tmp0, cmp_op0, cmp_op0); -+ tmp1 = gen_reg_rtx (SImode); -+ riscv_emit_binary (EQ, tmp1, cmp_op1, cmp_op1); -+ final_op = gen_reg_rtx (SImode); -+ riscv_emit_binary (AND, final_op, tmp0, tmp1); -+ break; -+ -+ case LTGT: -+ /* a < b || a > b */ -+ tmp0 = gen_reg_rtx (SImode); -+ riscv_emit_binary (LT, tmp0, cmp_op0, cmp_op1); -+ tmp1 = gen_reg_rtx (SImode); -+ riscv_emit_binary (GT, tmp1, cmp_op0, cmp_op1); -+ final_op = gen_reg_rtx (SImode); -+ riscv_emit_binary (IOR, final_op, tmp0, tmp1); -+ break; -+ -+ case EQ: -+ case LE: -+ case LT: -+ case GE: -+ case GT: -+ /* We have instructions for these cases. */ -+ final_op = gen_reg_rtx (SImode); -+ riscv_emit_binary (fp_code, final_op, cmp_op0, cmp_op1); -+ break; -+ -+ default: -+ gcc_unreachable (); -+ } -+ -+ /* Compare the binary result against 0. */ -+ *op0 = final_op; -+ *op1 = const0_rtx; -+ } -+} -+ -+/* Try performing the comparison in OPERANDS[1], whose arms are OPERANDS[2] -+ and OPERAND[3]. Store the result in OPERANDS[0]. -+ -+ On 64-bit targets, the mode of the comparison and target will always be -+ SImode, thus possibly narrower than that of the comparison's operands. */ -+ -+void -+riscv_expand_scc (rtx operands[]) -+{ -+ rtx target = operands[0]; -+ enum rtx_code code = GET_CODE (operands[1]); -+ rtx op0 = operands[2]; -+ rtx op1 = operands[3]; -+ -+ gcc_assert (GET_MODE_CLASS (GET_MODE (op0)) == MODE_INT); -+ -+ if (code == EQ || code == NE) -+ { -+ rtx zie = riscv_zero_if_equal (op0, op1); -+ riscv_emit_binary (code, target, zie, const0_rtx); -+ } -+ else -+ riscv_emit_int_order_test (code, 0, target, op0, op1); -+} -+ -+/* Compare OPERANDS[1] with OPERANDS[2] using comparison code -+ CODE and jump to OPERANDS[3] if the condition holds. */ -+ -+void -+riscv_expand_conditional_branch (rtx *operands) -+{ -+ enum rtx_code code = GET_CODE (operands[0]); -+ rtx op0 = operands[1]; -+ rtx op1 = operands[2]; -+ rtx condition; -+ -+ riscv_emit_compare (&code, &op0, &op1); -+ condition = gen_rtx_fmt_ee (code, VOIDmode, op0, op1); -+ emit_jump_insn (gen_condjump (condition, operands[3])); -+} -+ -+/* Implement TARGET_FUNCTION_ARG_BOUNDARY. Every parameter gets at -+ least PARM_BOUNDARY bits of alignment, but will be given anything up -+ to STACK_BOUNDARY bits if the type requires it. */ -+ -+static unsigned int -+riscv_function_arg_boundary (enum machine_mode mode, const_tree type) -+{ -+ unsigned int alignment; -+ -+ alignment = type ? TYPE_ALIGN (type) : GET_MODE_ALIGNMENT (mode); -+ if (alignment < PARM_BOUNDARY) -+ alignment = PARM_BOUNDARY; -+ if (alignment > STACK_BOUNDARY) -+ alignment = STACK_BOUNDARY; -+ return alignment; -+} -+ -+/* Fill INFO with information about a single argument. CUM is the -+ cumulative state for earlier arguments. MODE is the mode of this -+ argument and TYPE is its type (if known). NAMED is true if this -+ is a named (fixed) argument rather than a variable one. */ -+ -+static void -+riscv_get_arg_info (struct riscv_arg_info *info, const CUMULATIVE_ARGS *cum, -+ enum machine_mode mode, const_tree type, bool named) -+{ -+ bool doubleword_aligned_p; -+ unsigned int num_bytes, num_words, max_regs; -+ -+ /* Work out the size of the argument. */ -+ num_bytes = type ? int_size_in_bytes (type) : GET_MODE_SIZE (mode); -+ num_words = (num_bytes + UNITS_PER_WORD - 1) / UNITS_PER_WORD; -+ -+ /* Scalar, complex and vector floating-point types are passed in -+ floating-point registers, as long as this is a named rather -+ than a variable argument. */ -+ info->fpr_p = (named -+ && (type == 0 || FLOAT_TYPE_P (type)) -+ && (GET_MODE_CLASS (mode) == MODE_FLOAT -+ || GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT -+ || GET_MODE_CLASS (mode) == MODE_VECTOR_FLOAT) -+ && GET_MODE_UNIT_SIZE (mode) <= UNITS_PER_FPVALUE); -+ -+ /* Complex floats should only go into FPRs if there are two FPRs free, -+ otherwise they should be passed in the same way as a struct -+ containing two floats. */ -+ if (info->fpr_p -+ && GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT -+ && GET_MODE_UNIT_SIZE (mode) < UNITS_PER_FPVALUE) -+ { -+ if (cum->num_gprs >= MAX_ARGS_IN_REGISTERS - 1) -+ info->fpr_p = false; -+ else -+ num_words = 2; -+ } -+ -+ /* See whether the argument has doubleword alignment. */ -+ doubleword_aligned_p = (riscv_function_arg_boundary (mode, type) -+ > BITS_PER_WORD); -+ -+ /* Set REG_OFFSET to the register count we're interested in. -+ The EABI allocates the floating-point registers separately, -+ but the other ABIs allocate them like integer registers. */ -+ info->reg_offset = cum->num_gprs; -+ -+ /* Advance to an even register if the argument is doubleword-aligned. */ -+ if (doubleword_aligned_p) -+ info->reg_offset += info->reg_offset & 1; -+ -+ /* Work out the offset of a stack argument. */ -+ info->stack_offset = cum->stack_words; -+ if (doubleword_aligned_p) -+ info->stack_offset += info->stack_offset & 1; -+ -+ max_regs = MAX_ARGS_IN_REGISTERS - info->reg_offset; -+ -+ /* Partition the argument between registers and stack. */ -+ info->reg_words = MIN (num_words, max_regs); -+ info->stack_words = num_words - info->reg_words; -+} -+ -+/* INFO describes a register argument that has the normal format for the -+ argument's mode. Return the register it uses, assuming that FPRs are -+ available if HARD_FLOAT_P. */ -+ -+static unsigned int -+riscv_arg_regno (const struct riscv_arg_info *info, bool hard_float_p) -+{ -+ if (!info->fpr_p || !hard_float_p) -+ return GP_ARG_FIRST + info->reg_offset; -+ else -+ return FP_ARG_FIRST + info->reg_offset; -+} -+ -+/* Implement TARGET_FUNCTION_ARG. */ -+ -+static rtx -+riscv_function_arg (cumulative_args_t cum_v, enum machine_mode mode, -+ const_tree type, bool named) -+{ -+ CUMULATIVE_ARGS *cum = get_cumulative_args (cum_v); -+ struct riscv_arg_info info; -+ -+ if (mode == VOIDmode) -+ return NULL; -+ -+ riscv_get_arg_info (&info, cum, mode, type, named); -+ -+ /* Return straight away if the whole argument is passed on the stack. */ -+ if (info.reg_offset == MAX_ARGS_IN_REGISTERS) -+ return NULL; -+ -+ /* The n32 and n64 ABIs say that if any 64-bit chunk of the structure -+ contains a double in its entirety, then that 64-bit chunk is passed -+ in a floating-point register. */ -+ if (TARGET_HARD_FLOAT -+ && named -+ && type != 0 -+ && TREE_CODE (type) == RECORD_TYPE -+ && TYPE_SIZE_UNIT (type) -+ && host_integerp (TYPE_SIZE_UNIT (type), 1)) -+ //&& tree_fits_uhwi_p (TYPE_SIZE_UNIT (type))) -+ { -+ tree field; -+ -+ /* First check to see if there is any such field. */ -+ for (field = TYPE_FIELDS (type); field; field = DECL_CHAIN (field)) -+ if (TREE_CODE (field) == FIELD_DECL -+ && SCALAR_FLOAT_TYPE_P (TREE_TYPE (field)) -+ && TYPE_PRECISION (TREE_TYPE (field)) == BITS_PER_WORD -+ && host_integerp (bit_position (field), 0) -+ //&& tree_fits_shwi_p (bit_position (field)) -+ && int_bit_position (field) % BITS_PER_WORD == 0) -+ break; -+ -+ if (field != 0) -+ { -+ /* Now handle the special case by returning a PARALLEL -+ indicating where each 64-bit chunk goes. INFO.REG_WORDS -+ chunks are passed in registers. */ -+ unsigned int i; -+ HOST_WIDE_INT bitpos; -+ rtx ret; -+ -+ /* assign_parms checks the mode of ENTRY_PARM, so we must -+ use the actual mode here. */ -+ ret = gen_rtx_PARALLEL (mode, rtvec_alloc (info.reg_words)); -+ -+ bitpos = 0; -+ field = TYPE_FIELDS (type); -+ for (i = 0; i < info.reg_words; i++) -+ { -+ rtx reg; -+ -+ for (; field; field = DECL_CHAIN (field)) -+ if (TREE_CODE (field) == FIELD_DECL -+ && int_bit_position (field) >= bitpos) -+ break; -+ -+ if (field -+ && int_bit_position (field) == bitpos -+ && SCALAR_FLOAT_TYPE_P (TREE_TYPE (field)) -+ && TYPE_PRECISION (TREE_TYPE (field)) == BITS_PER_WORD) -+ reg = gen_rtx_REG (DFmode, FP_ARG_FIRST + info.reg_offset + i); -+ else -+ reg = gen_rtx_REG (DImode, GP_ARG_FIRST + info.reg_offset + i); -+ -+ XVECEXP (ret, 0, i) -+ = gen_rtx_EXPR_LIST (VOIDmode, reg, -+ GEN_INT (bitpos / BITS_PER_UNIT)); -+ -+ bitpos += BITS_PER_WORD; -+ } -+ return ret; -+ } -+ } -+ -+ /* Handle the n32/n64 conventions for passing complex floating-point -+ arguments in FPR pairs. The real part goes in the lower register -+ and the imaginary part goes in the upper register. */ -+ if (info.fpr_p -+ && GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT) -+ { -+ rtx real, imag; -+ enum machine_mode inner; -+ unsigned int regno; -+ -+ inner = GET_MODE_INNER (mode); -+ regno = FP_ARG_FIRST + info.reg_offset; -+ if (info.reg_words * UNITS_PER_WORD == GET_MODE_SIZE (inner)) -+ { -+ /* Real part in registers, imaginary part on stack. */ -+ gcc_assert (info.stack_words == info.reg_words); -+ return gen_rtx_REG (inner, regno); -+ } -+ else -+ { -+ gcc_assert (info.stack_words == 0); -+ real = gen_rtx_EXPR_LIST (VOIDmode, -+ gen_rtx_REG (inner, regno), -+ const0_rtx); -+ imag = gen_rtx_EXPR_LIST (VOIDmode, -+ gen_rtx_REG (inner, -+ regno + info.reg_words / 2), -+ GEN_INT (GET_MODE_SIZE (inner))); -+ return gen_rtx_PARALLEL (mode, gen_rtvec (2, real, imag)); -+ } -+ } -+ -+ return gen_rtx_REG (mode, riscv_arg_regno (&info, TARGET_HARD_FLOAT)); -+} -+ -+/* Implement TARGET_FUNCTION_ARG_ADVANCE. */ -+ -+static void -+riscv_function_arg_advance (cumulative_args_t cum_v, enum machine_mode mode, -+ const_tree type, bool named) -+{ -+ CUMULATIVE_ARGS *cum = get_cumulative_args (cum_v); -+ struct riscv_arg_info info; -+ -+ riscv_get_arg_info (&info, cum, mode, type, named); -+ -+ /* Advance the register count. This has the effect of setting -+ num_gprs to MAX_ARGS_IN_REGISTERS if a doubleword-aligned -+ argument required us to skip the final GPR and pass the whole -+ argument on the stack. */ -+ cum->num_gprs = info.reg_offset + info.reg_words; -+ -+ /* Advance the stack word count. */ -+ if (info.stack_words > 0) -+ cum->stack_words = info.stack_offset + info.stack_words; -+} -+ -+/* Implement TARGET_ARG_PARTIAL_BYTES. */ -+ -+static int -+riscv_arg_partial_bytes (cumulative_args_t cum, -+ enum machine_mode mode, tree type, bool named) -+{ -+ struct riscv_arg_info info; -+ -+ riscv_get_arg_info (&info, get_cumulative_args (cum), mode, type, named); -+ return info.stack_words > 0 ? info.reg_words * UNITS_PER_WORD : 0; -+} -+ -+/* See whether VALTYPE is a record whose fields should be returned in -+ floating-point registers. If so, return the number of fields and -+ list them in FIELDS (which should have two elements). Return 0 -+ otherwise. -+ -+ For n32 & n64, a structure with one or two fields is returned in -+ floating-point registers as long as every field has a floating-point -+ type. */ -+ -+static int -+riscv_fpr_return_fields (const_tree valtype, tree *fields) -+{ -+ tree field; -+ int i; -+ -+ if (TREE_CODE (valtype) != RECORD_TYPE) -+ return 0; -+ -+ i = 0; -+ for (field = TYPE_FIELDS (valtype); field != 0; field = DECL_CHAIN (field)) -+ { -+ if (TREE_CODE (field) != FIELD_DECL) -+ continue; -+ -+ if (!SCALAR_FLOAT_TYPE_P (TREE_TYPE (field))) -+ return 0; -+ -+ if (i == 2) -+ return 0; -+ -+ fields[i++] = field; -+ } -+ return i; -+} -+ -+/* Return true if the function return value MODE will get returned in a -+ floating-point register. */ -+ -+static bool -+riscv_return_mode_in_fpr_p (enum machine_mode mode) -+{ -+ return ((GET_MODE_CLASS (mode) == MODE_FLOAT -+ || GET_MODE_CLASS (mode) == MODE_VECTOR_FLOAT -+ || GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT) -+ && GET_MODE_UNIT_SIZE (mode) <= UNITS_PER_HWFPVALUE); -+} -+ -+/* Return the representation of an FPR return register when the -+ value being returned in FP_RETURN has mode VALUE_MODE and the -+ return type itself has mode TYPE_MODE. On NewABI targets, -+ the two modes may be different for structures like: -+ -+ struct __attribute__((packed)) foo { float f; } -+ -+ where we return the SFmode value of "f" in FP_RETURN, but where -+ the structure itself has mode BLKmode. */ -+ -+static rtx -+riscv_return_fpr_single (enum machine_mode type_mode, -+ enum machine_mode value_mode) -+{ -+ rtx x; -+ -+ x = gen_rtx_REG (value_mode, FP_RETURN); -+ if (type_mode != value_mode) -+ { -+ x = gen_rtx_EXPR_LIST (VOIDmode, x, const0_rtx); -+ x = gen_rtx_PARALLEL (type_mode, gen_rtvec (1, x)); -+ } -+ return x; -+} -+ -+/* Return a composite value in a pair of floating-point registers. -+ MODE1 and OFFSET1 are the mode and byte offset for the first value, -+ likewise MODE2 and OFFSET2 for the second. MODE is the mode of the -+ complete value. -+ -+ For n32 & n64, $f0 always holds the first value and $f2 the second. -+ Otherwise the values are packed together as closely as possible. */ -+ -+static rtx -+riscv_return_fpr_pair (enum machine_mode mode, -+ enum machine_mode mode1, HOST_WIDE_INT offset1, -+ enum machine_mode mode2, HOST_WIDE_INT offset2) -+{ -+ return gen_rtx_PARALLEL -+ (mode, -+ gen_rtvec (2, -+ gen_rtx_EXPR_LIST (VOIDmode, -+ gen_rtx_REG (mode1, FP_RETURN), -+ GEN_INT (offset1)), -+ gen_rtx_EXPR_LIST (VOIDmode, -+ gen_rtx_REG (mode2, FP_RETURN + 1), -+ GEN_INT (offset2)))); -+ -+} -+ -+/* Implement FUNCTION_VALUE and LIBCALL_VALUE. For normal calls, -+ VALTYPE is the return type and MODE is VOIDmode. For libcalls, -+ VALTYPE is null and MODE is the mode of the return value. */ -+ -+rtx -+riscv_function_value (const_tree valtype, const_tree func, enum machine_mode mode) -+{ -+ if (valtype) -+ { -+ tree fields[2]; -+ int unsigned_p; -+ -+ mode = TYPE_MODE (valtype); -+ unsigned_p = TYPE_UNSIGNED (valtype); -+ -+ /* Since TARGET_PROMOTE_FUNCTION_MODE unconditionally promotes, -+ return values, promote the mode here too. */ -+ mode = promote_function_mode (valtype, mode, &unsigned_p, func, 1); -+ -+ /* Handle structures whose fields are returned in $f0/$f2. */ -+ switch (riscv_fpr_return_fields (valtype, fields)) -+ { -+ case 1: -+ return riscv_return_fpr_single (mode, -+ TYPE_MODE (TREE_TYPE (fields[0]))); -+ -+ case 2: -+ return riscv_return_fpr_pair (mode, -+ TYPE_MODE (TREE_TYPE (fields[0])), -+ int_byte_position (fields[0]), -+ TYPE_MODE (TREE_TYPE (fields[1])), -+ int_byte_position (fields[1])); -+ } -+ -+ /* Only use FPRs for scalar, complex or vector types. */ -+ if (!FLOAT_TYPE_P (valtype)) -+ return gen_rtx_REG (mode, GP_RETURN); -+ } -+ -+ /* Handle long doubles for n32 & n64. */ -+ if (mode == TFmode) -+ return riscv_return_fpr_pair (mode, -+ DImode, 0, -+ DImode, GET_MODE_SIZE (mode) / 2); -+ -+ if (riscv_return_mode_in_fpr_p (mode)) -+ { -+ if (GET_MODE_CLASS (mode) == MODE_COMPLEX_FLOAT) -+ return riscv_return_fpr_pair (mode, -+ GET_MODE_INNER (mode), 0, -+ GET_MODE_INNER (mode), -+ GET_MODE_SIZE (mode) / 2); -+ else -+ return gen_rtx_REG (mode, FP_RETURN); -+ } -+ -+ return gen_rtx_REG (mode, GP_RETURN); -+} -+ -+/* Implement TARGET_RETURN_IN_MEMORY. Scalars and small structures -+ that fit in two registers are returned in a0/a1. */ -+ -+static bool -+riscv_return_in_memory (const_tree type, const_tree fndecl ATTRIBUTE_UNUSED) -+{ -+ return !IN_RANGE (int_size_in_bytes (type), 0, 2 * UNITS_PER_WORD); -+} -+ -+/* Implement TARGET_PASS_BY_REFERENCE. */ -+ -+static bool -+riscv_pass_by_reference (cumulative_args_t cum ATTRIBUTE_UNUSED, -+ enum machine_mode mode, const_tree type, -+ bool named ATTRIBUTE_UNUSED) -+{ -+ if (type && riscv_return_in_memory (type, NULL_TREE)) -+ return true; -+ return targetm.calls.must_pass_in_stack (mode, type); -+} -+ -+/* Implement TARGET_SETUP_INCOMING_VARARGS. */ -+ -+static void -+riscv_setup_incoming_varargs (cumulative_args_t cum, enum machine_mode mode, -+ tree type, int *pretend_size ATTRIBUTE_UNUSED, -+ int no_rtl) -+{ -+ CUMULATIVE_ARGS local_cum; -+ int gp_saved; -+ -+ /* The caller has advanced CUM up to, but not beyond, the last named -+ argument. Advance a local copy of CUM past the last "real" named -+ argument, to find out how many registers are left over. */ -+ local_cum = *get_cumulative_args (cum); -+ riscv_function_arg_advance (pack_cumulative_args (&local_cum), mode, type, 1); -+ -+ /* Found out how many registers we need to save. */ -+ gp_saved = MAX_ARGS_IN_REGISTERS - local_cum.num_gprs; -+ -+ if (!no_rtl && gp_saved > 0) -+ { -+ rtx ptr, mem; -+ -+ ptr = plus_constant (Pmode, virtual_incoming_args_rtx, -+ REG_PARM_STACK_SPACE (cfun->decl) -+ - gp_saved * UNITS_PER_WORD); -+ mem = gen_frame_mem (BLKmode, ptr); -+ set_mem_alias_set (mem, get_varargs_alias_set ()); -+ -+ move_block_from_reg (local_cum.num_gprs + GP_ARG_FIRST, -+ mem, gp_saved); -+ } -+ if (REG_PARM_STACK_SPACE (cfun->decl) == 0) -+ cfun->machine->varargs_size = gp_saved * UNITS_PER_WORD; -+} -+ -+/* Implement TARGET_EXPAND_BUILTIN_VA_START. */ -+ -+static void -+riscv_va_start (tree valist, rtx nextarg) -+{ -+ nextarg = plus_constant (Pmode, nextarg, -cfun->machine->varargs_size); -+ std_expand_builtin_va_start (valist, nextarg); -+} -+ -+/* Expand a call of type TYPE. RESULT is where the result will go (null -+ for "call"s and "sibcall"s), ADDR is the address of the function, -+ ARGS_SIZE is the size of the arguments and AUX is the value passed -+ to us by riscv_function_arg. Return the call itself. */ -+ -+rtx -+riscv_expand_call (bool sibcall_p, rtx result, rtx addr, rtx args_size) -+{ -+ rtx pattern; -+ -+ if (!call_insn_operand (addr, VOIDmode)) -+ { -+ rtx reg = RISCV_EPILOGUE_TEMP (Pmode); -+ riscv_emit_move (reg, addr); -+ addr = reg; -+ } -+ -+ if (result == 0) -+ { -+ rtx (*fn) (rtx, rtx); -+ -+ if (sibcall_p) -+ fn = gen_sibcall_internal; -+ else -+ fn = gen_call_internal; -+ -+ pattern = fn (addr, args_size); -+ } -+ else if (GET_CODE (result) == PARALLEL && XVECLEN (result, 0) == 2) -+ { -+ /* Handle return values created by riscv_return_fpr_pair. */ -+ rtx (*fn) (rtx, rtx, rtx, rtx); -+ rtx reg1, reg2; -+ -+ if (sibcall_p) -+ fn = gen_sibcall_value_multiple_internal; -+ else -+ fn = gen_call_value_multiple_internal; -+ -+ reg1 = XEXP (XVECEXP (result, 0, 0), 0); -+ reg2 = XEXP (XVECEXP (result, 0, 1), 0); -+ pattern = fn (reg1, addr, args_size, reg2); -+ } -+ else -+ { -+ rtx (*fn) (rtx, rtx, rtx); -+ -+ if (sibcall_p) -+ fn = gen_sibcall_value_internal; -+ else -+ fn = gen_call_value_internal; -+ -+ /* Handle return values created by riscv_return_fpr_single. */ -+ if (GET_CODE (result) == PARALLEL && XVECLEN (result, 0) == 1) -+ result = XEXP (XVECEXP (result, 0, 0), 0); -+ pattern = fn (result, addr, args_size); -+ } -+ -+ return emit_call_insn (pattern); -+} -+ -+/* Emit straight-line code to move LENGTH bytes from SRC to DEST. -+ Assume that the areas do not overlap. */ -+ -+static void -+riscv_block_move_straight (rtx dest, rtx src, HOST_WIDE_INT length) -+{ -+ HOST_WIDE_INT offset, delta; -+ unsigned HOST_WIDE_INT bits; -+ int i; -+ enum machine_mode mode; -+ rtx *regs; -+ -+ bits = MAX( BITS_PER_UNIT, -+ MIN( BITS_PER_WORD, MIN( MEM_ALIGN(src),MEM_ALIGN(dest) ) ) ); -+ -+ mode = mode_for_size (bits, MODE_INT, 0); -+ delta = bits / BITS_PER_UNIT; -+ -+ /* Allocate a buffer for the temporary registers. */ -+ regs = XALLOCAVEC (rtx, length / delta); -+ -+ /* Load as many BITS-sized chunks as possible. Use a normal load if -+ the source has enough alignment, otherwise use left/right pairs. */ -+ for (offset = 0, i = 0; offset + delta <= length; offset += delta, i++) -+ { -+ regs[i] = gen_reg_rtx (mode); -+ riscv_emit_move (regs[i], adjust_address (src, mode, offset)); -+ } -+ -+ /* Copy the chunks to the destination. */ -+ for (offset = 0, i = 0; offset + delta <= length; offset += delta, i++) -+ riscv_emit_move (adjust_address (dest, mode, offset), regs[i]); -+ -+ /* Mop up any left-over bytes. */ -+ if (offset < length) -+ { -+ src = adjust_address (src, BLKmode, offset); -+ dest = adjust_address (dest, BLKmode, offset); -+ move_by_pieces (dest, src, length - offset, -+ MIN (MEM_ALIGN (src), MEM_ALIGN (dest)), 0); -+ } -+} -+ -+/* Helper function for doing a loop-based block operation on memory -+ reference MEM. Each iteration of the loop will operate on LENGTH -+ bytes of MEM. -+ -+ Create a new base register for use within the loop and point it to -+ the start of MEM. Create a new memory reference that uses this -+ register. Store them in *LOOP_REG and *LOOP_MEM respectively. */ -+ -+static void -+riscv_adjust_block_mem (rtx mem, HOST_WIDE_INT length, -+ rtx *loop_reg, rtx *loop_mem) -+{ -+ *loop_reg = copy_addr_to_reg (XEXP (mem, 0)); -+ -+ /* Although the new mem does not refer to a known location, -+ it does keep up to LENGTH bytes of alignment. */ -+ *loop_mem = change_address (mem, BLKmode, *loop_reg); -+ set_mem_align (*loop_mem, MIN (MEM_ALIGN (mem), length * BITS_PER_UNIT)); -+} -+ -+/* Move LENGTH bytes from SRC to DEST using a loop that moves BYTES_PER_ITER -+ bytes at a time. LENGTH must be at least BYTES_PER_ITER. Assume that -+ the memory regions do not overlap. */ -+ -+static void -+riscv_block_move_loop (rtx dest, rtx src, HOST_WIDE_INT length, -+ HOST_WIDE_INT bytes_per_iter) -+{ -+ rtx label, src_reg, dest_reg, final_src, test; -+ HOST_WIDE_INT leftover; -+ -+ leftover = length % bytes_per_iter; -+ length -= leftover; -+ -+ /* Create registers and memory references for use within the loop. */ -+ riscv_adjust_block_mem (src, bytes_per_iter, &src_reg, &src); -+ riscv_adjust_block_mem (dest, bytes_per_iter, &dest_reg, &dest); -+ -+ /* Calculate the value that SRC_REG should have after the last iteration -+ of the loop. */ -+ final_src = expand_simple_binop (Pmode, PLUS, src_reg, GEN_INT (length), -+ 0, 0, OPTAB_WIDEN); -+ -+ /* Emit the start of the loop. */ -+ label = gen_label_rtx (); -+ emit_label (label); -+ -+ /* Emit the loop body. */ -+ riscv_block_move_straight (dest, src, bytes_per_iter); -+ -+ /* Move on to the next block. */ -+ riscv_emit_move (src_reg, plus_constant (Pmode, src_reg, bytes_per_iter)); -+ riscv_emit_move (dest_reg, plus_constant (Pmode, dest_reg, bytes_per_iter)); -+ -+ /* Emit the loop condition. */ -+ test = gen_rtx_NE (VOIDmode, src_reg, final_src); -+ if (Pmode == DImode) -+ emit_jump_insn (gen_cbranchdi4 (test, src_reg, final_src, label)); -+ else -+ emit_jump_insn (gen_cbranchsi4 (test, src_reg, final_src, label)); -+ -+ /* Mop up any left-over bytes. */ -+ if (leftover) -+ riscv_block_move_straight (dest, src, leftover); -+} -+ -+/* Expand a movmemsi instruction, which copies LENGTH bytes from -+ memory reference SRC to memory reference DEST. */ -+ -+bool -+riscv_expand_block_move (rtx dest, rtx src, rtx length) -+{ -+ if (CONST_INT_P (length)) -+ { -+ HOST_WIDE_INT factor, align; -+ -+ align = MIN (MIN (MEM_ALIGN (src), MEM_ALIGN (dest)), BITS_PER_WORD); -+ factor = BITS_PER_WORD / align; -+ -+ if (INTVAL (length) <= RISCV_MAX_MOVE_BYTES_STRAIGHT / factor) -+ { -+ riscv_block_move_straight (dest, src, INTVAL (length)); -+ return true; -+ } -+ else if (optimize && align >= BITS_PER_WORD) -+ { -+ riscv_block_move_loop (dest, src, INTVAL (length), -+ RISCV_MAX_MOVE_BYTES_PER_LOOP_ITER / factor); -+ return true; -+ } -+ } -+ return false; -+} -+ -+/* (Re-)Initialize riscv_lo_relocs and riscv_hi_relocs. */ -+ -+static void -+riscv_init_relocs (void) -+{ -+ memset (riscv_hi_relocs, '\0', sizeof (riscv_hi_relocs)); -+ memset (riscv_lo_relocs, '\0', sizeof (riscv_lo_relocs)); -+ -+ if (!flag_pic && riscv_cmodel == CM_MEDLOW) -+ { -+ riscv_hi_relocs[SYMBOL_ABSOLUTE] = "%hi("; -+ riscv_lo_relocs[SYMBOL_ABSOLUTE] = "%lo("; -+ } -+ -+ if (!flag_pic || flag_pie) -+ { -+ riscv_hi_relocs[SYMBOL_TLS_LE] = "%tprel_hi("; -+ riscv_lo_relocs[SYMBOL_TLS_LE] = "%tprel_lo("; -+ } -+} -+ -+/* Print symbolic operand OP, which is part of a HIGH or LO_SUM -+ in context CONTEXT. RELOCS is the array of relocations to use. */ -+ -+static void -+riscv_print_operand_reloc (FILE *file, rtx op, const char **relocs) -+{ -+ enum riscv_symbol_type symbol_type; -+ const char *p; -+ -+ symbol_type = riscv_classify_symbolic_expression (op); -+ gcc_assert (relocs[symbol_type]); -+ -+ fputs (relocs[symbol_type], file); -+ output_addr_const (file, riscv_strip_unspec_address (op)); -+ for (p = relocs[symbol_type]; *p != 0; p++) -+ if (*p == '(') -+ fputc (')', file); -+} -+ -+static const char * -+riscv_memory_model_suffix (enum memmodel model) -+{ -+ switch (model) -+ { -+ case MEMMODEL_ACQ_REL: -+ case MEMMODEL_SEQ_CST: -+ return ".sc"; -+ case MEMMODEL_ACQUIRE: -+ case MEMMODEL_CONSUME: -+ return ".aq"; -+ case MEMMODEL_RELEASE: -+ return ".rl"; -+ case MEMMODEL_RELAXED: -+ return ""; -+ default: gcc_unreachable(); -+ } -+} -+ -+/* Implement TARGET_PRINT_OPERAND. The RISCV-specific operand codes are: -+ -+ 'h' Print the high-part relocation associated with OP, after stripping -+ any outermost HIGH. -+ 'R' Print the low-part relocation associated with OP. -+ 'C' Print the integer branch condition for comparison OP. -+ 'A' Print the atomic operation suffix for memory model OP. -+ 'z' Print $0 if OP is zero, otherwise print OP normally. */ -+ -+static void -+riscv_print_operand (FILE *file, rtx op, int letter) -+{ -+ enum rtx_code code; -+ -+ gcc_assert (op); -+ code = GET_CODE (op); -+ -+ switch (letter) -+ { -+ case 'h': -+ if (code == HIGH) -+ op = XEXP (op, 0); -+ riscv_print_operand_reloc (file, op, riscv_hi_relocs); -+ break; -+ -+ case 'R': -+ riscv_print_operand_reloc (file, op, riscv_lo_relocs); -+ break; -+ -+ case 'C': -+ /* The RTL names match the instruction names. */ -+ fputs (GET_RTX_NAME (code), file); -+ break; -+ -+ case 'A': -+ fputs (riscv_memory_model_suffix ((enum memmodel)INTVAL (op)), file); -+ break; -+ -+ default: -+ switch (code) -+ { -+ case REG: -+ if (letter && letter != 'z') -+ output_operand_lossage ("invalid use of '%%%c'", letter); -+ fprintf (file, "%s", reg_names[REGNO (op)]); -+ break; -+ -+ case MEM: -+ if (letter == 'y') -+ fprintf (file, "%s", reg_names[REGNO(XEXP(op, 0))]); -+ else if (letter && letter != 'z') -+ output_operand_lossage ("invalid use of '%%%c'", letter); -+ else -+ output_address (XEXP (op, 0)); -+ break; -+ -+ default: -+ if (letter == 'z' && op == CONST0_RTX (GET_MODE (op))) -+ fputs (reg_names[GP_REG_FIRST], file); -+ else if (letter && letter != 'z') -+ output_operand_lossage ("invalid use of '%%%c'", letter); -+ else -+ output_addr_const (file, riscv_strip_unspec_address (op)); -+ break; -+ } -+ } -+} -+ -+/* Implement TARGET_PRINT_OPERAND_ADDRESS. */ -+ -+static void -+riscv_print_operand_address (FILE *file, rtx x) -+{ -+ struct riscv_address_info addr; -+ -+ if (riscv_classify_address (&addr, x, word_mode, true)) -+ switch (addr.type) -+ { -+ case ADDRESS_REG: -+ riscv_print_operand (file, addr.offset, 0); -+ fprintf (file, "(%s)", reg_names[REGNO (addr.reg)]); -+ return; -+ -+ case ADDRESS_LO_SUM: -+ riscv_print_operand_reloc (file, addr.offset, riscv_lo_relocs); -+ fprintf (file, "(%s)", reg_names[REGNO (addr.reg)]); -+ return; -+ -+ case ADDRESS_CONST_INT: -+ output_addr_const (file, x); -+ fprintf (file, "(%s)", reg_names[GP_REG_FIRST]); -+ return; -+ -+ case ADDRESS_SYMBOLIC: -+ output_addr_const (file, riscv_strip_unspec_address (x)); -+ return; -+ } -+ gcc_unreachable (); -+} -+ -+static bool -+riscv_size_ok_for_small_data_p (int size) -+{ -+ return g_switch_value && IN_RANGE (size, 1, g_switch_value); -+} -+ -+/* Return true if EXP should be placed in the small data section. */ -+ -+static bool -+riscv_in_small_data_p (const_tree x) -+{ -+ if (TREE_CODE (x) == STRING_CST || TREE_CODE (x) == FUNCTION_DECL) -+ return false; -+ -+ if (TREE_CODE (x) == VAR_DECL && DECL_SECTION_NAME (x)) -+ { -+ const char *sec = TREE_STRING_POINTER (DECL_SECTION_NAME (x)); -+ return strcmp (sec, ".sdata") == 0 || strcmp (sec, ".sbss") == 0; -+ } -+ -+ return riscv_size_ok_for_small_data_p (int_size_in_bytes (TREE_TYPE (x))); -+} -+ -+/* Return a section for X, handling small data. */ -+ -+static section * -+riscv_elf_select_rtx_section (enum machine_mode mode, rtx x, -+ unsigned HOST_WIDE_INT align) -+{ -+ section *s = default_elf_select_rtx_section (mode, x, align); -+ -+ if (riscv_size_ok_for_small_data_p (GET_MODE_SIZE (mode))) -+ { -+ if (strncmp (s->named.name, ".rodata.cst", strlen (".rodata.cst")) == 0) -+ { -+ /* Rename .rodata.cst* to .srodata.cst*. */ -+ char name[32]; -+ sprintf (name, ".s%s", s->named.name + 1); -+ return get_section (name, s->named.common.flags, NULL); -+ } -+ -+ if (s == data_section) -+ return sdata_section; -+ } -+ -+ return s; -+} -+ -+/* Implement TARGET_ASM_OUTPUT_DWARF_DTPREL. */ -+ -+static void ATTRIBUTE_UNUSED -+riscv_output_dwarf_dtprel (FILE *file, int size, rtx x) -+{ -+ switch (size) -+ { -+ case 4: -+ fputs ("\t.dtprelword\t", file); -+ break; -+ -+ case 8: -+ fputs ("\t.dtpreldword\t", file); -+ break; -+ -+ default: -+ gcc_unreachable (); -+ } -+ output_addr_const (file, x); -+ fputs ("+0x800", file); -+} -+ -+/* Make the last instruction frame-related and note that it performs -+ the operation described by FRAME_PATTERN. */ -+ -+static void -+riscv_set_frame_expr (rtx frame_pattern) -+{ -+ rtx insn; -+ -+ insn = get_last_insn (); -+ RTX_FRAME_RELATED_P (insn) = 1; -+ REG_NOTES (insn) = alloc_EXPR_LIST (REG_FRAME_RELATED_EXPR, -+ frame_pattern, -+ REG_NOTES (insn)); -+} -+ -+/* Return a frame-related rtx that stores REG at MEM. -+ REG must be a single register. */ -+ -+static rtx -+riscv_frame_set (rtx mem, rtx reg) -+{ -+ rtx set; -+ -+ set = gen_rtx_SET (VOIDmode, mem, reg); -+ RTX_FRAME_RELATED_P (set) = 1; -+ -+ return set; -+} -+ -+/* Return true if the current function must save register REGNO. */ -+ -+static bool -+riscv_save_reg_p (unsigned int regno) -+{ -+ bool call_saved = !global_regs[regno] && !call_really_used_regs[regno]; -+ bool might_clobber = crtl->saves_all_registers -+ || df_regs_ever_live_p (regno) -+ || (regno == HARD_FRAME_POINTER_REGNUM -+ && frame_pointer_needed); -+ -+ return (call_saved && might_clobber) -+ || (regno == RETURN_ADDR_REGNUM && crtl->calls_eh_return); -+} -+ -+/* Populate the current function's riscv_frame_info structure. -+ -+ RISC-V stack frames grown downward. High addresses are at the top. -+ -+ +-------------------------------+ -+ | | -+ | incoming stack arguments | -+ | | -+ +-------------------------------+ <-- incoming stack pointer -+ | | -+ | callee-allocated save area | -+ | for arguments that are | -+ | split between registers and | -+ | the stack | -+ | | -+ +-------------------------------+ <-- arg_pointer_rtx -+ | | -+ | callee-allocated save area | -+ | for register varargs | -+ | | -+ +-------------------------------+ <-- hard_frame_pointer_rtx; -+ | | stack_pointer_rtx + gp_sp_offset -+ | GPR save area | + UNITS_PER_WORD -+ | | -+ +-------------------------------+ <-- stack_pointer_rtx + fp_sp_offset -+ | | + UNITS_PER_HWVALUE -+ | FPR save area | -+ | | -+ +-------------------------------+ <-- frame_pointer_rtx (virtual) -+ | | -+ | local variables | -+ | | -+ P +-------------------------------+ -+ | | -+ | outgoing stack arguments | -+ | | -+ +-------------------------------+ <-- stack_pointer_rtx -+ -+ Dynamic stack allocations such as alloca insert data at point P. -+ They decrease stack_pointer_rtx but leave frame_pointer_rtx and -+ hard_frame_pointer_rtx unchanged. */ -+ -+static void -+riscv_compute_frame_info (void) -+{ -+ struct riscv_frame_info *frame; -+ HOST_WIDE_INT offset; -+ unsigned int regno, i; -+ -+ frame = &cfun->machine->frame; -+ memset (frame, 0, sizeof (*frame)); -+ -+ /* Find out which GPRs we need to save. */ -+ for (regno = GP_REG_FIRST; regno <= GP_REG_LAST; regno++) -+ if (riscv_save_reg_p (regno)) -+ frame->mask |= 1 << (regno - GP_REG_FIRST); -+ -+ /* If this function calls eh_return, we must also save and restore the -+ EH data registers. */ -+ if (crtl->calls_eh_return) -+ for (i = 0; EH_RETURN_DATA_REGNO (i) != INVALID_REGNUM; i++) -+ frame->mask |= 1 << (EH_RETURN_DATA_REGNO (i) - GP_REG_FIRST); -+ -+ /* Find out which FPRs we need to save. This loop must iterate over -+ the same space as its companion in riscv_for_each_saved_gpr_and_fpr. */ -+ if (TARGET_HARD_FLOAT) -+ for (regno = FP_REG_FIRST; regno <= FP_REG_LAST; regno++) -+ if (riscv_save_reg_p (regno)) -+ frame->fmask |= 1 << (regno - FP_REG_FIRST); -+ -+ /* At the bottom of the frame are any outgoing stack arguments. */ -+ offset = crtl->outgoing_args_size; -+ /* Next are local stack variables. */ -+ offset += RISCV_STACK_ALIGN (get_frame_size ()); -+ /* The virtual frame pointer points above the local variables. */ -+ frame->frame_pointer_offset = offset; -+ /* Next are the callee-saved FPRs. */ -+ if (frame->fmask) -+ { -+ unsigned num_saved = __builtin_popcount(frame->fmask); -+ offset += RISCV_STACK_ALIGN (num_saved * UNITS_PER_FPREG); -+ frame->fp_sp_offset = offset - UNITS_PER_HWFPVALUE; -+ } -+ /* Next are the callee-saved GPRs. */ -+ if (frame->mask) -+ { -+ unsigned num_saved = __builtin_popcount(frame->mask); -+ offset += RISCV_STACK_ALIGN (num_saved * UNITS_PER_WORD); -+ frame->gp_sp_offset = offset - UNITS_PER_WORD; -+ } -+ /* The hard frame pointer points above the callee-saved GPRs. */ -+ frame->hard_frame_pointer_offset = offset; -+ /* Above the hard frame pointer is the callee-allocated varags save area. */ -+ offset += RISCV_STACK_ALIGN (cfun->machine->varargs_size); -+ frame->arg_pointer_offset = offset; -+ /* Next is the callee-allocated area for pretend stack arguments. */ -+ offset += crtl->args.pretend_args_size; -+ frame->total_size = offset; -+ /* Next points the incoming stack pointer and any incoming arguments. */ -+} -+ -+/* Make sure that we're not trying to eliminate to the wrong hard frame -+ pointer. */ -+ -+static bool -+riscv_can_eliminate (const int from ATTRIBUTE_UNUSED, const int to) -+{ -+ return (to == HARD_FRAME_POINTER_REGNUM || to == STACK_POINTER_REGNUM); -+} -+ -+/* Implement INITIAL_ELIMINATION_OFFSET. FROM is either the frame pointer -+ or argument pointer. TO is either the stack pointer or hard frame -+ pointer. */ -+ -+HOST_WIDE_INT -+riscv_initial_elimination_offset (int from, int to) -+{ -+ HOST_WIDE_INT src, dest; -+ -+ riscv_compute_frame_info (); -+ -+ if (to == HARD_FRAME_POINTER_REGNUM) -+ dest = cfun->machine->frame.hard_frame_pointer_offset; -+ else if (to == STACK_POINTER_REGNUM) -+ dest = 0; /* this is the base of all offsets */ -+ else -+ gcc_unreachable (); -+ -+ if (from == FRAME_POINTER_REGNUM) -+ src = cfun->machine->frame.frame_pointer_offset; -+ else if (from == ARG_POINTER_REGNUM) -+ src = cfun->machine->frame.arg_pointer_offset; -+ else -+ gcc_unreachable (); -+ -+ return src - dest; -+} -+ -+/* Implement RETURN_ADDR_RTX. We do not support moving back to a -+ previous frame. */ -+ -+rtx -+riscv_return_addr (int count, rtx frame ATTRIBUTE_UNUSED) -+{ -+ if (count != 0) -+ return const0_rtx; -+ -+ return get_hard_reg_initial_val (Pmode, RETURN_ADDR_REGNUM); -+} -+ -+/* Emit code to change the current function's return address to -+ ADDRESS. SCRATCH is available as a scratch register, if needed. -+ ADDRESS and SCRATCH are both word-mode GPRs. */ -+ -+void -+riscv_set_return_address (rtx address, rtx scratch) -+{ -+ rtx slot_address; -+ -+ gcc_assert (BITSET_P (cfun->machine->frame.mask, RETURN_ADDR_REGNUM)); -+ slot_address = riscv_add_offset (scratch, stack_pointer_rtx, -+ cfun->machine->frame.gp_sp_offset); -+ riscv_emit_move (gen_frame_mem (GET_MODE (address), slot_address), address); -+} -+ -+/* A function to save or store a register. The first argument is the -+ register and the second is the stack slot. */ -+typedef void (*riscv_save_restore_fn) (rtx, rtx); -+ -+/* Use FN to save or restore register REGNO. MODE is the register's -+ mode and OFFSET is the offset of its save slot from the current -+ stack pointer. */ -+ -+static void -+riscv_save_restore_reg (enum machine_mode mode, int regno, -+ HOST_WIDE_INT offset, riscv_save_restore_fn fn) -+{ -+ rtx mem; -+ -+ mem = gen_frame_mem (mode, plus_constant (Pmode, stack_pointer_rtx, offset)); -+ fn (gen_rtx_REG (mode, regno), mem); -+} -+ -+/* Call FN for each register that is saved by the current function. -+ SP_OFFSET is the offset of the current stack pointer from the start -+ of the frame. */ -+ -+static void -+riscv_for_each_saved_gpr_and_fpr (HOST_WIDE_INT sp_offset, -+ riscv_save_restore_fn fn) -+{ -+ HOST_WIDE_INT offset; -+ int regno; -+ -+ /* Save the link register and s-registers. */ -+ offset = cfun->machine->frame.gp_sp_offset - sp_offset; -+ for (regno = GP_REG_FIRST; regno <= GP_REG_LAST-1; regno++) -+ if (BITSET_P (cfun->machine->frame.mask, regno - GP_REG_FIRST)) -+ { -+ riscv_save_restore_reg (word_mode, regno, offset, fn); -+ offset -= UNITS_PER_WORD; -+ } -+ -+ /* This loop must iterate over the same space as its companion in -+ riscv_compute_frame_info. */ -+ offset = cfun->machine->frame.fp_sp_offset - sp_offset; -+ for (regno = FP_REG_FIRST; regno <= FP_REG_LAST; regno++) -+ if (BITSET_P (cfun->machine->frame.fmask, regno - FP_REG_FIRST)) -+ { -+ riscv_save_restore_reg (DFmode, regno, offset, fn); -+ offset -= GET_MODE_SIZE (DFmode); -+ } -+} -+ -+/* Emit a move from SRC to DEST, given that one of them is a register -+ save slot and that the other is a register. TEMP is a temporary -+ GPR of the same mode that is available if need be. */ -+ -+static void -+riscv_emit_save_slot_move (rtx dest, rtx src, rtx temp) -+{ -+ unsigned int regno; -+ rtx mem; -+ enum reg_class rclass; -+ -+ if (REG_P (src)) -+ { -+ regno = REGNO (src); -+ mem = dest; -+ } -+ else -+ { -+ regno = REGNO (dest); -+ mem = src; -+ } -+ -+ rclass = riscv_secondary_reload_class (REGNO_REG_CLASS (regno), -+ GET_MODE (mem), mem, mem == src); -+ -+ if (rclass == NO_REGS) -+ riscv_emit_move (dest, src); -+ else -+ { -+ gcc_assert (!reg_overlap_mentioned_p (dest, temp)); -+ riscv_emit_move (temp, src); -+ riscv_emit_move (dest, temp); -+ } -+ if (MEM_P (dest)) -+ riscv_set_frame_expr (riscv_frame_set (dest, src)); -+} -+ -+/* Save register REG to MEM. Make the instruction frame-related. */ -+ -+static void -+riscv_save_reg (rtx reg, rtx mem) -+{ -+ riscv_emit_save_slot_move (mem, reg, RISCV_PROLOGUE_TEMP (GET_MODE (reg))); -+} -+ -+ -+/* Expand the "prologue" pattern. */ -+ -+void -+riscv_expand_prologue (void) -+{ -+ const struct riscv_frame_info *frame; -+ HOST_WIDE_INT size; -+ rtx insn; -+ -+ frame = &cfun->machine->frame; -+ size = frame->total_size; -+ -+ if (flag_stack_usage_info) -+ current_function_static_stack_size = size; -+ -+ /* Save the registers. Allocate up to RISCV_MAX_FIRST_STACK_STEP -+ bytes beforehand; this is enough to cover the register save area -+ without going out of range. */ -+ if ((frame->mask | frame->fmask) != 0) -+ { -+ HOST_WIDE_INT step1; -+ -+ step1 = MIN (size, RISCV_MAX_FIRST_STACK_STEP); -+ insn = gen_add3_insn (stack_pointer_rtx, -+ stack_pointer_rtx, -+ GEN_INT (-step1)); -+ RTX_FRAME_RELATED_P (emit_insn (insn)) = 1; -+ size -= step1; -+ riscv_for_each_saved_gpr_and_fpr (size, riscv_save_reg); -+ } -+ -+ /* Set up the frame pointer, if we're using one. */ -+ if (frame_pointer_needed) -+ { -+ insn = gen_add3_insn (hard_frame_pointer_rtx, stack_pointer_rtx, -+ GEN_INT (frame->hard_frame_pointer_offset - size)); -+ RTX_FRAME_RELATED_P (emit_insn (insn)) = 1; -+ } -+ -+ /* Allocate the rest of the frame. */ -+ if (size > 0) -+ { -+ if (SMALL_OPERAND (-size)) -+ RTX_FRAME_RELATED_P (emit_insn (gen_add3_insn (stack_pointer_rtx, -+ stack_pointer_rtx, -+ GEN_INT (-size)))) = 1; -+ else -+ { -+ riscv_emit_move (RISCV_PROLOGUE_TEMP (Pmode), GEN_INT (size)); -+ emit_insn (gen_sub3_insn (stack_pointer_rtx, -+ stack_pointer_rtx, -+ RISCV_PROLOGUE_TEMP (Pmode))); -+ -+ /* Describe the combined effect of the previous instructions. */ -+ riscv_set_frame_expr -+ (gen_rtx_SET (VOIDmode, stack_pointer_rtx, -+ plus_constant (Pmode, stack_pointer_rtx, -size))); -+ } -+ } -+} -+ -+/* Emit instructions to restore register REG from slot MEM. */ -+ -+static void -+riscv_restore_reg (rtx reg, rtx mem) -+{ -+ riscv_emit_save_slot_move (reg, mem, RISCV_EPILOGUE_TEMP (GET_MODE (reg))); -+} -+ -+/* Expand an "epilogue" or "sibcall_epilogue" pattern; SIBCALL_P -+ says which. */ -+ -+void -+riscv_expand_epilogue (bool sibcall_p) -+{ -+ const struct riscv_frame_info *frame; -+ HOST_WIDE_INT step1, step2; -+ -+ if (!sibcall_p && riscv_can_use_return_insn ()) -+ { -+ emit_jump_insn (gen_return ()); -+ return; -+ } -+ -+ /* Split the frame into two. STEP1 is the amount of stack we should -+ deallocate before restoring the registers. STEP2 is the amount we -+ should deallocate afterwards. -+ -+ Start off by assuming that no registers need to be restored. */ -+ frame = &cfun->machine->frame; -+ step1 = frame->total_size; -+ step2 = 0; -+ -+ /* Move past any dynamic stack allocations. */ -+ if (cfun->calls_alloca) -+ { -+ rtx adjust = GEN_INT (-frame->hard_frame_pointer_offset); -+ if (!SMALL_INT (adjust)) -+ { -+ riscv_emit_move (RISCV_EPILOGUE_TEMP (Pmode), adjust); -+ adjust = RISCV_EPILOGUE_TEMP (Pmode); -+ } -+ -+ emit_insn (gen_add3_insn (stack_pointer_rtx, hard_frame_pointer_rtx, adjust)); -+ } -+ -+ /* If we need to restore registers, deallocate as much stack as -+ possible in the second step without going out of range. */ -+ if ((frame->mask | frame->fmask) != 0) -+ { -+ step2 = MIN (step1, RISCV_MAX_FIRST_STACK_STEP); -+ step1 -= step2; -+ } -+ -+ /* Set TARGET to BASE + STEP1. */ -+ if (step1 > 0) -+ { -+ /* Get an rtx for STEP1 that we can add to BASE. */ -+ rtx adjust = GEN_INT (step1); -+ if (!SMALL_OPERAND (step1)) -+ { -+ riscv_emit_move (RISCV_EPILOGUE_TEMP (Pmode), adjust); -+ adjust = RISCV_EPILOGUE_TEMP (Pmode); -+ } -+ -+ emit_insn (gen_add3_insn (stack_pointer_rtx, stack_pointer_rtx, adjust)); -+ } -+ -+ /* Restore the registers. */ -+ riscv_for_each_saved_gpr_and_fpr (frame->total_size - step2, -+ riscv_restore_reg); -+ -+ /* Deallocate the final bit of the frame. */ -+ if (step2 > 0) -+ emit_insn (gen_add3_insn (stack_pointer_rtx, stack_pointer_rtx, -+ GEN_INT (step2))); -+ -+ /* Add in the __builtin_eh_return stack adjustment. */ -+ if (crtl->calls_eh_return) -+ emit_insn (gen_add3_insn (stack_pointer_rtx, stack_pointer_rtx, -+ EH_RETURN_STACKADJ_RTX)); -+ -+ if (!sibcall_p) -+ { -+ rtx ra = gen_rtx_REG (Pmode, RETURN_ADDR_REGNUM); -+ emit_jump_insn (gen_simple_return_internal (ra)); -+ } -+} -+ -+/* Return nonzero if this function is known to have a null epilogue. -+ This allows the optimizer to omit jumps to jumps if no stack -+ was created. */ -+ -+bool -+riscv_can_use_return_insn (void) -+{ -+ return reload_completed && cfun->machine->frame.total_size == 0; -+} -+ -+/* Return true if register REGNO can store a value of mode MODE. -+ The result of this function is cached in riscv_hard_regno_mode_ok. */ -+ -+static bool -+riscv_hard_regno_mode_ok_p (unsigned int regno, enum machine_mode mode) -+{ -+ unsigned int size = GET_MODE_SIZE (mode); -+ enum mode_class mclass = GET_MODE_CLASS (mode); -+ -+ /* This is hella bogus but ira_build segfaults on RV32 without it. */ -+ if (VECTOR_MODE_P (mode)) -+ return true; -+ -+ if (GP_REG_P (regno)) -+ { -+ if (size <= UNITS_PER_WORD) -+ return true; -+ -+ /* Double-word values must be even-register-aligned. */ -+ if (size <= 2 * UNITS_PER_WORD) -+ return regno % 2 == 0; -+ } -+ -+ if (FP_REG_P (regno)) -+ { -+ if (mclass == MODE_FLOAT -+ || mclass == MODE_COMPLEX_FLOAT -+ || mclass == MODE_VECTOR_FLOAT) -+ return size <= UNITS_PER_FPVALUE; -+ } -+ -+ return false; -+} -+ -+/* Implement HARD_REGNO_NREGS. */ -+ -+unsigned int -+riscv_hard_regno_nregs (int regno, enum machine_mode mode) -+{ -+ if (FP_REG_P (regno)) -+ return (GET_MODE_SIZE (mode) + UNITS_PER_FPREG - 1) / UNITS_PER_FPREG; -+ -+ /* All other registers are word-sized. */ -+ return (GET_MODE_SIZE (mode) + UNITS_PER_WORD - 1) / UNITS_PER_WORD; -+} -+ -+/* Implement CLASS_MAX_NREGS, taking the maximum of the cases -+ in riscv_hard_regno_nregs. */ -+ -+int -+riscv_class_max_nregs (enum reg_class rclass, enum machine_mode mode) -+{ -+ int size; -+ HARD_REG_SET left; -+ -+ size = 0x8000; -+ COPY_HARD_REG_SET (left, reg_class_contents[(int) rclass]); -+ if (hard_reg_set_intersect_p (left, reg_class_contents[(int) FP_REGS])) -+ { -+ size = MIN (size, UNITS_PER_FPREG); -+ AND_COMPL_HARD_REG_SET (left, reg_class_contents[(int) FP_REGS]); -+ } -+ if (!hard_reg_set_empty_p (left)) -+ size = MIN (size, UNITS_PER_WORD); -+ return (GET_MODE_SIZE (mode) + size - 1) / size; -+} -+ -+/* Implement TARGET_PREFERRED_RELOAD_CLASS. */ -+ -+static reg_class_t -+riscv_preferred_reload_class (rtx x ATTRIBUTE_UNUSED, reg_class_t rclass) -+{ -+ return reg_class_subset_p (FP_REGS, rclass) ? FP_REGS : -+ reg_class_subset_p (GR_REGS, rclass) ? GR_REGS : -+ rclass; -+} -+ -+/* RCLASS is a class involved in a REGISTER_MOVE_COST calculation. -+ Return a "canonical" class to represent it in later calculations. */ -+ -+static reg_class_t -+riscv_canonicalize_move_class (reg_class_t rclass) -+{ -+ if (reg_class_subset_p (rclass, GENERAL_REGS)) -+ rclass = GENERAL_REGS; -+ -+ return rclass; -+} -+ -+/* Implement TARGET_REGISTER_MOVE_COST. Return 0 for classes that are the -+ maximum of the move costs for subclasses; regclass will work out -+ the maximum for us. */ -+ -+static int -+riscv_register_move_cost (enum machine_mode mode ATTRIBUTE_UNUSED, -+ reg_class_t from, reg_class_t to) -+{ -+ from = riscv_canonicalize_move_class (from); -+ to = riscv_canonicalize_move_class (to); -+ -+ if ((from == GENERAL_REGS && to == GENERAL_REGS) -+ || (from == GENERAL_REGS && to == FP_REGS) -+ || (from == FP_REGS && to == FP_REGS)) -+ return COSTS_N_INSNS (1); -+ -+ if (from == FP_REGS && to == GENERAL_REGS) -+ return tune_info->fp_to_int_cost; -+ -+ return 0; -+} -+ -+/* Implement TARGET_MEMORY_MOVE_COST. */ -+ -+static int -+riscv_memory_move_cost (enum machine_mode mode, reg_class_t rclass, bool in) -+{ -+ return (tune_info->memory_cost -+ + memory_move_secondary_cost (mode, rclass, in)); -+} -+ -+/* Return the register class required for a secondary register when -+ copying between one of the registers in RCLASS and value X, which -+ has mode MODE. X is the source of the move if IN_P, otherwise it -+ is the destination. Return NO_REGS if no secondary register is -+ needed. */ -+ -+enum reg_class -+riscv_secondary_reload_class (enum reg_class rclass, -+ enum machine_mode mode, rtx x, -+ bool in_p ATTRIBUTE_UNUSED) -+{ -+ int regno; -+ -+ regno = true_regnum (x); -+ -+ if (reg_class_subset_p (rclass, FP_REGS)) -+ { -+ if (MEM_P (x) && (GET_MODE_SIZE (mode) == 4 || GET_MODE_SIZE (mode) == 8)) -+ /* We can use flw/fld/fsw/fsd. */ -+ return NO_REGS; -+ -+ if (GP_REG_P (regno) || x == CONST0_RTX (mode)) -+ /* We can use fmv or go through memory when mode > Pmode. */ -+ return NO_REGS; -+ -+ if (CONSTANT_P (x) && !targetm.cannot_force_const_mem (mode, x)) -+ /* We can force the constant to memory and use flw/fld. */ -+ return NO_REGS; -+ -+ if (FP_REG_P (regno)) -+ /* We can use fmv.fmt. */ -+ return NO_REGS; -+ -+ /* Otherwise, we need to reload through an integer register. */ -+ return GR_REGS; -+ } -+ if (FP_REG_P (regno)) -+ return reg_class_subset_p (rclass, GR_REGS) ? NO_REGS : GR_REGS; -+ -+ return NO_REGS; -+} -+ -+/* Implement TARGET_MODE_REP_EXTENDED. */ -+ -+static int -+riscv_mode_rep_extended (enum machine_mode mode, enum machine_mode mode_rep) -+{ -+ /* On 64-bit targets, SImode register values are sign-extended to DImode. */ -+ if (TARGET_64BIT && mode == SImode && mode_rep == DImode) -+ return SIGN_EXTEND; -+ -+ return UNKNOWN; -+} -+ -+/* Implement TARGET_SCALAR_MODE_SUPPORTED_P. */ -+ -+static bool -+riscv_scalar_mode_supported_p (enum machine_mode mode) -+{ -+ if (ALL_FIXED_POINT_MODE_P (mode) -+ && GET_MODE_PRECISION (mode) <= 2 * BITS_PER_WORD) -+ return true; -+ -+ return default_scalar_mode_supported_p (mode); -+} -+ -+/* Implement TARGET_SCHED_ADJUST_COST. We assume that anti and output -+ dependencies have no cost. */ -+ -+static int -+riscv_adjust_cost (rtx insn ATTRIBUTE_UNUSED, rtx link, -+ rtx dep ATTRIBUTE_UNUSED, int cost) -+{ -+ if (REG_NOTE_KIND (link) != 0) -+ return 0; -+ return cost; -+} -+ -+/* Return the number of instructions that can be issued per cycle. */ -+ -+static int -+riscv_issue_rate (void) -+{ -+ return tune_info->issue_rate; -+} -+ -+/* This structure describes a single built-in function. */ -+struct riscv_builtin_description { -+ /* The code of the main .md file instruction. See riscv_builtin_type -+ for more information. */ -+ enum insn_code icode; -+ -+ /* The name of the built-in function. */ -+ const char *name; -+ -+ /* Specifies how the function should be expanded. */ -+ enum riscv_builtin_type builtin_type; -+ -+ /* The function's prototype. */ -+ enum riscv_function_type function_type; -+ -+ /* Whether the function is available. */ -+ unsigned int (*avail) (void); -+}; -+ -+static unsigned int -+riscv_builtin_avail_riscv (void) -+{ -+ return 1; -+} -+ -+/* Construct a riscv_builtin_description from the given arguments. -+ -+ INSN is the name of the associated instruction pattern, without the -+ leading CODE_FOR_riscv_. -+ -+ CODE is the floating-point condition code associated with the -+ function. It can be 'f' if the field is not applicable. -+ -+ NAME is the name of the function itself, without the leading -+ "__builtin_riscv_". -+ -+ BUILTIN_TYPE and FUNCTION_TYPE are riscv_builtin_description fields. -+ -+ AVAIL is the name of the availability predicate, without the leading -+ riscv_builtin_avail_. */ -+#define RISCV_BUILTIN(INSN, NAME, BUILTIN_TYPE, FUNCTION_TYPE, AVAIL) \ -+ { CODE_FOR_ ## INSN, "__builtin_riscv_" NAME, \ -+ BUILTIN_TYPE, FUNCTION_TYPE, riscv_builtin_avail_ ## AVAIL } -+ -+/* Define __builtin_riscv_, which is a RISCV_BUILTIN_DIRECT function -+ mapped to instruction CODE_FOR_, FUNCTION_TYPE and AVAIL -+ are as for RISCV_BUILTIN. */ -+#define DIRECT_BUILTIN(INSN, FUNCTION_TYPE, AVAIL) \ -+ RISCV_BUILTIN (INSN, #INSN, RISCV_BUILTIN_DIRECT, FUNCTION_TYPE, AVAIL) -+ -+/* Define __builtin_riscv_, which is a RISCV_BUILTIN_DIRECT_NO_TARGET -+ function mapped to instruction CODE_FOR_, FUNCTION_TYPE -+ and AVAIL are as for RISCV_BUILTIN. */ -+#define DIRECT_NO_TARGET_BUILTIN(INSN, FUNCTION_TYPE, AVAIL) \ -+ RISCV_BUILTIN (INSN, #INSN, RISCV_BUILTIN_DIRECT_NO_TARGET, \ -+ FUNCTION_TYPE, AVAIL) -+ -+static const struct riscv_builtin_description riscv_builtins[] = { -+ DIRECT_NO_TARGET_BUILTIN (nop, RISCV_VOID_FTYPE_VOID, riscv), -+}; -+ -+/* Index I is the function declaration for riscv_builtins[I], or null if the -+ function isn't defined on this target. */ -+static GTY(()) tree riscv_builtin_decls[ARRAY_SIZE (riscv_builtins)]; -+ -+ -+/* Source-level argument types. */ -+#define RISCV_ATYPE_VOID void_type_node -+#define RISCV_ATYPE_INT integer_type_node -+#define RISCV_ATYPE_POINTER ptr_type_node -+#define RISCV_ATYPE_CPOINTER const_ptr_type_node -+ -+/* Standard mode-based argument types. */ -+#define RISCV_ATYPE_UQI unsigned_intQI_type_node -+#define RISCV_ATYPE_SI intSI_type_node -+#define RISCV_ATYPE_USI unsigned_intSI_type_node -+#define RISCV_ATYPE_DI intDI_type_node -+#define RISCV_ATYPE_UDI unsigned_intDI_type_node -+#define RISCV_ATYPE_SF float_type_node -+#define RISCV_ATYPE_DF double_type_node -+ -+/* RISCV_FTYPE_ATYPESN takes N RISCV_FTYPES-like type codes and lists -+ their associated RISCV_ATYPEs. */ -+#define RISCV_FTYPE_ATYPES1(A, B) \ -+ RISCV_ATYPE_##A, RISCV_ATYPE_##B -+ -+#define RISCV_FTYPE_ATYPES2(A, B, C) \ -+ RISCV_ATYPE_##A, RISCV_ATYPE_##B, RISCV_ATYPE_##C -+ -+#define RISCV_FTYPE_ATYPES3(A, B, C, D) \ -+ RISCV_ATYPE_##A, RISCV_ATYPE_##B, RISCV_ATYPE_##C, RISCV_ATYPE_##D -+ -+#define RISCV_FTYPE_ATYPES4(A, B, C, D, E) \ -+ RISCV_ATYPE_##A, RISCV_ATYPE_##B, RISCV_ATYPE_##C, RISCV_ATYPE_##D, \ -+ RISCV_ATYPE_##E -+ -+/* Return the function type associated with function prototype TYPE. */ -+ -+static tree -+riscv_build_function_type (enum riscv_function_type type) -+{ -+ static tree types[(int) RISCV_MAX_FTYPE_MAX]; -+ -+ if (types[(int) type] == NULL_TREE) -+ switch (type) -+ { -+#define DEF_RISCV_FTYPE(NUM, ARGS) \ -+ case RISCV_FTYPE_NAME##NUM ARGS: \ -+ types[(int) type] \ -+ = build_function_type_list (RISCV_FTYPE_ATYPES##NUM ARGS, \ -+ NULL_TREE); \ -+ break; -+#include "config/riscv/riscv-ftypes.def" -+#undef DEF_RISCV_FTYPE -+ default: -+ gcc_unreachable (); -+ } -+ -+ return types[(int) type]; -+} -+ -+/* Implement TARGET_INIT_BUILTINS. */ -+ -+static void -+riscv_init_builtins (void) -+{ -+ const struct riscv_builtin_description *d; -+ unsigned int i; -+ -+ /* Iterate through all of the bdesc arrays, initializing all of the -+ builtin functions. */ -+ for (i = 0; i < ARRAY_SIZE (riscv_builtins); i++) -+ { -+ d = &riscv_builtins[i]; -+ if (d->avail ()) -+ riscv_builtin_decls[i] -+ = add_builtin_function (d->name, -+ riscv_build_function_type (d->function_type), -+ i, BUILT_IN_MD, NULL, NULL); -+ } -+} -+ -+/* Implement TARGET_BUILTIN_DECL. */ -+ -+static tree -+riscv_builtin_decl (unsigned int code, bool initialize_p ATTRIBUTE_UNUSED) -+{ -+ if (code >= ARRAY_SIZE (riscv_builtins)) -+ return error_mark_node; -+ return riscv_builtin_decls[code]; -+} -+ -+/* Take argument ARGNO from EXP's argument list and convert it into a -+ form suitable for input operand OPNO of instruction ICODE. Return the -+ value. */ -+ -+static rtx -+riscv_prepare_builtin_arg (enum insn_code icode, -+ unsigned int opno, tree exp, unsigned int argno) -+{ -+ tree arg; -+ rtx value; -+ enum machine_mode mode; -+ -+ arg = CALL_EXPR_ARG (exp, argno); -+ value = expand_normal (arg); -+ mode = insn_data[icode].operand[opno].mode; -+ if (!insn_data[icode].operand[opno].predicate (value, mode)) -+ { -+ /* We need to get the mode from ARG for two reasons: -+ -+ - to cope with address operands, where MODE is the mode of the -+ memory, rather than of VALUE itself. -+ -+ - to cope with special predicates like pmode_register_operand, -+ where MODE is VOIDmode. */ -+ value = copy_to_mode_reg (TYPE_MODE (TREE_TYPE (arg)), value); -+ -+ /* Check the predicate again. */ -+ if (!insn_data[icode].operand[opno].predicate (value, mode)) -+ { -+ error ("invalid argument to built-in function"); -+ return const0_rtx; -+ } -+ } -+ -+ return value; -+} -+ -+/* Return an rtx suitable for output operand OP of instruction ICODE. -+ If TARGET is non-null, try to use it where possible. */ -+ -+static rtx -+riscv_prepare_builtin_target (enum insn_code icode, unsigned int op, rtx target) -+{ -+ enum machine_mode mode; -+ -+ mode = insn_data[icode].operand[op].mode; -+ if (target == 0 || !insn_data[icode].operand[op].predicate (target, mode)) -+ target = gen_reg_rtx (mode); -+ -+ return target; -+} -+ -+/* Expand a RISCV_BUILTIN_DIRECT or RISCV_BUILTIN_DIRECT_NO_TARGET function; -+ HAS_TARGET_P says which. EXP is the CALL_EXPR that calls the function -+ and ICODE is the code of the associated .md pattern. TARGET, if nonnull, -+ suggests a good place to put the result. */ -+ -+static rtx -+riscv_expand_builtin_direct (enum insn_code icode, rtx target, tree exp, -+ bool has_target_p) -+{ -+ rtx ops[MAX_RECOG_OPERANDS]; -+ int opno, argno; -+ -+ /* Map any target to operand 0. */ -+ opno = 0; -+ if (has_target_p) -+ { -+ target = riscv_prepare_builtin_target (icode, opno, target); -+ ops[opno] = target; -+ opno++; -+ } -+ -+ /* Map the arguments to the other operands. The n_operands value -+ for an expander includes match_dups and match_scratches as well as -+ match_operands, so n_operands is only an upper bound on the number -+ of arguments to the expander function. */ -+ gcc_assert (opno + call_expr_nargs (exp) <= insn_data[icode].n_operands); -+ for (argno = 0; argno < call_expr_nargs (exp); argno++, opno++) -+ ops[opno] = riscv_prepare_builtin_arg (icode, opno, exp, argno); -+ -+ switch (opno) -+ { -+ case 2: -+ emit_insn (GEN_FCN (icode) (ops[0], ops[1])); -+ break; -+ -+ case 3: -+ emit_insn (GEN_FCN (icode) (ops[0], ops[1], ops[2])); -+ break; -+ -+ case 4: -+ emit_insn (GEN_FCN (icode) (ops[0], ops[1], ops[2], ops[3])); -+ break; -+ -+ default: -+ gcc_unreachable (); -+ } -+ return target; -+} -+ -+/* Implement TARGET_EXPAND_BUILTIN. */ -+ -+static rtx -+riscv_expand_builtin (tree exp, rtx target, rtx subtarget ATTRIBUTE_UNUSED, -+ enum machine_mode mode ATTRIBUTE_UNUSED, -+ int ignore ATTRIBUTE_UNUSED) -+{ -+ tree fndecl; -+ unsigned int fcode, avail; -+ const struct riscv_builtin_description *d; -+ -+ fndecl = TREE_OPERAND (CALL_EXPR_FN (exp), 0); -+ fcode = DECL_FUNCTION_CODE (fndecl); -+ gcc_assert (fcode < ARRAY_SIZE (riscv_builtins)); -+ d = &riscv_builtins[fcode]; -+ avail = d->avail (); -+ gcc_assert (avail != 0); -+ switch (d->builtin_type) -+ { -+ case RISCV_BUILTIN_DIRECT: -+ return riscv_expand_builtin_direct (d->icode, target, exp, true); -+ -+ case RISCV_BUILTIN_DIRECT_NO_TARGET: -+ return riscv_expand_builtin_direct (d->icode, target, exp, false); -+ } -+ gcc_unreachable (); -+} -+ -+/* Implement TARGET_ASM_OUTPUT_MI_THUNK. Generate rtl rather than asm text -+ in order to avoid duplicating too much logic from elsewhere. */ -+ -+static void -+riscv_output_mi_thunk (FILE *file, tree thunk_fndecl ATTRIBUTE_UNUSED, -+ HOST_WIDE_INT delta, HOST_WIDE_INT vcall_offset, -+ tree function) -+{ -+ rtx this_rtx, temp1, temp2, insn, fnaddr; -+ bool use_sibcall_p; -+ -+ /* Pretend to be a post-reload pass while generating rtl. */ -+ reload_completed = 1; -+ -+ /* Mark the end of the (empty) prologue. */ -+ emit_note (NOTE_INSN_PROLOGUE_END); -+ -+ /* Determine if we can use a sibcall to call FUNCTION directly. */ -+ fnaddr = XEXP (DECL_RTL (function), 0); -+ use_sibcall_p = absolute_symbolic_operand (fnaddr, Pmode); -+ -+ /* We need two temporary registers in some cases. */ -+ temp1 = gen_rtx_REG (Pmode, GP_TEMP_FIRST); -+ temp2 = gen_rtx_REG (Pmode, GP_TEMP_FIRST + 1); -+ -+ /* Find out which register contains the "this" pointer. */ -+ if (aggregate_value_p (TREE_TYPE (TREE_TYPE (function)), function)) -+ this_rtx = gen_rtx_REG (Pmode, GP_ARG_FIRST + 1); -+ else -+ this_rtx = gen_rtx_REG (Pmode, GP_ARG_FIRST); -+ -+ /* Add DELTA to THIS_RTX. */ -+ if (delta != 0) -+ { -+ rtx offset = GEN_INT (delta); -+ if (!SMALL_OPERAND (delta)) -+ { -+ riscv_emit_move (temp1, offset); -+ offset = temp1; -+ } -+ emit_insn (gen_add3_insn (this_rtx, this_rtx, offset)); -+ } -+ -+ /* If needed, add *(*THIS_RTX + VCALL_OFFSET) to THIS_RTX. */ -+ if (vcall_offset != 0) -+ { -+ rtx addr; -+ -+ /* Set TEMP1 to *THIS_RTX. */ -+ riscv_emit_move (temp1, gen_rtx_MEM (Pmode, this_rtx)); -+ -+ /* Set ADDR to a legitimate address for *THIS_RTX + VCALL_OFFSET. */ -+ addr = riscv_add_offset (temp2, temp1, vcall_offset); -+ -+ /* Load the offset and add it to THIS_RTX. */ -+ riscv_emit_move (temp1, gen_rtx_MEM (Pmode, addr)); -+ emit_insn (gen_add3_insn (this_rtx, this_rtx, temp1)); -+ } -+ -+ /* Jump to the target function. Use a sibcall if direct jumps are -+ allowed, otherwise load the address into a register first. */ -+ if (use_sibcall_p) -+ { -+ insn = emit_call_insn (gen_sibcall_internal (fnaddr, const0_rtx)); -+ SIBLING_CALL_P (insn) = 1; -+ } -+ else -+ { -+ riscv_emit_move(temp1, fnaddr); -+ emit_jump_insn (gen_indirect_jump (temp1)); -+ } -+ -+ /* Run just enough of rest_of_compilation. This sequence was -+ "borrowed" from alpha.c. */ -+ insn = get_insns (); -+ split_all_insns_noflow (); -+ shorten_branches (insn); -+ final_start_function (insn, file, 1); -+ final (insn, file, 1); -+ final_end_function (); -+ -+ /* Clean up the vars set above. Note that final_end_function resets -+ the global pointer for us. */ -+ reload_completed = 0; -+} -+ -+/* Allocate a chunk of memory for per-function machine-dependent data. */ -+ -+static struct machine_function * -+riscv_init_machine_status (void) -+{ -+ return ggc_alloc_cleared_machine_function (); -+} -+ -+/* Implement TARGET_OPTION_OVERRIDE. */ -+ -+static void -+riscv_option_override (void) -+{ -+ int regno, mode; -+ const struct riscv_cpu_info *cpu; -+ -+#ifdef SUBTARGET_OVERRIDE_OPTIONS -+ SUBTARGET_OVERRIDE_OPTIONS; -+#endif -+ -+ flag_pcc_struct_return = 0; -+ -+ if (flag_pic) -+ g_switch_value = 0; -+ -+ /* Prefer a call to memcpy over inline code when optimizing for size, -+ though see MOVE_RATIO in riscv.h. */ -+ if (optimize_size && (target_flags_explicit & MASK_MEMCPY) == 0) -+ target_flags |= MASK_MEMCPY; -+ -+ /* Handle -mtune. */ -+ cpu = riscv_parse_cpu (riscv_tune_string ? riscv_tune_string : -+ RISCV_TUNE_STRING_DEFAULT); -+ tune_info = optimize_size ? &optimize_size_tune_info : cpu->tune_info; -+ -+ /* If the user hasn't specified a branch cost, use the processor's -+ default. */ -+ if (riscv_branch_cost == 0) -+ riscv_branch_cost = tune_info->branch_cost; -+ -+ /* Set up riscv_hard_regno_mode_ok. */ -+ for (mode = 0; mode < MAX_MACHINE_MODE; mode++) -+ for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++) -+ riscv_hard_regno_mode_ok[mode][regno] -+ = riscv_hard_regno_mode_ok_p (regno, (enum machine_mode) mode); -+ -+ /* Function to allocate machine-dependent function status. */ -+ init_machine_status = &riscv_init_machine_status; -+ -+ if (riscv_cmodel_string) -+ { -+ if (strcmp (riscv_cmodel_string, "medlow") == 0) -+ riscv_cmodel = CM_MEDLOW; -+ else if (strcmp (riscv_cmodel_string, "medany") == 0) -+ riscv_cmodel = CM_MEDANY; -+ else -+ error ("unsupported code model: %s", riscv_cmodel_string); -+ } -+ -+ if (flag_pic) -+ riscv_cmodel = CM_PIC; -+ -+ riscv_init_relocs (); -+} -+ -+/* Implement TARGET_CONDITIONAL_REGISTER_USAGE. */ -+ -+static void -+riscv_conditional_register_usage (void) -+{ -+ int regno; -+ -+ if (!TARGET_HARD_FLOAT) -+ { -+ for (regno = FP_REG_FIRST; regno <= FP_REG_LAST; regno++) -+ fixed_regs[regno] = call_used_regs[regno] = 1; -+ } -+} -+ -+/* Implement TARGET_TRAMPOLINE_INIT. */ -+ -+static void -+riscv_trampoline_init (rtx m_tramp, tree fndecl, rtx chain_value) -+{ -+ rtx addr, end_addr, mem; -+ rtx trampoline[4]; -+ unsigned int i; -+ HOST_WIDE_INT static_chain_offset, target_function_offset; -+ -+ /* Work out the offsets of the pointers from the start of the -+ trampoline code. */ -+ gcc_assert (ARRAY_SIZE (trampoline) * 4 == TRAMPOLINE_CODE_SIZE); -+ static_chain_offset = TRAMPOLINE_CODE_SIZE; -+ target_function_offset = static_chain_offset + GET_MODE_SIZE (ptr_mode); -+ -+ /* Get pointers to the beginning and end of the code block. */ -+ addr = force_reg (Pmode, XEXP (m_tramp, 0)); -+ end_addr = riscv_force_binary (Pmode, PLUS, addr, GEN_INT (TRAMPOLINE_CODE_SIZE)); -+ -+#define OP(X) gen_int_mode (X, SImode) -+#define MATCH_LREG ((Pmode) == DImode ? MATCH_LD : MATCH_LW) -+ -+ /* auipc t0, 0 -+ l[wd] t1, target_function_offset(t0) -+ l[wd] $static_chain, static_chain_offset(t0) -+ jr t1 -+ */ -+ -+ trampoline[0] = OP (RISCV_UTYPE (AUIPC, STATIC_CHAIN_REGNUM, 0)); -+ trampoline[1] = OP (RISCV_ITYPE (LREG, RISCV_PROLOGUE_TEMP_REGNUM, -+ STATIC_CHAIN_REGNUM, target_function_offset)); -+ trampoline[2] = OP (RISCV_ITYPE (LREG, STATIC_CHAIN_REGNUM, -+ STATIC_CHAIN_REGNUM, static_chain_offset)); -+ trampoline[3] = OP (RISCV_ITYPE (JALR, 0, RISCV_PROLOGUE_TEMP_REGNUM, 0)); -+ -+#undef MATCH_LREG -+#undef OP -+ -+ /* Copy the trampoline code. Leave any padding uninitialized. */ -+ for (i = 0; i < ARRAY_SIZE (trampoline); i++) -+ { -+ mem = adjust_address (m_tramp, SImode, i * GET_MODE_SIZE (SImode)); -+ riscv_emit_move (mem, trampoline[i]); -+ } -+ -+ /* Set up the static chain pointer field. */ -+ mem = adjust_address (m_tramp, ptr_mode, static_chain_offset); -+ riscv_emit_move (mem, chain_value); -+ -+ /* Set up the target function field. */ -+ mem = adjust_address (m_tramp, ptr_mode, target_function_offset); -+ riscv_emit_move (mem, XEXP (DECL_RTL (fndecl), 0)); -+ -+ /* Flush the code part of the trampoline. */ -+ emit_insn (gen_add3_insn (end_addr, addr, GEN_INT (TRAMPOLINE_SIZE))); -+ emit_insn (gen_clear_cache (addr, end_addr)); -+} -+ -+static bool -+riscv_lra_p (void) -+{ -+ return riscv_lra_flag; -+} -+ -+/* Initialize the GCC target structure. */ -+#undef TARGET_ASM_ALIGNED_HI_OP -+#define TARGET_ASM_ALIGNED_HI_OP "\t.half\t" -+#undef TARGET_ASM_ALIGNED_SI_OP -+#define TARGET_ASM_ALIGNED_SI_OP "\t.word\t" -+#undef TARGET_ASM_ALIGNED_DI_OP -+#define TARGET_ASM_ALIGNED_DI_OP "\t.dword\t" -+ -+#undef TARGET_OPTION_OVERRIDE -+#define TARGET_OPTION_OVERRIDE riscv_option_override -+ -+#undef TARGET_LEGITIMIZE_ADDRESS -+#define TARGET_LEGITIMIZE_ADDRESS riscv_legitimize_address -+ -+#undef TARGET_SCHED_ADJUST_COST -+#define TARGET_SCHED_ADJUST_COST riscv_adjust_cost -+#undef TARGET_SCHED_ISSUE_RATE -+#define TARGET_SCHED_ISSUE_RATE riscv_issue_rate -+ -+#undef TARGET_FUNCTION_OK_FOR_SIBCALL -+#define TARGET_FUNCTION_OK_FOR_SIBCALL hook_bool_tree_tree_true -+ -+#undef TARGET_REGISTER_MOVE_COST -+#define TARGET_REGISTER_MOVE_COST riscv_register_move_cost -+#undef TARGET_MEMORY_MOVE_COST -+#define TARGET_MEMORY_MOVE_COST riscv_memory_move_cost -+#undef TARGET_RTX_COSTS -+#define TARGET_RTX_COSTS riscv_rtx_costs -+#undef TARGET_ADDRESS_COST -+#define TARGET_ADDRESS_COST riscv_address_cost -+ -+#undef TARGET_PREFERRED_RELOAD_CLASS -+#define TARGET_PREFERRED_RELOAD_CLASS riscv_preferred_reload_class -+ -+#undef TARGET_ASM_FILE_START_FILE_DIRECTIVE -+#define TARGET_ASM_FILE_START_FILE_DIRECTIVE true -+ -+#undef TARGET_EXPAND_BUILTIN_VA_START -+#define TARGET_EXPAND_BUILTIN_VA_START riscv_va_start -+ -+#undef TARGET_PROMOTE_FUNCTION_MODE -+#define TARGET_PROMOTE_FUNCTION_MODE default_promote_function_mode_always_promote -+ -+#undef TARGET_RETURN_IN_MEMORY -+#define TARGET_RETURN_IN_MEMORY riscv_return_in_memory -+ -+#undef TARGET_ASM_OUTPUT_MI_THUNK -+#define TARGET_ASM_OUTPUT_MI_THUNK riscv_output_mi_thunk -+#undef TARGET_ASM_CAN_OUTPUT_MI_THUNK -+#define TARGET_ASM_CAN_OUTPUT_MI_THUNK hook_bool_const_tree_hwi_hwi_const_tree_true -+ -+#undef TARGET_PRINT_OPERAND -+#define TARGET_PRINT_OPERAND riscv_print_operand -+#undef TARGET_PRINT_OPERAND_ADDRESS -+#define TARGET_PRINT_OPERAND_ADDRESS riscv_print_operand_address -+ -+#undef TARGET_SETUP_INCOMING_VARARGS -+#define TARGET_SETUP_INCOMING_VARARGS riscv_setup_incoming_varargs -+#undef TARGET_STRICT_ARGUMENT_NAMING -+#define TARGET_STRICT_ARGUMENT_NAMING hook_bool_CUMULATIVE_ARGS_true -+#undef TARGET_MUST_PASS_IN_STACK -+#define TARGET_MUST_PASS_IN_STACK must_pass_in_stack_var_size -+#undef TARGET_PASS_BY_REFERENCE -+#define TARGET_PASS_BY_REFERENCE riscv_pass_by_reference -+#undef TARGET_ARG_PARTIAL_BYTES -+#define TARGET_ARG_PARTIAL_BYTES riscv_arg_partial_bytes -+#undef TARGET_FUNCTION_ARG -+#define TARGET_FUNCTION_ARG riscv_function_arg -+#undef TARGET_FUNCTION_ARG_ADVANCE -+#define TARGET_FUNCTION_ARG_ADVANCE riscv_function_arg_advance -+#undef TARGET_FUNCTION_ARG_BOUNDARY -+#define TARGET_FUNCTION_ARG_BOUNDARY riscv_function_arg_boundary -+ -+#undef TARGET_MODE_REP_EXTENDED -+#define TARGET_MODE_REP_EXTENDED riscv_mode_rep_extended -+ -+#undef TARGET_SCALAR_MODE_SUPPORTED_P -+#define TARGET_SCALAR_MODE_SUPPORTED_P riscv_scalar_mode_supported_p -+ -+#undef TARGET_INIT_BUILTINS -+#define TARGET_INIT_BUILTINS riscv_init_builtins -+#undef TARGET_BUILTIN_DECL -+#define TARGET_BUILTIN_DECL riscv_builtin_decl -+#undef TARGET_EXPAND_BUILTIN -+#define TARGET_EXPAND_BUILTIN riscv_expand_builtin -+ -+#undef TARGET_HAVE_TLS -+#define TARGET_HAVE_TLS HAVE_AS_TLS -+ -+#undef TARGET_CANNOT_FORCE_CONST_MEM -+#define TARGET_CANNOT_FORCE_CONST_MEM riscv_cannot_force_const_mem -+ -+#undef TARGET_LEGITIMATE_CONSTANT_P -+#define TARGET_LEGITIMATE_CONSTANT_P riscv_legitimate_constant_p -+ -+#undef TARGET_USE_BLOCKS_FOR_CONSTANT_P -+#define TARGET_USE_BLOCKS_FOR_CONSTANT_P hook_bool_mode_const_rtx_true -+ -+#ifdef HAVE_AS_DTPRELWORD -+#undef TARGET_ASM_OUTPUT_DWARF_DTPREL -+#define TARGET_ASM_OUTPUT_DWARF_DTPREL riscv_output_dwarf_dtprel -+#endif -+ -+#undef TARGET_LEGITIMATE_ADDRESS_P -+#define TARGET_LEGITIMATE_ADDRESS_P riscv_legitimate_address_p -+ -+#undef TARGET_CAN_ELIMINATE -+#define TARGET_CAN_ELIMINATE riscv_can_eliminate -+ -+#undef TARGET_CONDITIONAL_REGISTER_USAGE -+#define TARGET_CONDITIONAL_REGISTER_USAGE riscv_conditional_register_usage -+ -+#undef TARGET_TRAMPOLINE_INIT -+#define TARGET_TRAMPOLINE_INIT riscv_trampoline_init -+ -+#undef TARGET_IN_SMALL_DATA_P -+#define TARGET_IN_SMALL_DATA_P riscv_in_small_data_p -+ -+#undef TARGET_ASM_SELECT_RTX_SECTION -+#define TARGET_ASM_SELECT_RTX_SECTION riscv_elf_select_rtx_section -+ -+#undef TARGET_MIN_ANCHOR_OFFSET -+#define TARGET_MIN_ANCHOR_OFFSET (-RISCV_IMM_REACH/2) -+ -+#undef TARGET_MAX_ANCHOR_OFFSET -+#define TARGET_MAX_ANCHOR_OFFSET (RISCV_IMM_REACH/2-1) -+ -+#undef TARGET_LRA_P -+#define TARGET_LRA_P riscv_lra_p -+ -+struct gcc_target targetm = TARGET_INITIALIZER; -+ -+#include "gt-riscv.h" -diff -rNU3 dist.orig/gcc/config/riscv/riscv.h dist/gcc/config/riscv/riscv.h ---- dist.orig/gcc/config/riscv/riscv.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/riscv/riscv.h 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,1132 @@ -+/* Definition of RISC-V target for GNU compiler. -+ Copyright (C) 2011-2014 Free Software Foundation, Inc. -+ Contributed by Andrew Waterman (waterman@cs.berkeley.edu) at UC Berkeley. -+ Based on MIPS target for GNU compiler. -+ -+This file is part of GCC. -+ -+GCC is free software; you can redistribute it and/or modify -+it under the terms of the GNU General Public License as published by -+the Free Software Foundation; either version 3, or (at your option) -+any later version. -+ -+GCC is distributed in the hope that it will be useful, -+but WITHOUT ANY WARRANTY; without even the implied warranty of -+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+GNU General Public License for more details. -+ -+You should have received a copy of the GNU General Public License -+along with GCC; see the file COPYING3. If not see -+. */ -+ -+/* TARGET_HARD_FLOAT and TARGET_SOFT_FLOAT reflect whether the FPU is -+ directly accessible, while the command-line options select -+ TARGET_HARD_FLOAT_ABI and TARGET_SOFT_FLOAT_ABI to reflect the ABI -+ in use. */ -+#define TARGET_HARD_FLOAT TARGET_HARD_FLOAT_ABI -+#define TARGET_SOFT_FLOAT TARGET_SOFT_FLOAT_ABI -+ -+/* Target CPU builtins. */ -+#define TARGET_CPU_CPP_BUILTINS() \ -+ do \ -+ { \ -+ builtin_assert ("machine=riscv"); \ -+ \ -+ builtin_assert ("cpu=riscv"); \ -+ builtin_define ("__riscv__"); \ -+ builtin_define ("__riscv"); \ -+ builtin_define ("_riscv"); \ -+ \ -+ if (TARGET_64BIT) \ -+ { \ -+ builtin_define ("__riscv64"); \ -+ builtin_define ("_RISCV_SIM=_ABI64"); \ -+ } \ -+ else \ -+ builtin_define ("_RISCV_SIM=_ABI32"); \ -+ \ -+ builtin_define ("_ABI32=1"); \ -+ builtin_define ("_ABI64=3"); \ -+ \ -+ \ -+ builtin_define_with_int_value ("_RISCV_SZINT", INT_TYPE_SIZE); \ -+ builtin_define_with_int_value ("_RISCV_SZLONG", LONG_TYPE_SIZE); \ -+ builtin_define_with_int_value ("_RISCV_SZPTR", POINTER_SIZE); \ -+ builtin_define_with_int_value ("_RISCV_FPSET", 32); \ -+ \ -+ if (TARGET_ATOMIC) { \ -+ builtin_define ("__riscv_atomic"); \ -+ } \ -+ \ -+ /* These defines reflect the ABI in use, not whether the \ -+ FPU is directly accessible. */ \ -+ if (TARGET_HARD_FLOAT_ABI) { \ -+ builtin_define ("__riscv_hard_float"); \ -+ if (TARGET_FDIV) { \ -+ builtin_define ("__riscv_fdiv"); \ -+ builtin_define ("__riscv_fsqrt"); \ -+ } \ -+ } else \ -+ builtin_define ("__riscv_soft_float"); \ -+ \ -+ /* The base RISC-V ISA is always little-endian. */ \ -+ builtin_define_std ("RISCVEL"); \ -+ builtin_define ("_RISCVEL"); \ -+ \ -+ /* Macros dependent on the C dialect. */ \ -+ if (preprocessing_asm_p ()) \ -+ { \ -+ builtin_define_std ("LANGUAGE_ASSEMBLY"); \ -+ builtin_define ("_LANGUAGE_ASSEMBLY"); \ -+ } \ -+ else if (c_dialect_cxx ()) \ -+ { \ -+ builtin_define ("_LANGUAGE_C_PLUS_PLUS"); \ -+ builtin_define ("__LANGUAGE_C_PLUS_PLUS"); \ -+ builtin_define ("__LANGUAGE_C_PLUS_PLUS__"); \ -+ } \ -+ else \ -+ { \ -+ builtin_define_std ("LANGUAGE_C"); \ -+ builtin_define ("_LANGUAGE_C"); \ -+ } \ -+ if (c_dialect_objc ()) \ -+ { \ -+ builtin_define ("_LANGUAGE_OBJECTIVE_C"); \ -+ builtin_define ("__LANGUAGE_OBJECTIVE_C"); \ -+ /* Bizarre, but needed at least for Irix. */ \ -+ builtin_define_std ("LANGUAGE_C"); \ -+ builtin_define ("_LANGUAGE_C"); \ -+ } \ -+ if (riscv_cmodel == CM_MEDANY) \ -+ builtin_define ("_RISCV_CMODEL_MEDANY"); \ -+ } \ -+ while (0) -+ -+/* Default target_flags if no switches are specified */ -+ -+#ifndef TARGET_DEFAULT -+#define TARGET_DEFAULT 0 -+#endif -+ -+#ifndef RISCV_ARCH_STRING_DEFAULT -+#define RISCV_ARCH_STRING_DEFAULT "IMAFD" -+#endif -+ -+#ifndef RISCV_TUNE_STRING_DEFAULT -+#define RISCV_TUNE_STRING_DEFAULT "rocket" -+#endif -+ -+#ifndef TARGET_64BIT_DEFAULT -+#define TARGET_64BIT_DEFAULT 1 -+#endif -+ -+#if TARGET_64BIT_DEFAULT -+# define MULTILIB_ARCH_DEFAULT "m64" -+# define OPT_ARCH64 "!m32" -+# define OPT_ARCH32 "m32" -+#else -+# define MULTILIB_ARCH_DEFAULT "m32" -+# define OPT_ARCH64 "m64" -+# define OPT_ARCH32 "!m64" -+#endif -+ -+#ifndef MULTILIB_DEFAULTS -+#define MULTILIB_DEFAULTS \ -+ { MULTILIB_ARCH_DEFAULT } -+#endif -+ -+ -+/* Support for a compile-time default CPU, et cetera. The rules are: -+ --with-arch is ignored if -march is specified. -+ --with-tune is ignored if -mtune is specified. -+ --with-float is ignored if -mhard-float or -msoft-float are specified. */ -+#define OPTION_DEFAULT_SPECS \ -+ {"arch_32", "%{" OPT_ARCH32 ":%{m32}}" }, \ -+ {"arch_64", "%{" OPT_ARCH64 ":%{m64}}" }, \ -+ {"tune", "%{!mtune=*:-mtune=%(VALUE)}" }, \ -+ {"float", "%{!msoft-float:%{!mhard-float:-m%(VALUE)-float}}" }, \ -+ -+#define DRIVER_SELF_SPECS "" -+ -+#ifdef IN_LIBGCC2 -+#undef TARGET_64BIT -+/* Make this compile time constant for libgcc2 */ -+#ifdef __riscv64 -+#define TARGET_64BIT 1 -+#else -+#define TARGET_64BIT 0 -+#endif -+#endif /* IN_LIBGCC2 */ -+ -+/* Tell collect what flags to pass to nm. */ -+#ifndef NM_FLAGS -+#define NM_FLAGS "-Bn" -+#endif -+ -+#undef ASM_SPEC -+#define ASM_SPEC "\ -+%(subtarget_asm_debugging_spec) \ -+%{m32} %{m64} %{!m32:%{!m64: %(asm_abi_default_spec)}} \ -+%{fPIC|fpic|fPIE|fpie:-fpic} \ -+%{march=*} \ -+%(subtarget_asm_spec)" -+ -+/* Extra switches sometimes passed to the linker. */ -+ -+#ifndef LINK_SPEC -+#define LINK_SPEC "\ -+%{!T:-dT riscv.ld} \ -+%{m64:-melf64lriscv} \ -+%{m32:-melf32lriscv} \ -+%{shared}" -+#endif /* LINK_SPEC defined */ -+ -+/* This macro defines names of additional specifications to put in the specs -+ that can be used in various specifications like CC1_SPEC. Its definition -+ is an initializer with a subgrouping for each command option. -+ -+ Each subgrouping contains a string constant, that defines the -+ specification name, and a string constant that used by the GCC driver -+ program. -+ -+ Do not define this macro if it does not need to do anything. */ -+ -+#define EXTRA_SPECS \ -+ { "asm_abi_default_spec", "-" MULTILIB_ARCH_DEFAULT }, \ -+ SUBTARGET_EXTRA_SPECS -+ -+#ifndef SUBTARGET_EXTRA_SPECS -+#define SUBTARGET_EXTRA_SPECS -+#endif -+ -+#define TARGET_DEFAULT_CMODEL CM_MEDLOW -+ -+/* By default, turn on GDB extensions. */ -+#define DEFAULT_GDB_EXTENSIONS 1 -+ -+#define LOCAL_LABEL_PREFIX "." -+#define USER_LABEL_PREFIX "" -+ -+#define DWARF2_DEBUGGING_INFO 1 -+#define DWARF2_ASM_LINE_DEBUG_INFO 0 -+ -+/* The mapping from gcc register number to DWARF 2 CFA column number. */ -+#define DWARF_FRAME_REGNUM(REGNO) \ -+ (GP_REG_P (REGNO) || FP_REG_P (REGNO) ? REGNO : INVALID_REGNUM) -+ -+/* The DWARF 2 CFA column which tracks the return address. */ -+#define DWARF_FRAME_RETURN_COLUMN RETURN_ADDR_REGNUM -+ -+/* Don't emit .cfi_sections, as it does not work */ -+#undef HAVE_GAS_CFI_SECTIONS_DIRECTIVE -+#define HAVE_GAS_CFI_SECTIONS_DIRECTIVE 0 -+ -+/* Before the prologue, RA lives in r31. */ -+#define INCOMING_RETURN_ADDR_RTX gen_rtx_REG (VOIDmode, RETURN_ADDR_REGNUM) -+ -+/* Describe how we implement __builtin_eh_return. */ -+#define EH_RETURN_DATA_REGNO(N) \ -+ ((N) < 4 ? (N) + GP_ARG_FIRST : INVALID_REGNUM) -+ -+#define EH_RETURN_STACKADJ_RTX gen_rtx_REG (Pmode, GP_ARG_FIRST + 4) -+ -+/* Target machine storage layout */ -+ -+#define BITS_BIG_ENDIAN 0 -+#define BYTES_BIG_ENDIAN 0 -+#define WORDS_BIG_ENDIAN 0 -+ -+#define MAX_BITS_PER_WORD 64 -+ -+/* Width of a word, in units (bytes). */ -+#define UNITS_PER_WORD (TARGET_64BIT ? 8 : 4) -+#ifndef IN_LIBGCC2 -+#define MIN_UNITS_PER_WORD 4 -+#endif -+ -+/* We currently require both or neither of the `F' and `D' extensions. */ -+#define UNITS_PER_FPREG 8 -+ -+/* If FP regs aren't wide enough for a given FP argument, it is passed in -+ integer registers. */ -+#define MIN_FPRS_PER_FMT 1 -+ -+/* The largest size of value that can be held in floating-point -+ registers and moved with a single instruction. */ -+#define UNITS_PER_HWFPVALUE \ -+ (TARGET_SOFT_FLOAT_ABI ? 0 : UNITS_PER_FPREG) -+ -+/* The largest size of value that can be held in floating-point -+ registers. */ -+#define UNITS_PER_FPVALUE \ -+ (TARGET_SOFT_FLOAT_ABI ? 0 \ -+ : LONG_DOUBLE_TYPE_SIZE / BITS_PER_UNIT) -+ -+/* The number of bytes in a double. */ -+#define UNITS_PER_DOUBLE (TYPE_PRECISION (double_type_node) / BITS_PER_UNIT) -+ -+/* Set the sizes of the core types. */ -+#define SHORT_TYPE_SIZE 16 -+#define INT_TYPE_SIZE 32 -+#define LONG_TYPE_SIZE (TARGET_64BIT ? 64 : 32) -+#define LONG_LONG_TYPE_SIZE 64 -+ -+#define FLOAT_TYPE_SIZE 32 -+#define DOUBLE_TYPE_SIZE 64 -+/* XXX The ABI says long doubles are IEEE-754-2008 float128s. */ -+#define LONG_DOUBLE_TYPE_SIZE 64 -+ -+#ifdef IN_LIBGCC2 -+# define LIBGCC2_LONG_DOUBLE_TYPE_SIZE LONG_DOUBLE_TYPE_SIZE -+#endif -+ -+/* Allocation boundary (in *bits*) for storing arguments in argument list. */ -+#define PARM_BOUNDARY BITS_PER_WORD -+ -+/* Allocation boundary (in *bits*) for the code of a function. */ -+#define FUNCTION_BOUNDARY 32 -+ -+/* There is no point aligning anything to a rounder boundary than this. */ -+#define BIGGEST_ALIGNMENT 128 -+ -+/* All accesses must be aligned. */ -+#define STRICT_ALIGNMENT 1 -+ -+/* Define this if you wish to imitate the way many other C compilers -+ handle alignment of bitfields and the structures that contain -+ them. -+ -+ The behavior is that the type written for a bit-field (`int', -+ `short', or other integer type) imposes an alignment for the -+ entire structure, as if the structure really did contain an -+ ordinary field of that type. In addition, the bit-field is placed -+ within the structure so that it would fit within such a field, -+ not crossing a boundary for it. -+ -+ Thus, on most machines, a bit-field whose type is written as `int' -+ would not cross a four-byte boundary, and would force four-byte -+ alignment for the whole structure. (The alignment used may not -+ be four bytes; it is controlled by the other alignment -+ parameters.) -+ -+ If the macro is defined, its definition should be a C expression; -+ a nonzero value for the expression enables this behavior. */ -+ -+#define PCC_BITFIELD_TYPE_MATTERS 1 -+ -+/* If defined, a C expression to compute the alignment given to a -+ constant that is being placed in memory. CONSTANT is the constant -+ and ALIGN is the alignment that the object would ordinarily have. -+ The value of this macro is used instead of that alignment to align -+ the object. -+ -+ If this macro is not defined, then ALIGN is used. -+ -+ The typical use of this macro is to increase alignment for string -+ constants to be word aligned so that `strcpy' calls that copy -+ constants can be done inline. */ -+ -+#define CONSTANT_ALIGNMENT(EXP, ALIGN) \ -+ ((TREE_CODE (EXP) == STRING_CST || TREE_CODE (EXP) == CONSTRUCTOR) \ -+ && (ALIGN) < BITS_PER_WORD ? BITS_PER_WORD : (ALIGN)) -+ -+/* If defined, a C expression to compute the alignment for a static -+ variable. TYPE is the data type, and ALIGN is the alignment that -+ the object would ordinarily have. The value of this macro is used -+ instead of that alignment to align the object. -+ -+ If this macro is not defined, then ALIGN is used. -+ -+ One use of this macro is to increase alignment of medium-size -+ data to make it all fit in fewer cache lines. Another is to -+ cause character arrays to be word-aligned so that `strcpy' calls -+ that copy constants to character arrays can be done inline. */ -+ -+#undef DATA_ALIGNMENT -+#define DATA_ALIGNMENT(TYPE, ALIGN) \ -+ ((((ALIGN) < BITS_PER_WORD) \ -+ && (TREE_CODE (TYPE) == ARRAY_TYPE \ -+ || TREE_CODE (TYPE) == UNION_TYPE \ -+ || TREE_CODE (TYPE) == RECORD_TYPE)) ? BITS_PER_WORD : (ALIGN)) -+ -+/* We need this for the same reason as DATA_ALIGNMENT, namely to cause -+ character arrays to be word-aligned so that `strcpy' calls that copy -+ constants to character arrays can be done inline, and 'strcmp' can be -+ optimised to use word loads. */ -+#define LOCAL_ALIGNMENT(TYPE, ALIGN) \ -+ DATA_ALIGNMENT (TYPE, ALIGN) -+ -+/* Define if operations between registers always perform the operation -+ on the full register even if a narrower mode is specified. */ -+#define WORD_REGISTER_OPERATIONS -+ -+/* When in 64-bit mode, move insns will sign extend SImode and CCmode -+ moves. All other references are zero extended. */ -+#define LOAD_EXTEND_OP(MODE) \ -+ (TARGET_64BIT && ((MODE) == SImode || (MODE) == CCmode) \ -+ ? SIGN_EXTEND : ZERO_EXTEND) -+ -+/* Define this macro if it is advisable to hold scalars in registers -+ in a wider mode than that declared by the program. In such cases, -+ the value is constrained to be within the bounds of the declared -+ type, but kept valid in the wider mode. The signedness of the -+ extension may differ from that of the type. */ -+ -+#define PROMOTE_MODE(MODE, UNSIGNEDP, TYPE) \ -+ if (GET_MODE_CLASS (MODE) == MODE_INT \ -+ && GET_MODE_SIZE (MODE) < 4) \ -+ { \ -+ (MODE) = Pmode; \ -+ } -+ -+/* Pmode is always the same as ptr_mode, but not always the same as word_mode. -+ Extensions of pointers to word_mode must be signed. */ -+#define POINTERS_EXTEND_UNSIGNED false -+ -+/* RV32 double-precision FP <-> integer moves go through memory */ -+#define SECONDARY_MEMORY_NEEDED(CLASS1,CLASS2,MODE) \ -+ (!TARGET_64BIT && GET_MODE_SIZE (MODE) == 8 && \ -+ (((CLASS1) == FP_REGS && (CLASS2) != FP_REGS) \ -+ || ((CLASS2) == FP_REGS && (CLASS1) != FP_REGS))) -+ -+/* Define if loading short immediate values into registers sign extends. */ -+#define SHORT_IMMEDIATES_SIGN_EXTEND -+ -+/* Standard register usage. */ -+ -+/* Number of hardware registers. We have: -+ -+ - 32 integer registers -+ - 32 floating point registers -+ - 32 vector integer registers -+ - 32 vector floating point registers -+ - 2 fake registers: -+ - ARG_POINTER_REGNUM -+ - FRAME_POINTER_REGNUM */ -+ -+#define FIRST_PSEUDO_REGISTER 66 -+ -+/* x0, sp, gp, and tp are fixed. */ -+ -+#define FIXED_REGISTERS \ -+{ /* General registers. */ \ -+ 1, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ -+ /* Floating-point registers. */ \ -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ -+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ -+ /* Others. */ \ -+ 1, 1 \ -+} -+ -+ -+/* a0-a7, t0-a6, fa0-fa7, and ft0-ft11 are volatile across calls. -+ The call RTLs themselves clobber ra. */ -+ -+#define CALL_USED_REGISTERS \ -+{ /* General registers. */ \ -+ 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, \ -+ 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, \ -+ /* Floating-point registers. */ \ -+ 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, \ -+ 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, \ -+ /* Others. */ \ -+ 1, 1 \ -+} -+ -+#define CALL_REALLY_USED_REGISTERS \ -+{ /* General registers. */ \ -+ 1, 0, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, \ -+ 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, \ -+ /* Floating-point registers. */ \ -+ 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 1, 1, 1, 1, 1, 1, \ -+ 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, \ -+ /* Others. */ \ -+ 1, 1 \ -+} -+ -+/* Internal macros to classify an ISA register's type. */ -+ -+#define GP_REG_FIRST 0 -+#define GP_REG_LAST 31 -+#define GP_REG_NUM (GP_REG_LAST - GP_REG_FIRST + 1) -+ -+#define FP_REG_FIRST 32 -+#define FP_REG_LAST 63 -+#define FP_REG_NUM (FP_REG_LAST - FP_REG_FIRST + 1) -+ -+/* The DWARF 2 CFA column which tracks the return address from a -+ signal handler context. This means that to maintain backwards -+ compatibility, no hard register can be assigned this column if it -+ would need to be handled by the DWARF unwinder. */ -+#define DWARF_ALT_FRAME_RETURN_COLUMN 64 -+ -+#define GP_REG_P(REGNO) \ -+ ((unsigned int) ((int) (REGNO) - GP_REG_FIRST) < GP_REG_NUM) -+#define FP_REG_P(REGNO) \ -+ ((unsigned int) ((int) (REGNO) - FP_REG_FIRST) < FP_REG_NUM) -+ -+#define FP_REG_RTX_P(X) (REG_P (X) && FP_REG_P (REGNO (X))) -+ -+/* Return coprocessor number from register number. */ -+ -+#define COPNUM_AS_CHAR_FROM_REGNUM(REGNO) \ -+ (COP0_REG_P (REGNO) ? '0' : COP2_REG_P (REGNO) ? '2' \ -+ : COP3_REG_P (REGNO) ? '3' : '?') -+ -+ -+#define HARD_REGNO_NREGS(REGNO, MODE) riscv_hard_regno_nregs (REGNO, MODE) -+ -+#define HARD_REGNO_MODE_OK(REGNO, MODE) \ -+ riscv_hard_regno_mode_ok[ (int)(MODE) ][ (REGNO) ] -+ -+#define MODES_TIEABLE_P(MODE1, MODE2) \ -+ ((MODE1) == (MODE2) || (GET_MODE_CLASS (MODE1) == MODE_INT \ -+ && GET_MODE_CLASS (MODE2) == MODE_INT)) -+ -+/* Use s0 as the frame pointer if it is so requested. */ -+#define HARD_FRAME_POINTER_REGNUM 8 -+#define STACK_POINTER_REGNUM 2 -+#define THREAD_POINTER_REGNUM 4 -+ -+/* These two registers don't really exist: they get eliminated to either -+ the stack or hard frame pointer. */ -+#define ARG_POINTER_REGNUM 64 -+#define FRAME_POINTER_REGNUM 65 -+ -+#define HARD_FRAME_POINTER_IS_FRAME_POINTER 0 -+#define HARD_FRAME_POINTER_IS_ARG_POINTER 0 -+ -+/* Register in which static-chain is passed to a function. */ -+#define STATIC_CHAIN_REGNUM GP_TEMP_FIRST -+ -+/* Registers used as temporaries in prologue/epilogue code. -+ -+ The prologue registers mustn't conflict with any -+ incoming arguments, the static chain pointer, or the frame pointer. -+ The epilogue temporary mustn't conflict with the return registers, -+ the frame pointer, the EH stack adjustment, or the EH data registers. */ -+ -+#define RISCV_PROLOGUE_TEMP_REGNUM (GP_TEMP_FIRST + 1) -+#define RISCV_EPILOGUE_TEMP_REGNUM RISCV_PROLOGUE_TEMP_REGNUM -+ -+#define RISCV_PROLOGUE_TEMP(MODE) gen_rtx_REG (MODE, RISCV_PROLOGUE_TEMP_REGNUM) -+#define RISCV_EPILOGUE_TEMP(MODE) gen_rtx_REG (MODE, RISCV_EPILOGUE_TEMP_REGNUM) -+ -+#define FUNCTION_PROFILER(STREAM, LABELNO) \ -+{ \ -+ sorry ("profiler support for RISC-V"); \ -+} -+ -+/* Define this macro if it is as good or better to call a constant -+ function address than to call an address kept in a register. */ -+#define NO_FUNCTION_CSE 1 -+ -+/* Define the classes of registers for register constraints in the -+ machine description. Also define ranges of constants. -+ -+ One of the classes must always be named ALL_REGS and include all hard regs. -+ If there is more than one class, another class must be named NO_REGS -+ and contain no registers. -+ -+ The name GENERAL_REGS must be the name of a class (or an alias for -+ another name such as ALL_REGS). This is the class of registers -+ that is allowed by "g" or "r" in a register constraint. -+ Also, registers outside this class are allocated only when -+ instructions express preferences for them. -+ -+ The classes must be numbered in nondecreasing order; that is, -+ a larger-numbered class must never be contained completely -+ in a smaller-numbered class. -+ -+ For any two classes, it is very desirable that there be another -+ class that represents their union. */ -+ -+enum reg_class -+{ -+ NO_REGS, /* no registers in set */ -+ T_REGS, /* registers used by indirect sibcalls */ -+ GR_REGS, /* integer registers */ -+ FP_REGS, /* floating point registers */ -+ FRAME_REGS, /* $arg and $frame */ -+ ALL_REGS, /* all registers */ -+ LIM_REG_CLASSES /* max value + 1 */ -+}; -+ -+#define N_REG_CLASSES (int) LIM_REG_CLASSES -+ -+#define GENERAL_REGS GR_REGS -+ -+/* An initializer containing the names of the register classes as C -+ string constants. These names are used in writing some of the -+ debugging dumps. */ -+ -+#define REG_CLASS_NAMES \ -+{ \ -+ "NO_REGS", \ -+ "T_REGS", \ -+ "GR_REGS", \ -+ "FP_REGS", \ -+ "FRAME_REGS", \ -+ "ALL_REGS" \ -+} -+ -+/* An initializer containing the contents of the register classes, -+ as integers which are bit masks. The Nth integer specifies the -+ contents of class N. The way the integer MASK is interpreted is -+ that register R is in the class if `MASK & (1 << R)' is 1. -+ -+ When the machine has more than 32 registers, an integer does not -+ suffice. Then the integers are replaced by sub-initializers, -+ braced groupings containing several integers. Each -+ sub-initializer must be suitable as an initializer for the type -+ `HARD_REG_SET' which is defined in `hard-reg-set.h'. */ -+ -+#define REG_CLASS_CONTENTS \ -+{ \ -+ { 0x00000000, 0x00000000, 0x00000000 }, /* NO_REGS */ \ -+ { 0xf00000e0, 0x00000000, 0x00000000 }, /* T_REGS */ \ -+ { 0xffffffff, 0x00000000, 0x00000000 }, /* GR_REGS */ \ -+ { 0x00000000, 0xffffffff, 0x00000000 }, /* FP_REGS */ \ -+ { 0x00000000, 0x00000000, 0x00000003 }, /* FRAME_REGS */ \ -+ { 0xffffffff, 0xffffffff, 0x00000003 } /* ALL_REGS */ \ -+} -+ -+/* A C expression whose value is a register class containing hard -+ register REGNO. In general there is more that one such class; -+ choose a class which is "minimal", meaning that no smaller class -+ also contains the register. */ -+ -+#define REGNO_REG_CLASS(REGNO) riscv_regno_to_class[ (REGNO) ] -+ -+/* A macro whose definition is the name of the class to which a -+ valid base register must belong. A base register is one used in -+ an address which is the register value plus a displacement. */ -+ -+#define BASE_REG_CLASS GR_REGS -+ -+/* A macro whose definition is the name of the class to which a -+ valid index register must belong. An index register is one used -+ in an address where its value is either multiplied by a scale -+ factor or added to another register (as well as added to a -+ displacement). */ -+ -+#define INDEX_REG_CLASS NO_REGS -+ -+/* We generally want to put call-clobbered registers ahead of -+ call-saved ones. (IRA expects this.) */ -+ -+#define REG_ALLOC_ORDER \ -+{ \ -+ /* Call-clobbered GPRs. */ \ -+ 15, 14, 13, 12, 11, 10, 16, 17, 5, 6, 7, 28, 29, 30, 31, 1, \ -+ /* Call-saved GPRs. */ \ -+ 8, 9, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, \ -+ /* GPRs that can never be exposed to the register allocator. */ \ -+ 0, 2, 3, 4, \ -+ /* Call-clobbered FPRs. */ \ -+ 32, 33, 34, 35, 36, 37, 38, 39, 42, 43, 44, 45, 46, 47, 48, 49, \ -+ 60, 61, 62, 63, \ -+ /* Call-saved FPRs. */ \ -+ 40, 41, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, \ -+ /* None of the remaining classes have defined call-saved \ -+ registers. */ \ -+ 64, 65 \ -+} -+ -+/* True if VALUE is a signed 16-bit number. */ -+ -+#include "opcode-riscv.h" -+#define SMALL_OPERAND(VALUE) \ -+ ((unsigned HOST_WIDE_INT) (VALUE) + RISCV_IMM_REACH/2 < RISCV_IMM_REACH) -+ -+/* True if VALUE can be loaded into a register using LUI. */ -+ -+#define LUI_OPERAND(VALUE) \ -+ (((VALUE) | ((1UL<<31) - RISCV_IMM_REACH)) == ((1UL<<31) - RISCV_IMM_REACH) \ -+ || ((VALUE) | ((1UL<<31) - RISCV_IMM_REACH)) + RISCV_IMM_REACH == 0) -+ -+/* Return a value X with the low 16 bits clear, and such that -+ VALUE - X is a signed 16-bit value. */ -+ -+#define SMALL_INT(X) SMALL_OPERAND (INTVAL (X)) -+#define LUI_INT(X) LUI_OPERAND (INTVAL (X)) -+ -+/* The HI and LO registers can only be reloaded via the general -+ registers. Condition code registers can only be loaded to the -+ general registers, and from the floating point registers. */ -+ -+#define SECONDARY_INPUT_RELOAD_CLASS(CLASS, MODE, X) \ -+ riscv_secondary_reload_class (CLASS, MODE, X, true) -+#define SECONDARY_OUTPUT_RELOAD_CLASS(CLASS, MODE, X) \ -+ riscv_secondary_reload_class (CLASS, MODE, X, false) -+ -+/* Return the maximum number of consecutive registers -+ needed to represent mode MODE in a register of class CLASS. */ -+ -+#define CLASS_MAX_NREGS(CLASS, MODE) riscv_class_max_nregs (CLASS, MODE) -+ -+/* It is undefined to interpret an FP register in a different format than -+ that which it was created to be. */ -+ -+#define CANNOT_CHANGE_MODE_CLASS(FROM, TO, CLASS) \ -+ reg_classes_intersect_p (FP_REGS, CLASS) -+ -+/* Stack layout; function entry, exit and calling. */ -+ -+#define STACK_GROWS_DOWNWARD -+ -+#define FRAME_GROWS_DOWNWARD 1 -+ -+#define STARTING_FRAME_OFFSET 0 -+ -+#define RETURN_ADDR_RTX riscv_return_addr -+ -+#define ELIMINABLE_REGS \ -+{{ ARG_POINTER_REGNUM, STACK_POINTER_REGNUM}, \ -+ { ARG_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}, \ -+ { FRAME_POINTER_REGNUM, STACK_POINTER_REGNUM}, \ -+ { FRAME_POINTER_REGNUM, HARD_FRAME_POINTER_REGNUM}} \ -+ -+#define INITIAL_ELIMINATION_OFFSET(FROM, TO, OFFSET) \ -+ (OFFSET) = riscv_initial_elimination_offset (FROM, TO) -+ -+/* Allocate stack space for arguments at the beginning of each function. */ -+#define ACCUMULATE_OUTGOING_ARGS 1 -+ -+/* The argument pointer always points to the first argument. */ -+#define FIRST_PARM_OFFSET(FNDECL) 0 -+ -+#define REG_PARM_STACK_SPACE(FNDECL) 0 -+ -+/* Define this if it is the responsibility of the caller to -+ allocate the area reserved for arguments passed in registers. -+ If `ACCUMULATE_OUTGOING_ARGS' is also defined, the only effect -+ of this macro is to determine whether the space is included in -+ `crtl->outgoing_args_size'. */ -+#define OUTGOING_REG_PARM_STACK_SPACE(FNTYPE) 1 -+ -+#define STACK_BOUNDARY 128 -+ -+/* Symbolic macros for the registers used to return integer and floating -+ point values. */ -+ -+#define GP_RETURN GP_ARG_FIRST -+#define FP_RETURN ((TARGET_SOFT_FLOAT) ? GP_RETURN : FP_ARG_FIRST) -+ -+#define MAX_ARGS_IN_REGISTERS 8 -+ -+/* Symbolic macros for the first/last argument registers. */ -+ -+#define GP_ARG_FIRST (GP_REG_FIRST + 10) -+#define GP_ARG_LAST (GP_ARG_FIRST + MAX_ARGS_IN_REGISTERS - 1) -+#define GP_TEMP_FIRST (GP_REG_FIRST + 5) -+#define FP_ARG_FIRST (FP_REG_FIRST + 10) -+#define FP_ARG_LAST (FP_ARG_FIRST + MAX_ARGS_IN_REGISTERS - 1) -+ -+#define LIBCALL_VALUE(MODE) \ -+ riscv_function_value (NULL_TREE, NULL_TREE, MODE) -+ -+#define FUNCTION_VALUE(VALTYPE, FUNC) \ -+ riscv_function_value (VALTYPE, FUNC, VOIDmode) -+ -+#define FUNCTION_VALUE_REGNO_P(N) ((N) == GP_RETURN || (N) == FP_RETURN) -+ -+/* 1 if N is a possible register number for function argument passing. -+ We have no FP argument registers when soft-float. When FP registers -+ are 32 bits, we can't directly reference the odd numbered ones. */ -+ -+/* Accept arguments in a0-a7 and/or fa0-fa7. */ -+#define FUNCTION_ARG_REGNO_P(N) \ -+ (IN_RANGE((N), GP_ARG_FIRST, GP_ARG_LAST) \ -+ || IN_RANGE((N), FP_ARG_FIRST, FP_ARG_LAST)) -+ -+/* The ABI views the arguments as a structure, of which the first 8 -+ words go in registers and the rest go on the stack. If I < 8, N, the Ith -+ word might go in the Ith integer argument register or the Ith -+ floating-point argument register. */ -+ -+typedef struct { -+ /* Number of integer registers used so far, up to MAX_ARGS_IN_REGISTERS. */ -+ unsigned int num_gprs; -+ -+ /* Number of words passed on the stack. */ -+ unsigned int stack_words; -+} CUMULATIVE_ARGS; -+ -+/* Initialize a variable CUM of type CUMULATIVE_ARGS -+ for a call to a function whose data type is FNTYPE. -+ For a library call, FNTYPE is 0. */ -+ -+#define INIT_CUMULATIVE_ARGS(CUM, FNTYPE, LIBNAME, INDIRECT, N_NAMED_ARGS) \ -+ memset (&(CUM), 0, sizeof (CUM)) -+ -+#define EPILOGUE_USES(REGNO) ((REGNO) == RETURN_ADDR_REGNUM) -+ -+/* ABI requires 16-byte alignment, even on ven on RV32. */ -+#define RISCV_STACK_ALIGN(LOC) (((LOC) + 15) & -16) -+ -+#define NO_PROFILE_COUNTERS 1 -+ -+/* Define this macro if the code for function profiling should come -+ before the function prologue. Normally, the profiling code comes -+ after. */ -+ -+/* #define PROFILE_BEFORE_PROLOGUE */ -+ -+/* EXIT_IGNORE_STACK should be nonzero if, when returning from a function, -+ the stack pointer does not matter. The value is tested only in -+ functions that have frame pointers. -+ No definition is equivalent to always zero. */ -+ -+#define EXIT_IGNORE_STACK 1 -+ -+ -+/* Trampolines are a block of code followed by two pointers. */ -+ -+#define TRAMPOLINE_CODE_SIZE 16 -+#define TRAMPOLINE_SIZE (TRAMPOLINE_CODE_SIZE + POINTER_SIZE * 2) -+#define TRAMPOLINE_ALIGNMENT POINTER_SIZE -+ -+/* Addressing modes, and classification of registers for them. */ -+ -+#define REGNO_OK_FOR_INDEX_P(REGNO) 0 -+#define REGNO_MODE_OK_FOR_BASE_P(REGNO, MODE) \ -+ riscv_regno_mode_ok_for_base_p (REGNO, MODE, 1) -+ -+/* The macros REG_OK_FOR..._P assume that the arg is a REG rtx -+ and check its validity for a certain class. -+ We have two alternate definitions for each of them. -+ The usual definition accepts all pseudo regs; the other rejects them all. -+ The symbol REG_OK_STRICT causes the latter definition to be used. -+ -+ Most source files want to accept pseudo regs in the hope that -+ they will get allocated to the class that the insn wants them to be in. -+ Some source files that are used after register allocation -+ need to be strict. */ -+ -+#ifndef REG_OK_STRICT -+#define REG_MODE_OK_FOR_BASE_P(X, MODE) \ -+ riscv_regno_mode_ok_for_base_p (REGNO (X), MODE, 0) -+#else -+#define REG_MODE_OK_FOR_BASE_P(X, MODE) \ -+ riscv_regno_mode_ok_for_base_p (REGNO (X), MODE, 1) -+#endif -+ -+#define REG_OK_FOR_INDEX_P(X) 0 -+ -+ -+/* Maximum number of registers that can appear in a valid memory address. */ -+ -+#define MAX_REGS_PER_ADDRESS 1 -+ -+#define CONSTANT_ADDRESS_P(X) \ -+ (CONSTANT_P (X) && memory_address_p (SImode, X)) -+ -+/* This handles the magic '..CURRENT_FUNCTION' symbol, which means -+ 'the start of the function that this code is output in'. */ -+ -+#define ASM_OUTPUT_LABELREF(FILE,NAME) \ -+ if (strcmp (NAME, "..CURRENT_FUNCTION") == 0) \ -+ asm_fprintf ((FILE), "%U%s", \ -+ XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0)); \ -+ else \ -+ asm_fprintf ((FILE), "%U%s", (NAME)) -+ -+/* This flag marks functions that cannot be lazily bound. */ -+#define SYMBOL_FLAG_BIND_NOW (SYMBOL_FLAG_MACH_DEP << 1) -+#define SYMBOL_REF_BIND_NOW_P(RTX) \ -+ ((SYMBOL_REF_FLAGS (RTX) & SYMBOL_FLAG_BIND_NOW) != 0) -+ -+#define JUMP_TABLES_IN_TEXT_SECTION 0 -+#define CASE_VECTOR_MODE SImode -+#define CASE_VECTOR_PC_RELATIVE (riscv_cmodel != CM_MEDLOW) -+ -+/* Define this as 1 if `char' should by default be signed; else as 0. */ -+#define DEFAULT_SIGNED_CHAR 0 -+ -+/* Consider using fld/fsd to move 8 bytes at a time for RV32IFD. */ -+#define MOVE_MAX UNITS_PER_WORD -+#define MAX_MOVE_MAX 8 -+ -+#define SLOW_BYTE_ACCESS 0 -+ -+#define SHIFT_COUNT_TRUNCATED 1 -+ -+/* Value is 1 if truncating an integer of INPREC bits to OUTPREC bits -+ is done just by pretending it is already truncated. */ -+#define TRULY_NOOP_TRUNCATION(OUTPREC, INPREC) \ -+ (TARGET_64BIT ? ((INPREC) <= 32 || (OUTPREC) < 32) : 1) -+ -+/* Specify the machine mode that pointers have. -+ After generation of rtl, the compiler makes no further distinction -+ between pointers and any other objects of this machine mode. */ -+ -+#ifndef Pmode -+#define Pmode (TARGET_64BIT ? DImode : SImode) -+#endif -+ -+/* Give call MEMs SImode since it is the "most permissive" mode -+ for both 32-bit and 64-bit targets. */ -+ -+#define FUNCTION_MODE SImode -+ -+/* A C expression for the cost of a branch instruction. A value of 2 -+ seems to minimize code size. */ -+ -+#define BRANCH_COST(speed_p, predictable_p) \ -+ ((!(speed_p) || (predictable_p)) ? 2 : riscv_branch_cost) -+ -+#define LOGICAL_OP_NON_SHORT_CIRCUIT 0 -+ -+/* Control the assembler format that we output. */ -+ -+/* Output to assembler file text saying following lines -+ may contain character constants, extra white space, comments, etc. */ -+ -+#ifndef ASM_APP_ON -+#define ASM_APP_ON " #APP\n" -+#endif -+ -+/* Output to assembler file text saying following lines -+ no longer contain unusual constructs. */ -+ -+#ifndef ASM_APP_OFF -+#define ASM_APP_OFF " #NO_APP\n" -+#endif -+ -+#define REGISTER_NAMES \ -+{ "zero","ra", "sp", "gp", "tp", "t0", "t1", "t2", \ -+ "s0", "s1", "a0", "a1", "a2", "a3", "a4", "a5", \ -+ "a6", "a7", "s2", "s3", "s4", "s5", "s6", "s7", \ -+ "s8", "s9", "s10", "s11", "t3", "t4", "t5", "t6", \ -+ "ft0", "ft1", "ft2", "ft3", "ft4", "ft5", "ft6", "ft7", \ -+ "fs0", "fs1", "fa0", "fa1", "fa2", "fa3", "fa4", "fa5", \ -+ "fa6", "fa7", "fs2", "fs3", "fs4", "fs5", "fs6", "fs7", \ -+ "fs8", "fs9", "fs10","fs11","ft8", "ft9", "ft10","ft11", \ -+ "arg", "frame", } -+ -+#define ADDITIONAL_REGISTER_NAMES \ -+{ \ -+ { "x0", 0 + GP_REG_FIRST }, \ -+ { "x1", 1 + GP_REG_FIRST }, \ -+ { "x2", 2 + GP_REG_FIRST }, \ -+ { "x3", 3 + GP_REG_FIRST }, \ -+ { "x4", 4 + GP_REG_FIRST }, \ -+ { "x5", 5 + GP_REG_FIRST }, \ -+ { "x6", 6 + GP_REG_FIRST }, \ -+ { "x7", 7 + GP_REG_FIRST }, \ -+ { "x8", 8 + GP_REG_FIRST }, \ -+ { "x9", 9 + GP_REG_FIRST }, \ -+ { "x10", 10 + GP_REG_FIRST }, \ -+ { "x11", 11 + GP_REG_FIRST }, \ -+ { "x12", 12 + GP_REG_FIRST }, \ -+ { "x13", 13 + GP_REG_FIRST }, \ -+ { "x14", 14 + GP_REG_FIRST }, \ -+ { "x15", 15 + GP_REG_FIRST }, \ -+ { "x16", 16 + GP_REG_FIRST }, \ -+ { "x17", 17 + GP_REG_FIRST }, \ -+ { "x18", 18 + GP_REG_FIRST }, \ -+ { "x19", 19 + GP_REG_FIRST }, \ -+ { "x20", 20 + GP_REG_FIRST }, \ -+ { "x21", 21 + GP_REG_FIRST }, \ -+ { "x22", 22 + GP_REG_FIRST }, \ -+ { "x23", 23 + GP_REG_FIRST }, \ -+ { "x24", 24 + GP_REG_FIRST }, \ -+ { "x25", 25 + GP_REG_FIRST }, \ -+ { "x26", 26 + GP_REG_FIRST }, \ -+ { "x27", 27 + GP_REG_FIRST }, \ -+ { "x28", 28 + GP_REG_FIRST }, \ -+ { "x29", 29 + GP_REG_FIRST }, \ -+ { "x30", 30 + GP_REG_FIRST }, \ -+ { "x31", 31 + GP_REG_FIRST }, \ -+ { "f0", 0 + FP_REG_FIRST }, \ -+ { "f1", 1 + FP_REG_FIRST }, \ -+ { "f2", 2 + FP_REG_FIRST }, \ -+ { "f3", 3 + FP_REG_FIRST }, \ -+ { "f4", 4 + FP_REG_FIRST }, \ -+ { "f5", 5 + FP_REG_FIRST }, \ -+ { "f6", 6 + FP_REG_FIRST }, \ -+ { "f7", 7 + FP_REG_FIRST }, \ -+ { "f8", 8 + FP_REG_FIRST }, \ -+ { "f9", 9 + FP_REG_FIRST }, \ -+ { "f10", 10 + FP_REG_FIRST }, \ -+ { "f11", 11 + FP_REG_FIRST }, \ -+ { "f12", 12 + FP_REG_FIRST }, \ -+ { "f13", 13 + FP_REG_FIRST }, \ -+ { "f14", 14 + FP_REG_FIRST }, \ -+ { "f15", 15 + FP_REG_FIRST }, \ -+ { "f16", 16 + FP_REG_FIRST }, \ -+ { "f17", 17 + FP_REG_FIRST }, \ -+ { "f18", 18 + FP_REG_FIRST }, \ -+ { "f19", 19 + FP_REG_FIRST }, \ -+ { "f20", 20 + FP_REG_FIRST }, \ -+ { "f21", 21 + FP_REG_FIRST }, \ -+ { "f22", 22 + FP_REG_FIRST }, \ -+ { "f23", 23 + FP_REG_FIRST }, \ -+ { "f24", 24 + FP_REG_FIRST }, \ -+ { "f25", 25 + FP_REG_FIRST }, \ -+ { "f26", 26 + FP_REG_FIRST }, \ -+ { "f27", 27 + FP_REG_FIRST }, \ -+ { "f28", 28 + FP_REG_FIRST }, \ -+ { "f29", 29 + FP_REG_FIRST }, \ -+ { "f30", 30 + FP_REG_FIRST }, \ -+ { "f31", 31 + FP_REG_FIRST }, \ -+} -+ -+/* Globalizing directive for a label. */ -+#define GLOBAL_ASM_OP "\t.globl\t" -+ -+/* This is how to store into the string LABEL -+ the symbol_ref name of an internal numbered label where -+ PREFIX is the class of label and NUM is the number within the class. -+ This is suitable for output with `assemble_name'. */ -+ -+#undef ASM_GENERATE_INTERNAL_LABEL -+#define ASM_GENERATE_INTERNAL_LABEL(LABEL,PREFIX,NUM) \ -+ sprintf ((LABEL), "*%s%s%ld", (LOCAL_LABEL_PREFIX), (PREFIX), (long)(NUM)) -+ -+/* This is how to output an element of a case-vector that is absolute. */ -+ -+#define ASM_OUTPUT_ADDR_VEC_ELT(STREAM, VALUE) \ -+ fprintf (STREAM, "\t.word\t%sL%d\n", LOCAL_LABEL_PREFIX, VALUE) -+ -+/* This is how to output an element of a PIC case-vector. */ -+ -+#define ASM_OUTPUT_ADDR_DIFF_ELT(STREAM, BODY, VALUE, REL) \ -+ fprintf (STREAM, "\t.word\t%sL%d-%sL%d\n", \ -+ LOCAL_LABEL_PREFIX, VALUE, LOCAL_LABEL_PREFIX, REL) -+ -+/* This is how to output an assembler line -+ that says to advance the location counter -+ to a multiple of 2**LOG bytes. */ -+ -+#define ASM_OUTPUT_ALIGN(STREAM,LOG) \ -+ fprintf (STREAM, "\t.align\t%d\n", (LOG)) -+ -+/* Define the strings to put out for each section in the object file. */ -+#define TEXT_SECTION_ASM_OP "\t.text" /* instructions */ -+#define DATA_SECTION_ASM_OP "\t.data" /* large data */ -+#define READONLY_DATA_SECTION_ASM_OP "\t.section\t.rodata" -+#define BSS_SECTION_ASM_OP "\t.bss" -+#define SBSS_SECTION_ASM_OP "\t.section\t.sbss,\"aw\",@nobits" -+#define SDATA_SECTION_ASM_OP "\t.section\t.sdata,\"aw\",@progbits" -+ -+#define ASM_OUTPUT_REG_PUSH(STREAM,REGNO) \ -+do \ -+ { \ -+ fprintf (STREAM, "\taddi\t%s,%s,-8\n\t%s\t%s,0(%s)\n", \ -+ reg_names[STACK_POINTER_REGNUM], \ -+ reg_names[STACK_POINTER_REGNUM], \ -+ TARGET_64BIT ? "sd" : "sw", \ -+ reg_names[REGNO], \ -+ reg_names[STACK_POINTER_REGNUM]); \ -+ } \ -+while (0) -+ -+#define ASM_OUTPUT_REG_POP(STREAM,REGNO) \ -+do \ -+ { \ -+ fprintf (STREAM, "\t%s\t%s,0(%s)\n\taddi\t%s,%s,8\n", \ -+ TARGET_64BIT ? "ld" : "lw", \ -+ reg_names[REGNO], \ -+ reg_names[STACK_POINTER_REGNUM], \ -+ reg_names[STACK_POINTER_REGNUM], \ -+ reg_names[STACK_POINTER_REGNUM]); \ -+ } \ -+while (0) -+ -+#define ASM_COMMENT_START "#" -+ -+#undef SIZE_TYPE -+#define SIZE_TYPE (POINTER_SIZE == 64 ? "long unsigned int" : "unsigned int") -+ -+#undef PTRDIFF_TYPE -+#define PTRDIFF_TYPE (POINTER_SIZE == 64 ? "long int" : "int") -+ -+/* The maximum number of bytes that can be copied by one iteration of -+ a movmemsi loop; see riscv_block_move_loop. */ -+#define RISCV_MAX_MOVE_BYTES_PER_LOOP_ITER (UNITS_PER_WORD * 4) -+ -+/* The maximum number of bytes that can be copied by a straight-line -+ implementation of movmemsi; see riscv_block_move_straight. We want -+ to make sure that any loop-based implementation will iterate at -+ least twice. */ -+#define RISCV_MAX_MOVE_BYTES_STRAIGHT (RISCV_MAX_MOVE_BYTES_PER_LOOP_ITER * 2) -+ -+/* The base cost of a memcpy call, for MOVE_RATIO and friends. */ -+ -+#define RISCV_CALL_RATIO 6 -+ -+/* Any loop-based implementation of movmemsi will have at least -+ RISCV_MAX_MOVE_BYTES_STRAIGHT / UNITS_PER_WORD memory-to-memory -+ moves, so allow individual copies of fewer elements. -+ -+ When movmemsi is not available, use a value approximating -+ the length of a memcpy call sequence, so that move_by_pieces -+ will generate inline code if it is shorter than a function call. -+ Since move_by_pieces_ninsns counts memory-to-memory moves, but -+ we'll have to generate a load/store pair for each, halve the -+ value of RISCV_CALL_RATIO to take that into account. */ -+ -+#define MOVE_RATIO(speed) \ -+ (HAVE_movmemsi \ -+ ? RISCV_MAX_MOVE_BYTES_STRAIGHT / MOVE_MAX \ -+ : RISCV_CALL_RATIO / 2) -+ -+/* movmemsi is meant to generate code that is at least as good as -+ move_by_pieces. However, movmemsi effectively uses a by-pieces -+ implementation both for moves smaller than a word and for word-aligned -+ moves of no more than RISCV_MAX_MOVE_BYTES_STRAIGHT bytes. We should -+ allow the tree-level optimisers to do such moves by pieces, as it -+ often exposes other optimization opportunities. We might as well -+ continue to use movmemsi at the rtl level though, as it produces -+ better code when scheduling is disabled (such as at -O). */ -+ -+#define MOVE_BY_PIECES_P(SIZE, ALIGN) \ -+ (HAVE_movmemsi \ -+ ? (!currently_expanding_to_rtl \ -+ && ((ALIGN) < BITS_PER_WORD \ -+ ? (SIZE) < UNITS_PER_WORD \ -+ : (SIZE) <= RISCV_MAX_MOVE_BYTES_STRAIGHT)) \ -+ : (move_by_pieces_ninsns (SIZE, ALIGN, MOVE_MAX_PIECES + 1) \ -+ < (unsigned int) MOVE_RATIO (false))) -+ -+/* For CLEAR_RATIO, when optimizing for size, give a better estimate -+ of the length of a memset call, but use the default otherwise. */ -+ -+#define CLEAR_RATIO(speed)\ -+ ((speed) ? 15 : RISCV_CALL_RATIO) -+ -+/* This is similar to CLEAR_RATIO, but for a non-zero constant, so when -+ optimizing for size adjust the ratio to account for the overhead of -+ loading the constant and replicating it across the word. */ -+ -+#define SET_RATIO(speed) \ -+ ((speed) ? 15 : RISCV_CALL_RATIO - 2) -+ -+/* STORE_BY_PIECES_P can be used when copying a constant string, but -+ in that case each word takes 3 insns (lui, ori, sw), or more in -+ 64-bit mode, instead of 2 (lw, sw). For now we always fail this -+ and let the move_by_pieces code copy the string from read-only -+ memory. In the future, this could be tuned further for multi-issue -+ CPUs that can issue stores down one pipe and arithmetic instructions -+ down another; in that case, the lui/ori/sw combination would be a -+ win for long enough strings. */ -+ -+#define STORE_BY_PIECES_P(SIZE, ALIGN) 0 -+ -+#ifndef HAVE_AS_TLS -+#define HAVE_AS_TLS 0 -+#endif -+ -+#ifndef USED_FOR_TARGET -+ -+extern const enum reg_class riscv_regno_to_class[]; -+extern bool riscv_hard_regno_mode_ok[][FIRST_PSEUDO_REGISTER]; -+extern const char* riscv_hi_relocs[]; -+#endif -+ -+#define ASM_PREFERRED_EH_DATA_FORMAT(CODE,GLOBAL) \ -+ (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel | DW_EH_PE_sdata4) -diff -rNU3 dist.orig/gcc/config/riscv/riscv.md dist/gcc/config/riscv/riscv.md ---- dist.orig/gcc/config/riscv/riscv.md 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/riscv/riscv.md 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,2427 @@ -+;; Machine description for RISC-V for GNU compiler. -+;; Copyright (C) 2011-2014 Free Software Foundation, Inc. -+;; Contributed by Andrew Waterman (waterman@cs.berkeley.edu) at UC Berkeley. -+;; Based on MIPS target for GNU compiler. -+ -+;; This file is part of GCC. -+ -+;; GCC is free software; you can redistribute it and/or modify -+;; it under the terms of the GNU General Public License as published by -+;; the Free Software Foundation; either version 3, or (at your option) -+;; any later version. -+ -+;; GCC is distributed in the hope that it will be useful, -+;; but WITHOUT ANY WARRANTY; without even the implied warranty of -+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+;; GNU General Public License for more details. -+ -+;; You should have received a copy of the GNU General Public License -+;; along with GCC; see the file COPYING3. If not see -+;; . -+ -+(define_c_enum "unspec" [ -+ ;; Floating-point moves. -+ UNSPEC_LOAD_LOW -+ UNSPEC_LOAD_HIGH -+ UNSPEC_STORE_WORD -+ -+ ;; GP manipulation. -+ UNSPEC_EH_RETURN -+ -+ ;; Symbolic accesses. -+ UNSPEC_ADDRESS_FIRST -+ UNSPEC_LOAD_GOT -+ UNSPEC_TLS -+ UNSPEC_TLS_LE -+ UNSPEC_TLS_IE -+ UNSPEC_TLS_GD -+ -+ ;; Blockage and synchronisation. -+ UNSPEC_BLOCKAGE -+ UNSPEC_FENCE -+ UNSPEC_FENCE_I -+]) -+ -+(define_constants -+ [(RETURN_ADDR_REGNUM 1) -+]) -+ -+(include "predicates.md") -+(include "constraints.md") -+ -+;; .................... -+;; -+;; Attributes -+;; -+;; .................... -+ -+(define_attr "got" "unset,xgot_high,load" -+ (const_string "unset")) -+ -+;; For jal instructions, this attribute is DIRECT when the target address -+;; is symbolic and INDIRECT when it is a register. -+(define_attr "jal" "unset,direct,indirect" -+ (const_string "unset")) -+ -+;; Classification of moves, extensions and truncations. Most values -+;; are as for "type" (see below) but there are also the following -+;; move-specific values: -+;; -+;; andi a single ANDI instruction -+;; shift_shift a shift left followed by a shift right -+;; -+;; This attribute is used to determine the instruction's length and -+;; scheduling type. For doubleword moves, the attribute always describes -+;; the split instructions; in some cases, it is more appropriate for the -+;; scheduling type to be "multi" instead. -+(define_attr "move_type" -+ "unknown,load,fpload,store,fpstore,mtc,mfc,move,fmove, -+ const,logical,arith,andi,shift_shift" -+ (const_string "unknown")) -+ -+(define_attr "alu_type" "unknown,add,sub,and,or,xor" -+ (const_string "unknown")) -+ -+;; Main data type used by the insn -+(define_attr "mode" "unknown,none,QI,HI,SI,DI,TI,SF,DF,TF,FPSW" -+ (const_string "unknown")) -+ -+;; True if the main data type is twice the size of a word. -+(define_attr "dword_mode" "no,yes" -+ (cond [(and (eq_attr "mode" "DI,DF") -+ (eq (symbol_ref "TARGET_64BIT") (const_int 0))) -+ (const_string "yes") -+ -+ (and (eq_attr "mode" "TI,TF") -+ (ne (symbol_ref "TARGET_64BIT") (const_int 0))) -+ (const_string "yes")] -+ (const_string "no"))) -+ -+;; Classification of each insn. -+;; branch conditional branch -+;; jump unconditional jump -+;; call unconditional call -+;; load load instruction(s) -+;; fpload floating point load -+;; fpidxload floating point indexed load -+;; store store instruction(s) -+;; fpstore floating point store -+;; fpidxstore floating point indexed store -+;; mtc transfer to coprocessor -+;; mfc transfer from coprocessor -+;; const load constant -+;; arith integer arithmetic instructions -+;; logical integer logical instructions -+;; shift integer shift instructions -+;; slt set less than instructions -+;; imul integer multiply -+;; idiv integer divide -+;; move integer register move (addi rd, rs1, 0) -+;; fmove floating point register move -+;; fadd floating point add/subtract -+;; fmul floating point multiply -+;; fmadd floating point multiply-add -+;; fdiv floating point divide -+;; fcmp floating point compare -+;; fcvt floating point convert -+;; fsqrt floating point square root -+;; multi multiword sequence (or user asm statements) -+;; nop no operation -+;; ghost an instruction that produces no real code -+(define_attr "type" -+ "unknown,branch,jump,call,load,fpload,fpidxload,store,fpstore,fpidxstore, -+ mtc,mfc,const,arith,logical,shift,slt,imul,idiv,move,fmove,fadd,fmul, -+ fmadd,fdiv,fcmp,fcvt,fsqrt,multi,nop,ghost" -+ (cond [(eq_attr "jal" "!unset") (const_string "call") -+ (eq_attr "got" "load") (const_string "load") -+ -+ (eq_attr "alu_type" "add,sub") (const_string "arith") -+ -+ (eq_attr "alu_type" "and,or,xor") (const_string "logical") -+ -+ ;; If a doubleword move uses these expensive instructions, -+ ;; it is usually better to schedule them in the same way -+ ;; as the singleword form, rather than as "multi". -+ (eq_attr "move_type" "load") (const_string "load") -+ (eq_attr "move_type" "fpload") (const_string "fpload") -+ (eq_attr "move_type" "store") (const_string "store") -+ (eq_attr "move_type" "fpstore") (const_string "fpstore") -+ (eq_attr "move_type" "mtc") (const_string "mtc") -+ (eq_attr "move_type" "mfc") (const_string "mfc") -+ -+ ;; These types of move are always single insns. -+ (eq_attr "move_type" "fmove") (const_string "fmove") -+ (eq_attr "move_type" "arith") (const_string "arith") -+ (eq_attr "move_type" "logical") (const_string "logical") -+ (eq_attr "move_type" "andi") (const_string "logical") -+ -+ ;; These types of move are always split. -+ (eq_attr "move_type" "shift_shift") -+ (const_string "multi") -+ -+ ;; These types of move are split for doubleword modes only. -+ (and (eq_attr "move_type" "move,const") -+ (eq_attr "dword_mode" "yes")) -+ (const_string "multi") -+ (eq_attr "move_type" "move") (const_string "move") -+ (eq_attr "move_type" "const") (const_string "const")] -+ (const_string "unknown"))) -+ -+;; Mode for conversion types (fcvt) -+;; I2S integer to float single (SI/DI to SF) -+;; I2D integer to float double (SI/DI to DF) -+;; S2I float to integer (SF to SI/DI) -+;; D2I float to integer (DF to SI/DI) -+;; D2S double to float single -+;; S2D float single to double -+ -+(define_attr "cnv_mode" "unknown,I2S,I2D,S2I,D2I,D2S,S2D" -+ (const_string "unknown")) -+ -+;; Length of instruction in bytes. -+(define_attr "length" "" -+ (cond [ -+ ;; Direct branch instructions have a range of [-0x1000,0xffc], -+ ;; relative to the address of the delay slot. If a branch is -+ ;; outside this range, convert a branch like: -+ ;; -+ ;; bne r1,r2,target -+ ;; -+ ;; to: -+ ;; -+ ;; beq r1,r2,1f -+ ;; j target -+ ;; 1: -+ ;; -+ (eq_attr "type" "branch") -+ (if_then_else (and (le (minus (match_dup 0) (pc)) (const_int 4088)) -+ (le (minus (pc) (match_dup 0)) (const_int 4092))) -+ (const_int 4) -+ (const_int 8)) -+ -+ ;; Conservatively assume calls take two instructions, as in: -+ ;; auipc t0, %pcrel_hi(target) -+ ;; jalr ra, t0, %lo(target) -+ ;; The linker will relax these into JAL when appropriate. -+ (eq_attr "type" "call") -+ (const_int 8) -+ -+ ;; "Ghost" instructions occupy no space. -+ (eq_attr "type" "ghost") -+ (const_int 0) -+ -+ (eq_attr "got" "load") (const_int 8) -+ -+ ;; SHIFT_SHIFTs are decomposed into two separate instructions. -+ (eq_attr "move_type" "shift_shift") -+ (const_int 8) -+ -+ ;; Check for doubleword moves that are decomposed into two -+ ;; instructions. -+ (and (eq_attr "move_type" "mtc,mfc,move") -+ (eq_attr "dword_mode" "yes")) -+ (const_int 8) -+ -+ ;; Doubleword CONST{,N} moves are split into two word -+ ;; CONST{,N} moves. -+ (and (eq_attr "move_type" "const") -+ (eq_attr "dword_mode" "yes")) -+ (symbol_ref "riscv_split_const_insns (operands[1]) * 4") -+ -+ ;; Otherwise, constants, loads and stores are handled by external -+ ;; routines. -+ (eq_attr "move_type" "load,fpload") -+ (symbol_ref "riscv_load_store_insns (operands[1], insn) * 4") -+ (eq_attr "move_type" "store,fpstore") -+ (symbol_ref "riscv_load_store_insns (operands[0], insn) * 4") -+ ] (const_int 4))) -+ -+;; Describe a user's asm statement. -+(define_asm_attributes -+ [(set_attr "type" "multi")]) -+ -+;; This mode iterator allows 32-bit and 64-bit GPR patterns to be generated -+;; from the same template. -+(define_mode_iterator GPR [SI (DI "TARGET_64BIT")]) -+(define_mode_iterator SUPERQI [HI SI (DI "TARGET_64BIT")]) -+ -+;; A copy of GPR that can be used when a pattern has two independent -+;; modes. -+(define_mode_iterator GPR2 [SI (DI "TARGET_64BIT")]) -+ -+;; This mode iterator allows :P to be used for patterns that operate on -+;; pointer-sized quantities. Exactly one of the two alternatives will match. -+(define_mode_iterator P [(SI "Pmode == SImode") (DI "Pmode == DImode")]) -+ -+;; 32-bit integer moves for which we provide move patterns. -+(define_mode_iterator IMOVE32 [SI]) -+ -+;; 64-bit modes for which we provide move patterns. -+(define_mode_iterator MOVE64 [DI DF]) -+ -+;; 128-bit modes for which we provide move patterns on 64-bit targets. -+(define_mode_iterator MOVE128 [TI TF]) -+ -+;; This mode iterator allows the QI and HI extension patterns to be -+;; defined from the same template. -+(define_mode_iterator SHORT [QI HI]) -+ -+;; Likewise the 64-bit truncate-and-shift patterns. -+(define_mode_iterator SUBDI [QI HI SI]) -+(define_mode_iterator HISI [HI SI]) -+(define_mode_iterator ANYI [QI HI SI (DI "TARGET_64BIT")]) -+ -+;; This mode iterator allows :ANYF to be used wherever a scalar or vector -+;; floating-point mode is allowed. -+(define_mode_iterator ANYF [(SF "TARGET_HARD_FLOAT") -+ (DF "TARGET_HARD_FLOAT")]) -+(define_mode_iterator ANYIF [QI HI SI (DI "TARGET_64BIT") -+ (SF "TARGET_HARD_FLOAT") -+ (DF "TARGET_HARD_FLOAT")]) -+ -+;; Like ANYF, but only applies to scalar modes. -+(define_mode_iterator SCALARF [(SF "TARGET_HARD_FLOAT") -+ (DF "TARGET_HARD_FLOAT")]) -+ -+;; A floating-point mode for which moves involving FPRs may need to be split. -+(define_mode_iterator SPLITF -+ [(DF "!TARGET_64BIT") -+ (DI "!TARGET_64BIT") -+ (TF "TARGET_64BIT")]) -+ -+;; This attribute gives the length suffix for a sign- or zero-extension -+;; instruction. -+(define_mode_attr size [(QI "b") (HI "h")]) -+ -+;; Mode attributes for loads. -+(define_mode_attr load [(QI "lb") (HI "lh") (SI "lw") (DI "ld") (SF "flw") (DF "fld")]) -+ -+;; Instruction names for stores. -+(define_mode_attr store [(QI "sb") (HI "sh") (SI "sw") (DI "sd") (SF "fsw") (DF "fsd")]) -+ -+;; This attribute gives the best constraint to use for registers of -+;; a given mode. -+(define_mode_attr reg [(SI "d") (DI "d") (CC "d")]) -+ -+;; This attribute gives the format suffix for floating-point operations. -+(define_mode_attr fmt [(SF "s") (DF "d")]) -+ -+;; This attribute gives the format suffix for atomic memory operations. -+(define_mode_attr amo [(SI "w") (DI "d")]) -+ -+;; This attribute gives the upper-case mode name for one unit of a -+;; floating-point mode. -+(define_mode_attr UNITMODE [(SF "SF") (DF "DF")]) -+ -+;; This attribute gives the integer mode that has half the size of -+;; the controlling mode. -+(define_mode_attr HALFMODE [(DF "SI") (DI "SI") (TF "DI")]) -+ -+;; This code iterator allows signed and unsigned widening multiplications -+;; to use the same template. -+(define_code_iterator any_extend [sign_extend zero_extend]) -+ -+;; This code iterator allows the two right shift instructions to be -+;; generated from the same template. -+(define_code_iterator any_shiftrt [ashiftrt lshiftrt]) -+ -+;; This code iterator allows the three shift instructions to be generated -+;; from the same template. -+(define_code_iterator any_shift [ashift ashiftrt lshiftrt]) -+ -+;; This code iterator allows unsigned and signed division to be generated -+;; from the same template. -+(define_code_iterator any_div [div udiv]) -+ -+;; This code iterator allows unsigned and signed modulus to be generated -+;; from the same template. -+(define_code_iterator any_mod [mod umod]) -+ -+;; These code iterators allow the signed and unsigned scc operations to use -+;; the same template. -+(define_code_iterator any_gt [gt gtu]) -+(define_code_iterator any_ge [ge geu]) -+(define_code_iterator any_lt [lt ltu]) -+(define_code_iterator any_le [le leu]) -+ -+;; expands to an empty string when doing a signed operation and -+;; "u" when doing an unsigned operation. -+(define_code_attr u [(sign_extend "") (zero_extend "u") -+ (div "") (udiv "u") -+ (mod "") (umod "u") -+ (gt "") (gtu "u") -+ (ge "") (geu "u") -+ (lt "") (ltu "u") -+ (le "") (leu "u")]) -+ -+;; is like , but the signed form expands to "s" rather than "". -+(define_code_attr su [(sign_extend "s") (zero_extend "u")]) -+ -+;; expands to the name of the optab for a particular code. -+(define_code_attr optab [(ashift "ashl") -+ (ashiftrt "ashr") -+ (lshiftrt "lshr") -+ (ior "ior") -+ (xor "xor") -+ (and "and") -+ (plus "add") -+ (minus "sub")]) -+ -+;; expands to the name of the insn that implements a particular code. -+(define_code_attr insn [(ashift "sll") -+ (ashiftrt "sra") -+ (lshiftrt "srl") -+ (ior "or") -+ (xor "xor") -+ (and "and") -+ (plus "add") -+ (minus "sub")]) -+ -+;; Pipeline descriptions. -+;; -+;; generic.md provides a fallback for processors without a specific -+;; pipeline description. It is derived from the old define_function_unit -+;; version and uses the "alu" and "imuldiv" units declared below. -+;; -+;; Some of the processor-specific files are also derived from old -+;; define_function_unit descriptions and simply override the parts of -+;; generic.md that don't apply. The other processor-specific files -+;; are self-contained. -+(define_automaton "alu,imuldiv") -+ -+(define_cpu_unit "alu" "alu") -+(define_cpu_unit "imuldiv" "imuldiv") -+ -+;; Ghost instructions produce no real code and introduce no hazards. -+;; They exist purely to express an effect on dataflow. -+(define_insn_reservation "ghost" 0 -+ (eq_attr "type" "ghost") -+ "nothing") -+ -+(include "generic.md") -+ -+;; -+;; .................... -+;; -+;; ADDITION -+;; -+;; .................... -+;; -+ -+(define_insn "add3" -+ [(set (match_operand:ANYF 0 "register_operand" "=f") -+ (plus:ANYF (match_operand:ANYF 1 "register_operand" "f") -+ (match_operand:ANYF 2 "register_operand" "f")))] -+ "" -+ "fadd.\t%0,%1,%2" -+ [(set_attr "type" "fadd") -+ (set_attr "mode" "")]) -+ -+(define_expand "add3" -+ [(set (match_operand:GPR 0 "register_operand") -+ (plus:GPR (match_operand:GPR 1 "register_operand") -+ (match_operand:GPR 2 "arith_operand")))] -+ "") -+ -+(define_insn "*addsi3" -+ [(set (match_operand:SI 0 "register_operand" "=r,r") -+ (plus:SI (match_operand:GPR 1 "register_operand" "r,r") -+ (match_operand:GPR2 2 "arith_operand" "r,Q")))] -+ "" -+ { return TARGET_64BIT ? "addw\t%0,%1,%2" : "add\t%0,%1,%2"; } -+ [(set_attr "type" "arith") -+ (set_attr "mode" "SI")]) -+ -+(define_insn "*adddi3" -+ [(set (match_operand:DI 0 "register_operand" "=r,r") -+ (plus:DI (match_operand:DI 1 "register_operand" "r,r") -+ (match_operand:DI 2 "arith_operand" "r,Q")))] -+ "TARGET_64BIT" -+ "add\t%0,%1,%2" -+ [(set_attr "type" "arith") -+ (set_attr "mode" "DI")]) -+ -+(define_insn "*addsi3_extended" -+ [(set (match_operand:DI 0 "register_operand" "=r,r") -+ (sign_extend:DI -+ (plus:SI (match_operand:SI 1 "register_operand" "r,r") -+ (match_operand:SI 2 "arith_operand" "r,Q"))))] -+ "TARGET_64BIT" -+ "addw\t%0,%1,%2" -+ [(set_attr "type" "arith") -+ (set_attr "mode" "SI")]) -+ -+(define_insn "*adddisi3" -+ [(set (match_operand:SI 0 "register_operand" "=r,r") -+ (plus:SI (truncate:SI (match_operand:DI 1 "register_operand" "r,r")) -+ (truncate:SI (match_operand:DI 2 "arith_operand" "r,Q"))))] -+ "TARGET_64BIT" -+ "addw\t%0,%1,%2" -+ [(set_attr "type" "arith") -+ (set_attr "mode" "SI")]) -+ -+(define_insn "*adddisisi3" -+ [(set (match_operand:SI 0 "register_operand" "=r,r") -+ (plus:SI (truncate:SI (match_operand:DI 1 "register_operand" "r,r")) -+ (match_operand:SI 2 "arith_operand" "r,Q")))] -+ "TARGET_64BIT" -+ "addw\t%0,%1,%2" -+ [(set_attr "type" "arith") -+ (set_attr "mode" "SI")]) -+ -+(define_insn "*adddi3_truncsi" -+ [(set (match_operand:SI 0 "register_operand" "=r,r") -+ (truncate:SI -+ (plus:DI (match_operand:DI 1 "register_operand" "r,r") -+ (match_operand:DI 2 "arith_operand" "r,Q"))))] -+ "TARGET_64BIT" -+ "addw\t%0,%1,%2" -+ [(set_attr "type" "arith") -+ (set_attr "mode" "SI")]) -+ -+;; -+;; .................... -+;; -+;; SUBTRACTION -+;; -+;; .................... -+;; -+ -+(define_insn "sub3" -+ [(set (match_operand:ANYF 0 "register_operand" "=f") -+ (minus:ANYF (match_operand:ANYF 1 "register_operand" "f") -+ (match_operand:ANYF 2 "register_operand" "f")))] -+ "" -+ "fsub.\t%0,%1,%2" -+ [(set_attr "type" "fadd") -+ (set_attr "mode" "")]) -+ -+(define_expand "sub3" -+ [(set (match_operand:GPR 0 "register_operand") -+ (minus:GPR (match_operand:GPR 1 "reg_or_0_operand") -+ (match_operand:GPR 2 "register_operand")))] -+ "") -+ -+(define_insn "*subdi3" -+ [(set (match_operand:DI 0 "register_operand" "=r") -+ (minus:DI (match_operand:DI 1 "reg_or_0_operand" "rJ") -+ (match_operand:DI 2 "register_operand" "r")))] -+ "TARGET_64BIT" -+ "sub\t%0,%z1,%2" -+ [(set_attr "type" "arith") -+ (set_attr "mode" "DI")]) -+ -+(define_insn "*subsi3" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (minus:SI (match_operand:GPR 1 "reg_or_0_operand" "rJ") -+ (match_operand:GPR2 2 "register_operand" "r")))] -+ "" -+ { return TARGET_64BIT ? "subw\t%0,%z1,%2" : "sub\t%0,%z1,%2"; } -+ [(set_attr "type" "arith") -+ (set_attr "mode" "SI")]) -+ -+(define_insn "*subsi3_extended" -+ [(set (match_operand:DI 0 "register_operand" "=r") -+ (sign_extend:DI -+ (minus:SI (match_operand:SI 1 "reg_or_0_operand" "rJ") -+ (match_operand:SI 2 "register_operand" "r"))))] -+ "TARGET_64BIT" -+ "subw\t%0,%z1,%2" -+ [(set_attr "type" "arith") -+ (set_attr "mode" "DI")]) -+ -+(define_insn "*subdisi3" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (minus:SI (truncate:SI (match_operand:DI 1 "reg_or_0_operand" "rJ")) -+ (truncate:SI (match_operand:DI 2 "register_operand" "r"))))] -+ "TARGET_64BIT" -+ "subw\t%0,%z1,%2" -+ [(set_attr "type" "arith") -+ (set_attr "mode" "SI")]) -+ -+(define_insn "*subdisisi3" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (minus:SI (truncate:SI (match_operand:DI 1 "reg_or_0_operand" "rJ")) -+ (match_operand:SI 2 "register_operand" "r")))] -+ "TARGET_64BIT" -+ "subw\t%0,%z1,%2" -+ [(set_attr "type" "arith") -+ (set_attr "mode" "SI")]) -+ -+(define_insn "*subsidisi3" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (minus:SI (match_operand:SI 1 "reg_or_0_operand" "rJ") -+ (truncate:SI (match_operand:DI 2 "register_operand" "r"))))] -+ "TARGET_64BIT" -+ "subw\t%0,%z1,%2" -+ [(set_attr "type" "arith") -+ (set_attr "mode" "SI")]) -+ -+(define_insn "*subdi3_truncsi" -+ [(set (match_operand:SI 0 "register_operand" "=r,r") -+ (truncate:SI -+ (minus:DI (match_operand:DI 1 "reg_or_0_operand" "rJ,r") -+ (match_operand:DI 2 "arith_operand" "r,Q"))))] -+ "TARGET_64BIT" -+ "subw\t%0,%z1,%2" -+ [(set_attr "type" "arith") -+ (set_attr "mode" "SI")]) -+ -+;; -+;; .................... -+;; -+;; MULTIPLICATION -+;; -+;; .................... -+;; -+ -+(define_insn "mul3" -+ [(set (match_operand:SCALARF 0 "register_operand" "=f") -+ (mult:SCALARF (match_operand:SCALARF 1 "register_operand" "f") -+ (match_operand:SCALARF 2 "register_operand" "f")))] -+ "" -+ "fmul.\t%0,%1,%2" -+ [(set_attr "type" "fmul") -+ (set_attr "mode" "")]) -+ -+(define_expand "mul3" -+ [(set (match_operand:GPR 0 "register_operand") -+ (mult:GPR (match_operand:GPR 1 "reg_or_0_operand") -+ (match_operand:GPR 2 "register_operand")))] -+ "TARGET_MULDIV") -+ -+(define_insn "*mulsi3" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (mult:SI (match_operand:GPR 1 "register_operand" "r") -+ (match_operand:GPR2 2 "register_operand" "r")))] -+ "TARGET_MULDIV" -+ { return TARGET_64BIT ? "mulw\t%0,%1,%2" : "mul\t%0,%1,%2"; } -+ [(set_attr "type" "imul") -+ (set_attr "mode" "SI")]) -+ -+(define_insn "*muldisi3" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (mult:SI (truncate:SI (match_operand:DI 1 "register_operand" "r")) -+ (truncate:SI (match_operand:DI 2 "register_operand" "r"))))] -+ "TARGET_MULDIV && TARGET_64BIT" -+ "mulw\t%0,%1,%2" -+ [(set_attr "type" "imul") -+ (set_attr "mode" "SI")]) -+ -+(define_insn "*muldi3_truncsi" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (truncate:SI -+ (mult:DI (match_operand:DI 1 "register_operand" "r") -+ (match_operand:DI 2 "register_operand" "r"))))] -+ "TARGET_MULDIV && TARGET_64BIT" -+ "mulw\t%0,%1,%2" -+ [(set_attr "type" "imul") -+ (set_attr "mode" "SI")]) -+ -+(define_insn "*muldi3" -+ [(set (match_operand:DI 0 "register_operand" "=r") -+ (mult:DI (match_operand:DI 1 "register_operand" "r") -+ (match_operand:DI 2 "register_operand" "r")))] -+ "TARGET_MULDIV && TARGET_64BIT" -+ "mul\t%0,%1,%2" -+ [(set_attr "type" "imul") -+ (set_attr "mode" "DI")]) -+ -+;; -+;; ........................ -+;; -+;; MULTIPLICATION HIGH-PART -+;; -+;; ........................ -+;; -+ -+ -+;; Using a clobber here is ghetto, but I'm not smart enough to do better. ' -+(define_insn_and_split "mulditi3" -+ [(set (match_operand:TI 0 "register_operand" "=r") -+ (mult:TI (any_extend:TI -+ (match_operand:DI 1 "register_operand" "r")) -+ (any_extend:TI -+ (match_operand:DI 2 "register_operand" "r")))) -+ (clobber (match_scratch:DI 3 "=r"))] -+ "TARGET_MULDIV && TARGET_64BIT" -+ "#" -+ "reload_completed" -+ [ -+ (set (match_dup 3) (mult:DI (match_dup 1) (match_dup 2))) -+ (set (match_dup 4) (truncate:DI -+ (lshiftrt:TI -+ (mult:TI (any_extend:TI (match_dup 1)) -+ (any_extend:TI (match_dup 2))) -+ (const_int 64)))) -+ (set (match_dup 5) (match_dup 3)) -+ ] -+{ -+ operands[4] = riscv_subword (operands[0], true); -+ operands[5] = riscv_subword (operands[0], false); -+} -+ ) -+ -+(define_insn "muldi3_highpart" -+ [(set (match_operand:DI 0 "register_operand" "=r") -+ (truncate:DI -+ (lshiftrt:TI -+ (mult:TI (any_extend:TI -+ (match_operand:DI 1 "register_operand" "r")) -+ (any_extend:TI -+ (match_operand:DI 2 "register_operand" "r"))) -+ (const_int 64))))] -+ "TARGET_MULDIV && TARGET_64BIT" -+ "mulh\t%0,%1,%2" -+ [(set_attr "type" "imul") -+ (set_attr "mode" "DI")]) -+ -+ -+(define_insn_and_split "usmulditi3" -+ [(set (match_operand:TI 0 "register_operand" "=r") -+ (mult:TI (zero_extend:TI -+ (match_operand:DI 1 "register_operand" "r")) -+ (sign_extend:TI -+ (match_operand:DI 2 "register_operand" "r")))) -+ (clobber (match_scratch:DI 3 "=r"))] -+ "TARGET_MULDIV && TARGET_64BIT" -+ "#" -+ "reload_completed" -+ [ -+ (set (match_dup 3) (mult:DI (match_dup 1) (match_dup 2))) -+ (set (match_dup 4) (truncate:DI -+ (lshiftrt:TI -+ (mult:TI (zero_extend:TI (match_dup 1)) -+ (sign_extend:TI (match_dup 2))) -+ (const_int 64)))) -+ (set (match_dup 5) (match_dup 3)) -+ ] -+{ -+ operands[4] = riscv_subword (operands[0], true); -+ operands[5] = riscv_subword (operands[0], false); -+} -+ ) -+ -+(define_insn "usmuldi3_highpart" -+ [(set (match_operand:DI 0 "register_operand" "=r") -+ (truncate:DI -+ (lshiftrt:TI -+ (mult:TI (zero_extend:TI -+ (match_operand:DI 1 "register_operand" "r")) -+ (sign_extend:TI -+ (match_operand:DI 2 "register_operand" "r"))) -+ (const_int 64))))] -+ "TARGET_MULDIV && TARGET_64BIT" -+ "mulhsu\t%0,%2,%1" -+ [(set_attr "type" "imul") -+ (set_attr "mode" "DI")]) -+ -+(define_expand "mulsidi3" -+ [(set (match_operand:DI 0 "register_operand" "=r") -+ (mult:DI (any_extend:DI -+ (match_operand:SI 1 "register_operand" "r")) -+ (any_extend:DI -+ (match_operand:SI 2 "register_operand" "r")))) -+ (clobber (match_scratch:SI 3 "=r"))] -+ "TARGET_MULDIV && !TARGET_64BIT" -+{ -+ rtx temp = gen_reg_rtx (SImode); -+ emit_insn (gen_mulsi3 (temp, operands[1], operands[2])); -+ emit_insn (gen_mulsi3_highpart (riscv_subword (operands[0], true), -+ operands[1], operands[2])); -+ emit_insn (gen_movsi (riscv_subword (operands[0], false), temp)); -+ DONE; -+} -+ ) -+ -+(define_insn "mulsi3_highpart" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (truncate:SI -+ (lshiftrt:DI -+ (mult:DI (any_extend:DI -+ (match_operand:SI 1 "register_operand" "r")) -+ (any_extend:DI -+ (match_operand:SI 2 "register_operand" "r"))) -+ (const_int 32))))] -+ "TARGET_MULDIV && !TARGET_64BIT" -+ "mulh\t%0,%1,%2" -+ [(set_attr "type" "imul") -+ (set_attr "mode" "SI")]) -+ -+ -+(define_expand "usmulsidi3" -+ [(set (match_operand:DI 0 "register_operand" "=r") -+ (mult:DI (zero_extend:DI -+ (match_operand:SI 1 "register_operand" "r")) -+ (sign_extend:DI -+ (match_operand:SI 2 "register_operand" "r")))) -+ (clobber (match_scratch:SI 3 "=r"))] -+ "TARGET_MULDIV && !TARGET_64BIT" -+{ -+ rtx temp = gen_reg_rtx (SImode); -+ emit_insn (gen_mulsi3 (temp, operands[1], operands[2])); -+ emit_insn (gen_usmulsi3_highpart (riscv_subword (operands[0], true), -+ operands[1], operands[2])); -+ emit_insn (gen_movsi (riscv_subword (operands[0], false), temp)); -+ DONE; -+} -+ ) -+ -+(define_insn "usmulsi3_highpart" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (truncate:SI -+ (lshiftrt:DI -+ (mult:DI (zero_extend:DI -+ (match_operand:SI 1 "register_operand" "r")) -+ (sign_extend:DI -+ (match_operand:SI 2 "register_operand" "r"))) -+ (const_int 32))))] -+ "TARGET_MULDIV && !TARGET_64BIT" -+ "mulhsu\t%0,%2,%1" -+ [(set_attr "type" "imul") -+ (set_attr "mode" "SI")]) -+ -+;; -+;; .................... -+;; -+;; DIVISION and REMAINDER -+;; -+;; .................... -+;; -+ -+(define_insn "divsi3" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (any_div:SI (match_operand:SI 1 "register_operand" "r") -+ (match_operand:SI 2 "register_operand" "r")))] -+ "TARGET_MULDIV" -+ { return TARGET_64BIT ? "divw\t%0,%1,%2" : "div\t%0,%1,%2"; } -+ [(set_attr "type" "idiv") -+ (set_attr "mode" "SI")]) -+ -+(define_insn "divdi3" -+ [(set (match_operand:DI 0 "register_operand" "=r") -+ (any_div:DI (match_operand:DI 1 "register_operand" "r") -+ (match_operand:DI 2 "register_operand" "r")))] -+ "TARGET_MULDIV && TARGET_64BIT" -+ "div\t%0,%1,%2" -+ [(set_attr "type" "idiv") -+ (set_attr "mode" "DI")]) -+ -+(define_insn "modsi3" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (any_mod:SI (match_operand:SI 1 "register_operand" "r") -+ (match_operand:SI 2 "register_operand" "r")))] -+ "TARGET_MULDIV" -+ { return TARGET_64BIT ? "remw\t%0,%1,%2" : "rem\t%0,%1,%2"; } -+ [(set_attr "type" "idiv") -+ (set_attr "mode" "SI")]) -+ -+(define_insn "moddi3" -+ [(set (match_operand:DI 0 "register_operand" "=r") -+ (any_mod:DI (match_operand:DI 1 "register_operand" "r") -+ (match_operand:DI 2 "register_operand" "r")))] -+ "TARGET_MULDIV && TARGET_64BIT" -+ "rem\t%0,%1,%2" -+ [(set_attr "type" "idiv") -+ (set_attr "mode" "DI")]) -+ -+(define_insn "div3" -+ [(set (match_operand:ANYF 0 "register_operand" "=f") -+ (div:ANYF (match_operand:ANYF 1 "register_operand" "f") -+ (match_operand:ANYF 2 "register_operand" "f")))] -+ "TARGET_HARD_FLOAT && TARGET_FDIV" -+ "fdiv.\t%0,%1,%2" -+ [(set_attr "type" "fdiv") -+ (set_attr "mode" "")]) -+ -+;; -+;; .................... -+;; -+;; SQUARE ROOT -+;; -+;; .................... -+ -+(define_insn "sqrt2" -+ [(set (match_operand:ANYF 0 "register_operand" "=f") -+ (sqrt:ANYF (match_operand:ANYF 1 "register_operand" "f")))] -+ "TARGET_HARD_FLOAT && TARGET_FDIV" -+{ -+ return "fsqrt.\t%0,%1"; -+} -+ [(set_attr "type" "fsqrt") -+ (set_attr "mode" "")]) -+ -+;; Floating point multiply accumulate instructions. -+ -+(define_insn "fma4" -+ [(set (match_operand:ANYF 0 "register_operand" "=f") -+ (fma:ANYF -+ (match_operand:ANYF 1 "register_operand" "f") -+ (match_operand:ANYF 2 "register_operand" "f") -+ (match_operand:ANYF 3 "register_operand" "f")))] -+ "TARGET_HARD_FLOAT" -+ "fmadd.\t%0,%1,%2,%3" -+ [(set_attr "type" "fmadd") -+ (set_attr "mode" "")]) -+ -+(define_insn "fms4" -+ [(set (match_operand:ANYF 0 "register_operand" "=f") -+ (fma:ANYF -+ (match_operand:ANYF 1 "register_operand" "f") -+ (match_operand:ANYF 2 "register_operand" "f") -+ (neg:ANYF (match_operand:ANYF 3 "register_operand" "f"))))] -+ "TARGET_HARD_FLOAT" -+ "fmsub.\t%0,%1,%2,%3" -+ [(set_attr "type" "fmadd") -+ (set_attr "mode" "")]) -+ -+(define_insn "nfma4" -+ [(set (match_operand:ANYF 0 "register_operand" "=f") -+ (neg:ANYF -+ (fma:ANYF -+ (match_operand:ANYF 1 "register_operand" "f") -+ (match_operand:ANYF 2 "register_operand" "f") -+ (match_operand:ANYF 3 "register_operand" "f"))))] -+ "TARGET_HARD_FLOAT" -+ "fnmadd.\t%0,%1,%2,%3" -+ [(set_attr "type" "fmadd") -+ (set_attr "mode" "")]) -+ -+(define_insn "nfms4" -+ [(set (match_operand:ANYF 0 "register_operand" "=f") -+ (neg:ANYF -+ (fma:ANYF -+ (match_operand:ANYF 1 "register_operand" "f") -+ (match_operand:ANYF 2 "register_operand" "f") -+ (neg:ANYF (match_operand:ANYF 3 "register_operand" "f")))))] -+ "TARGET_HARD_FLOAT" -+ "fnmsub.\t%0,%1,%2,%3" -+ [(set_attr "type" "fmadd") -+ (set_attr "mode" "")]) -+ -+;; modulo signed zeros, -(a*b+c) == -c-a*b -+(define_insn "*nfma4_fastmath" -+ [(set (match_operand:ANYF 0 "register_operand" "=f") -+ (minus:ANYF -+ (match_operand:ANYF 3 "register_operand" "f") -+ (mult:ANYF -+ (neg:ANYF (match_operand:ANYF 1 "register_operand" "f")) -+ (match_operand:ANYF 2 "register_operand" "f"))))] -+ "TARGET_HARD_FLOAT && !HONOR_SIGNED_ZEROS (mode)" -+ "fnmadd.\t%0,%1,%2,%3" -+ [(set_attr "type" "fmadd") -+ (set_attr "mode" "")]) -+ -+;; modulo signed zeros, -(a*b-c) == c-a*b -+(define_insn "*nfms4_fastmath" -+ [(set (match_operand:ANYF 0 "register_operand" "=f") -+ (minus:ANYF -+ (match_operand:ANYF 3 "register_operand" "f") -+ (mult:ANYF -+ (match_operand:ANYF 1 "register_operand" "f") -+ (match_operand:ANYF 2 "register_operand" "f"))))] -+ "TARGET_HARD_FLOAT && !HONOR_SIGNED_ZEROS (mode)" -+ "fnmsub.\t%0,%1,%2,%3" -+ [(set_attr "type" "fmadd") -+ (set_attr "mode" "")]) -+ -+;; -+;; .................... -+;; -+;; ABSOLUTE VALUE -+;; -+;; .................... -+ -+(define_insn "abs2" -+ [(set (match_operand:ANYF 0 "register_operand" "=f") -+ (abs:ANYF (match_operand:ANYF 1 "register_operand" "f")))] -+ "TARGET_HARD_FLOAT" -+ "fabs.\t%0,%1" -+ [(set_attr "type" "fmove") -+ (set_attr "mode" "")]) -+ -+ -+;; -+;; .................... -+;; -+;; MIN/MAX -+;; -+;; .................... -+ -+(define_insn "smin3" -+ [(set (match_operand:ANYF 0 "register_operand" "=f") -+ (smin:ANYF (match_operand:ANYF 1 "register_operand" "f") -+ (match_operand:ANYF 2 "register_operand" "f")))] -+ "TARGET_HARD_FLOAT" -+ "fmin.\t%0,%1,%2" -+ [(set_attr "type" "fmove") -+ (set_attr "mode" "")]) -+ -+(define_insn "smax3" -+ [(set (match_operand:ANYF 0 "register_operand" "=f") -+ (smax:ANYF (match_operand:ANYF 1 "register_operand" "f") -+ (match_operand:ANYF 2 "register_operand" "f")))] -+ "TARGET_HARD_FLOAT" -+ "fmax.\t%0,%1,%2" -+ [(set_attr "type" "fmove") -+ (set_attr "mode" "")]) -+ -+ -+;; -+;; .................... -+;; -+;; NEGATION and ONE'S COMPLEMENT ' -+;; -+;; .................... -+ -+(define_insn "neg2" -+ [(set (match_operand:ANYF 0 "register_operand" "=f") -+ (neg:ANYF (match_operand:ANYF 1 "register_operand" "f")))] -+ "TARGET_HARD_FLOAT" -+ "fneg.\t%0,%1" -+ [(set_attr "type" "fmove") -+ (set_attr "mode" "")]) -+ -+(define_insn "one_cmpl2" -+ [(set (match_operand:GPR 0 "register_operand" "=r") -+ (not:GPR (match_operand:GPR 1 "register_operand" "r")))] -+ "" -+ "not\t%0,%1" -+ [(set_attr "type" "logical") -+ (set_attr "mode" "")]) -+ -+;; -+;; .................... -+;; -+;; LOGICAL -+;; -+;; .................... -+;; -+ -+(define_insn "and3" -+ [(set (match_operand:GPR 0 "register_operand" "=r,r") -+ (and:GPR (match_operand:GPR 1 "register_operand" "%r,r") -+ (match_operand:GPR 2 "arith_operand" "r,Q")))] -+ "" -+ "and\t%0,%1,%2" -+ [(set_attr "type" "logical") -+ (set_attr "mode" "")]) -+ -+(define_insn "ior3" -+ [(set (match_operand:GPR 0 "register_operand" "=r,r") -+ (ior:GPR (match_operand:GPR 1 "register_operand" "%r,r") -+ (match_operand:GPR 2 "arith_operand" "r,Q")))] -+ "" -+ "or\t%0,%1,%2" -+ [(set_attr "type" "logical") -+ (set_attr "mode" "")]) -+ -+(define_insn "xor3" -+ [(set (match_operand:GPR 0 "register_operand" "=r,r") -+ (xor:GPR (match_operand:GPR 1 "register_operand" "%r,r") -+ (match_operand:GPR 2 "arith_operand" "r,Q")))] -+ "" -+ "xor\t%0,%1,%2" -+ [(set_attr "type" "logical") -+ (set_attr "mode" "")]) -+ -+;; -+;; .................... -+;; -+;; TRUNCATION -+;; -+;; .................... -+ -+(define_insn "truncdfsf2" -+ [(set (match_operand:SF 0 "register_operand" "=f") -+ (float_truncate:SF (match_operand:DF 1 "register_operand" "f")))] -+ "TARGET_HARD_FLOAT" -+ "fcvt.s.d\t%0,%1" -+ [(set_attr "type" "fcvt") -+ (set_attr "cnv_mode" "D2S") -+ (set_attr "mode" "SF")]) -+ -+;; Integer truncation patterns. Truncating to HImode/QImode is a no-op. -+;; Truncating from DImode to SImode is not, because we always keep SImode -+;; values sign-extended in a register so we can safely use DImode branches -+;; and comparisons on SImode values. -+ -+(define_insn "truncdisi2" -+ [(set (match_operand:SI 0 "nonimmediate_operand" "=r,m") -+ (truncate:SI (match_operand:DI 1 "register_operand" "r,r")))] -+ "TARGET_64BIT" -+ "@ -+ sext.w\t%0,%1 -+ sw\t%1,%0" -+ [(set_attr "move_type" "arith,store") -+ (set_attr "mode" "SI")]) -+ -+;; Combiner patterns to optimize shift/truncate combinations. -+ -+(define_insn "*ashr_trunc" -+ [(set (match_operand:SUBDI 0 "register_operand" "=r") -+ (truncate:SUBDI -+ (ashiftrt:DI (match_operand:DI 1 "register_operand" "r") -+ (match_operand:DI 2 "const_arith_operand" ""))))] -+ "TARGET_64BIT && IN_RANGE (INTVAL (operands[2]), 32, 63)" -+ "sra\t%0,%1,%2" -+ [(set_attr "type" "shift") -+ (set_attr "mode" "")]) -+ -+(define_insn "*lshr32_trunc" -+ [(set (match_operand:SUBDI 0 "register_operand" "=r") -+ (truncate:SUBDI -+ (lshiftrt:DI (match_operand:DI 1 "register_operand" "r") -+ (const_int 32))))] -+ "TARGET_64BIT" -+ "sra\t%0,%1,32" -+ [(set_attr "type" "shift") -+ (set_attr "mode" "")]) -+ -+;; -+;; .................... -+;; -+;; ZERO EXTENSION -+;; -+;; .................... -+ -+;; Extension insns. -+ -+(define_insn_and_split "zero_extendsidi2" -+ [(set (match_operand:DI 0 "register_operand" "=r,r") -+ (zero_extend:DI (match_operand:SI 1 "nonimmediate_operand" "r,W")))] -+ "TARGET_64BIT" -+ "@ -+ # -+ lwu\t%0,%1" -+ "&& reload_completed && REG_P (operands[1])" -+ [(set (match_dup 0) -+ (ashift:DI (match_dup 1) (const_int 32))) -+ (set (match_dup 0) -+ (lshiftrt:DI (match_dup 0) (const_int 32)))] -+ { operands[1] = gen_lowpart (DImode, operands[1]); } -+ [(set_attr "move_type" "shift_shift,load") -+ (set_attr "mode" "DI")]) -+ -+;; Combine is not allowed to convert this insn into a zero_extendsidi2 -+;; because of TRULY_NOOP_TRUNCATION. -+ -+(define_insn_and_split "*clear_upper32" -+ [(set (match_operand:DI 0 "register_operand" "=r,r") -+ (and:DI (match_operand:DI 1 "nonimmediate_operand" "r,W") -+ (const_int 4294967295)))] -+ "TARGET_64BIT" -+{ -+ if (which_alternative == 0) -+ return "#"; -+ -+ operands[1] = gen_lowpart (SImode, operands[1]); -+ return "lwu\t%0,%1"; -+} -+ "&& reload_completed && REG_P (operands[1])" -+ [(set (match_dup 0) -+ (ashift:DI (match_dup 1) (const_int 32))) -+ (set (match_dup 0) -+ (lshiftrt:DI (match_dup 0) (const_int 32)))] -+ "" -+ [(set_attr "move_type" "shift_shift,load") -+ (set_attr "mode" "DI")]) -+ -+(define_insn_and_split "zero_extendhi2" -+ [(set (match_operand:GPR 0 "register_operand" "=r,r") -+ (zero_extend:GPR (match_operand:HI 1 "nonimmediate_operand" "r,m")))] -+ "" -+ "@ -+ # -+ lhu\t%0,%1" -+ "&& reload_completed && REG_P (operands[1])" -+ [(set (match_dup 0) -+ (ashift:GPR (match_dup 1) (match_dup 2))) -+ (set (match_dup 0) -+ (lshiftrt:GPR (match_dup 0) (match_dup 2)))] -+ { -+ operands[1] = gen_lowpart (mode, operands[1]); -+ operands[2] = GEN_INT(GET_MODE_BITSIZE(mode) - 16); -+ } -+ [(set_attr "move_type" "shift_shift,load") -+ (set_attr "mode" "")]) -+ -+(define_insn "zero_extendqi2" -+ [(set (match_operand:SUPERQI 0 "register_operand" "=r,r") -+ (zero_extend:SUPERQI -+ (match_operand:QI 1 "nonimmediate_operand" "r,m")))] -+ "" -+ "@ -+ and\t%0,%1,0xff -+ lbu\t%0,%1" -+ [(set_attr "move_type" "andi,load") -+ (set_attr "mode" "")]) -+ -+;; -+;; .................... -+;; -+;; SIGN EXTENSION -+;; -+;; .................... -+ -+;; Extension insns. -+;; Those for integer source operand are ordered widest source type first. -+ -+;; When TARGET_64BIT, all SImode integer registers should already be in -+;; sign-extended form (see TRULY_NOOP_TRUNCATION and truncdisi2). We can -+;; therefore get rid of register->register instructions if we constrain -+;; the source to be in the same register as the destination. -+;; -+;; The register alternative has type "arith" so that the pre-reload -+;; scheduler will treat it as a move. This reflects what happens if -+;; the register alternative needs a reload. -+(define_insn_and_split "extendsidi2" -+ [(set (match_operand:DI 0 "register_operand" "=r,r") -+ (sign_extend:DI (match_operand:SI 1 "nonimmediate_operand" "r,m")))] -+ "TARGET_64BIT" -+ "@ -+ # -+ lw\t%0,%1" -+ "&& reload_completed && register_operand (operands[1], VOIDmode)" -+ [(set (match_dup 0) (match_dup 1))] -+{ -+ if (REGNO (operands[0]) == REGNO (operands[1])) -+ { -+ emit_note (NOTE_INSN_DELETED); -+ DONE; -+ } -+ operands[1] = gen_rtx_REG (DImode, REGNO (operands[1])); -+} -+ [(set_attr "move_type" "move,load") -+ (set_attr "mode" "DI")]) -+ -+(define_insn_and_split "extend2" -+ [(set (match_operand:SUPERQI 0 "register_operand" "=r,r") -+ (sign_extend:SUPERQI -+ (match_operand:SHORT 1 "nonimmediate_operand" "r,m")))] -+ "" -+ "@ -+ # -+ l\t%0,%1" -+ "&& reload_completed && REG_P (operands[1])" -+ [(set (match_dup 0) (ashift:SI (match_dup 1) (match_dup 2))) -+ (set (match_dup 0) (ashiftrt:SI (match_dup 0) (match_dup 2)))] -+{ -+ operands[0] = gen_lowpart (SImode, operands[0]); -+ operands[1] = gen_lowpart (SImode, operands[1]); -+ operands[2] = GEN_INT (GET_MODE_BITSIZE (SImode) -+ - GET_MODE_BITSIZE (mode)); -+} -+ [(set_attr "move_type" "shift_shift,load") -+ (set_attr "mode" "SI")]) -+ -+(define_insn "extendsfdf2" -+ [(set (match_operand:DF 0 "register_operand" "=f") -+ (float_extend:DF (match_operand:SF 1 "register_operand" "f")))] -+ "TARGET_HARD_FLOAT" -+ "fcvt.d.s\t%0,%1" -+ [(set_attr "type" "fcvt") -+ (set_attr "cnv_mode" "S2D") -+ (set_attr "mode" "DF")]) -+ -+;; -+;; .................... -+;; -+;; CONVERSIONS -+;; -+;; .................... -+ -+(define_insn "fix_truncdfsi2" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (fix:SI (match_operand:DF 1 "register_operand" "f")))] -+ "TARGET_HARD_FLOAT" -+ "fcvt.w.d %0,%1,rtz" -+ [(set_attr "type" "fcvt") -+ (set_attr "mode" "DF") -+ (set_attr "cnv_mode" "D2I")]) -+ -+ -+(define_insn "fix_truncsfsi2" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (fix:SI (match_operand:SF 1 "register_operand" "f")))] -+ "TARGET_HARD_FLOAT" -+ "fcvt.w.s %0,%1,rtz" -+ [(set_attr "type" "fcvt") -+ (set_attr "mode" "SF") -+ (set_attr "cnv_mode" "S2I")]) -+ -+ -+(define_insn "fix_truncdfdi2" -+ [(set (match_operand:DI 0 "register_operand" "=r") -+ (fix:DI (match_operand:DF 1 "register_operand" "f")))] -+ "TARGET_HARD_FLOAT && TARGET_64BIT" -+ "fcvt.l.d %0,%1,rtz" -+ [(set_attr "type" "fcvt") -+ (set_attr "mode" "DF") -+ (set_attr "cnv_mode" "D2I")]) -+ -+ -+(define_insn "fix_truncsfdi2" -+ [(set (match_operand:DI 0 "register_operand" "=r") -+ (fix:DI (match_operand:SF 1 "register_operand" "f")))] -+ "TARGET_HARD_FLOAT && TARGET_64BIT" -+ "fcvt.l.s %0,%1,rtz" -+ [(set_attr "type" "fcvt") -+ (set_attr "mode" "SF") -+ (set_attr "cnv_mode" "S2I")]) -+ -+ -+(define_insn "floatsidf2" -+ [(set (match_operand:DF 0 "register_operand" "=f") -+ (float:DF (match_operand:SI 1 "reg_or_0_operand" "rJ")))] -+ "TARGET_HARD_FLOAT" -+ "fcvt.d.w\t%0,%z1" -+ [(set_attr "type" "fcvt") -+ (set_attr "mode" "DF") -+ (set_attr "cnv_mode" "I2D")]) -+ -+ -+(define_insn "floatdidf2" -+ [(set (match_operand:DF 0 "register_operand" "=f") -+ (float:DF (match_operand:DI 1 "reg_or_0_operand" "rJ")))] -+ "TARGET_HARD_FLOAT && TARGET_64BIT" -+ "fcvt.d.l\t%0,%z1" -+ [(set_attr "type" "fcvt") -+ (set_attr "mode" "DF") -+ (set_attr "cnv_mode" "I2D")]) -+ -+ -+(define_insn "floatsisf2" -+ [(set (match_operand:SF 0 "register_operand" "=f") -+ (float:SF (match_operand:SI 1 "reg_or_0_operand" "rJ")))] -+ "TARGET_HARD_FLOAT" -+ "fcvt.s.w\t%0,%z1" -+ [(set_attr "type" "fcvt") -+ (set_attr "mode" "SF") -+ (set_attr "cnv_mode" "I2S")]) -+ -+ -+(define_insn "floatdisf2" -+ [(set (match_operand:SF 0 "register_operand" "=f") -+ (float:SF (match_operand:DI 1 "reg_or_0_operand" "rJ")))] -+ "TARGET_HARD_FLOAT && TARGET_64BIT" -+ "fcvt.s.l\t%0,%z1" -+ [(set_attr "type" "fcvt") -+ (set_attr "mode" "SF") -+ (set_attr "cnv_mode" "I2S")]) -+ -+ -+(define_insn "floatunssidf2" -+ [(set (match_operand:DF 0 "register_operand" "=f") -+ (unsigned_float:DF (match_operand:SI 1 "reg_or_0_operand" "rJ")))] -+ "TARGET_HARD_FLOAT" -+ "fcvt.d.wu\t%0,%z1" -+ [(set_attr "type" "fcvt") -+ (set_attr "mode" "DF") -+ (set_attr "cnv_mode" "I2D")]) -+ -+ -+(define_insn "floatunsdidf2" -+ [(set (match_operand:DF 0 "register_operand" "=f") -+ (unsigned_float:DF (match_operand:DI 1 "reg_or_0_operand" "rJ")))] -+ "TARGET_HARD_FLOAT && TARGET_64BIT" -+ "fcvt.d.lu\t%0,%z1" -+ [(set_attr "type" "fcvt") -+ (set_attr "mode" "DF") -+ (set_attr "cnv_mode" "I2D")]) -+ -+ -+(define_insn "floatunssisf2" -+ [(set (match_operand:SF 0 "register_operand" "=f") -+ (unsigned_float:SF (match_operand:SI 1 "reg_or_0_operand" "rJ")))] -+ "TARGET_HARD_FLOAT" -+ "fcvt.s.wu\t%0,%z1" -+ [(set_attr "type" "fcvt") -+ (set_attr "mode" "SF") -+ (set_attr "cnv_mode" "I2S")]) -+ -+ -+(define_insn "floatunsdisf2" -+ [(set (match_operand:SF 0 "register_operand" "=f") -+ (unsigned_float:SF (match_operand:DI 1 "reg_or_0_operand" "rJ")))] -+ "TARGET_HARD_FLOAT && TARGET_64BIT" -+ "fcvt.s.lu\t%0,%z1" -+ [(set_attr "type" "fcvt") -+ (set_attr "mode" "SF") -+ (set_attr "cnv_mode" "I2S")]) -+ -+ -+(define_insn "fixuns_truncdfsi2" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (unsigned_fix:SI (match_operand:DF 1 "register_operand" "f")))] -+ "TARGET_HARD_FLOAT" -+ "fcvt.wu.d %0,%1,rtz" -+ [(set_attr "type" "fcvt") -+ (set_attr "mode" "DF") -+ (set_attr "cnv_mode" "D2I")]) -+ -+ -+(define_insn "fixuns_truncsfsi2" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (unsigned_fix:SI (match_operand:SF 1 "register_operand" "f")))] -+ "TARGET_HARD_FLOAT" -+ "fcvt.wu.s %0,%1,rtz" -+ [(set_attr "type" "fcvt") -+ (set_attr "mode" "SF") -+ (set_attr "cnv_mode" "S2I")]) -+ -+ -+(define_insn "fixuns_truncdfdi2" -+ [(set (match_operand:DI 0 "register_operand" "=r") -+ (unsigned_fix:DI (match_operand:DF 1 "register_operand" "f")))] -+ "TARGET_HARD_FLOAT && TARGET_64BIT" -+ "fcvt.lu.d %0,%1,rtz" -+ [(set_attr "type" "fcvt") -+ (set_attr "mode" "DF") -+ (set_attr "cnv_mode" "D2I")]) -+ -+ -+(define_insn "fixuns_truncsfdi2" -+ [(set (match_operand:DI 0 "register_operand" "=r") -+ (unsigned_fix:DI (match_operand:SF 1 "register_operand" "f")))] -+ "TARGET_HARD_FLOAT && TARGET_64BIT" -+ "fcvt.lu.s %0,%1,rtz" -+ [(set_attr "type" "fcvt") -+ (set_attr "mode" "SF") -+ (set_attr "cnv_mode" "S2I")]) -+ -+;; -+;; .................... -+;; -+;; DATA MOVEMENT -+;; -+;; .................... -+ -+;; Lower-level instructions for loading an address from the GOT. -+;; We could use MEMs, but an unspec gives more optimization -+;; opportunities. -+ -+(define_insn "got_load" -+ [(set (match_operand:P 0 "register_operand" "=r") -+ (unspec:P [(match_operand:P 1 "symbolic_operand" "")] -+ UNSPEC_LOAD_GOT))] -+ "flag_pic" -+ "la\t%0,%1" -+ [(set_attr "got" "load") -+ (set_attr "mode" "")]) -+ -+(define_insn "tls_add_tp_le" -+ [(set (match_operand:P 0 "register_operand" "=r") -+ (unspec:P [(match_operand:P 1 "register_operand" "r") -+ (match_operand:P 2 "register_operand" "r") -+ (match_operand:P 3 "symbolic_operand" "")] -+ UNSPEC_TLS_LE))] -+ "!flag_pic || flag_pie" -+ "add\t%0,%1,%2,%%tprel_add(%3)" -+ [(set_attr "type" "arith") -+ (set_attr "mode" "")]) -+ -+(define_insn "got_load_tls_gd" -+ [(set (match_operand:P 0 "register_operand" "=r") -+ (unspec:P [(match_operand:P 1 "symbolic_operand" "")] -+ UNSPEC_TLS_GD))] -+ "flag_pic" -+ "la.tls.gd\t%0,%1" -+ [(set_attr "got" "load") -+ (set_attr "mode" "")]) -+ -+(define_insn "got_load_tls_ie" -+ [(set (match_operand:P 0 "register_operand" "=r") -+ (unspec:P [(match_operand:P 1 "symbolic_operand" "")] -+ UNSPEC_TLS_IE))] -+ "flag_pic" -+ "la.tls.ie\t%0,%1" -+ [(set_attr "got" "load") -+ (set_attr "mode" "")]) -+ -+;; Instructions for adding the low 16 bits of an address to a register. -+;; Operand 2 is the address: riscv_print_operand works out which relocation -+;; should be applied. -+ -+(define_insn "*low" -+ [(set (match_operand:P 0 "register_operand" "=r") -+ (lo_sum:P (match_operand:P 1 "register_operand" "r") -+ (match_operand:P 2 "immediate_operand" "")))] -+ "" -+ "add\t%0,%1,%R2" -+ [(set_attr "alu_type" "add") -+ (set_attr "mode" "")]) -+ -+;; Allow combine to split complex const_int load sequences, using operand 2 -+;; to store the intermediate results. See move_operand for details. -+(define_split -+ [(set (match_operand:GPR 0 "register_operand") -+ (match_operand:GPR 1 "splittable_const_int_operand")) -+ (clobber (match_operand:GPR 2 "register_operand"))] -+ "" -+ [(const_int 0)] -+{ -+ riscv_move_integer (operands[2], operands[0], INTVAL (operands[1])); -+ DONE; -+}) -+ -+;; Likewise, for symbolic operands. -+(define_split -+ [(set (match_operand:P 0 "register_operand") -+ (match_operand:P 1)) -+ (clobber (match_operand:P 2 "register_operand"))] -+ "riscv_split_symbol (operands[2], operands[1], MAX_MACHINE_MODE, NULL)" -+ [(set (match_dup 0) (match_dup 3))] -+{ -+ riscv_split_symbol (operands[2], operands[1], -+ MAX_MACHINE_MODE, &operands[3]); -+}) -+ -+;; 64-bit integer moves -+ -+;; Unlike most other insns, the move insns can't be split with ' -+;; different predicates, because register spilling and other parts of -+;; the compiler, have memoized the insn number already. -+ -+(define_expand "movdi" -+ [(set (match_operand:DI 0 "") -+ (match_operand:DI 1 ""))] -+ "" -+{ -+ if (riscv_legitimize_move (DImode, operands[0], operands[1])) -+ DONE; -+}) -+ -+(define_insn "*movdi_32bit" -+ [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,r,m,*f,*f,*r,*m") -+ (match_operand:DI 1 "move_operand" "r,i,m,r,*J*r,*m,*f,*f"))] -+ "!TARGET_64BIT -+ && (register_operand (operands[0], DImode) -+ || reg_or_0_operand (operands[1], DImode))" -+ { return riscv_output_move (operands[0], operands[1]); } -+ [(set_attr "move_type" "move,const,load,store,mtc,fpload,mfc,fpstore") -+ (set_attr "mode" "DI")]) -+ -+(define_insn "*movdi_64bit" -+ [(set (match_operand:DI 0 "nonimmediate_operand" "=r,r,r,m,*f,*f,*r,*m") -+ (match_operand:DI 1 "move_operand" "r,T,m,rJ,*r*J,*m,*f,*f"))] -+ "TARGET_64BIT -+ && (register_operand (operands[0], DImode) -+ || reg_or_0_operand (operands[1], DImode))" -+ { return riscv_output_move (operands[0], operands[1]); } -+ [(set_attr "move_type" "move,const,load,store,mtc,fpload,mfc,fpstore") -+ (set_attr "mode" "DI")]) -+ -+;; 32-bit Integer moves -+ -+;; Unlike most other insns, the move insns can't be split with -+;; different predicates, because register spilling and other parts of -+;; the compiler, have memoized the insn number already. -+ -+(define_expand "mov" -+ [(set (match_operand:IMOVE32 0 "") -+ (match_operand:IMOVE32 1 ""))] -+ "" -+{ -+ if (riscv_legitimize_move (mode, operands[0], operands[1])) -+ DONE; -+}) -+ -+;; The difference between these two is whether or not ints are allowed -+;; in FP registers (off by default, use -mdebugh to enable). -+ -+(define_insn "*mov_internal" -+ [(set (match_operand:IMOVE32 0 "nonimmediate_operand" "=r,r,r,m,*f,*f,*r,*m") -+ (match_operand:IMOVE32 1 "move_operand" "r,T,m,rJ,*r*J,*m,*f,*f"))] -+ "(register_operand (operands[0], mode) -+ || reg_or_0_operand (operands[1], mode))" -+ { return riscv_output_move (operands[0], operands[1]); } -+ [(set_attr "move_type" "move,const,load,store,mtc,fpload,mfc,fpstore") -+ (set_attr "mode" "SI")]) -+ -+;; 16-bit Integer moves -+ -+;; Unlike most other insns, the move insns can't be split with -+;; different predicates, because register spilling and other parts of -+;; the compiler, have memoized the insn number already. -+;; Unsigned loads are used because LOAD_EXTEND_OP returns ZERO_EXTEND. -+ -+(define_expand "movhi" -+ [(set (match_operand:HI 0 "") -+ (match_operand:HI 1 ""))] -+ "" -+{ -+ if (riscv_legitimize_move (HImode, operands[0], operands[1])) -+ DONE; -+}) -+ -+(define_insn "*movhi_internal" -+ [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r,r,m,*f,*r") -+ (match_operand:HI 1 "move_operand" "r,T,m,rJ,*r*J,*f"))] -+ "(register_operand (operands[0], HImode) -+ || reg_or_0_operand (operands[1], HImode))" -+ { return riscv_output_move (operands[0], operands[1]); } -+ [(set_attr "move_type" "move,const,load,store,mtc,mfc") -+ (set_attr "mode" "HI")]) -+ -+;; HImode constant generation; see riscv_move_integer for details. -+;; si+si->hi without truncation is legal because of TRULY_NOOP_TRUNCATION. -+ -+(define_insn "addhi3" -+ [(set (match_operand:HI 0 "register_operand" "=r,r") -+ (plus:HI (match_operand:HISI 1 "register_operand" "r,r") -+ (match_operand:HISI 2 "arith_operand" "r,Q")))] -+ "" -+ { return TARGET_64BIT ? "addw\t%0,%1,%2" : "add\t%0,%1,%2"; } -+ [(set_attr "type" "arith") -+ (set_attr "mode" "HI")]) -+ -+(define_insn "xorhi3" -+ [(set (match_operand:HI 0 "register_operand" "=r,r") -+ (xor:HI (match_operand:HISI 1 "register_operand" "r,r") -+ (match_operand:HISI 2 "arith_operand" "r,Q")))] -+ "" -+ "xor\t%0,%1,%2" -+ [(set_attr "type" "logical") -+ (set_attr "mode" "HI")]) -+ -+;; 8-bit Integer moves -+ -+(define_expand "movqi" -+ [(set (match_operand:QI 0 "") -+ (match_operand:QI 1 ""))] -+ "" -+{ -+ if (riscv_legitimize_move (QImode, operands[0], operands[1])) -+ DONE; -+}) -+ -+(define_insn "*movqi_internal" -+ [(set (match_operand:QI 0 "nonimmediate_operand" "=r,r,r,m,*f,*r") -+ (match_operand:QI 1 "move_operand" "r,I,m,rJ,*r*J,*f"))] -+ "(register_operand (operands[0], QImode) -+ || reg_or_0_operand (operands[1], QImode))" -+ { return riscv_output_move (operands[0], operands[1]); } -+ [(set_attr "move_type" "move,const,load,store,mtc,mfc") -+ (set_attr "mode" "QI")]) -+ -+;; 32-bit floating point moves -+ -+(define_expand "movsf" -+ [(set (match_operand:SF 0 "") -+ (match_operand:SF 1 ""))] -+ "" -+{ -+ if (riscv_legitimize_move (SFmode, operands[0], operands[1])) -+ DONE; -+}) -+ -+(define_insn "*movsf_hardfloat" -+ [(set (match_operand:SF 0 "nonimmediate_operand" "=f,f,f,m,m,*f,*r,*r,*r,*m") -+ (match_operand:SF 1 "move_operand" "f,G,m,f,G,*r,*f,*G*r,*m,*r"))] -+ "TARGET_HARD_FLOAT -+ && (register_operand (operands[0], SFmode) -+ || reg_or_0_operand (operands[1], SFmode))" -+ { return riscv_output_move (operands[0], operands[1]); } -+ [(set_attr "move_type" "fmove,mtc,fpload,fpstore,store,mtc,mfc,move,load,store") -+ (set_attr "mode" "SF")]) -+ -+(define_insn "*movsf_softfloat" -+ [(set (match_operand:SF 0 "nonimmediate_operand" "=r,r,m") -+ (match_operand:SF 1 "move_operand" "Gr,m,r"))] -+ "TARGET_SOFT_FLOAT -+ && (register_operand (operands[0], SFmode) -+ || reg_or_0_operand (operands[1], SFmode))" -+ { return riscv_output_move (operands[0], operands[1]); } -+ [(set_attr "move_type" "move,load,store") -+ (set_attr "mode" "SF")]) -+ -+;; 64-bit floating point moves -+ -+(define_expand "movdf" -+ [(set (match_operand:DF 0 "") -+ (match_operand:DF 1 ""))] -+ "" -+{ -+ if (riscv_legitimize_move (DFmode, operands[0], operands[1])) -+ DONE; -+}) -+ -+;; In RV32, we lack mtf.d/mff.d. Go through memory instead. -+;; (except for moving a constant 0 to an FPR. for that we use fcvt.d.w.) -+(define_insn "*movdf_hardfloat_rv32" -+ [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,f,m,m,*r,*r,*m") -+ (match_operand:DF 1 "move_operand" "f,G,m,f,G,*r*G,*m,*r"))] -+ "!TARGET_64BIT && TARGET_HARD_FLOAT -+ && (register_operand (operands[0], DFmode) -+ || reg_or_0_operand (operands[1], DFmode))" -+ { return riscv_output_move (operands[0], operands[1]); } -+ [(set_attr "move_type" "fmove,mtc,fpload,fpstore,store,move,load,store") -+ (set_attr "mode" "DF")]) -+ -+(define_insn "*movdf_hardfloat_rv64" -+ [(set (match_operand:DF 0 "nonimmediate_operand" "=f,f,f,m,m,*f,*r,*r,*r,*m") -+ (match_operand:DF 1 "move_operand" "f,G,m,f,G,*r,*f,*r*G,*m,*r"))] -+ "TARGET_64BIT && TARGET_HARD_FLOAT -+ && (register_operand (operands[0], DFmode) -+ || reg_or_0_operand (operands[1], DFmode))" -+ { return riscv_output_move (operands[0], operands[1]); } -+ [(set_attr "move_type" "fmove,mtc,fpload,fpstore,store,mtc,mfc,move,load,store") -+ (set_attr "mode" "DF")]) -+ -+(define_insn "*movdf_softfloat" -+ [(set (match_operand:DF 0 "nonimmediate_operand" "=r,r,m") -+ (match_operand:DF 1 "move_operand" "rG,m,rG"))] -+ "TARGET_SOFT_FLOAT -+ && (register_operand (operands[0], DFmode) -+ || reg_or_0_operand (operands[1], DFmode))" -+ { return riscv_output_move (operands[0], operands[1]); } -+ [(set_attr "move_type" "move,load,store") -+ (set_attr "mode" "DF")]) -+ -+;; 128-bit integer moves -+ -+(define_expand "movti" -+ [(set (match_operand:TI 0) -+ (match_operand:TI 1))] -+ "TARGET_64BIT" -+{ -+ if (riscv_legitimize_move (TImode, operands[0], operands[1])) -+ DONE; -+}) -+ -+(define_insn "*movti" -+ [(set (match_operand:TI 0 "nonimmediate_operand" "=r,r,r,m") -+ (match_operand:TI 1 "move_operand" "r,i,m,rJ"))] -+ "TARGET_64BIT -+ && (register_operand (operands[0], TImode) -+ || reg_or_0_operand (operands[1], TImode))" -+ "#" -+ [(set_attr "move_type" "move,const,load,store") -+ (set_attr "mode" "TI")]) -+ -+(define_split -+ [(set (match_operand:MOVE64 0 "nonimmediate_operand") -+ (match_operand:MOVE64 1 "move_operand"))] -+ "reload_completed && !TARGET_64BIT -+ && riscv_split_64bit_move_p (operands[0], operands[1])" -+ [(const_int 0)] -+{ -+ riscv_split_doubleword_move (operands[0], operands[1]); -+ DONE; -+}) -+ -+(define_split -+ [(set (match_operand:MOVE128 0 "nonimmediate_operand") -+ (match_operand:MOVE128 1 "move_operand"))] -+ "TARGET_64BIT && reload_completed" -+ [(const_int 0)] -+{ -+ riscv_split_doubleword_move (operands[0], operands[1]); -+ DONE; -+}) -+ -+;; 64-bit paired-single floating point moves -+ -+;; Load the low word of operand 0 with operand 1. -+(define_insn "load_low" -+ [(set (match_operand:SPLITF 0 "register_operand" "=f,f") -+ (unspec:SPLITF [(match_operand: 1 "general_operand" "rJ,m")] -+ UNSPEC_LOAD_LOW))] -+ "TARGET_HARD_FLOAT" -+{ -+ operands[0] = riscv_subword (operands[0], 0); -+ return riscv_output_move (operands[0], operands[1]); -+} -+ [(set_attr "move_type" "mtc,fpload") -+ (set_attr "mode" "")]) -+ -+;; Load the high word of operand 0 from operand 1, preserving the value -+;; in the low word. -+(define_insn "load_high" -+ [(set (match_operand:SPLITF 0 "register_operand" "=f,f") -+ (unspec:SPLITF [(match_operand: 1 "general_operand" "rJ,m") -+ (match_operand:SPLITF 2 "register_operand" "0,0")] -+ UNSPEC_LOAD_HIGH))] -+ "TARGET_HARD_FLOAT" -+{ -+ operands[0] = riscv_subword (operands[0], 1); -+ return riscv_output_move (operands[0], operands[1]); -+} -+ [(set_attr "move_type" "mtc,fpload") -+ (set_attr "mode" "")]) -+ -+;; Store one word of operand 1 in operand 0. Operand 2 is 1 to store the -+;; high word and 0 to store the low word. -+(define_insn "store_word" -+ [(set (match_operand: 0 "nonimmediate_operand" "=r,m") -+ (unspec: [(match_operand:SPLITF 1 "register_operand" "f,f") -+ (match_operand 2 "const_int_operand")] -+ UNSPEC_STORE_WORD))] -+ "TARGET_HARD_FLOAT" -+{ -+ operands[1] = riscv_subword (operands[1], INTVAL (operands[2])); -+ return riscv_output_move (operands[0], operands[1]); -+} -+ [(set_attr "move_type" "mfc,fpstore") -+ (set_attr "mode" "")]) -+ -+;; Expand in-line code to clear the instruction cache between operand[0] and -+;; operand[1]. -+(define_expand "clear_cache" -+ [(match_operand 0 "pmode_register_operand") -+ (match_operand 1 "pmode_register_operand")] -+ "" -+ " -+{ -+ emit_insn(gen_fence_i()); -+ DONE; -+}") -+ -+(define_insn "fence" -+ [(unspec_volatile [(const_int 0)] UNSPEC_FENCE)] -+ "" -+ "%|fence%-") -+ -+(define_insn "fence_i" -+ [(unspec_volatile [(const_int 0)] UNSPEC_FENCE_I)] -+ "" -+ "fence.i") -+ -+;; Block moves, see riscv.c for more details. -+;; Argument 0 is the destination -+;; Argument 1 is the source -+;; Argument 2 is the length -+;; Argument 3 is the alignment -+ -+(define_expand "movmemsi" -+ [(parallel [(set (match_operand:BLK 0 "general_operand") -+ (match_operand:BLK 1 "general_operand")) -+ (use (match_operand:SI 2 "")) -+ (use (match_operand:SI 3 "const_int_operand"))])] -+ "!TARGET_MEMCPY" -+{ -+ if (riscv_expand_block_move (operands[0], operands[1], operands[2])) -+ DONE; -+ else -+ FAIL; -+}) -+ -+;; -+;; .................... -+;; -+;; SHIFTS -+;; -+;; .................... -+ -+(define_insn "si3" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (any_shift:SI (match_operand:SI 1 "register_operand" "r") -+ (match_operand:SI 2 "arith_operand" "rI")))] -+ "" -+{ -+ if (GET_CODE (operands[2]) == CONST_INT) -+ operands[2] = GEN_INT (INTVAL (operands[2]) -+ & (GET_MODE_BITSIZE (SImode) - 1)); -+ -+ return TARGET_64BIT ? "w\t%0,%1,%2" : "\t%0,%1,%2"; -+} -+ [(set_attr "type" "shift") -+ (set_attr "mode" "SI")]) -+ -+(define_insn "*disi3" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (any_shift:SI (truncate:SI (match_operand:DI 1 "register_operand" "r")) -+ (truncate:SI (match_operand:DI 2 "arith_operand" "rI"))))] -+ "TARGET_64BIT" -+ "w\t%0,%1,%2" -+ [(set_attr "type" "shift") -+ (set_attr "mode" "SI")]) -+ -+(define_insn "*ashldi3_truncsi" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (truncate:SI -+ (ashift:DI (match_operand:DI 1 "register_operand" "r") -+ (match_operand:DI 2 "const_arith_operand" "I"))))] -+ "TARGET_64BIT && INTVAL (operands[2]) < 32" -+ "sllw\t%0,%1,%2" -+ [(set_attr "type" "shift") -+ (set_attr "mode" "SI")]) -+ -+(define_insn "*ashldisi3" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (ashift:SI (match_operand:GPR 1 "register_operand" "r") -+ (match_operand:GPR2 2 "arith_operand" "rI")))] -+ "TARGET_64BIT && (GET_CODE (operands[2]) == CONST_INT ? INTVAL (operands[2]) < 32 : 1)" -+ "sllw\t%0,%1,%2" -+ [(set_attr "type" "shift") -+ (set_attr "mode" "SI")]) -+ -+(define_insn "di3" -+ [(set (match_operand:DI 0 "register_operand" "=r") -+ (any_shift:DI (match_operand:DI 1 "register_operand" "r") -+ (match_operand:DI 2 "arith_operand" "rI")))] -+ "TARGET_64BIT" -+{ -+ if (GET_CODE (operands[2]) == CONST_INT) -+ operands[2] = GEN_INT (INTVAL (operands[2]) -+ & (GET_MODE_BITSIZE (DImode) - 1)); -+ -+ return "\t%0,%1,%2"; -+} -+ [(set_attr "type" "shift") -+ (set_attr "mode" "DI")]) -+ -+(define_insn "si3_extend" -+ [(set (match_operand:DI 0 "register_operand" "=r") -+ (sign_extend:DI -+ (any_shift:SI (match_operand:SI 1 "register_operand" "r") -+ (match_operand:SI 2 "arith_operand" "rI"))))] -+ "TARGET_64BIT" -+{ -+ if (GET_CODE (operands[2]) == CONST_INT) -+ operands[2] = GEN_INT (INTVAL (operands[2]) & 0x1f); -+ -+ return "w\t%0,%1,%2"; -+} -+ [(set_attr "type" "shift") -+ (set_attr "mode" "SI")]) -+ -+;; -+;; .................... -+;; -+;; CONDITIONAL BRANCHES -+;; -+;; .................... -+ -+;; Conditional branches -+ -+(define_insn "*branch_order" -+ [(set (pc) -+ (if_then_else -+ (match_operator 1 "order_operator" -+ [(match_operand:GPR 2 "register_operand" "r") -+ (match_operand:GPR 3 "reg_or_0_operand" "rJ")]) -+ (label_ref (match_operand 0 "" "")) -+ (pc)))] -+ "" -+{ -+ if (GET_CODE (operands[3]) == CONST_INT) -+ return "b%C1z\t%2,%0"; -+ return "b%C1\t%2,%3,%0"; -+} -+ [(set_attr "type" "branch") -+ (set_attr "mode" "none")]) -+ -+;; Used to implement built-in functions. -+(define_expand "condjump" -+ [(set (pc) -+ (if_then_else (match_operand 0) -+ (label_ref (match_operand 1)) -+ (pc)))]) -+ -+(define_expand "cbranch4" -+ [(set (pc) -+ (if_then_else (match_operator 0 "comparison_operator" -+ [(match_operand:GPR 1 "register_operand") -+ (match_operand:GPR 2 "nonmemory_operand")]) -+ (label_ref (match_operand 3 "")) -+ (pc)))] -+ "" -+{ -+ riscv_expand_conditional_branch (operands); -+ DONE; -+}) -+ -+(define_expand "cbranch4" -+ [(set (pc) -+ (if_then_else (match_operator 0 "comparison_operator" -+ [(match_operand:SCALARF 1 "register_operand") -+ (match_operand:SCALARF 2 "register_operand")]) -+ (label_ref (match_operand 3 "")) -+ (pc)))] -+ "" -+{ -+ riscv_expand_conditional_branch (operands); -+ DONE; -+}) -+ -+(define_insn_and_split "*branch_on_bit" -+ [(set (pc) -+ (if_then_else -+ (match_operator 0 "equality_operator" -+ [(zero_extract:GPR (match_operand:GPR 2 "register_operand" "r") -+ (const_int 1) -+ (match_operand 3 "const_int_operand")) -+ (const_int 0)]) -+ (label_ref (match_operand 1)) -+ (pc))) -+ (clobber (match_scratch:GPR 4 "=&r"))] -+ "" -+ "#" -+ "reload_completed" -+ [(set (match_dup 4) -+ (ashift:GPR (match_dup 2) (match_dup 3))) -+ (set (pc) -+ (if_then_else -+ (match_op_dup 0 [(match_dup 4) (const_int 0)]) -+ (label_ref (match_operand 1)) -+ (pc)))] -+{ -+ int shift = GET_MODE_BITSIZE (mode) - 1 - INTVAL (operands[3]); -+ operands[3] = GEN_INT (shift); -+ -+ if (GET_CODE (operands[0]) == EQ) -+ operands[0] = gen_rtx_GE (mode, operands[4], const0_rtx); -+ else -+ operands[0] = gen_rtx_LT (mode, operands[4], const0_rtx); -+}) -+ -+(define_insn_and_split "*branch_on_bit_range" -+ [(set (pc) -+ (if_then_else -+ (match_operator 0 "equality_operator" -+ [(zero_extract:GPR (match_operand:GPR 2 "register_operand" "r") -+ (match_operand 3 "const_int_operand") -+ (const_int 0)) -+ (const_int 0)]) -+ (label_ref (match_operand 1)) -+ (pc))) -+ (clobber (match_scratch:GPR 4 "=&r"))] -+ "" -+ "#" -+ "reload_completed" -+ [(set (match_dup 4) -+ (ashift:GPR (match_dup 2) (match_dup 3))) -+ (set (pc) -+ (if_then_else -+ (match_op_dup 0 [(match_dup 4) (const_int 0)]) -+ (label_ref (match_operand 1)) -+ (pc)))] -+{ -+ operands[3] = GEN_INT (GET_MODE_BITSIZE (mode) - INTVAL (operands[3])); -+}) -+ -+;; -+;; .................... -+;; -+;; SETTING A REGISTER FROM A COMPARISON -+;; -+;; .................... -+ -+;; Destination is always set in SI mode. -+ -+(define_expand "cstore4" -+ [(set (match_operand:SI 0 "register_operand") -+ (match_operator:SI 1 "order_operator" -+ [(match_operand:GPR 2 "register_operand") -+ (match_operand:GPR 3 "nonmemory_operand")]))] -+ "" -+{ -+ riscv_expand_scc (operands); -+ DONE; -+}) -+ -+(define_insn "cstore4" -+ [(set (match_operand:SI 0 "register_operand" "=r") -+ (match_operator:SI 1 "fp_order_operator" -+ [(match_operand:SCALARF 2 "register_operand" "f") -+ (match_operand:SCALARF 3 "register_operand" "f")]))] -+ "TARGET_HARD_FLOAT" -+ "f%C1.\t%0,%2,%3" -+ [(set_attr "type" "fcmp") -+ (set_attr "mode" "")]) -+ -+(define_insn "*seq_zero_" -+ [(set (match_operand:GPR2 0 "register_operand" "=r") -+ (eq:GPR2 (match_operand:GPR 1 "register_operand" "r") -+ (const_int 0)))] -+ "" -+ "seqz\t%0,%1" -+ [(set_attr "type" "slt") -+ (set_attr "mode" "")]) -+ -+(define_insn "*sne_zero_" -+ [(set (match_operand:GPR2 0 "register_operand" "=r") -+ (ne:GPR2 (match_operand:GPR 1 "register_operand" "r") -+ (const_int 0)))] -+ "" -+ "snez\t%0,%1" -+ [(set_attr "type" "slt") -+ (set_attr "mode" "")]) -+ -+(define_insn "*sgt_" -+ [(set (match_operand:GPR2 0 "register_operand" "=r") -+ (any_gt:GPR2 (match_operand:GPR 1 "register_operand" "r") -+ (match_operand:GPR 2 "reg_or_0_operand" "rJ")))] -+ "" -+ "slt\t%0,%z2,%1" -+ [(set_attr "type" "slt") -+ (set_attr "mode" "")]) -+ -+(define_insn "*sge_" -+ [(set (match_operand:GPR2 0 "register_operand" "=r") -+ (any_ge:GPR2 (match_operand:GPR 1 "register_operand" "r") -+ (const_int 1)))] -+ "" -+ "slt\t%0,zero,%1" -+ [(set_attr "type" "slt") -+ (set_attr "mode" "")]) -+ -+(define_insn "*slt_" -+ [(set (match_operand:GPR2 0 "register_operand" "=r") -+ (any_lt:GPR2 (match_operand:GPR 1 "register_operand" "r") -+ (match_operand:GPR 2 "arith_operand" "rI")))] -+ "" -+ "slt\t%0,%1,%2" -+ [(set_attr "type" "slt") -+ (set_attr "mode" "")]) -+ -+(define_insn "*sle_" -+ [(set (match_operand:GPR2 0 "register_operand" "=r") -+ (any_le:GPR2 (match_operand:GPR 1 "register_operand" "r") -+ (match_operand:GPR 2 "sle_operand" "")))] -+ "" -+{ -+ operands[2] = GEN_INT (INTVAL (operands[2]) + 1); -+ return "slt\t%0,%1,%2"; -+} -+ [(set_attr "type" "slt") -+ (set_attr "mode" "")]) -+ -+;; -+;; .................... -+;; -+;; UNCONDITIONAL BRANCHES -+;; -+;; .................... -+ -+;; Unconditional branches. -+ -+(define_insn "jump" -+ [(set (pc) -+ (label_ref (match_operand 0 "" "")))] -+ "" -+ "j\t%l0" -+ [(set_attr "type" "jump") -+ (set_attr "mode" "none")]) -+ -+(define_expand "indirect_jump" -+ [(set (pc) (match_operand 0 "register_operand"))] -+ "" -+{ -+ operands[0] = force_reg (Pmode, operands[0]); -+ if (Pmode == SImode) -+ emit_jump_insn (gen_indirect_jumpsi (operands[0])); -+ else -+ emit_jump_insn (gen_indirect_jumpdi (operands[0])); -+ DONE; -+}) -+ -+(define_insn "indirect_jump" -+ [(set (pc) (match_operand:P 0 "register_operand" "r"))] -+ "" -+ "jr\t%0" -+ [(set_attr "type" "jump") -+ (set_attr "mode" "none")]) -+ -+(define_expand "tablejump" -+ [(set (pc) (match_operand 0 "register_operand" "")) -+ (use (label_ref (match_operand 1 "" "")))] -+ "" -+{ -+ if (CASE_VECTOR_PC_RELATIVE) -+ operands[0] = expand_simple_binop (Pmode, PLUS, operands[0], -+ gen_rtx_LABEL_REF (Pmode, operands[1]), -+ NULL_RTX, 0, OPTAB_DIRECT); -+ -+ if (CASE_VECTOR_PC_RELATIVE && Pmode == DImode) -+ emit_jump_insn (gen_tablejumpdi (operands[0], operands[1])); -+ else -+ emit_jump_insn (gen_tablejumpsi (operands[0], operands[1])); -+ DONE; -+}) -+ -+(define_insn "tablejump" -+ [(set (pc) (match_operand:GPR 0 "register_operand" "r")) -+ (use (label_ref (match_operand 1 "" "")))] -+ "" -+ "jr\t%0" -+ [(set_attr "type" "jump") -+ (set_attr "mode" "none")]) -+ -+;; -+;; .................... -+;; -+;; Function prologue/epilogue -+;; -+;; .................... -+;; -+ -+(define_expand "prologue" -+ [(const_int 1)] -+ "" -+{ -+ riscv_expand_prologue (); -+ DONE; -+}) -+ -+;; Block any insns from being moved before this point, since the -+;; profiling call to mcount can use various registers that aren't -+;; saved or used to pass arguments. -+ -+(define_insn "blockage" -+ [(unspec_volatile [(const_int 0)] UNSPEC_BLOCKAGE)] -+ "" -+ "" -+ [(set_attr "type" "ghost") -+ (set_attr "mode" "none")]) -+ -+(define_expand "epilogue" -+ [(const_int 2)] -+ "" -+{ -+ riscv_expand_epilogue (false); -+ DONE; -+}) -+ -+(define_expand "sibcall_epilogue" -+ [(const_int 2)] -+ "" -+{ -+ riscv_expand_epilogue (true); -+ DONE; -+}) -+ -+;; Trivial return. Make it look like a normal return insn as that -+;; allows jump optimizations to work better. -+ -+(define_expand "return" -+ [(simple_return)] -+ "riscv_can_use_return_insn ()" -+ "") -+ -+(define_insn "simple_return" -+ [(simple_return)] -+ "" -+ "ret" -+ [(set_attr "type" "jump") -+ (set_attr "mode" "none")]) -+ -+;; Normal return. -+ -+(define_insn "simple_return_internal" -+ [(simple_return) -+ (use (match_operand 0 "pmode_register_operand" ""))] -+ "" -+ "jr\t%0" -+ [(set_attr "type" "jump") -+ (set_attr "mode" "none")]) -+ -+;; This is used in compiling the unwind routines. -+(define_expand "eh_return" -+ [(use (match_operand 0 "general_operand"))] -+ "" -+{ -+ if (GET_MODE (operands[0]) != word_mode) -+ operands[0] = convert_to_mode (word_mode, operands[0], 0); -+ if (TARGET_64BIT) -+ emit_insn (gen_eh_set_lr_di (operands[0])); -+ else -+ emit_insn (gen_eh_set_lr_si (operands[0])); -+ DONE; -+}) -+ -+;; Clobber the return address on the stack. We can't expand this -+;; until we know where it will be put in the stack frame. -+ -+(define_insn "eh_set_lr_si" -+ [(unspec [(match_operand:SI 0 "register_operand" "r")] UNSPEC_EH_RETURN) -+ (clobber (match_scratch:SI 1 "=&r"))] -+ "! TARGET_64BIT" -+ "#") -+ -+(define_insn "eh_set_lr_di" -+ [(unspec [(match_operand:DI 0 "register_operand" "r")] UNSPEC_EH_RETURN) -+ (clobber (match_scratch:DI 1 "=&r"))] -+ "TARGET_64BIT" -+ "#") -+ -+(define_split -+ [(unspec [(match_operand 0 "register_operand")] UNSPEC_EH_RETURN) -+ (clobber (match_scratch 1))] -+ "reload_completed" -+ [(const_int 0)] -+{ -+ riscv_set_return_address (operands[0], operands[1]); -+ DONE; -+}) -+ -+;; -+;; .................... -+;; -+;; FUNCTION CALLS -+;; -+;; .................... -+ -+;; Sibling calls. All these patterns use jump instructions. -+ -+;; call_insn_operand will only accept constant -+;; addresses if a direct jump is acceptable. Since the 'S' constraint -+;; is defined in terms of call_insn_operand, the same is true of the -+;; constraints. -+ -+;; When we use an indirect jump, we need a register that will be -+;; preserved by the epilogue (constraint j). -+ -+(define_expand "sibcall" -+ [(parallel [(call (match_operand 0 "") -+ (match_operand 1 "")) -+ (use (match_operand 2 "")) ;; next_arg_reg -+ (use (match_operand 3 ""))])] ;; struct_value_size_rtx -+ "" -+{ -+ riscv_expand_call (true, NULL_RTX, XEXP (operands[0], 0), operands[1]); -+ DONE; -+}) -+ -+(define_insn "sibcall_internal" -+ [(call (mem:SI (match_operand 0 "call_insn_operand" "j,S")) -+ (match_operand 1 "" ""))] -+ "SIBLING_CALL_P (insn)" -+ { return REG_P (operands[0]) ? "jr\t%0" -+ : absolute_symbolic_operand (operands[0], VOIDmode) ? "tail\t%0" -+ : "tail\t%0@"; } -+ [(set_attr "type" "call")]) -+ -+(define_expand "sibcall_value" -+ [(parallel [(set (match_operand 0 "") -+ (call (match_operand 1 "") -+ (match_operand 2 ""))) -+ (use (match_operand 3 ""))])] ;; next_arg_reg -+ "" -+{ -+ riscv_expand_call (true, operands[0], XEXP (operands[1], 0), operands[2]); -+ DONE; -+}) -+ -+(define_insn "sibcall_value_internal" -+ [(set (match_operand 0 "register_operand" "") -+ (call (mem:SI (match_operand 1 "call_insn_operand" "j,S")) -+ (match_operand 2 "" "")))] -+ "SIBLING_CALL_P (insn)" -+ { return REG_P (operands[1]) ? "jr\t%1" -+ : absolute_symbolic_operand (operands[1], VOIDmode) ? "tail\t%1" -+ : "tail\t%1@"; } -+ [(set_attr "type" "call")]) -+ -+(define_insn "sibcall_value_multiple_internal" -+ [(set (match_operand 0 "register_operand" "") -+ (call (mem:SI (match_operand 1 "call_insn_operand" "j,S")) -+ (match_operand 2 "" ""))) -+ (set (match_operand 3 "register_operand" "") -+ (call (mem:SI (match_dup 1)) -+ (match_dup 2))) -+ (clobber (match_scratch:SI 4 "=j,j"))] -+ "SIBLING_CALL_P (insn)" -+ { return REG_P (operands[1]) ? "jr\t%1" -+ : absolute_symbolic_operand (operands[1], VOIDmode) ? "tail\t%1" -+ : "tail\t%1@"; } -+ [(set_attr "type" "call")]) -+ -+(define_expand "call" -+ [(parallel [(call (match_operand 0 "") -+ (match_operand 1 "")) -+ (use (match_operand 2 "")) ;; next_arg_reg -+ (use (match_operand 3 ""))])] ;; struct_value_size_rtx -+ "" -+{ -+ riscv_expand_call (false, NULL_RTX, XEXP (operands[0], 0), operands[1]); -+ DONE; -+}) -+ -+(define_insn "call_internal" -+ [(call (mem:SI (match_operand 0 "call_insn_operand" "r,S")) -+ (match_operand 1 "" "")) -+ (clobber (reg:SI RETURN_ADDR_REGNUM))] -+ "" -+ { return REG_P (operands[0]) ? "jalr\t%0" -+ : absolute_symbolic_operand (operands[0], VOIDmode) ? "call\t%0" -+ : "call\t%0@"; } -+ [(set_attr "jal" "indirect,direct")]) -+ -+(define_expand "call_value" -+ [(parallel [(set (match_operand 0 "") -+ (call (match_operand 1 "") -+ (match_operand 2 ""))) -+ (use (match_operand 3 ""))])] ;; next_arg_reg -+ "" -+{ -+ riscv_expand_call (false, operands[0], XEXP (operands[1], 0), operands[2]); -+ DONE; -+}) -+ -+;; See comment for call_internal. -+(define_insn "call_value_internal" -+ [(set (match_operand 0 "register_operand" "") -+ (call (mem:SI (match_operand 1 "call_insn_operand" "r,S")) -+ (match_operand 2 "" ""))) -+ (clobber (reg:SI RETURN_ADDR_REGNUM))] -+ "" -+ { return REG_P (operands[1]) ? "jalr\t%1" -+ : absolute_symbolic_operand (operands[1], VOIDmode) ? "call\t%1" -+ : "call\t%1@"; } -+ [(set_attr "jal" "indirect,direct")]) -+ -+;; See comment for call_internal. -+(define_insn "call_value_multiple_internal" -+ [(set (match_operand 0 "register_operand" "") -+ (call (mem:SI (match_operand 1 "call_insn_operand" "r,S")) -+ (match_operand 2 "" ""))) -+ (set (match_operand 3 "register_operand" "") -+ (call (mem:SI (match_dup 1)) -+ (match_dup 2))) -+ (clobber (reg:SI RETURN_ADDR_REGNUM))] -+ "" -+ { return REG_P (operands[1]) ? "jalr\t%1" -+ : absolute_symbolic_operand (operands[1], VOIDmode) ? "call\t%1" -+ : "call\t%1@"; } -+ [(set_attr "jal" "indirect,direct")]) -+ -+;; Call subroutine returning any type. -+ -+(define_expand "untyped_call" -+ [(parallel [(call (match_operand 0 "") -+ (const_int 0)) -+ (match_operand 1 "") -+ (match_operand 2 "")])] -+ "" -+{ -+ int i; -+ -+ emit_call_insn (GEN_CALL (operands[0], const0_rtx, NULL, const0_rtx)); -+ -+ for (i = 0; i < XVECLEN (operands[2], 0); i++) -+ { -+ rtx set = XVECEXP (operands[2], 0, i); -+ riscv_emit_move (SET_DEST (set), SET_SRC (set)); -+ } -+ -+ emit_insn (gen_blockage ()); -+ DONE; -+}) -+ -+(define_insn "nop" -+ [(const_int 0)] -+ "" -+ "nop" -+ [(set_attr "type" "nop") -+ (set_attr "mode" "none")]) -+ -+(define_insn "trap" -+ [(trap_if (const_int 1) (const_int 0))] -+ "" -+ "sbreak") -+ -+(include "sync.md") -+(include "peephole.md") -diff -rNU3 dist.orig/gcc/config/riscv/riscv.opt dist/gcc/config/riscv/riscv.opt ---- dist.orig/gcc/config/riscv/riscv.opt 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/riscv/riscv.opt 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,79 @@ -+; Options for the MIPS port of the compiler -+; -+; Copyright (C) 2005, 2007, 2008, 2010, 2011 Free Software Foundation, Inc. -+; -+; This file is part of GCC. -+; -+; GCC is free software; you can redistribute it and/or modify it under -+; the terms of the GNU General Public License as published by the Free -+; Software Foundation; either version 3, or (at your option) any later -+; version. -+; -+; GCC is distributed in the hope that it will be useful, but WITHOUT -+; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -+; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -+; License for more details. -+; -+; You should have received a copy of the GNU General Public License -+; along with GCC; see the file COPYING3. If not see -+; . -+ -+m32 -+Target RejectNegative Mask(32BIT) -+Generate RV32 code -+ -+m64 -+Target RejectNegative InverseMask(32BIT, 64BIT) -+Generate RV64 code -+ -+mbranch-cost= -+Target RejectNegative Joined UInteger Var(riscv_branch_cost) -+-mbranch-cost=COST Set the cost of branches to roughly COST instructions -+ -+mhard-float -+Target Report RejectNegative InverseMask(SOFT_FLOAT_ABI, HARD_FLOAT_ABI) -+Allow the use of hardware floating-point ABI and instructions -+ -+mmemcpy -+Target Report Mask(MEMCPY) -+Don't optimize block moves -+ -+mplt -+Target Report Var(TARGET_PLT) Init(1) -+When generating -fpic code, allow the use of PLTs. Ignored for fno-pic. -+ -+msoft-float -+Target Report RejectNegative Mask(SOFT_FLOAT_ABI) -+Prevent the use of all hardware floating-point instructions -+ -+mfdiv -+Target Report RejectNegative Mask(FDIV) -+Use hardware floating-point divide and square root instructions -+ -+march= -+Target RejectNegative Joined Var(riscv_arch_string) -+-march= Generate code for given RISC-V ISA (e.g. RV64IM) -+ -+mtune= -+Target RejectNegative Joined Var(riscv_tune_string) -+-mtune=PROCESSOR Optimize the output for PROCESSOR -+ -+msmall-data-limit= -+Target Joined Separate UInteger Var(g_switch_value) Init(8) -+-msmall-data-limit= Put global and static data smaller than bytes into a special section (on some targets) -+ -+matomic -+Target Report Mask(ATOMIC) -+Use hardware atomic memory instructions. -+ -+mmuldiv -+Target Report Mask(MULDIV) -+Use hardware instructions for integer multiplication and division. -+ -+mlra -+Target Report Var(riscv_lra_flag) Init(0) Save -+Use LRA instead of reload -+ -+mcmodel= -+Target RejectNegative Joined Var(riscv_cmodel_string) -+Use given RISC-V code model (medlow or medany) -diff -rNU3 dist.orig/gcc/config/riscv/sync.md dist/gcc/config/riscv/sync.md ---- dist.orig/gcc/config/riscv/sync.md 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/riscv/sync.md 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,198 @@ -+;; Machine description for RISC-V atomic operations. -+;; Copyright (C) 2011-2014 Free Software Foundation, Inc. -+;; Contributed by Andrew Waterman (waterman@cs.berkeley.edu) at UC Berkeley. -+;; Based on MIPS target for GNU compiler. -+ -+;; This file is part of GCC. -+ -+;; GCC is free software; you can redistribute it and/or modify -+;; it under the terms of the GNU General Public License as published by -+;; the Free Software Foundation; either version 3, or (at your option) -+;; any later version. -+ -+;; GCC is distributed in the hope that it will be useful, -+;; but WITHOUT ANY WARRANTY; without even the implied warranty of -+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+;; GNU General Public License for more details. -+ -+;; You should have received a copy of the GNU General Public License -+;; along with GCC; see the file COPYING3. If not see -+;; . -+ -+(define_c_enum "unspec" [ -+ UNSPEC_COMPARE_AND_SWAP -+ UNSPEC_SYNC_OLD_OP -+ UNSPEC_SYNC_EXCHANGE -+ UNSPEC_ATOMIC_STORE -+ UNSPEC_MEMORY_BARRIER -+]) -+ -+(define_code_iterator any_atomic [plus ior xor and]) -+(define_code_attr atomic_optab -+ [(plus "add") (ior "or") (xor "xor") (and "and")]) -+ -+;; Memory barriers. -+ -+(define_expand "mem_thread_fence" -+ [(match_operand:SI 0 "const_int_operand" "")] ;; model -+ "" -+{ -+ if (INTVAL (operands[0]) != MEMMODEL_RELAXED) -+ { -+ rtx mem = gen_rtx_MEM (BLKmode, gen_rtx_SCRATCH (Pmode)); -+ MEM_VOLATILE_P (mem) = 1; -+ emit_insn (gen_mem_thread_fence_1 (mem, operands[0])); -+ } -+ DONE; -+}) -+ -+(define_insn "mem_thread_fence_1" -+ [(set (match_operand:BLK 0 "" "") -+ (unspec:BLK [(match_dup 0)] UNSPEC_MEMORY_BARRIER)) -+ (match_operand:SI 1 "const_int_operand" "")] ;; model -+ "" -+{ -+ switch (INTVAL (operands[1])) -+ { -+ case MEMMODEL_SEQ_CST: -+ case MEMMODEL_ACQ_REL: -+ return "fence rw,rw"; -+ case MEMMODEL_ACQUIRE: -+ case MEMMODEL_CONSUME: -+ return "fence r,rw"; -+ case MEMMODEL_RELEASE: -+ return "fence rw,w"; -+ default: -+ gcc_unreachable(); -+ } -+}) -+ -+;; Atomic memory operations. -+ -+;; Implement atomic stores with amoswap. Fall back to fences for atomic loads. -+(define_insn "atomic_store" -+ [(set (match_operand:GPR 0 "memory_operand" "=A") -+ (unspec_volatile:GPR -+ [(match_operand:GPR 1 "reg_or_0_operand" "rJ") -+ (match_operand:SI 2 "const_int_operand")] ;; model -+ UNSPEC_ATOMIC_STORE))] -+ "TARGET_ATOMIC" -+ "amoswap.%A2 zero,%z1,%0") -+ -+(define_insn "atomic_" -+ [(set (match_operand:GPR 0 "memory_operand" "+A") -+ (unspec_volatile:GPR -+ [(any_atomic:GPR (match_dup 0) -+ (match_operand:GPR 1 "reg_or_0_operand" "rJ")) -+ (match_operand:SI 2 "const_int_operand")] ;; model -+ UNSPEC_SYNC_OLD_OP))] -+ "TARGET_ATOMIC" -+ "amo.%A2 zero,%z1,%0") -+ -+(define_insn "atomic_fetch_" -+ [(set (match_operand:GPR 0 "register_operand" "=&r") -+ (match_operand:GPR 1 "memory_operand" "+A")) -+ (set (match_dup 1) -+ (unspec_volatile:GPR -+ [(any_atomic:GPR (match_dup 1) -+ (match_operand:GPR 2 "reg_or_0_operand" "rJ")) -+ (match_operand:SI 3 "const_int_operand")] ;; model -+ UNSPEC_SYNC_OLD_OP))] -+ "TARGET_ATOMIC" -+ "amo.%A3 %0,%z2,%1") -+ -+(define_insn "atomic_exchange" -+ [(set (match_operand:GPR 0 "register_operand" "=&r") -+ (unspec_volatile:GPR -+ [(match_operand:GPR 1 "memory_operand" "+A") -+ (match_operand:SI 3 "const_int_operand")] ;; model -+ UNSPEC_SYNC_EXCHANGE)) -+ (set (match_dup 1) -+ (match_operand:GPR 2 "register_operand" "0"))] -+ "TARGET_ATOMIC" -+ "amoswap.%A3 %0,%z2,%1") -+ -+(define_insn "atomic_cas_value_strong" -+ [(set (match_operand:GPR 0 "register_operand" "=&r") -+ (match_operand:GPR 1 "memory_operand" "+A")) -+ (set (match_dup 1) -+ (unspec_volatile:GPR [(match_operand:GPR 2 "reg_or_0_operand" "rJ") -+ (match_operand:GPR 3 "reg_or_0_operand" "rJ") -+ (match_operand:SI 4 "const_int_operand") ;; mod_s -+ (match_operand:SI 5 "const_int_operand")] ;; mod_f -+ UNSPEC_COMPARE_AND_SWAP)) -+ (clobber (match_scratch:GPR 6 "=&r"))] -+ "TARGET_ATOMIC" -+ "1: lr.%A5 %0,%1; bne %0,%z2,1f; sc.%A4 %6,%z3,%1; bnez %6,1b; 1:" -+ [(set (attr "length") (const_int 16))]) -+ -+(define_expand "atomic_compare_and_swap" -+ [(match_operand:SI 0 "register_operand" "") ;; bool output -+ (match_operand:GPR 1 "register_operand" "") ;; val output -+ (match_operand:GPR 2 "memory_operand" "") ;; memory -+ (match_operand:GPR 3 "reg_or_0_operand" "") ;; expected value -+ (match_operand:GPR 4 "reg_or_0_operand" "") ;; desired value -+ (match_operand:SI 5 "const_int_operand" "") ;; is_weak -+ (match_operand:SI 6 "const_int_operand" "") ;; mod_s -+ (match_operand:SI 7 "const_int_operand" "")] ;; mod_f -+ "TARGET_ATOMIC" -+{ -+ emit_insn (gen_atomic_cas_value_strong (operands[1], operands[2], -+ operands[3], operands[4], -+ operands[6], operands[7])); -+ -+ rtx compare = operands[1]; -+ if (operands[3] != const0_rtx) -+ { -+ rtx difference = gen_rtx_MINUS (mode, operands[1], operands[3]); -+ compare = gen_reg_rtx (mode); -+ emit_insn (gen_rtx_SET (VOIDmode, compare, difference)); -+ } -+ -+ rtx eq = gen_rtx_EQ (mode, compare, const0_rtx); -+ rtx result = gen_reg_rtx (mode); -+ emit_insn (gen_rtx_SET (VOIDmode, result, eq)); -+ emit_insn (gen_rtx_SET (VOIDmode, operands[0], gen_lowpart (SImode, result))); -+ DONE; -+}) -+ -+(define_expand "atomic_test_and_set" -+ [(match_operand:QI 0 "register_operand" "") ;; bool output -+ (match_operand:QI 1 "memory_operand" "+A") ;; memory -+ (match_operand:SI 2 "const_int_operand" "")] ;; model -+ "TARGET_ATOMIC" -+{ -+ /* We have no QImode atomics, so use the address LSBs to form a mask, -+ then use an aligned SImode atomic. */ -+ rtx result = operands[0]; -+ rtx mem = operands[1]; -+ rtx model = operands[2]; -+ rtx addr = force_reg (Pmode, XEXP (mem, 0)); -+ -+ rtx aligned_addr = gen_reg_rtx (Pmode); -+ emit_move_insn (aligned_addr, gen_rtx_AND (Pmode, addr, GEN_INT (-4))); -+ -+ rtx aligned_mem = change_address (mem, SImode, aligned_addr); -+ set_mem_alias_set (aligned_mem, 0); -+ -+ rtx offset = gen_reg_rtx (SImode); -+ emit_move_insn (offset, gen_rtx_AND (SImode, gen_lowpart (SImode, addr), -+ GEN_INT (3))); -+ -+ rtx tmp = gen_reg_rtx (SImode); -+ emit_move_insn (tmp, GEN_INT (1)); -+ -+ rtx shmt = gen_reg_rtx (SImode); -+ emit_move_insn (shmt, gen_rtx_ASHIFT (SImode, offset, GEN_INT (3))); -+ -+ rtx word = gen_reg_rtx (SImode); -+ emit_move_insn (word, gen_rtx_ASHIFT (SImode, tmp, shmt)); -+ -+ tmp = gen_reg_rtx (SImode); -+ emit_insn (gen_atomic_fetch_orsi (tmp, aligned_mem, word, model)); -+ -+ emit_move_insn (gen_lowpart (SImode, result), -+ gen_rtx_LSHIFTRT (SImode, tmp, -+ gen_lowpart (SImode, shmt))); -+ DONE; -+}) -diff -rNU3 dist.orig/gcc/config/riscv/t-elf dist/gcc/config/riscv/t-elf ---- dist.orig/gcc/config/riscv/t-elf 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/riscv/t-elf 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,4 @@ -+# Build the libraries for both hard and soft floating point -+ -+MULTILIB_OPTIONS = msoft-float m64/m32 mno-atomic -+MULTILIB_DIRNAMES = soft-float 64 32 no-atomic -diff -rNU3 dist.orig/gcc/config/riscv/t-linux64 dist/gcc/config/riscv/t-linux64 ---- dist.orig/gcc/config/riscv/t-linux64 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/riscv/t-linux64 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,5 @@ -+# Build the libraries for both hard and soft floating point -+ -+MULTILIB_OPTIONS = m64/m32 msoft-float mno-atomic -+MULTILIB_DIRNAMES = 64 32 soft-float no-atomic -+MULTILIB_OSDIRNAMES = ../lib ../lib32 -diff -rNU3 dist.orig/gcc/config/riscv/t-netbsd64 dist/gcc/config/riscv/t-netbsd64 ---- dist.orig/gcc/config/riscv/t-netbsd64 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/riscv/t-netbsd64 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,21 @@ -+# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc. -+# -+# This file is part of GCC. -+# -+# GCC is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3, or (at your option) -+# any later version. -+# -+# GCC is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with GCC; see the file COPYING3. If not see -+# . -+ -+MULTILIB_OPTIONS = m64/m32 -+MULTILIB_DIRNAMES = 64 32 -+MULTILIB_OSDIRNAMES = . ../lib/rv32 -diff -rNU3 dist.orig/gcc/config/rs6000/netbsd.h dist/gcc/config/rs6000/netbsd.h ---- dist.orig/gcc/config/rs6000/netbsd.h 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/config/rs6000/netbsd.h 2015-10-18 13:19:50.000000000 +0200 -@@ -27,6 +27,12 @@ - builtin_define ("__powerpc__"); \ - builtin_assert ("cpu=powerpc"); \ - builtin_assert ("machine=powerpc"); \ -+ if (TARGET_SECURE_PLT) \ -+ builtin_define ("_SECURE_PLT"); \ -+ if (TARGET_SOFT_FLOAT) \ -+ builtin_define ("_SOFT_FLOAT"); \ -+ if (TARGET_ISEL) \ -+ builtin_define ("__PPC_ISEL__"); \ - } \ - while (0) - -@@ -58,6 +64,29 @@ - #undef PTRDIFF_TYPE - #define PTRDIFF_TYPE "int" - -+/* Redefine some types that where redefined by rs6000 include files. */ -+ -+#undef WCHAR_TYPE -+#define WCHAR_TYPE "int" -+ -+#undef WCHAR_TYPE_SIZE -+#define WCHAR_TYPE_SIZE 32 -+ -+#undef WINT_TYPE -+#define WINT_TYPE "int" -+ -+#undef INT64_TYPE -+#define INT64_TYPE "long long int" -+ -+#undef UINT64_TYPE -+#define UINT64_TYPE "long long unsigned int" -+ -+#undef INTMAX_TYPE -+#define INTMAX_TYPE "long long int" -+ -+#undef UINTMAX_TYPE -+#define UINTMAX_TYPE "long long unsigned int" -+ - /* Undo the spec mess from sysv4.h, and just define the specs - the way NetBSD systems actually expect. */ - -@@ -75,16 +104,44 @@ - #define STARTFILE_SPEC NETBSD_STARTFILE_SPEC - - #undef ENDFILE_SPEC --#define ENDFILE_SPEC "%(netbsd_endfile_spec)" -+#define ENDFILE_SPEC NETBSD_ENDFILE_SPEC - - #undef LIB_SPEC - #define LIB_SPEC NETBSD_LIB_SPEC - - #undef SUBTARGET_EXTRA_SPECS - #define SUBTARGET_EXTRA_SPECS \ -+ { "cc1_secure_plt_default", CC1_SECURE_PLT_DEFAULT_SPEC }, \ - { "netbsd_link_spec", NETBSD_LINK_SPEC_ELF }, \ - { "netbsd_entry_point", NETBSD_ENTRY_POINT }, \ - { "netbsd_endfile_spec", NETBSD_ENDFILE_SPEC }, - -+/* -+ * Add NetBSD specific defaults: -mstrict-align -+ */ -+#undef TARGET_DEFAULT -+#define TARGET_DEFAULT (MASK_STRICT_ALIGN) -+ -+/* -+ * We know we have the right binutils for this (we shouldn't need to do this -+ * but until the cross build does the right thing...) -+ */ -+#undef TARGET_SECURE_PLT -+#define TARGET_SECURE_PLT secure_plt -+#undef HAVE_AS_TLS -+#define HAVE_AS_TLS 1 -+#define POWERPC_NETBSD -+ -+/* Attempt to enable execute permissions on the stack. */ -+//#define TRANSFER_FROM_TRAMPOLINE NETBSD_ENABLE_EXECUTE_STACK -+// XXXMRG use enable-execute-stack-mprotect.c ? -+#ifdef L_trampoline -+#undef TRAMPOLINE_SIZE -+#define TRAMPOLINE_SIZE 48 -+#endif -+ -+/* Override STACK_BOUNDARY to use Altivec compliant one. */ -+#undef STACK_BOUNDARY -+#define STACK_BOUNDARY 128 - - #define DBX_REGISTER_NUMBER(REGNO) rs6000_dbx_register_number (REGNO) -diff -rNU3 dist.orig/gcc/config/rs6000/netbsd64.h dist/gcc/config/rs6000/netbsd64.h ---- dist.orig/gcc/config/rs6000/netbsd64.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/rs6000/netbsd64.h 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,629 @@ -+/* Definitions of target machine for GNU compiler, -+ for 64 bit PowerPC NetBSD. -+ Copyright (C) 2006 Free Software Foundation, Inc. -+ Contributed by Matthew Green (mrg@eterna.com.au). -+ -+ This file is part of GCC. -+ -+ GCC is free software; you can redistribute it and/or modify it -+ under the terms of the GNU General Public License as published -+ by the Free Software Foundation; either version 2, or (at your -+ option) any later version. -+ -+ GCC is distributed in the hope that it will be useful, but WITHOUT -+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public -+ License for more details. -+ -+ You should have received a copy of the GNU General Public License -+ along with GCC; see the file COPYING. If not, write to the -+ Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, -+ MA 02110-1301, USA. */ -+ -+#ifndef RS6000_BI_ARCH -+ -+#undef DEFAULT_ABI -+#define DEFAULT_ABI ABI_AIX -+ -+#undef TARGET_64BIT -+#define TARGET_64BIT 1 -+ -+#define DEFAULT_ARCH64_P 1 -+#define RS6000_BI_ARCH_P 0 -+ -+#else -+ -+#define DEFAULT_ARCH64_P (TARGET_DEFAULT & MASK_64BIT) -+#define RS6000_BI_ARCH_P 1 -+ -+#endif -+ -+#ifdef IN_LIBGCC2 -+#undef TARGET_64BIT -+#ifdef __powerpc64__ -+#define TARGET_64BIT 1 -+#else -+#define TARGET_64BIT 0 -+#endif -+#endif -+ -+#undef TARGET_AIX -+#define TARGET_AIX TARGET_64BIT -+ -+#ifdef HAVE_LD_NO_DOT_SYMS -+/* New ABI uses a local sym for the function entry point. */ -+extern int dot_symbols; -+#undef DOT_SYMBOLS -+#define DOT_SYMBOLS dot_symbols -+#endif -+ -+#define TARGET_PROFILE_KERNEL profile_kernel -+ -+#define TARGET_USES_LINUX64_OPT 1 -+#ifdef HAVE_LD_LARGE_TOC -+#undef TARGET_CMODEL -+#define TARGET_CMODEL rs6000_current_cmodel -+#define SET_CMODEL(opt) rs6000_current_cmodel = opt -+#else -+#define SET_CMODEL(opt) do {} while (0) -+#endif -+ -+#undef PROCESSOR_DEFAULT -+#define PROCESSOR_DEFAULT PROCESSOR_POWER4 -+#undef PROCESSOR_DEFAULT64 -+#define PROCESSOR_DEFAULT64 PROCESSOR_POWER4 -+ -+/* We don't need to generate entries in .fixup, except when -+ -mrelocatable or -mrelocatable-lib is given. */ -+#undef RELOCATABLE_NEEDS_FIXUP -+#define RELOCATABLE_NEEDS_FIXUP \ -+ (rs6000_isa_flags & rs6000_isa_flags_explicit & OPTION_MASK_RELOCATABLE) -+ -+#undef RS6000_ABI_NAME -+#define RS6000_ABI_NAME "netbsd" -+ -+#define INVALID_64BIT "-m%s not supported in this configuration" -+#define INVALID_32BIT INVALID_64BIT -+ -+#define ELFv2_ABI_CHECK (rs6000_elf_abi == 2) -+ -+#undef CC1_OS_NETBSD_SPEC -+#define CC1_OS_NETBSD_SPEC \ -+ NETBSD_CC1_AND_CC1PLUS_SPEC \ -+ "%{!m32: %{!mrelocatable: %{!fno-pie: %{!fno-pic: \ -+ %{!fpie: %{!fpic: \ -+ %{!fPIE: %{!fPIC:-fPIC}}}}}}}}" -+/* %{!m32: %{!mcmodel*: -mcmodel=medium}}" */ -+ -+#undef CC1PLUS_SPEC -+#define CC1PLUS_SPEC CC1_OS_NETBSD_SPEC -+ -+#undef SUBSUBTARGET_OVERRIDE_OPTIONS -+#define SUBSUBTARGET_OVERRIDE_OPTIONS \ -+ do \ -+ { \ -+ if (!global_options_set.x_rs6000_alignment_flags) \ -+ rs6000_alignment_flags = MASK_ALIGN_NATURAL; \ -+ if (TARGET_64BIT) \ -+ { \ -+ if (DEFAULT_ABI != ABI_AIX) \ -+ { \ -+ rs6000_current_abi = ABI_AIX; \ -+ error (INVALID_64BIT, "call"); \ -+ } \ -+ dot_symbols = !strcmp (rs6000_abi_name, "aixdesc"); \ -+ if (ELFv2_ABI_CHECK) \ -+ { \ -+ rs6000_current_abi = ABI_ELFv2; \ -+ if (dot_symbols) \ -+ error ("-mcall-aixdesc incompatible with -mabi=elfv2"); \ -+ } \ -+ if (rs6000_isa_flags & OPTION_MASK_RELOCATABLE) \ -+ { \ -+ rs6000_isa_flags &= ~OPTION_MASK_RELOCATABLE; \ -+ error (INVALID_64BIT, "relocatable"); \ -+ } \ -+ if (rs6000_isa_flags & OPTION_MASK_EABI) \ -+ { \ -+ rs6000_isa_flags &= ~OPTION_MASK_EABI; \ -+ error (INVALID_64BIT, "eabi"); \ -+ } \ -+ if (TARGET_PROTOTYPE) \ -+ { \ -+ target_prototype = 0; \ -+ error (INVALID_64BIT, "prototype"); \ -+ } \ -+ if ((rs6000_isa_flags & OPTION_MASK_POWERPC64) == 0) \ -+ { \ -+ rs6000_isa_flags |= OPTION_MASK_POWERPC64; \ -+ error ("-m64 requires a PowerPC64 cpu"); \ -+ } \ -+ if ((rs6000_isa_flags_explicit \ -+ & OPTION_MASK_MINIMAL_TOC) != 0) \ -+ { \ -+ if (global_options_set.x_rs6000_current_cmodel \ -+ && rs6000_current_cmodel != CMODEL_SMALL) \ -+ error ("-mcmodel incompatible with other toc options"); \ -+ SET_CMODEL (CMODEL_SMALL); \ -+ } \ -+ { \ -+ if (!global_options_set.x_rs6000_current_cmodel) \ -+ SET_CMODEL (CMODEL_MEDIUM); \ -+ if (rs6000_current_cmodel != CMODEL_SMALL) \ -+ { \ -+ TARGET_NO_FP_IN_TOC = 0; \ -+ TARGET_NO_SUM_IN_TOC = 0; \ -+ } \ -+ } \ -+ } \ -+ else \ -+ { \ -+ if (!RS6000_BI_ARCH_P) \ -+ error (INVALID_32BIT, "32"); \ -+ if (TARGET_PROFILE_KERNEL) \ -+ { \ -+ TARGET_PROFILE_KERNEL = 0; \ -+ error (INVALID_32BIT, "profile-kernel"); \ -+ } \ -+ if (global_options_set.x_rs6000_current_cmodel) \ -+ { \ -+ SET_CMODEL (CMODEL_SMALL); \ -+ error (INVALID_32BIT, "cmodel"); \ -+ } \ -+ } \ -+ } \ -+ while (0) -+ -+#ifdef RS6000_BI_ARCH -+ -+#if 0 -+#undef OVERRIDE_OPTIONS -+#define OVERRIDE_OPTIONS \ -+ rs6000_override_options (((TARGET_DEFAULT ^ target_flags) & MASK_64BIT) \ -+ ? (char *) 0 : TARGET_CPU_DEFAULT) -+#endif -+ -+#endif -+ -+#undef ASM_DEFAULT_SPEC -+#undef ASM_SPEC -+#undef LINK_OS_NETBSD_SPEC -+ -+#ifndef RS6000_BI_ARCH -+#define ASM_DEFAULT_SPEC "-mppc64" -+#define ASM_SPEC "%(asm_spec64) %(asm_spec_common)" -+#define LINK_OS_NETBSD_SPEC "%(link_os_netbsd_spec64)" -+#else -+#if DEFAULT_ARCH64_P -+#define ASM_DEFAULT_SPEC "-mppc%{!m32:64}" -+#define ASM_SPEC "%{m32:%(asm_spec32)}%{!m32:%(asm_spec64)} %(asm_spec_common)" -+#define LINK_OS_NETBSD_SPEC "%{m32:%(link_os_netbsd_spec32)}%{!m32:%(link_os_netbsd_spec64)}" -+#else -+#define ASM_DEFAULT_SPEC "-mppc%{m64:64}" -+#define ASM_SPEC "%{!m64:%(asm_spec32)}%{m64:%(asm_spec64)} %(asm_spec_common)" -+#define LINK_OS_NETBSD_SPEC "%{!m64:%(link_os_netbsd_spec32)}%{m64:%(link_os_netbsd_spec64)}" -+#endif -+#endif -+ -+#define ASM_SPEC32 "-a32 \ -+%{mrelocatable} %{mrelocatable-lib} %{fpic|fpie|fPIC|fPIE:-K PIC} \ -+%{memb|msdata=eabi: -memb}" -+ -+#define ASM_SPEC64 "-a64" -+ -+#define ASM_SPEC_COMMON "%(asm_cpu) \ -+%{,assembler|,assembler-with-cpp: %{mregnames} %{mno-regnames}}" \ -+ ENDIAN_SELECT(" -mbig", " -mlittle", DEFAULT_ASM_ENDIAN) -+ -+#undef SUBSUBTARGET_EXTRA_SPECS -+#define SUBSUBTARGET_EXTRA_SPECS \ -+ { "asm_spec_common", ASM_SPEC_COMMON }, \ -+ { "asm_spec32", ASM_SPEC32 }, \ -+ { "asm_spec64", ASM_SPEC64 }, \ -+ { "link_os_netbsd_spec32", LINK_OS_NETBSD_SPEC32 }, \ -+ { "link_os_netbsd_spec64", LINK_OS_NETBSD_SPEC64 }, -+ -+#undef MULTILIB_DEFAULTS -+#if DEFAULT_ARCH64_P -+#define MULTILIB_DEFAULTS { "m64" } -+#else -+#define MULTILIB_DEFAULTS { "m32" } -+#endif -+ -+#ifndef RS6000_BI_ARCH -+ -+/* 64-bit PowerPC NetBSD is always big-endian. */ -+#undef TARGET_LITTLE_ENDIAN -+#define TARGET_LITTLE_ENDIAN 0 -+ -+/* 64-bit PowerPC NetBSD always has a TOC. */ -+#undef TARGET_TOC -+#define TARGET_TOC 1 -+ -+/* Some things from sysv4.h we don't do when 64 bit. */ -+#undef TARGET_RELOCATABLE -+#define TARGET_RELOCATABLE 0 -+#undef TARGET_EABI -+#define TARGET_EABI 0 -+#undef TARGET_PROTOTYPE -+#define TARGET_PROTOTYPE 0 -+#undef RELOCATABLE_NEEDS_FIXUP -+#define RELOCATABLE_NEEDS_FIXUP 0 -+ -+#endif -+ -+/* PowerPC64 NetBSD word-aligns FP doubles when -malign-power is given. */ -+#undef ADJUST_FIELD_ALIGN -+#define ADJUST_FIELD_ALIGN(FIELD, COMPUTED) \ -+ ((TARGET_ALTIVEC && TREE_CODE (TREE_TYPE (FIELD)) == VECTOR_TYPE) \ -+ ? 128 \ -+ : (TARGET_64BIT \ -+ && TARGET_ALIGN_NATURAL == 0 \ -+ && TYPE_MODE (strip_array_types (TREE_TYPE (FIELD))) == DFmode) \ -+ ? MIN ((COMPUTED), 32) \ -+ : (COMPUTED)) -+ -+/* PowerPC64 NetBSD increases natural record alignment to doubleword if -+ the first field is an FP double, only if in power alignment mode. */ -+#undef ROUND_TYPE_ALIGN -+#define ROUND_TYPE_ALIGN(STRUCT, COMPUTED, SPECIFIED) \ -+ ((TARGET_64BIT \ -+ && (TREE_CODE (STRUCT) == RECORD_TYPE \ -+ || TREE_CODE (STRUCT) == UNION_TYPE \ -+ || TREE_CODE (STRUCT) == QUAL_UNION_TYPE) \ -+ && TARGET_ALIGN_NATURAL == 0) \ -+ ? rs6000_special_round_type_align (STRUCT, COMPUTED, SPECIFIED) \ -+ : MAX ((COMPUTED), (SPECIFIED))) -+ -+/* Use the default for compiling target libs. */ -+#ifdef IN_TARGET_LIBS -+#undef TARGET_ALIGN_NATURAL -+#define TARGET_ALIGN_NATURAL 1 -+#endif -+ -+/* Indicate that jump tables go in the text section. */ -+#undef JUMP_TABLES_IN_TEXT_SECTION -+#define JUMP_TABLES_IN_TEXT_SECTION TARGET_64BIT -+ -+/* The linux ppc64 ABI isn't explicit on whether aggregates smaller -+ than a doubleword should be padded upward or downward. You could -+ reasonably assume that they follow the normal rules for structure -+ layout treating the parameter area as any other block of memory, -+ then map the reg param area to registers. i.e. pad upward. -+ Setting both of the following defines results in this behavior. -+ Setting just the first one will result in aggregates that fit in a -+ doubleword being padded downward, and others being padded upward. -+ Not a bad idea as this results in struct { int x; } being passed -+ the same way as an int. */ -+#define AGGREGATE_PADDING_FIXED TARGET_64BIT -+#define AGGREGATES_PAD_UPWARD_ALWAYS 0 -+ -+/* Specify padding for the last element of a block move between -+ registers and memory. FIRST is nonzero if this is the only -+ element. */ -+#define BLOCK_REG_PADDING(MODE, TYPE, FIRST) \ -+ (!(FIRST) ? upward : FUNCTION_ARG_PADDING (MODE, TYPE)) -+ -+/* NetBSD doesn't support saving and restoring 64-bit regs in a 32-bit -+ process. XXXMRG? */ -+#define OS_MISSING_POWERPC64 !TARGET_64BIT -+ -+/* NetBSD has float and long double forms of math functions. */ -+#undef TARGET_C99_FUNCTIONS -+#define TARGET_C99_FUNCTIONS 1 -+ -+/* NetBSD doesn't have sincos that follows the GNU extension. */ -+#undef TARGET_HAS_SINCOS -+ -+#undef TARGET_OS_CPP_BUILTINS -+#define TARGET_OS_CPP_BUILTINS() \ -+ do \ -+ { \ -+ NETBSD_OS_CPP_BUILTINS_ELF(); \ -+ if (TARGET_ISEL) \ -+ builtin_define ("__PPC_ISEL__"); \ -+ if (TARGET_64BIT) \ -+ { \ -+ builtin_define ("__PPC__"); \ -+ builtin_define ("__PPC64__"); \ -+ builtin_define ("__powerpc__"); \ -+ builtin_define ("__powerpc64__"); \ -+ builtin_define_with_int_value ("__PIC__", 2); \ -+ builtin_assert ("cpu=powerpc64"); \ -+ builtin_assert ("machine=powerpc64"); \ -+ } \ -+ else \ -+ { \ -+ builtin_define_std ("PPC"); \ -+ builtin_define_std ("powerpc"); \ -+ builtin_assert ("cpu=powerpc"); \ -+ builtin_assert ("machine=powerpc"); \ -+ TARGET_OS_SYSV_CPP_BUILTINS (); \ -+ } \ -+ } \ -+ while (0) -+ -+/* Override the default from rs6000.h to avoid conflicts with macros -+ defined in NetBSD header files. */ -+ -+#undef RS6000_CPU_CPP_ENDIAN_BUILTINS -+#define RS6000_CPU_CPP_ENDIAN_BUILTINS() \ -+ do \ -+ { \ -+ builtin_define ("__BIG_ENDIAN__"); \ -+ builtin_assert ("machine=bigendian"); \ -+ } \ -+ while (0) -+ -+#undef CPP_OS_DEFAULT_SPEC -+#define CPP_OS_DEFAULT_SPEC "%(cpp_os_netbsd)" -+ -+#undef LINK_SHLIB_SPEC -+#define LINK_SHLIB_SPEC "%{shared:-shared} %{!shared: %{static:-static}}" -+ -+#undef LIB_DEFAULT_SPEC -+#define LIB_DEFAULT_SPEC "%(lib_netbsd)" -+ -+#undef STARTFILE_DEFAULT_SPEC -+#define STARTFILE_DEFAULT_SPEC "%(startfile_netbsd)" -+ -+#undef ENDFILE_DEFAULT_SPEC -+#define ENDFILE_DEFAULT_SPEC "%(endfile_netbsd)" -+ -+#undef LINK_START_DEFAULT_SPEC -+#define LINK_START_DEFAULT_SPEC "%(link_start_netbsd)" -+ -+#undef LINK_OS_DEFAULT_SPEC -+#define LINK_OS_DEFAULT_SPEC "%(link_os_netbsd)" -+ -+#define LINK_OS_NETBSD_SPEC32 "-m elf32ppc %{!shared: %{!static: \ -+ %{rdynamic:-export-dynamic} \ -+ %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}}}" -+ -+#define LINK_OS_NETBSD_SPEC64 "-m elf64ppc %{!shared: %{!static: \ -+ %{rdynamic:-export-dynamic} \ -+ %{!dynamic-linker:-dynamic-linker /usr/libexec/ld.elf_so}}}" -+ -+#undef TOC_SECTION_ASM_OP -+#define TOC_SECTION_ASM_OP \ -+ (TARGET_64BIT \ -+ ? "\t.section\t\".toc\",\"aw\"" \ -+ : "\t.section\t\".got\",\"aw\"") -+ -+#undef MINIMAL_TOC_SECTION_ASM_OP -+#define MINIMAL_TOC_SECTION_ASM_OP \ -+ (TARGET_64BIT \ -+ ? "\t.section\t\".toc1\",\"aw\"" \ -+ : ((TARGET_RELOCATABLE || flag_pic) \ -+ ? "\t.section\t\".got2\",\"aw\"" \ -+ : "\t.section\t\".got1\",\"aw\"")) -+ -+/* Make GCC agree with . */ -+ -+#undef SIZE_TYPE -+#define SIZE_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "unsigned int") -+ -+#undef PTRDIFF_TYPE -+#define PTRDIFF_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "int") -+ -+#undef INTPTR_TYPE -+#define INTPTR_TYPE PTRDIFF_TYPE -+ -+#undef UINTPTR_TYPE -+#define UINTPTR_TYPE SIZE_TYPE -+ -+#undef WCHAR_TYPE -+#define WCHAR_TYPE "int" -+ -+#undef INT8_TYPE -+#define INT8_TYPE "signed char" -+ -+#undef INT16_TYPE -+#define INT16_TYPE "short int" -+ -+#undef INT32_TYPE -+#define INT32_TYPE "int" -+ -+#undef INT64_TYPE -+#define INT64_TYPE "long long int" -+ -+#undef UINT8_TYPE -+#define UINT8_TYPE "unsigned char" -+ -+#undef UINT16_TYPE -+#define UINT16_TYPE "short unsigned int" -+ -+#undef UINT32_TYPE -+#define UINT32_TYPE "unsigned int" -+ -+#undef UINT64_TYPE -+#define UINT64_TYPE "long long unsigned int" -+ -+#undef INT_FAST8_TYPE -+#define INT_FAST8_TYPE "int" -+ -+#undef INT_FAST16_TYPE -+#define INT_FAST16_TYPE "int" -+ -+#undef INT_FAST32_TYPE -+#define INT_FAST32_TYPE "int" -+ -+#undef INT_FAST64_TYPE -+#define INT_FAST64_TYPE INT64_TYPE -+ -+#undef UINT_FAST8_TYPE -+#define UINT_FAST8_TYPE "unsigned int" -+ -+#undef UINT_FAST16_TYPE -+#define UINT_FAST16_TYPE "unsigned int" -+ -+#undef UINT_FAST32_TYPE -+#define UINT_FAST32_TYPE "unsigned int" -+ -+#undef UINT_FAST8_TYPE -+#define UINT_FAST8_TYPE "unsigned int" -+ -+#undef UINT_FAST16_TYPE -+#define UINT_FAST16_TYPE "unsigned int" -+ -+#undef UINT_FAST32_TYPE -+#define UINT_FAST32_TYPE "unsigned int" -+ -+#undef UINT_FAST64_TYPE -+#define UINT_FAST64_TYPE UINT64_TYPE -+ -+#undef INT_LEAST8_TYPE -+#define INT_LEAST8_TYPE INT8_TYPE -+ -+#undef INT_LEAST16_TYPE -+#define INT_LEAST16_TYPE INT16_TYPE -+ -+#undef INT_LEAST32_TYPE -+#define INT_LEAST32_TYPE "int" -+ -+#undef INT_LEAST64_TYPE -+#define INT_LEAST64_TYPE INT64_TYPE -+ -+#undef UINT_LEAST8_TYPE -+#define UINT_LEAST8_TYPE UINT8_TYPE -+ -+#undef UINT_LEAST16_TYPE -+#define UINT_LEAST16_TYPE UINT16_TYPE -+ -+#undef UINT_LEAST32_TYPE -+#define UINT_LEAST32_TYPE "unsigned int" -+ -+#undef UINT_LEAST64_TYPE -+#define UINT_LEAST64_TYPE UINT64_TYPE -+ -+#undef INTMAX_TYPE -+#define INTMAX_TYPE INT64_TYPE -+ -+#undef UINTMAX_TYPE -+#define UINTMAX_TYPE UINT64_TYPE -+ -+/* Override rs6000.h definition. */ -+#undef ASM_APP_ON -+#define ASM_APP_ON "#APP\n" -+ -+/* Override rs6000.h definition. */ -+#undef ASM_APP_OFF -+#define ASM_APP_OFF "#NO_APP\n" -+ -+/* PowerPC no-op instruction. */ -+#undef RS6000_CALL_GLUE -+#define RS6000_CALL_GLUE (TARGET_64BIT ? "nop" : "cror 31,31,31") -+ -+#undef RS6000_MCOUNT -+#define RS6000_MCOUNT "_mcount" -+ -+#ifdef __powerpc64__ -+/* _init and _fini functions are built from bits spread across many -+ object files, each potentially with a different TOC pointer. For -+ that reason, place a nop after the call so that the linker can -+ restore the TOC pointer if a TOC adjusting call stub is needed. */ -+#if DOT_SYMBOLS -+#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \ -+ asm (SECTION_OP "\n" \ -+" bl ." #FUNC "\n" \ -+" nop\n" \ -+" .previous"); -+#else -+#define CRT_CALL_STATIC_FUNCTION(SECTION_OP, FUNC) \ -+ asm (SECTION_OP "\n" \ -+" bl " #FUNC "\n" \ -+" nop\n" \ -+" .previous"); -+#endif -+#endif -+ -+/* FP save and restore routines. */ -+#undef SAVE_FP_PREFIX -+#define SAVE_FP_PREFIX (TARGET_64BIT ? "._savef" : "_savefpr_") -+#undef SAVE_FP_SUFFIX -+#define SAVE_FP_SUFFIX (TARGET_64BIT ? "" : "_l") -+#undef RESTORE_FP_PREFIX -+#define RESTORE_FP_PREFIX (TARGET_64BIT ? "._restf" : "_restfpr_") -+#undef RESTORE_FP_SUFFIX -+#define RESTORE_FP_SUFFIX (TARGET_64BIT ? "" : "_l") -+ -+/* Dwarf2 debugging. */ -+#undef PREFERRED_DEBUGGING_TYPE -+#define PREFERRED_DEBUGGING_TYPE DWARF2_DEBUG -+ -+/* This is how to declare the size of a function. */ -+#undef ASM_DECLARE_FUNCTION_SIZE -+#define ASM_DECLARE_FUNCTION_SIZE(FILE, FNAME, DECL) \ -+ do \ -+ { \ -+ if (!flag_inhibit_size_directive) \ -+ { \ -+ fputs ("\t.size\t", (FILE)); \ -+ if (TARGET_64BIT && DOT_SYMBOLS) \ -+ putc ('.', (FILE)); \ -+ assemble_name ((FILE), (FNAME)); \ -+ fputs (",.-", (FILE)); \ -+ rs6000_output_function_entry (FILE, FNAME); \ -+ putc ('\n', (FILE)); \ -+ } \ -+ } \ -+ while (0) -+ -+/* Return nonzero if this entry is to be written into the constant -+ pool in a special way. We do so if this is a SYMBOL_REF, LABEL_REF -+ or a CONST containing one of them. If -mfp-in-toc (the default), -+ we also do this for floating-point constants. We actually can only -+ do this if the FP formats of the target and host machines are the -+ same, but we can't check that since not every file that uses -+ the macros includes real.h. We also do this when we can write the -+ entry into the TOC and the entry is not larger than a TOC entry. */ -+ -+#undef ASM_OUTPUT_SPECIAL_POOL_ENTRY_P -+#define ASM_OUTPUT_SPECIAL_POOL_ENTRY_P(X, MODE) \ -+ (TARGET_TOC \ -+ && (GET_CODE (X) == SYMBOL_REF \ -+ || (GET_CODE (X) == CONST && GET_CODE (XEXP (X, 0)) == PLUS \ -+ && GET_CODE (XEXP (XEXP (X, 0), 0)) == SYMBOL_REF) \ -+ || GET_CODE (X) == LABEL_REF \ -+ || (GET_CODE (X) == CONST_INT \ -+ && GET_MODE_BITSIZE (MODE) <= GET_MODE_BITSIZE (Pmode)) \ -+ || (GET_CODE (X) == CONST_DOUBLE \ -+ && ((TARGET_64BIT \ -+ && (TARGET_MINIMAL_TOC \ -+ || (SCALAR_FLOAT_MODE_P (GET_MODE (X)) \ -+ && ! TARGET_NO_FP_IN_TOC))) \ -+ || (!TARGET_64BIT \ -+ && !TARGET_NO_FP_IN_TOC \ -+ && !TARGET_RELOCATABLE \ -+ && SCALAR_FLOAT_MODE_P (GET_MODE (X)) \ -+ && BITS_PER_WORD == HOST_BITS_PER_INT))))) -+ -+/* Select a format to encode pointers in exception handling data. CODE -+ is 0 for data, 1 for code labels, 2 for function pointers. GLOBAL is -+ true if the symbol may be affected by dynamic relocations. */ -+#undef ASM_PREFERRED_EH_DATA_FORMAT -+#define ASM_PREFERRED_EH_DATA_FORMAT(CODE, GLOBAL) \ -+ ((TARGET_64BIT || flag_pic || TARGET_RELOCATABLE) \ -+ ? (((GLOBAL) ? DW_EH_PE_indirect : 0) | DW_EH_PE_pcrel \ -+ | (TARGET_64BIT ? DW_EH_PE_udata8 : DW_EH_PE_sdata4)) \ -+ : DW_EH_PE_absptr) -+ -+/* For backward compatibility, we must continue to use the AIX -+ structure return convention. */ -+#undef DRAFT_V4_STRUCT_RET -+#define DRAFT_V4_STRUCT_RET (!TARGET_64BIT) -+ -+#define TARGET_POSIX_IO -+ -+#define LINK_GCC_C_SEQUENCE_SPEC \ -+ "%{static:--start-group} %G %L %{static:--end-group}%{!static:%G}" -+ -+/* Use --as-needed -lgcc_s for eh support. */ -+#ifdef HAVE_LD_AS_NEEDED -+#define USE_LD_AS_NEEDED 1 -+#endif -+ -+/* NetBSD ppc64 has 128-bit long double support. */ -+#undef RS6000_DEFAULT_LONG_DOUBLE_SIZE -+#define RS6000_DEFAULT_LONG_DOUBLE_SIZE 128 -+#define POWERPC_NETBSD -diff -rNU3 dist.orig/gcc/config/rs6000/rs6000.c dist/gcc/config/rs6000/rs6000.c ---- dist.orig/gcc/config/rs6000/rs6000.c 2015-05-05 16:27:30.000000000 +0200 -+++ dist/gcc/config/rs6000/rs6000.c 2015-10-18 13:19:50.000000000 +0200 -@@ -3260,10 +3260,14 @@ - - /* If we are optimizing big endian systems for space and it's OK to - use instructions that would be microcoded on the Cell, use the -- load/store multiple and string instructions. */ -+ load/store multiple and string instructions. Don't use string -+ instructions on NetBSD because the e500 doesn't support them. */ - if (BYTES_BIG_ENDIAN && optimize_size && rs6000_gen_cell_microcode) - rs6000_isa_flags |= ~rs6000_isa_flags_explicit & (OPTION_MASK_MULTIPLE -- | OPTION_MASK_STRING); -+#if !defined (POWERPC_NETBSD) -+ | OPTION_MASK_STRING -+#endif -+ | 0); - - /* Don't allow -mmultiple or -mstring on little endian systems - unless the cpu is a 750, because the hardware doesn't support the -@@ -3534,7 +3538,8 @@ - rs6000_long_double_type_size = RS6000_DEFAULT_LONG_DOUBLE_SIZE; - } - --#if !defined (POWERPC_LINUX) && !defined (POWERPC_FREEBSD) -+#if !defined (POWERPC_LINUX) && !defined (POWERPC_FREEBSD) \ -+ && !defined (POWERPC_NETBSD) - if (!global_options_set.x_rs6000_ieeequad) - rs6000_ieeequad = 1; - #endif -@@ -22820,7 +22825,8 @@ - } - else if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2) - { --#if !defined (POWERPC_LINUX) && !defined (POWERPC_FREEBSD) -+#if !defined (POWERPC_LINUX) && !defined (POWERPC_FREEBSD) \ -+ && !defined(POWERPC_NETBSD) - /* No out-of-line save/restore routines for GPRs on AIX. */ - gcc_assert (!TARGET_AIX || (sel & SAVRES_REG) != SAVRES_GPR); - #endif -@@ -22832,7 +22838,8 @@ - : ((sel & SAVRES_LR) ? "_restgpr0_" : "_restgpr1_")); - else if ((sel & SAVRES_REG) == SAVRES_FPR) - { --#if defined (POWERPC_LINUX) || defined (POWERPC_FREEBSD) -+#if defined (POWERPC_LINUX) || defined (POWERPC_FREEBSD) \ -+ || defined (POWERPC_NETBSD) - if ((sel & SAVRES_LR)) - prefix = ((sel & SAVRES_SAVE) ? "_savefpr_" : "_restfpr_"); - else -@@ -29294,7 +29301,11 @@ - if (flag_pic) - return 3; - else if (DEFAULT_ABI == ABI_AIX || DEFAULT_ABI == ABI_ELFv2) -+#if defined (POWERPC_NETBSD) -+ return 3; -+#else - return 2; -+#endif - else - return 0; - } -@@ -29463,7 +29474,8 @@ - aix_struct_return ? 2 : 1); - } - #endif --#if defined (POWERPC_LINUX) || defined (POWERPC_FREEBSD) -+#if defined (POWERPC_LINUX) || defined (POWERPC_FREEBSD) \ -+ || defined (POWERPC_NETBSD) - if (TARGET_32BIT || DEFAULT_ABI == ABI_ELFv2) - file_end_indicate_exec_stack (); - #endif -diff -rNU3 dist.orig/gcc/config/rs6000/sysv4.h dist/gcc/config/rs6000/sysv4.h ---- dist.orig/gcc/config/rs6000/sysv4.h 2014-07-24 19:34:24.000000000 +0200 -+++ dist/gcc/config/rs6000/sysv4.h 2015-10-18 13:19:50.000000000 +0200 -@@ -97,7 +97,12 @@ - rs6000_current_abi = ABI_V4; \ - } \ - else if (!strcmp (rs6000_abi_name, "netbsd")) \ -- rs6000_current_abi = ABI_V4; \ -+ { \ -+ if (TARGET_64BIT) \ -+ rs6000_current_abi = ABI_AIX; \ -+ else \ -+ rs6000_current_abi = ABI_V4; \ -+ } \ - else if (!strcmp (rs6000_abi_name, "openbsd")) \ - rs6000_current_abi = ABI_V4; \ - else if (!strcmp (rs6000_abi_name, "i960-old")) \ -@@ -539,6 +544,7 @@ - #endif - - /* Pass -G xxx to the compiler. */ -+#undef CC1_SPEC - #define CC1_SPEC "%{G*} %(cc1_cpu)" \ - "%{meabi: %{!mcall-*: -mcall-sysv }} \ - %{!meabi: %{!mno-eabi: \ -@@ -551,7 +557,8 @@ - %{msdata: -msdata=default} \ - %{mno-sdata: -msdata=none} \ - %{!mbss-plt: %{!msecure-plt: %(cc1_secure_plt_default)}} \ --%{profile: -p}" -+%{profile: -p} \ -+%(cc1_os_netbsd)" - - /* Default starting address if specified. */ - #define LINK_START_SPEC "\ -@@ -777,7 +784,7 @@ - %{rdynamic:-export-dynamic} \ - -dynamic-linker " GNU_USER_DYNAMIC_LINKER "}}" - --#if defined(HAVE_LD_EH_FRAME_HDR) -+#if defined(HAVE_LD_EH_FRAME_HDR) && !defined(LINK_EH_SPEC) - # define LINK_EH_SPEC "%{!static:--eh-frame-hdr} " - #endif - -@@ -789,28 +796,23 @@ - -Asystem=linux -Asystem=unix -Asystem=posix %{pthread:-D_REENTRANT}" - - /* NetBSD support. */ --#define LIB_NETBSD_SPEC "\ ---lc" -+#define LIB_NETBSD_SPEC NETBSD_LIB_SPEC - --#define STARTFILE_NETBSD_SPEC "\ --ncrti.o%s crt0.o%s \ --%{!shared:crtbegin.o%s} %{shared:crtbeginS.o%s}" -+#define STARTFILE_NETBSD_SPEC NETBSD_STARTFILE_SPEC - --#define ENDFILE_NETBSD_SPEC "\ --%{!shared:crtend.o%s} %{shared:crtendS.o%s} \ --ncrtn.o%s" -+#define ENDFILE_NETBSD_SPEC NETBSD_ENDFILE_SPEC - - #define LINK_START_NETBSD_SPEC "\ - " - --#define LINK_OS_NETBSD_SPEC "\ --%{!shared: %{!static: \ -- %{rdynamic:-export-dynamic} \ -- -dynamic-linker /usr/libexec/ld.elf_so}}" -+#define LINK_OS_NETBSD_SPEC NETBSD_LINK_SPEC_ELF - - #define CPP_OS_NETBSD_SPEC "\ - -D__powerpc__ -D__NetBSD__ -D__KPRINTF_ATTRIBUTE__" - -+#define CC1_OS_NETBSD_SPEC "\ -+%{cxx-isystem}" -+ - /* OpenBSD support. */ - #ifndef LIB_OPENBSD_SPEC - #define LIB_OPENBSD_SPEC "%{!shared:%{pthread:-lpthread%{p:_p}%{!p:%{pg:_p}}}} %{!shared:-lc%{p:_p}%{!p:%{pg:_p}}}" -@@ -894,6 +896,7 @@ - { "link_os_openbsd", LINK_OS_OPENBSD_SPEC }, \ - { "link_os_default", LINK_OS_DEFAULT_SPEC }, \ - { "cc1_secure_plt_default", CC1_SECURE_PLT_DEFAULT_SPEC }, \ -+ { "cc1_os_netbsd", CC1_OS_NETBSD_SPEC }, \ - { "cpp_os_ads", CPP_OS_ADS_SPEC }, \ - { "cpp_os_yellowknife", CPP_OS_YELLOWKNIFE_SPEC }, \ - { "cpp_os_mvme", CPP_OS_MVME_SPEC }, \ -diff -rNU3 dist.orig/gcc/config/rs6000/t-netbsd dist/gcc/config/rs6000/t-netbsd ---- dist.orig/gcc/config/rs6000/t-netbsd 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/config/rs6000/t-netbsd 2015-10-18 13:19:50.000000000 +0200 -@@ -18,6 +18,10 @@ - # along with GCC; see the file COPYING3. If not see - # . - -+# It is important that crtbegin.o, etc., aren't surprised by stuff in .sdata. -+CRTSTUFF_T_CFLAGS += -msdata=none -+CRTSTUFF_T_CFLAGS_S += -msdata=none -+ - # Switch synonyms - MULTILIB_MATCHES_FLOAT = msoft-float=mcpu?401 \ - msoft-float=mcpu?403 \ -@@ -34,3 +38,9 @@ - MULTILIB_EXCEPTIONS = - - MULTILIB_MATCHES = ${MULTILIB_MATCHES_FLOAT} -+ -+LIBGCC = stmp-multilib -+ -+INSTALL_LIBGCC = install-multilib -+EXTRA_MULTILIB_PARTS = crtbegin$(objext) crtend$(objext) \ -+ crtbeginS$(objext) crtendS$(objext) crtbeginT$(objext) -diff -rNU3 dist.orig/gcc/config/rs6000/t-netbsd64 dist/gcc/config/rs6000/t-netbsd64 ---- dist.orig/gcc/config/rs6000/t-netbsd64 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/rs6000/t-netbsd64 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,30 @@ -+# Support for NetBSD PowerPC64 ELF targets (ELF64 ABI). -+ -+LIB2FUNCS_EXTRA = $(srcdir)/config/rs6000/tramp.asm \ -+ $(srcdir)/config/rs6000/ppc64-fp.c \ -+ $(srcdir)/config/rs6000/darwin-ldouble.c -+ -+TARGET_LIBGCC2_CFLAGS += -mno-minimal-toc -+ -+MULTILIB_OPTIONS = m64/m32 -+MULTILIB_DIRNAMES = 64 32 -+MULTILIB_OSDIRNAMES = . ../lib/powerpc -+ -+MULTILIB_MATCHES = $(MULTILIB_MATCHES_FLOAT) -+ -+# We want fine grained libraries, so use the new code to build the -+# floating point emulation libraries. -+# fp-bit is only to be used by 32-bit multilibs -+FPBIT = fp-bit32.c -+DPBIT = dp-bit32.c -+ -+dp-bit32.c: $(srcdir)/config/fp-bit.c -+ ( echo '#ifndef __powerpc64__'; \ -+ cat $(srcdir)/config/fp-bit.c; \ -+ echo '#endif' ) > dp-bit32.c -+ -+fp-bit32.c: $(srcdir)/config/fp-bit.c -+ ( echo '#ifndef __powerpc64__'; \ -+ echo '#define FLOAT'; \ -+ cat $(srcdir)/config/fp-bit.c; \ -+ echo '#endif' ) > fp-bit32.c -diff -rNU3 dist.orig/gcc/config/rs6000/t-rs6000 dist/gcc/config/rs6000/t-rs6000 ---- dist.orig/gcc/config/rs6000/t-rs6000 2014-04-04 15:45:28.000000000 +0200 -+++ dist/gcc/config/rs6000/t-rs6000 2015-10-18 13:19:50.000000000 +0200 -@@ -38,6 +38,8 @@ - - $(srcdir)/config/rs6000/rs6000-tables.opt: $(srcdir)/config/rs6000/genopt.sh \ - $(srcdir)/config/rs6000/rs6000-cpus.def -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_rs6000-tables.opt: - $(SHELL) $(srcdir)/config/rs6000/genopt.sh $(srcdir)/config/rs6000 > \ - $(srcdir)/config/rs6000/rs6000-tables.opt - -diff -rNU3 dist.orig/gcc/config/sh/t-sh dist/gcc/config/sh/t-sh ---- dist.orig/gcc/config/sh/t-sh 2015-03-26 08:49:35.000000000 +0100 -+++ dist/gcc/config/sh/t-sh 2015-10-18 13:19:50.000000000 +0200 -@@ -86,7 +86,6 @@ - m5-64media-nofpu=!m5-64media-nofpu $(OTHER_ENDIAN)/m5-64media-nofpu=!$(OTHER_ENDIAN)/m5-64media-nofpu - - $(out_object_file): gt-sh.h --gt-sh.h : s-gtype ; @true - - # Local Variables: - # mode: Makefile -diff -rNU3 dist.orig/gcc/config/sparc/netbsd-elf.h dist/gcc/config/sparc/netbsd-elf.h ---- dist.orig/gcc/config/sparc/netbsd-elf.h 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/config/sparc/netbsd-elf.h 2015-10-18 13:19:50.000000000 +0200 -@@ -46,6 +46,37 @@ - #undef PTRDIFF_TYPE - #define PTRDIFF_TYPE "long int" - -+/* we keep these "long" on both 32bit and 64bit targets */ -+#undef INTPTR_TYPE -+#define INTPTR_TYPE PTRDIFF_TYPE -+ -+#undef UINTPTR_TYPE -+#define UINTPTR_TYPE SIZE_TYPE -+ -+#undef INT_FAST8_TYPE -+#define INT_FAST8_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "int") -+ -+#undef UINT_FAST8_TYPE -+#define UINT_FAST8_TYPE (LONG_TYPE_SIZE == 64 ? "unsigned char" : "unsigned int") -+ -+#undef INT_FAST16_TYPE -+#define INT_FAST16_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "int") -+ -+#undef UINT_FAST16_TYPE -+#define UINT_FAST16_TYPE (LONG_TYPE_SIZE == 64 ? "short unsigned int" : "unsigned int") -+ -+#undef INT_FAST32_TYPE -+#define INT_FAST32_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "int") -+ -+#undef UINT_FAST32_TYPE -+#define UINT_FAST32_TYPE "unsigned int" -+ -+#undef INT_FAST64_TYPE -+#define INT_FAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long int" : "long long int") -+ -+#undef UINT_FAST64_TYPE -+#define UINT_FAST64_TYPE (LONG_TYPE_SIZE == 64 ? "long unsigned int" : "long long unsigned int") -+ - /* This is the char to use for continuation (in case we need to turn - continuation back on). */ - #undef DBX_CONTIN_CHAR -@@ -99,7 +130,7 @@ - + MASK_STACK_BIAS + MASK_APP_REGS + MASK_FPU + MASK_LONG_DOUBLE_128) - - #undef SPARC_DEFAULT_CMODEL --#define SPARC_DEFAULT_CMODEL CM_MEDANY -+#define SPARC_DEFAULT_CMODEL CM_MEDMID - - #endif - -@@ -111,7 +142,8 @@ - %{!mcpu*:%{!mv8plus:-mcpu=ultrasparc}} \ - %{!mno-vis:%{!mcpu=v9:-mvis}} \ - %{p:-mcmodel=medlow} \ -- %{pg:-mcmodel=medlow}}" -+ %{pg:-mcmodel=medlow}} " \ -+ NETBSD_CC1_AND_CC1PLUS_SPEC - - #define CC1_SPEC64 \ - "%{m32:%{m64:%emay not use both -m32 and -m64}} \ -@@ -120,8 +152,28 @@ - %{!mlong-double-128:-mlong-double-64} \ - %{!mcpu*:%{!mv8plus:-mcpu=cypress}}} \ - %{!m32: \ -- %{p:-mcmodel=medlow} \ -- %{pg:-mcmodel=medlow}}" -+ %{p:-mcmodel=medlow} \ -+ %{pg:-mcmodel=medlow}} " \ -+ NETBSD_CC1_AND_CC1PLUS_SPEC -+ -+#if defined(SPARC_BI_ARCH) || defined(__arch64__) -+/* add code model specific object to the link line for 64bit */ -+#define LINK_SPEC_CODE_MODEL64 \ -+ "%{!shared:" \ -+ "%{!mcmodel=*:%:if-exists(%R/usr/lib/sparc_mcmedmid.o)}" \ -+ "%{mcmodel=medlow:%:if-exists(%R/usr/lib/sparc_mcmedlow.o)}" \ -+ "%{mcmodel=medmid:%:if-exists(%R/usr/lib/sparc_mcmedmid.o)}" \ -+ "%{mcmodel=medany:%:if-exists(%R/usr/lib/sparc_mcmedany.o)}" \ -+ "}" -+ -+#ifdef SPARC_BI_ARCH -+#define LINK_SPEC_CODE_MODEL "%{!m32:" LINK_SPEC_CODE_MODEL64 "}" -+#else -+#define LINK_SPEC_CODE_MODEL LINK_SPEC_CODE_MODEL64 -+#endif -+#else -+#define LINK_SPEC_CODE_MODEL "" -+#endif - - /* Make sure we use the right output format. Pick a default and then - make sure -m32/-m64 switch to the right one. */ -@@ -139,7 +191,8 @@ - #define LINK_SPEC \ - "%(link_arch) \ - %{!mno-relax:%{!r:-relax}} \ -- %(netbsd_link_spec)" -+ %(netbsd_link_spec) " \ -+ LINK_SPEC_CODE_MODEL - - #define NETBSD_ENTRY_POINT "__start" - -@@ -221,6 +274,13 @@ - - #endif /* SPARC_BI_ARCH */ - -+#ifdef HAVE_AS_TLS -+#undef TARGET_SUN_TLS -+#undef TARGET_GNU_TLS -+#define TARGET_SUN_TLS 0 -+#define TARGET_GNU_TLS 1 -+#endif -+ - /* We use GNU ld so undefine this so that attribute((init_priority)) works. */ - #undef CTORS_SECTION_ASM_OP - #undef DTORS_SECTION_ASM_OP -diff -rNU3 dist.orig/gcc/config/sparc/t-netbsd64 dist/gcc/config/sparc/t-netbsd64 ---- dist.orig/gcc/config/sparc/t-netbsd64 2011-11-02 16:23:48.000000000 +0100 -+++ dist/gcc/config/sparc/t-netbsd64 2015-10-18 13:19:50.000000000 +0200 -@@ -1,5 +1,9 @@ --# Disable multilib for now, as NetBSD/sparc64 does not ship with --# a 32-bit environment. --#MULTILIB_OPTIONS = m32/m64 --#MULTILIB_DIRNAMES = 32 64 --#MULTILIB_MATCHES = -+# NetBSD has (will have) "non-native" libraries in /usr/lib/. -+# For NetBSD/sparc64 we thus have /usr/lib and /usr/lib/sparc. -+ -+MULTILIB_OPTIONS = m64/m32 -+MULTILIB_DIRNAMES = 64 32 -+MULTILIB_OSDIRNAMES = . ../lib/sparc -+ -+LIBGCC = stmp-multilib -+INSTALL_LIBGCC = install-multilib -diff -rNU3 dist.orig/gcc/config/vax/builtins.md dist/gcc/config/vax/builtins.md ---- dist.orig/gcc/config/vax/builtins.md 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/config/vax/builtins.md 2015-10-18 13:19:50.000000000 +0200 -@@ -24,6 +24,12 @@ - ] - ) - -+(define_expand "condjump" -+ [(set (pc) -+ (if_then_else (match_operand 0) -+ (label_ref (match_operand 1)) -+ (pc)))]) -+ - (define_expand "ffssi2" - [(set (match_operand:SI 0 "nonimmediate_operand" "") - (ffs:SI (match_operand:SI 1 "general_operand" "")))] -@@ -31,17 +37,17 @@ - " - { - rtx label = gen_label_rtx (); -- emit_insn (gen_ffssi2_internal (operands[0], operands[1])); -- emit_jump_insn (gen_bne (label)); -- emit_insn (gen_negsi2 (operands[0], const1_rtx)); -+ emit_insn (gen_ctzsi2 (operands[0], operands[1])); -+ emit_jump_insn (gen_condjump (gen_rtx_NE(VOIDmode, cc0_rtx, const0_rtx), label)); -+ emit_move_insn (operands[0], constm1_rtx); - emit_label (label); - emit_insn (gen_addsi3 (operands[0], operands[0], const1_rtx)); - DONE; - }") - --(define_insn "ffssi2_internal" -+(define_insn "ctzsi2" - [(set (match_operand:SI 0 "nonimmediate_operand" "=rQ") -- (ffs:SI (match_operand:SI 1 "general_operand" "nrmT"))) -+ (ctz:SI (match_operand:SI 1 "general_operand" "nrmT"))) - (set (cc0) (match_dup 0))] - "" - "ffs $0,$32,%1,%0") -@@ -189,4 +195,3 @@ - (const_int 0))])] - "" - "jbcci %1,%0,%l2") -- -diff -rNU3 dist.orig/gcc/config/vax/constraints.md dist/gcc/config/vax/constraints.md ---- dist.orig/gcc/config/vax/constraints.md 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/config/vax/constraints.md 2015-10-18 13:19:50.000000000 +0200 -@@ -114,5 +114,6 @@ - - (define_constraint "T" - "@internal satisfies CONSTANT_P and, if pic is enabled, is not a SYMBOL_REF, LABEL_REF, or CONST." -- (ior (not (match_code "const,symbol_ref,label_ref")) -- (match_test "!flag_pic"))) -+ (and (match_test ("CONSTANT_P (op)")) -+ (ior (not (match_code "symbol_ref,label_ref,const")) -+ (match_test "!flag_pic")))) -diff -rNU3 dist.orig/gcc/config/vax/elf.h dist/gcc/config/vax/elf.h ---- dist.orig/gcc/config/vax/elf.h 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/config/vax/elf.h 2015-10-18 13:19:50.000000000 +0200 -@@ -108,5 +108,5 @@ - fputs (integer_asm_op (SIZE, FALSE), FILE); \ - fprintf (FILE, "%%pcrel%d(", SIZE * 8); \ - assemble_name (FILE, LABEL); \ -- fputc (')', FILE); \ -+ fprintf (FILE, "%+d)", SIZE); \ - } while (0) -diff -rNU3 dist.orig/gcc/config/vax/netbsd-elf.h dist/gcc/config/vax/netbsd-elf.h ---- dist.orig/gcc/config/vax/netbsd-elf.h 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/config/vax/netbsd-elf.h 2015-10-18 13:19:50.000000000 +0200 -@@ -63,6 +63,12 @@ - #define EXTRA_SPECS \ - { "netbsd_entry_point", NETBSD_ENTRY_POINT }, - -+#undef INTPTR_TYPE -+#define INTPTR_TYPE "long int" -+ -+#undef UINTPTR_TYPE -+#define UINTPTR_TYPE "long unsigned int" -+ - /* We use gas, not the UNIX assembler. */ - #undef TARGET_DEFAULT - #define TARGET_DEFAULT MASK_QMATH -diff -rNU3 dist.orig/gcc/config/vax/vax-protos.h dist/gcc/config/vax/vax-protos.h ---- dist.orig/gcc/config/vax/vax-protos.h 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/config/vax/vax-protos.h 2015-10-18 13:19:50.000000000 +0200 -@@ -18,6 +18,7 @@ - . */ - - extern bool legitimate_constant_address_p (rtx); -+extern bool legitimate_pic_operand_p (rtx); - extern void vax_expand_prologue (void); - - #ifdef RTX_CODE -@@ -28,6 +29,7 @@ - extern void print_operand (FILE *, rtx, int); - extern void vax_notice_update_cc (rtx, rtx); - extern void vax_expand_addsub_di_operands (rtx *, enum rtx_code); -+extern bool vax_decomposed_dimode_operand_p (rtx, rtx); - extern const char * vax_output_int_move (rtx, rtx *, enum machine_mode); - extern const char * vax_output_int_add (rtx, rtx *, enum machine_mode); - extern const char * vax_output_int_subtract (rtx, rtx *, enum machine_mode); -diff -rNU3 dist.orig/gcc/config/vax/vax.c dist/gcc/config/vax/vax.c ---- dist.orig/gcc/config/vax/vax.c 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/config/vax/vax.c 2015-10-18 13:19:50.000000000 +0200 -@@ -162,9 +162,13 @@ - HOST_WIDE_INT size; - rtx insn; - -+ offset = 20; - for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++) - if (df_regs_ever_live_p (regno) && !call_used_regs[regno]) -- mask |= 1 << regno; -+ { -+ mask |= 1 << regno; -+ offset += 4; -+ } - - insn = emit_insn (gen_procedure_entry_mask (GEN_INT (mask))); - RTX_FRAME_RELATED_P (insn) = 1; -@@ -186,11 +190,17 @@ - - The rest of the prologue will adjust the SP for the local frame. */ - -- vax_add_reg_cfa_offset (insn, 4, arg_pointer_rtx); -- vax_add_reg_cfa_offset (insn, 8, frame_pointer_rtx); -- vax_add_reg_cfa_offset (insn, 12, pc_rtx); -+ add_reg_note (insn, REG_CFA_DEF_CFA, -+ plus_constant (Pmode, frame_pointer_rtx, offset)); -+ insn = emit_insn (gen_blockage ()); -+ RTX_FRAME_RELATED_P (insn) = 1; - -- offset = 16; -+ vax_add_reg_cfa_offset (insn, 4, gen_rtx_REG (Pmode, PSW_REGNUM)); -+ vax_add_reg_cfa_offset (insn, 8, arg_pointer_rtx); -+ vax_add_reg_cfa_offset (insn, 12, frame_pointer_rtx); -+ vax_add_reg_cfa_offset (insn, 16, pc_rtx); -+ -+ offset = 20; - for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++) - if (mask & (1 << regno)) - { -@@ -198,12 +208,6 @@ - offset += 4; - } - -- /* Because add_reg_note pushes the notes, adding this last means that -- it will be processed first. This is required to allow the other -- notes be interpreted properly. */ -- add_reg_note (insn, REG_CFA_DEF_CFA, -- plus_constant (Pmode, frame_pointer_rtx, offset)); -- - /* Allocate the local stack frame. */ - size = get_frame_size (); - size -= STARTING_FRAME_OFFSET; -@@ -354,7 +358,10 @@ - addr = XEXP (addr, 1); - } - else -- gcc_unreachable (); -+ { -+ debug_rtx (orig); -+ gcc_unreachable (); -+ } - - if (REG_P (addr)) - { -@@ -365,9 +372,8 @@ - } - else if (GET_CODE (addr) == MULT) - ireg = addr; -- else -+ else if (GET_CODE (addr) == PLUS) - { -- gcc_assert (GET_CODE (addr) == PLUS); - if (CONSTANT_ADDRESS_P (XEXP (addr, 0)) - || MEM_P (XEXP (addr, 0))) - { -@@ -375,7 +381,7 @@ - { - if (CONST_INT_P (offset)) - offset = plus_constant (Pmode, XEXP (addr, 0), -- INTVAL (offset)); -+ INTVAL (offset)); - else - { - gcc_assert (CONST_INT_P (XEXP (addr, 0))); -@@ -392,12 +398,15 @@ - else - reg1 = XEXP (addr, 0); - } -- else -+ else if (GET_CODE (XEXP (addr, 0)) == MULT && !ireg) - { -- gcc_assert (GET_CODE (XEXP (addr, 0)) == MULT); -- gcc_assert (!ireg); - ireg = XEXP (addr, 0); - } -+ else -+ { -+ debug_rtx (orig); -+ gcc_unreachable (); -+ } - - if (CONSTANT_ADDRESS_P (XEXP (addr, 1)) - || MEM_P (XEXP (addr, 1))) -@@ -423,12 +432,20 @@ - else - reg1 = XEXP (addr, 1); - } -- else -+ else if (GET_CODE (XEXP (addr, 1)) == MULT && !ireg) - { -- gcc_assert (GET_CODE (XEXP (addr, 1)) == MULT); -- gcc_assert (!ireg); - ireg = XEXP (addr, 1); - } -+ else -+ { -+ debug_rtx (orig); -+ gcc_unreachable (); -+ } -+ } -+ else -+ { -+ debug_rtx (orig); -+ gcc_unreachable (); - } - - /* If REG1 is nonzero, figure out if it is a base or index register. */ -@@ -440,7 +457,11 @@ - && (MEM_P (offset) - || (flag_pic && symbolic_operand (offset, SImode))))) - { -- gcc_assert (!ireg); -+ if (ireg) -+ { -+ debug_rtx (orig); -+ gcc_unreachable (); -+ } - ireg = reg1; - } - else -@@ -486,12 +507,17 @@ - { - if (GET_CODE (ireg) == MULT) - ireg = XEXP (ireg, 0); -- gcc_assert (REG_P (ireg)); -+ if (! REG_P (ireg)) -+ { -+ debug_rtx (orig); -+ output_operand_lossage ("non-register index expression"); -+ } - fprintf (file, "[%s]", reg_names[REGNO (ireg)]); - } - break; - - default: -+ gcc_assert (! REG_P(addr)); - output_addr_const (file, addr); - } - } -@@ -546,6 +572,11 @@ - sizeof (dstr), 0, 1); - fprintf (file, "$0%c%s", ASM_DOUBLE_CHAR, dstr); - } -+ else if (GET_CODE (x) == SUBREG) -+ { -+ debug_rtx (x); -+ output_operand_lossage ("SUBREG operand"); -+ } - else - { - if (flag_pic > 1 && symbolic_operand (x, SImode)) -@@ -1086,6 +1117,7 @@ - case IOR: - case XOR: - case NOT: -+ case CTZ: - case MEM: - case REG: - cc_status.flags = CC_NO_OVERFLOW; -@@ -1187,7 +1219,7 @@ - { - operands[1] = GEN_INT (lval); - operands[2] = GEN_INT (n); -- return "ashq %2,%1,%0"; -+ return "ashq %2,%D1,%0"; - } - #if HOST_BITS_PER_WIDE_INT == 32 - } -@@ -1199,7 +1231,7 @@ - { - operands[1] = GEN_INT (hval >> n); - operands[2] = GEN_INT (n + 32); -- return "ashq %2,%1,%0"; -+ return "ashq %2,%D1,%0"; - #endif - } - } -@@ -1261,7 +1293,7 @@ - - if (operands[1] == const0_rtx) - { -- if (push_operand (operands[1], SImode)) -+ if (push_operand (operands[0], SImode)) - return "pushl %1"; - return "clrl %0"; - } -@@ -1626,6 +1658,111 @@ - } - } - -+static rtx -+mkrtx(enum rtx_code code, enum machine_mode mode, rtx base, HOST_WIDE_INT off) -+{ -+ rtx tmp; -+ -+ if (GET_CODE (base) == CONST) -+ base = XEXP (base, 0); -+ -+ if (GET_CODE (base) == PLUS) -+ { -+ rtx a = XEXP (base, 0); -+ rtx b = XEXP (base, 1); -+ if (GET_CODE (b) == CONST) -+ b = XEXP (b, 0); -+ if (CONST_INT_P (b)) -+ { -+ off += INTVAL (b); -+ base = a; -+ } -+ else if (REG_P (a) && GET_CODE (b) == SYMBOL_REF) -+ { -+ if (off != 0) -+ { -+ base = gen_rtx_PLUS (Pmode, a, plus_constant(Pmode, b, off)); -+ off = 0; -+ } -+ } -+ else if (REG_P (a) && GET_CODE (b) == PLUS) -+ { -+ off += INTVAL (XEXP (b, 1)); -+ base = gen_rtx_PLUS (Pmode, a, plus_constant(Pmode, XEXP (b, 0), off)); -+ off = 0; -+ } -+ else -+ { -+ debug_rtx(base); -+ gcc_unreachable (); -+ } -+ } -+ if (code == POST_INC) -+ tmp = gen_rtx_POST_INC (SImode, base); -+ else if (off == 0 || (REG_P (base) && code == REG)) -+ tmp = base; -+ else -+ tmp = plus_constant (Pmode, base, off); -+ return gen_rtx_MEM (mode, tmp); -+} -+ -+const char * -+vax_output_movmemsi (rtx insn, rtx *operands) -+{ -+ HOST_WIDE_INT n = INTVAL (operands[2]); -+ HOST_WIDE_INT off; -+ rtx src, dest; -+ const char *pat = NULL; -+ const enum rtx_code *src_codes; -+ const enum rtx_code *dest_codes; -+ int code_idx = 0; -+ int mode_idx; -+ -+ static const enum machine_mode xmodes[4] = -+ { -+ QImode, HImode, SImode, DImode -+ }; -+ static const char * const pats[4] = -+ { -+ "movb %1,%0", "movw %1,%0", "movl %1,%0", "movq %1,%0", -+ }; -+ static const enum rtx_code codes[2][3] = -+ { -+ { PLUS, PLUS, PLUS }, -+ { POST_INC, POST_INC, REG }, -+ }; -+ -+ src = XEXP (operands[1], 0); -+ -+ src_codes = -+ codes[REG_P (src) && find_regno_note (insn, REG_DEAD, REGNO(src))]; -+ -+ dest = XEXP (operands[0], 0); -+ -+ dest_codes = -+ codes[REG_P (dest) && find_regno_note (insn, REG_DEAD, REGNO(dest))]; -+ -+ for (off = 0, code_idx = 0, mode_idx = 3; mode_idx >= 0; mode_idx--) -+ { -+ const enum machine_mode mode = xmodes[mode_idx]; -+ const HOST_WIDE_INT mode_len = GET_MODE_SIZE (mode); -+ for (; n >= mode_len; n -= mode_len, off += mode_len) -+ { -+ if (pat != NULL) -+ output_asm_insn (pat, operands); -+ if (n == mode_len) -+ code_idx = 2; -+ operands[0] = mkrtx(dest_codes[code_idx], mode, dest, off); -+ operands[1] = mkrtx(src_codes[code_idx], mode, src, off); -+ if (pat == NULL) -+ code_idx = 1; -+ pat = pats[mode_idx]; -+ } -+ } -+ -+ return pat; -+} -+ - /* True if X is an rtx for a constant that is a valid address. */ - - bool -@@ -1642,9 +1779,23 @@ - && !SYMBOL_REF_LOCAL_P (XEXP (XEXP (x, 0), 0))) - return false; - #endif -+ gcc_assert (! REG_P (x)); - return true; - } - -+bool -+legitimate_pic_operand_p (rtx x) -+{ -+#ifdef NO_EXTERNAL_INDIRECT_ADDRESS -+ if (GET_CODE (x) != CONST) -+ return true; -+ if (GET_CODE (XEXP (XEXP (x, 0), 0)) == SYMBOL_REF -+ && !SYMBOL_REF_LOCAL_P (XEXP (XEXP (x, 0), 0))) -+ return false; -+#endif -+ return true; -+} -+ - /* The other macros defined here are used only in legitimate_address_p (). */ - - /* Nonzero if X is a hard reg that can be used as an index -@@ -1951,8 +2102,10 @@ - and that's just a left shift of 1. */ - if (rtx_equal_p (operands[1], operands[2])) - { -- gcc_assert (code != MINUS); -- emit_insn (gen_ashldi3 (operands[0], operands[1], const1_rtx)); -+ if (code == MINUS) -+ emit_insn (gen_movdi (operands[0], const0_rtx)); -+ else -+ emit_insn (gen_ashldi3 (operands[0], operands[1], const1_rtx)); - return; - } - -@@ -2173,3 +2326,54 @@ - ? (GET_MODE_SIZE (mode) + 3) & ~3 - : (int_size_in_bytes (type) + 3) & ~3); - } -+ -+bool -+vax_decomposed_dimode_operand_p (rtx lo, rtx hi) -+{ -+ HOST_WIDE_INT lo_offset = 0; -+ HOST_WIDE_INT hi_offset = 0; -+ -+ /* If the codes aren't the same, can't be a DImode operand. */ -+ if (GET_CODE (lo) != GET_CODE (hi)) -+ return false; -+ -+ /* If a register, hi regno must be one more than the lo regno. */ -+ if (REG_P (lo)) -+ return REGNO (lo) + 1 == REGNO (hi); -+ -+ /* If not memory, can't be a DImode operand. */ -+ if (!MEM_P (lo)) -+ return false; -+ -+ /* Get addresses of memory operands. */ -+ lo = XEXP(lo, 0); -+ hi = XEXP(hi, 0); -+ -+ /* If POST_INC, regno must match. */ -+ if (GET_CODE (lo) == POST_INC && GET_CODE (hi) == POST_INC) -+ return REGNO (XEXP (lo, 0)) == REGNO (XEXP (hi, 0)); -+ -+ if (GET_CODE (lo) == PLUS) -+ { -+ /* If PLUS or MULT, this must an indexed address so fail. */ -+ if (GET_CODE (XEXP (lo, 0)) == PLUS -+ || GET_CODE (XEXP (lo, 0)) == MULT -+ || !CONST_INT_P (XEXP (lo, 1))) -+ return false; -+ lo_offset = INTVAL (XEXP (lo, 1)); -+ lo = XEXP(lo, 0); -+ } -+ -+ if (GET_CODE (hi) == PLUS) -+ { -+ /* If PLUS or MULT, this must an indexed address so fail. */ -+ if (GET_CODE (XEXP (hi, 0)) == PLUS -+ || GET_CODE (XEXP (hi, 0)) == MULT -+ || !CONST_INT_P (XEXP (hi, 1))) -+ return false; -+ hi_offset = INTVAL (XEXP (hi, 1)); -+ hi = XEXP(hi, 0); -+ } -+ -+ return rtx_equal_p(lo, hi) && lo_offset + 4 == hi_offset; -+} -diff -rNU3 dist.orig/gcc/config/vax/vax.h dist/gcc/config/vax/vax.h ---- dist.orig/gcc/config/vax/vax.h 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/config/vax/vax.h 2015-10-18 13:19:50.000000000 +0200 -@@ -156,6 +156,9 @@ - /* Specify the registers used for certain standard purposes. - The values of these macros are register numbers. */ - -+/* VAX PSW for DWARF-2 */ -+#define PSW_REGNUM VAX_PSW_REGNUM -+ - /* VAX pc is overloaded on a register. */ - #define PC_REGNUM VAX_PC_REGNUM - -@@ -370,6 +373,10 @@ - RETURN_ADDRESS_OFFSET)) \ - : (rtx) 0) - -+/* A C expression that is nonzero if X is a legitimate immediate operand -+ on the target machine when generating position independent code. */ -+ -+#define LEGITIMATE_PIC_OPERAND_P(X) legitimate_pic_operand_p (X) - - /* Addressing modes, and classification of registers for them. */ - -diff -rNU3 dist.orig/gcc/config/vax/vax.md dist/gcc/config/vax/vax.md ---- dist.orig/gcc/config/vax/vax.md 2013-01-15 22:30:24.000000000 +0100 -+++ dist/gcc/config/vax/vax.md 2015-10-18 13:19:50.000000000 +0200 -@@ -40,6 +40,7 @@ - (VAX_FP_REGNUM 13) ; Register 13 contains the frame pointer - (VAX_SP_REGNUM 14) ; Register 14 contains the stack pointer - (VAX_PC_REGNUM 15) ; Register 15 contains the program counter -+ (VAX_PSW_REGNUM 16) ; Program Status Word - ] - ) - -@@ -215,6 +216,11 @@ - "" - " - { -+ if (CONST_INT_P (operands[2]) && INTVAL (operands[2]) <= 48) -+ { -+ emit_insn (gen_movmemsi1_2 (operands[0], operands[1], operands[2])); -+ DONE; -+ } - emit_insn (gen_movmemhi1 (operands[0], operands[1], operands[2])); - DONE; - }") -@@ -224,6 +230,13 @@ - ;; that anything generated as this insn will be recognized as one - ;; and that it won't successfully combine with anything. - -+(define_insn "movmemsi1_2" -+ [(set (match_operand:BLK 0 "memory_operand" "=B") -+ (match_operand:BLK 1 "memory_operand" "B")) -+ (use (match_operand:SI 2 "const_int_operand" "g"))] -+ "INTVAL (operands[2]) <= 48" -+ "* return vax_output_movmemsi (insn, operands);") -+ - (define_insn "movmemhi1" - [(set (match_operand:BLK 0 "memory_operand" "=o") - (match_operand:BLK 1 "memory_operand" "o")) -@@ -633,7 +646,7 @@ - "" - " - { -- if (! CONST_INT_P(operands[2])) -+ if (! CONST_INT_P (operands[2])) - operands[2] = gen_rtx_NEG (QImode, negate_rtx (QImode, operands[2])); - }") - -@@ -697,14 +710,14 @@ - (ashift:DI (match_operand:DI 1 "general_operand" "g") - (match_operand:QI 2 "general_operand" "g")))] - "" -- "ashq %2,%1,%0") -+ "ashq %2,%D1,%0") - - (define_insn "" - [(set (match_operand:DI 0 "nonimmediate_operand" "=g") - (ashiftrt:DI (match_operand:DI 1 "general_operand" "g") - (neg:QI (match_operand:QI 2 "general_operand" "g"))))] - "" -- "ashq %2,%1,%0") -+ "ashq %2,%D1,%0") - - ;; We used to have expand_shift handle logical right shifts by using extzv, - ;; but this make it very difficult to do lshrdi3. Since the VAX is the -@@ -781,8 +794,9 @@ - "(INTVAL (operands[1]) == 8 || INTVAL (operands[1]) == 16) - && INTVAL (operands[2]) % INTVAL (operands[1]) == 0 - && (REG_P (operands[0]) -- || ! mode_dependent_address_p (XEXP (operands[0], 0), -- MEM_ADDR_SPACE (operands[0])))" -+ || (MEM_P (operands[0]) -+ && ! mode_dependent_address_p (XEXP (operands[0], 0), -+ MEM_ADDR_SPACE (operands[0]))))" - "* - { - if (REG_P (operands[0])) -@@ -810,8 +824,9 @@ - "(INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16) - && INTVAL (operands[3]) % INTVAL (operands[2]) == 0 - && (REG_P (operands[1]) -- || ! mode_dependent_address_p (XEXP (operands[1], 0), -- MEM_ADDR_SPACE (operands[1])))" -+ || (MEM_P (operands[1]) -+ && ! mode_dependent_address_p (XEXP (operands[1], 0), -+ MEM_ADDR_SPACE (operands[1]))))" - "* - { - if (REG_P (operands[1])) -@@ -838,8 +853,9 @@ - "(INTVAL (operands[2]) == 8 || INTVAL (operands[2]) == 16) - && INTVAL (operands[3]) % INTVAL (operands[2]) == 0 - && (REG_P (operands[1]) -- || ! mode_dependent_address_p (XEXP (operands[1], 0), -- MEM_ADDR_SPACE (operands[1])))" -+ || (MEM_P (operands[1]) -+ && ! mode_dependent_address_p (XEXP (operands[1], 0), -+ MEM_ADDR_SPACE (operands[1]))))" - "* - { - if (REG_P (operands[1])) -@@ -956,8 +972,8 @@ - "" - "* - { -- if (!REG_P (operands[0]) || !CONST_INT_P (operands[2]) -- || !CONST_INT_P (operands[3]) -+ if (! REG_P (operands[0]) || ! CONST_INT_P (operands[2]) -+ || ! CONST_INT_P (operands[3]) - || (INTVAL (operands[2]) != 8 && INTVAL (operands[2]) != 16) - || INTVAL (operands[2]) + INTVAL (operands[3]) > 32 - || side_effects_p (operands[1]) -@@ -986,8 +1002,8 @@ - "" - "* - { -- if (!REG_P (operands[0]) || !CONST_INT_P (operands[2]) -- || !CONST_INT_P (operands[3]) -+ if (! REG_P (operands[0]) || ! CONST_INT_P (operands[2]) -+ || ! CONST_INT_P (operands[3]) - || INTVAL (operands[2]) + INTVAL (operands[3]) > 32 - || side_effects_p (operands[1]) - || (MEM_P (operands[1]) -@@ -1660,3 +1676,50 @@ - emit_barrier (); - DONE; - }) -+ -+(include "builtins.md") -+ -+(define_peephole2 -+ [(set (match_operand:SI 0 "push_operand" "") -+ (const_int 0)) -+ (set (match_dup 0) -+ (match_operand:SI 1 "const_int_operand" ""))] -+ "INTVAL (operands[1]) >= 0" -+ [(set (match_dup 0) -+ (match_dup 1))] -+ "operands[0] = gen_rtx_MEM(DImode, XEXP (operands[0], 0));") -+ -+(define_peephole2 -+ [(set (match_operand:SI 0 "push_operand" "") -+ (match_operand:SI 1 "general_operand" "")) -+ (set (match_dup 0) -+ (match_operand:SI 2 "general_operand" ""))] -+ "vax_decomposed_dimode_operand_p (operands[2], operands[1])" -+ [(set (match_dup 0) -+ (match_dup 2))] -+ "{ -+ operands[0] = gen_rtx_MEM(DImode, XEXP (operands[0], 0)); -+ operands[2] = REG_P (operands[2]) -+ ? gen_rtx_REG(DImode, REGNO (operands[2])) -+ : gen_rtx_MEM(DImode, XEXP (operands[2], 0)); -+}") -+ -+; Leave this commented out until we can determine whether the second move -+; precedes a jump which relies on the CC flags being set correctly. -+(define_peephole2 -+ [(set (match_operand:SI 0 "nonimmediate_operand" "") -+ (match_operand:SI 1 "general_operand" "")) -+ (set (match_operand:SI 2 "nonimmediate_operand" "") -+ (match_operand:SI 3 "general_operand" ""))] -+ "0 && vax_decomposed_dimode_operand_p (operands[1], operands[3]) -+ && vax_decomposed_dimode_operand_p (operands[0], operands[2])" -+ [(set (match_dup 0) -+ (match_dup 1))] -+ "{ -+ operands[0] = REG_P (operands[0]) -+ ? gen_rtx_REG(DImode, REGNO (operands[0])) -+ : gen_rtx_MEM(DImode, XEXP (operands[0], 0)); -+ operands[1] = REG_P (operands[1]) -+ ? gen_rtx_REG(DImode, REGNO (operands[1])) -+ : gen_rtx_MEM(DImode, XEXP (operands[1], 0)); -+}") -diff -rNU3 dist.orig/gcc/config/x-netbsd dist/gcc/config/x-netbsd ---- dist.orig/gcc/config/x-netbsd 1970-01-01 01:00:00.000000000 +0100 -+++ dist/gcc/config/x-netbsd 2015-10-18 13:19:50.000000000 +0200 -@@ -0,0 +1,4 @@ -+host-netbsd.o : $(srcdir)/config/host-netbsd.c $(CONFIG_H) $(SYSTEM_H) \ -+ coretypes.h hosthooks.h hosthooks-def.h $(HOOKS_H) -+ $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ -+ $(srcdir)/config/host-netbsd.c -diff -rNU3 dist.orig/gcc/config.gcc dist/gcc/config.gcc ---- dist.orig/gcc/config.gcc 2015-05-21 22:57:29.000000000 +0200 -+++ dist/gcc/config.gcc 2015-10-18 13:19:50.000000000 +0200 -@@ -325,6 +325,7 @@ - ;; - arm*-*-*) - cpu_type=arm -+ need_64bit_hwint=yes - extra_headers="mmintrin.h arm_neon.h" - target_type_format_char='%' - c_target_objs="arm-c.o" -@@ -401,6 +402,16 @@ - cpu_type=m32r - extra_options="${extra_options} g.opt" - ;; -+m5200-*-*|m5407-*-*) -+ cpu_type=m68k -+ extra_headers=math-68881.h -+ extra_options="${extra_options} m68k/m68k-tables.opt" -+ ;; -+m680[012]0-*-*) -+ cpu_type=m68k -+ extra_headers=math-68881.h -+ extra_options="${extra_options} m68k/m68k-tables.opt" -+ ;; - m68k-*-*) - extra_headers=math-68881.h - extra_options="${extra_options} m68k/m68k-tables.opt" -@@ -415,6 +426,12 @@ - extra_headers="loongson.h" - extra_options="${extra_options} g.opt mips/mips-tables.opt" - ;; -+or1k-*-*) -+ cpu_type=or1k -+ ;; -+or1knd-*-*) -+ cpu_type=or1k -+ ;; - picochip-*-*) - cpu_type=picochip - ;; -@@ -429,6 +446,10 @@ - esac - extra_options="${extra_options} g.opt fused-madd.opt rs6000/rs6000-tables.opt" - ;; -+riscv*-*-*) -+ cpu_type=riscv -+ need_64bit_hwint=yes -+ ;; - rs6000*-*-*) - need_64bit_hwint=yes - extra_options="${extra_options} g.opt fused-madd.opt rs6000/rs6000-tables.opt" -@@ -712,6 +733,7 @@ - default_use_cxa_atexit=yes - ;; - esac -+ nbsd_tm_file="${nbsd_tm_file} netbsd.h netbsd-stdint.h netbsd-elf.h" - ;; - *-*-openbsd*) - tmake_file="t-openbsd" -@@ -846,7 +868,7 @@ - extra_options="${extra_options} alpha/elf.opt" - ;; - alpha*-*-netbsd*) -- tm_file="elfos.h ${tm_file} netbsd.h alpha/elf.h netbsd-elf.h alpha/netbsd.h" -+ tm_file="elfos.h ${tm_file} ${nbsd_tm_file} alpha/elf.h alpha/netbsd.h" - extra_options="${extra_options} netbsd.opt netbsd-elf.opt \ - alpha/elf.opt" - ;; -@@ -866,9 +888,38 @@ - tmake_file="${tmake_file} arm/t-arm arm/t-vxworks" - ;; - arm*-*-netbsdelf*) -- tm_file="dbxelf.h elfos.h netbsd.h netbsd-elf.h arm/elf.h arm/aout.h ${tm_file} arm/netbsd-elf.h" -- extra_options="${extra_options} netbsd.opt netbsd-elf.opt" - tmake_file="${tmake_file} arm/t-arm" -+ tm_file="dbxelf.h elfos.h ${nbsd_tm_file} arm/elf.h arm/aout.h arm/arm.h" -+ extra_options="${extra_options} netbsd.opt netbsd-elf.opt" -+ case ${target} in -+ arm*eb-*) tm_defines="${tm_defines} TARGET_BIG_ENDIAN_DEFAULT=1" ;; -+ esac -+ case ${target} in -+ arm*-*-netbsdelf-*eabi*) -+ tm_file="$tm_file arm/bpabi.h arm/netbsd-elf.h arm/netbsd-eabi.h" -+ tmake_file="$tmake_file arm/t-bpabi arm/t-netbsdeabi" -+ # The BPABI long long divmod functions return a 128-bit value in -+ # registers r0-r3. Correctly modeling that requires the use of -+ # TImode. -+ need_64bit_hwint=yes -+ # The EABI requires the use of __cxa_atexit. -+ default_use_cxa_atexit=yes -+ ;; -+ *) -+ tm_file="$tm_file arm/netbsd-elf.h" -+ tmake_file="$tmake_file arm/t-netbsd" -+ ;; -+ esac -+ case ${target} in -+ arm*-*-netbsdelf-*eabihf*) -+ tm_defines="${tm_defines} TARGET_DEFAULT_FLOAT_ABI=ARM_FLOAT_ABI_HARD" -+ ;; -+ esac -+ case ${target} in -+ armv4*) with_cpu=${with_cpu:-strongarm};; -+ armv6*) with_cpu=${with_cpu:-arm1176jzf-s};; -+ armv7*) with_cpu=${with_cpu:-cortex-a8};; -+ esac - ;; - arm*-*-linux-*) # ARM GNU/Linux with ELF - tm_file="dbxelf.h elfos.h gnu-user.h linux.h linux-android.h glibc-stdint.h arm/elf.h arm/linux-gas.h arm/linux-elf.h" -@@ -1077,6 +1128,14 @@ - gas=yes - gnu_ld=yes - ;; -+hppa*-*-netbsd* | parisc*-*-netbsd*) -+ target_cpu_default="MASK_PA_11|MASK_NO_SPACE_REGS" -+ tm_file="${tm_file} dbxelf.h elfos.h ${nbsd_tm_file} \ -+ pa/pa-netbsd.h pa/pa32-regs.h pa/pa32-netbsd.h" -+ tmake_file="${tmake_file} pa/t-netbsd" -+ tm_defines="${tm_defines} CHAR_FAST8=1 SHORT_FAST16=1" -+ extra_options="${extra_options} netbsd.opt netbsd-elf.opt" -+ ;; - hppa[12]*-*-hpux10*) - case ${target} in - hppa1.1-*-* | hppa2*-*-*) -@@ -1229,11 +1288,20 @@ - tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h ${fbsd_tm_file} i386/x86-64.h i386/freebsd.h i386/freebsd64.h" - ;; - i[34567]86-*-netbsdelf*) -- tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h netbsd.h netbsd-elf.h i386/netbsd-elf.h" -+ tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h ${nbsd_tm_file} i386/netbsd-elf.h" -+ tmake_file="${tmake_file} i386/t-crtstuff" - extra_options="${extra_options} netbsd.opt netbsd-elf.opt" - ;; -+i[34567]86-*-netbsd*) -+ tm_file="${tm_file} i386/unix.h i386/bsd.h i386/gas.h i386/gstabs.h netbsd.h netbsd-aout.h i386/netbsd.h" -+ tmake_file="${tmake_file} t-netbsd" -+ extra_options="${extra_options} netbsd.opt netbsd-elf.opt" -+ extra_parts="" -+ use_collect2=yes -+ ;; - x86_64-*-netbsd*) -- tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h netbsd.h netbsd-elf.h i386/x86-64.h i386/netbsd64.h" -+ tm_file="${tm_file} i386/unix.h i386/att.h dbxelf.h elfos.h ${nbsd_tm_file} i386/x86-64.h i386/netbsd64.h" -+ tmake_file="${tmake_file} i386/t-netbsd64" - extra_options="${extra_options} netbsd.opt netbsd-elf.opt" - ;; - i[34567]86-*-openbsd2.*|i[34567]86-*openbsd3.[0123]) -@@ -1563,6 +1631,16 @@ - target_cpu_default="${target_cpu_default}|MASK_GNU_LD" - fi - ;; -+ia64*-*-netbsd*) -+ tm_file="${tm_file} dbxelf.h elfos.h ${nbsd_tm_file} ia64/sysv4.h ia64/netbsd.h" -+ target_cpu_default="MASK_GNU_AS|MASK_GNU_LD" -+ tmake_file="${tmake_file} ia64/t-ia64" -+ if test x$with_system_libunwind != xyes ; then -+ tmake_file="${tmake_file} t-libunwind-elf ia64/t-glibc-libunwind" -+ fi -+ extra_parts="crtbegin.o crtend.o crtbeginS.o crtendS.o crtfastmath.o" -+ extra_options="${extra_options} netbsd.opt netbsd-elf.opt" -+ ;; - ia64*-*-freebsd*) - tm_file="${tm_file} dbxelf.h elfos.h ${fbsd_tm_file} ia64/sysv4.h ia64/freebsd.h" - target_cpu_default="MASK_GNU_AS|MASK_GNU_LD" -@@ -1682,12 +1760,30 @@ - ;; - esac - ;; --m68k*-*-netbsdelf*) -- default_m68k_cpu=68020 -- default_cf_cpu=5475 -- tm_file="${tm_file} dbxelf.h elfos.h netbsd.h netbsd-elf.h m68k/netbsd-elf.h" -+m68010-*-netbsdelf* | m68k-*-netbsdelf* | m5407-*-netbsdelf*) -+ tm_file="${tm_file} dbxelf.h elfos.h ${nbsd_tm_file} m68k/netbsd-elf.h" -+ tm_defines="${tm_defines} MOTOROLA=1 USE_GAS=1" -+ tm_defines="${tm_defines} CHAR_FAST8=1 SHORT_FAST16=1" - extra_options="${extra_options} netbsd.opt netbsd-elf.opt" -- tm_defines="${tm_defines} MOTOROLA=1" -+ default_cf_cpu=5475 -+ default_m68k_cpu=68020 -+ case ${target} in -+ m5407*) -+ with_arch=${with_arch:-cf} -+ target_cpu_default="mcf5475" -+# target="`echo ${target} | sed 's/m68kcf/m68k/'`" -+ ;; -+ m68010*) -+ target_cpu_default="m68010" -+ tmake_file="m68k/t-m68kelf m68k/t-m68010-netbsd" -+ default_m68k_cpu=68010 -+ tmake_file="${tmake_file} m68k/t-floatlib" -+ ;; -+ *) -+ with_arch=${with_arch:-m68k} -+ tmake_file="${tmake_file} m68k/t-floatlib" -+ ;; -+ esac - ;; - m68k*-*-openbsd*) - default_m68k_cpu=68020 -@@ -1790,9 +1886,16 @@ - cxx_target_objs="${cxx_target_objs} microblaze-c.o" - tmake_file="${tmake_file} microblaze/t-microblaze" - ;; -+mips64*-*-netbsd*) # NetBSD/mips64, either endian. -+ target_cpu_default="MASK_ABICALLS|MASK_FLOAT64|MASK_SOFT_FLOAT_ABI" -+ tm_file="elfos.h ${tm_file} mips/elf.h ${nbsd_tm_file} mips/netbsd.h mips/netbsd64.h" -+ tmake_file="${tmake_file} mips/t-netbsd64" -+ tm_defines="${tm_defines} MIPS_ABI_DEFAULT=ABI_N32" -+ extra_options="${extra_options} netbsd.opt netbsd-elf.opt" -+ ;; - mips*-*-netbsd*) # NetBSD/mips, either endian. - target_cpu_default="MASK_ABICALLS" -- tm_file="elfos.h ${tm_file} mips/elf.h netbsd.h netbsd-elf.h mips/netbsd.h" -+ tm_file="elfos.h ${tm_file} mips/elf.h ${nbsd_tm_file} mips/netbsd.h" - extra_options="${extra_options} netbsd.opt netbsd-elf.opt" - ;; - mips*-mti-linux*) -@@ -1972,6 +2075,42 @@ - use_collect2=no - use_gcc_stdint=wrap - ;; -+or1k*-*-elf*) -+ tm_file="${tm_file} dbxelf.h elfos.h newlib-stdint.h ${cpu_type}/elf.h" -+ extra_parts="crti.o crtbegin.o crtend.o crtn.o" -+ case ${target} in -+ or1knd-*) -+ tmake_file=or1k/t-or1knd -+ tm_defines="${tm_defines} OR1K_DELAY_DEFAULT=OR1K_DELAY_OFF" -+ ;; -+ *) -+ tmake_file=or1k/t-or1k -+ tm_defines="${tm_defines} OR1K_DELAY_DEFAULT=OR1K_DELAY_ON" -+ ;; -+ esac -+ ;; -+or1k*-*-linux-*) -+ tm_file="${tm_file} dbxelf.h elfos.h or1k/elf.h gnu-user.h linux.h or1k/linux-gas.h or1k/linux-elf.h uclibc-stdint.h" -+ case ${target} in -+ or1knd-*) -+ tmake_file="or1k/t-or1knd or1k/t-linux ${tmake_file}" -+ tm_defines="${tm_defines} OR1K_DELAY_DEFAULT=OR1K_DELAY_OFF" -+ ;; -+ *) -+ tmake_file="or1k/t-or1k or1k/t-linux ${tmake_file}" -+ tm_defines="${tm_defines} OR1K_DELAY_DEFAULT=OR1K_DELAY_ON" -+ ;; -+ esac -+ ;; -+or1k*-*-netbsd*) -+ tm_file="${tm_file} dbxelf.h elfos.h netbsd.h netbsd-elf.h netbsd-stdint.h or1k/netbsd.h" -+ extra_options="${extra_options} netbsd.opt netbsd-elf.opt" -+ case ${target} in -+ or1knd-*) tm_defines="${tm_defines} OR1K_DELAY_DEFAULT=OR1K_DELAY_OFF" ;; -+ *) tm_defines="${tm_defines} OR1K_DELAY_DEFAULT=OR1K_DELAY_ON" ;; -+ esac -+ gcc_cv_initfini_array=yes -+ ;; - pdp11-*-*) - tm_file="${tm_file} newlib-stdint.h" - use_gcc_stdint=wrap -@@ -2023,11 +2162,24 @@ - ;; - esac - ;; --powerpc-*-netbsd*) -- tm_file="${tm_file} dbxelf.h elfos.h netbsd.h netbsd-elf.h freebsd-spec.h rs6000/sysv4.h rs6000/netbsd.h" -+powerpc*-*-netbsd*) -+ tm_file="${tm_file} dbxelf.h elfos.h freebsd-spec.h" -+ tm_file="${tm_file} netbsd.h netbsd-elf.h" -+ case ${target} in -+ powerpc64*) -+ tm_file="rs6000/biarch64.h ${tm_file} rs6000/sysv4.h rs6000/default64.h rs6000/netbsd64.h" -+ tmake_file="${tmake_file} rs6000/t-netbsd64" -+ ;; -+ *) -+ tm_file="${tm_file} rs6000/sysv4.h rs6000/netbsd.h" -+ tmake_file="${tmake_file} rs6000/t-netbsd" -+ ;; -+ esac - extra_options="${extra_options} netbsd.opt netbsd-elf.opt" -- tmake_file="${tmake_file} rs6000/t-netbsd" -- extra_options="${extra_options} rs6000/sysv4.opt" -+ if test x${enable_secureplt} != xno; then -+ tm_file="rs6000/secureplt.h ${tm_file}" -+ fi -+ extra_options="${extra_options} rs6000/sysv4.opt rs6000/linux64.opt" - ;; - powerpc-*-eabispe*) - tm_file="${tm_file} dbxelf.h elfos.h freebsd-spec.h newlib-stdint.h rs6000/sysv4.h rs6000/eabi.h rs6000/e500.h rs6000/eabispe.h" -@@ -2190,6 +2342,31 @@ - extra_options="${extra_options} rs6000/sysv4.opt" - use_gcc_stdint=wrap - ;; -+riscv*-*-linux*) # Linux RISC-V -+ tm_file="elfos.h gnu-user.h linux.h glibc-stdint.h ${tm_file} riscv/linux.h riscv/linux64.h" -+ tmake_file="${tmake_file} riscv/t-linux64" -+ gnu_ld=yes -+ gas=yes -+ gcc_cv_initfini_array=yes -+ ;; -+riscv*-*-elf*) # Linux RISC-V -+ tm_file="elfos.h newlib-stdint.h ${tm_file} riscv/elf.h" -+ tmake_file="${tmake_file} riscv/t-elf" -+ gnu_ld=yes -+ gas=yes -+ gcc_cv_initfini_array=yes -+ ;; -+riscv*-*-netbsd*) # NetBSD RISC-V -+ tm_file="elfos.h ${tm_file} netbsd.h netbsd-elf.h riscv/netbsd.h" -+ case ${target} in -+ riscv32*) tm_defines="${tm_defines} TARGET_64BIT_DEFAULT=0" ;; -+ *) tmake_file="${tmake_file} riscv/t-netbsd64" ;; -+ esac -+ extra_options="${extra_options} netbsd.opt netbsd-elf.opt" -+ gnu_ld=yes -+ gas=yes -+ gcc_cv_initfini_array=yes -+ ;; - rs6000-ibm-aix4.[3456789]* | powerpc-ibm-aix4.[3456789]*) - tm_file="rs6000/biarch64.h ${tm_file} rs6000/aix.h rs6000/aix43.h rs6000/xcoff.h rs6000/aix-stdint.h" - tmake_file="rs6000/t-aix43 t-slibgcc" -@@ -2310,7 +2487,7 @@ - sh*-*-linux*) tmake_file="${tmake_file} sh/t-linux" - tm_file="${tm_file} gnu-user.h linux.h glibc-stdint.h sh/linux.h" ;; - sh*-*-netbsd*) -- tm_file="${tm_file} netbsd.h netbsd-elf.h sh/netbsd-elf.h" -+ tm_file="${tm_file} ${nbsd_tm_file} sh/netbsd-elf.h" - extra_options="${extra_options} netbsd.opt netbsd-elf.opt" - - ;; -@@ -2336,7 +2513,8 @@ - # SHmedia, 64-bit ABI - tmake_file="${tmake_file} sh/t-sh64 sh/t-netbsd-sh5-64" - ;; -- *-*-netbsd) -+ *-*-netbsd*) -+ tmake_file="${tmake_file} sh/t-netbsd" - ;; - sh64*-*-linux*) - tmake_file="${tmake_file} sh/t-sh64" -@@ -2501,7 +2679,7 @@ - fi - ;; - sparc-*-netbsdelf*) -- tm_file="${tm_file} dbxelf.h elfos.h sparc/sysv4.h netbsd.h netbsd-elf.h sparc/netbsd-elf.h" -+ tm_file="${tm_file} dbxelf.h elfos.h sparc/sysv4.h ${nbsd_tm_file} sparc/netbsd-elf.h" - extra_options="${extra_options} netbsd.opt netbsd-elf.opt" - extra_options="${extra_options} sparc/long-double-switch.opt" - tmake_file="${tmake_file} sparc/t-sparc" -@@ -2549,10 +2727,11 @@ - ;; - sparc64-*-netbsd*) - tm_file="sparc/biarch64.h ${tm_file}" -- tm_file="${tm_file} dbxelf.h elfos.h sparc/sysv4.h netbsd.h netbsd-elf.h sparc/netbsd-elf.h" -+ tm_file="${tm_file} dbxelf.h elfos.h sparc/sysv4.h ${nbsd_tm_file} sparc/netbsd-elf.h" - extra_options="${extra_options} netbsd.opt netbsd-elf.opt" - extra_options="${extra_options} sparc/long-double-switch.opt" - tmake_file="${tmake_file} sparc/t-sparc sparc/t-netbsd64" -+ with_cpu=ultrasparc - ;; - sparc64-*-openbsd*) - tm_file="sparc/openbsd1-64.h ${tm_file} dbxelf.h elfos.h sparc/sysv4.h sparc/sp64-elf.h" -@@ -2648,7 +2827,8 @@ - extra_options="${extra_options} vax/elf.opt" - ;; - vax-*-netbsdelf*) -- tm_file="${tm_file} elfos.h netbsd.h netbsd-elf.h vax/elf.h vax/netbsd-elf.h" -+ tm_file="${tm_file} elfos.h ${nbsd_tm_file} vax/elf.h vax/netbsd-elf.h" -+ tm_defines="${tm_defines} CHAR_FAST8=1 SHORT_FAST16=1" - extra_options="${extra_options} netbsd.opt netbsd-elf.opt vax/elf.opt" - ;; - vax-*-openbsd*) -@@ -2974,6 +3154,9 @@ - frv550-*-*linux*) - with_cpu=fr550 - ;; -+ m5200-*-*|m5407-*-*) -+ with_cpu=${default_cf_cpu} -+ ;; - m68k*-*-*) - case "$with_arch" in - "cf") -@@ -3355,7 +3538,7 @@ - esac - ;; - -- fido-*-* | m68k*-*-*) -+ fido-*-* | m68k*-*-* | m5200-*-* | m5407-*-*) - supported_defaults="arch cpu" - case "$with_arch" in - "" | "m68k"| "cf") -@@ -3589,6 +3772,30 @@ - esac - ;; - -+ riscv*-*-*) -+ supported_defaults="abi arch arch_32 arch_64 float tune tune_32 tune_64" -+ -+ case ${with_float} in -+ "" | soft | hard) -+ # OK -+ ;; -+ *) -+ echo "Unknown floating point type used in --with-float=$with_float" 1>&2 -+ exit 1 -+ ;; -+ esac -+ -+ case ${with_abi} in -+ "" | 32 | 64) -+ # OK -+ ;; -+ *) -+ echo "Unknown ABI used in --with-abi=$with_abi" 1>&2 -+ exit 1 -+ ;; -+ esac -+ ;; -+ - s390*-*-*) - supported_defaults="arch mode tune" - -diff -rNU3 dist.orig/gcc/config.host dist/gcc/config.host ---- dist.orig/gcc/config.host 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/config.host 2015-10-18 13:19:50.000000000 +0200 -@@ -214,7 +214,7 @@ - ;; - esac - ;; -- i[34567]86-*-cygwin*) -+ i[34567]86-*-cygwin* | x86_64-*-cygwin*) - host_xm_file=i386/xm-cygwin.h - out_host_hook_obj=host-cygwin.o - host_xmake_file="${host_xmake_file} i386/x-cygwin" -@@ -271,6 +271,10 @@ - out_host_hook_obj=host-openbsd.o - host_xmake_file="${host_xmake_file} x-openbsd" - ;; -+ *-*-netbsd*) -+ out_host_hook_obj=host-netbsd.o -+ host_xmake_file="${host_xmake_file} x-netbsd" -+ ;; - ia64-*-hpux*) - use_long_long_for_widest_fast_int=yes - out_host_hook_obj=host-hpux.o -diff -rNU3 dist.orig/gcc/configure dist/gcc/configure ---- dist.orig/gcc/configure 2014-12-08 12:29:43.000000000 +0100 -+++ dist/gcc/configure 2015-10-18 13:19:50.000000000 +0200 -@@ -3031,7 +3031,7 @@ - for ac_t in install-sh install.sh shtool; do - if test -f "$ac_dir/$ac_t"; then - ac_aux_dir=$ac_dir -- ac_install_sh="$ac_aux_dir/$ac_t -c" -+ ac_install_sh="$SHELL $ac_aux_dir/$ac_t -c" - break 2 - fi - done -@@ -23105,7 +23105,7 @@ - tls_first_major=2 - tls_first_minor=14 - ;; -- hppa*-*-linux*) -+ hppa*-*-linux* | hppa*-*-netbsd*) - conftest_s=' - t1: .reg %r20 - t2: .reg %r21 -@@ -23253,7 +23253,7 @@ - tls_first_minor=16 - tls_as_opt='-32 --fatal-warnings' - ;; -- m68k-*-*) -+ m68k-*-*|m5407-*-*) - conftest_s=' - .section .tdata,"awT",@progbits - x: -@@ -23360,6 +23360,25 @@ - tls_first_minor=14 - tls_as_opt="-a32 --fatal-warnings" - ;; -+ riscv*-*-*) -+ conftest_s=' -+ .section .tdata,"awT",@progbits -+x: -+ .word 2 -+ .text -+ la.tls.gd a0,x -+ la.tls.ie a1,x -+ lui a0,%tls_ie_pcrel_hi(x) -+ lw a0,%pcrel_lo(x)(a0) -+ add a0,a0,tp -+ lw a0,(a0) -+ lui a0,%tprel_hi(x) -+ add a0,a0,tp,%tprel_add(x) -+ lw a0,%tprel_lo(x)(a0)' -+ tls_first_major=2 -+ tls_first_minor=21 -+ tls_as_opt='-m32 --fatal-warnings' -+ ;; - s390-*-*) - conftest_s=' - .section ".tdata","awT",@progbits -@@ -23397,7 +23416,7 @@ - tls_first_minor=14 - tls_as_opt="-m64 -Aesame --fatal-warnings" - ;; -- sh-*-* | sh[34]-*-*) -+ sh-*-* | sh[34]-*-* | sh*l*-*-*) - conftest_s=' - .section ".tdata","awT",@progbits - foo: .long 25 -@@ -26886,7 +26905,7 @@ - # simply assert that glibc does provide this, which is true for all - # realistically usable GNU/Hurd configurations. - gcc_cv_libc_provides_ssp=yes;; -- *-*-darwin* | *-*-freebsd*) -+ *-*-darwin* | *-*-freebsd* | *-*-netbsd*) - ac_fn_c_check_func "$LINENO" "__stack_chk_fail" "ac_cv_func___stack_chk_fail" - if test "x$ac_cv_func___stack_chk_fail" = x""yes; then : - gcc_cv_libc_provides_ssp=yes -@@ -28921,5 +28940,3 @@ - { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 - $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} - fi -- -- -diff -rNU3 dist.orig/gcc/configure.ac dist/gcc/configure.ac ---- dist.orig/gcc/configure.ac 2014-12-08 12:29:43.000000000 +0100 -+++ dist/gcc/configure.ac 2015-10-18 13:19:50.000000000 +0200 -@@ -2852,7 +2852,7 @@ - tls_first_major=2 - tls_first_minor=14 - ;; -- hppa*-*-linux*) -+ hppa*-*-linux* | hppa*-*-netbsd*) - conftest_s=' - t1: .reg %r20 - t2: .reg %r21 -@@ -3001,7 +3001,7 @@ - tls_first_minor=16 - tls_as_opt='-32 --fatal-warnings' - ;; -- m68k-*-*) -+ m68k-*-* | m5407-*-*) - conftest_s=' - .section .tdata,"awT",@progbits - x: -@@ -3108,6 +3108,25 @@ - tls_first_minor=14 - tls_as_opt="-a32 --fatal-warnings" - ;; -+ riscv*-*-*) -+ conftest_s=' -+ .section .tdata,"awT",@progbits -+x: -+ .word 2 -+ .text -+ la.tls.gd a0,x -+ la.tls.ie a1,x -+ lui a0,%tls_ie_pcrel_hi(x) -+ lw a0,%pcrel_lo(x)(a0) -+ add a0,a0,tp -+ lw a0,0(a0) -+ lui a0,%tprel_hi(x) -+ add a0,a0,tp,%tprel_add(x) -+ lw a0,%tprel_lo(x)(a0)' -+ tls_first_major=2 -+ tls_first_minor=21 -+ tls_as_opt='-m32 --fatal-warnings' -+ ;; - s390-*-*) - conftest_s=' - .section ".tdata","awT",@progbits -@@ -3145,7 +3164,7 @@ - tls_first_minor=14 - tls_as_opt="-m64 -Aesame --fatal-warnings" - ;; -- sh-*-* | sh[34]-*-*) -+ sh-*-* | sh[34]-*-* | sh*l*-*-*) - conftest_s=' - .section ".tdata","awT",@progbits - foo: .long 25 -@@ -4810,7 +4829,7 @@ - # simply assert that glibc does provide this, which is true for all - # realistically usable GNU/Hurd configurations. - gcc_cv_libc_provides_ssp=yes;; -- *-*-darwin* | *-*-freebsd*) -+ *-*-darwin* | *-*-freebsd* | *-*-netbsd*) - AC_CHECK_FUNC(__stack_chk_fail,[gcc_cv_libc_provides_ssp=yes], - [echo "no __stack_chk_fail on this target"]) - ;; -diff -rNU3 dist.orig/gcc/cp/Make-lang.in dist/gcc/cp/Make-lang.in ---- dist.orig/gcc/cp/Make-lang.in 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/cp/Make-lang.in 2015-10-18 13:19:50.000000000 +0200 -@@ -95,7 +95,7 @@ - $(CXX_OBJS) $(BACKEND) $(LIBDEPS) - build/genchecksum$(build_exeext) $(CXX_OBJS) $(BACKEND) $(LIBDEPS) \ - checksum-options > cc1plus-checksum.c.tmp && \ -- $(srcdir)/../move-if-change cc1plus-checksum.c.tmp cc1plus-checksum.c -+ $(SHELL) $(srcdir)/../move-if-change cc1plus-checksum.c.tmp cc1plus-checksum.c - - cc1plus-checksum.o : cc1plus-checksum.c $(CONFIG_H) $(SYSTEM_H) - -@@ -109,6 +109,8 @@ - # other cases, it is not available to avoid triggering rebuilds if a - # user has the source checked out with unusual timestamps. - $(srcdir)/cp/cfns.h: $(srcdir)/cp/cfns.gperf -+ @echo "NOT REBUILDING $@" -+NetBSD_DISABLED_cfns.h: - else - # We keep the rule so that you can still force a rebuild, even if you - # didn't configure GCC with --enable-maintainer-mode, by manually -diff -rNU3 dist.orig/gcc/cppdefault.c dist/gcc/cppdefault.c ---- dist.orig/gcc/cppdefault.c 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/cppdefault.c 2015-10-18 13:19:50.000000000 +0200 -@@ -56,8 +56,12 @@ - GPLUSPLUS_INCLUDE_DIR_ADD_SYSROOT, 0 }, - #endif - #ifdef GCC_INCLUDE_DIR -+#ifndef GCC_INCLUDE_DIR_ADD_SYSROOT -+#define GCC_INCLUDE_DIR_ADD_SYSROOT 0 -+#endif - /* This is the dir for gcc's private headers. */ -- { GCC_INCLUDE_DIR, "GCC", 0, 0, 0, 0 }, -+ { GCC_INCLUDE_DIR, "GCC", 0, 0, -+ GCC_INCLUDE_DIR_ADD_SYSROOT, 0 }, - #endif - #ifdef LOCAL_INCLUDE_DIR - /* /usr/local/include comes before the fixincluded header files. */ -diff -rNU3 dist.orig/gcc/doc/cpp.texi dist/gcc/doc/cpp.texi ---- dist.orig/gcc/doc/cpp.texi 2015-06-23 09:35:08.000000000 +0200 -+++ dist/gcc/doc/cpp.texi 2015-10-18 13:19:51.000000000 +0200 -@@ -1159,6 +1159,9 @@ - @option{-isystem}, the @option{-I} option is ignored. GCC provides an - informative message when this occurs if @option{-v} is used. - -+The @option{-cxx-isystem} command line option adds its argument to the -+list of C++ system headers, similar to @option{-isystem} for C headers. -+ - @findex #pragma GCC system_header - There is also a directive, @code{@w{#pragma GCC system_header}}, which - tells GCC to consider the rest of the current include file a system -@@ -4397,6 +4400,7 @@ - @c man begin SYNOPSIS - cpp [@option{-D}@var{macro}[=@var{defn}]@dots{}] [@option{-U}@var{macro}] - [@option{-I}@var{dir}@dots{}] [@option{-iquote}@var{dir}@dots{}] -+ [@option{-iremap}@var{src}:@var{dst}] - [@option{-W}@var{warn}@dots{}] - [@option{-M}|@option{-MM}] [@option{-MG}] [@option{-MF} @var{filename}] - [@option{-MP}] [@option{-MQ} @var{target}@dots{}] -diff -rNU3 dist.orig/gcc/doc/cppenv.texi dist/gcc/doc/cppenv.texi ---- dist.orig/gcc/doc/cppenv.texi 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/doc/cppenv.texi 2015-10-18 13:19:51.000000000 +0200 -@@ -79,4 +79,17 @@ - @ifclear cppmanual - @xref{Preprocessor Options}. - @end ifclear -+ -+@item CPP_RESTRICTED -+@cindex only open regular files -+If this variable is defined, cpp will skip any include file which is not a -+regular file, and will continue searching for the requested name (this is -+always done if the found file is a directory). -+@ifset cppmanual -+@xref{Invocation}. -+@end ifset -+@ifclear cppmanual -+@xref{Preprocessor Options}. -+@end ifclear -+ - @end vtable -diff -rNU3 dist.orig/gcc/doc/cppopts.texi dist/gcc/doc/cppopts.texi ---- dist.orig/gcc/doc/cppopts.texi 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/doc/cppopts.texi 2015-10-18 13:19:51.000000000 +0200 -@@ -515,6 +515,16 @@ - If @var{dir} begins with @code{=}, then the @code{=} will be replaced - by the sysroot prefix; see @option{--sysroot} and @option{-isysroot}. - -+@item -cxx-isystem @var{dir} -+@opindex cxxisystem -+Search @var{dir} for C++ header files, after all directories specified by -+@option{-I} but before the standard system directories. Mark it -+as a system directory, so that it gets the same special treatment as -+is applied to the standard system directories. -+@ifset cppmanual -+@xref{System Headers}. -+@end ifset -+ - @item -iquote @var{dir} - @opindex iquote - Search @var{dir} only for header files requested with -@@ -549,6 +559,12 @@ - @option{-fpreprocessed} take precedence. This enables full preprocessing of - files previously preprocessed with @code{-E -fdirectives-only}. - -+@item -iremap @var{src}:@var{dst} -+@opindex iremap -+Replace the prefix @var{src} in __FILE__ with @var{dst} at expansion time. -+This option can be specified more than once. Processing stops at the first -+match. -+ - @item -fdollars-in-identifiers - @opindex fdollars-in-identifiers - @anchor{fdollars-in-identifiers} -diff -rNU3 dist.orig/gcc/doc/invoke.texi dist/gcc/doc/invoke.texi ---- dist.orig/gcc/doc/invoke.texi 2015-06-23 09:35:08.000000000 +0200 -+++ dist/gcc/doc/invoke.texi 2015-10-18 13:19:51.000000000 +0200 -@@ -436,6 +436,7 @@ - -include @var{file} -imacros @var{file} @gol - -iprefix @var{file} -iwithprefix @var{dir} @gol - -iwithprefixbefore @var{dir} -isystem @var{dir} @gol -+-cxx-isystem @var{dir} @gol - -imultilib @var{dir} -isysroot @var{dir} @gol - -M -MM -MF -MG -MP -MQ -MT -nostdinc @gol - -P -fdebug-cpp -ftrack-macro-expansion -fworking-directory @gol -@@ -458,6 +459,14 @@ - - @item Directory Options - @xref{Directory Options,,Options for Directory Search}. -+@gccoptlist{-B@var{prefix} -I@var{dir} -iquote@var{dir} -+-iremap@var{src}:@var{dst} -L@var{dir} -+-specs=@var{file} -I- --sysroot=@var{dir}} -+ -+@item Target Options -+@c I wrote this xref this way to avoid overfull hbox. -- rms -+@xref{Target Options}. -+@gccoptlist{-V @var{version} -b @var{machine}} - @gccoptlist{-B@var{prefix} -I@var{dir} -iplugindir=@var{dir} @gol - -iquote@var{dir} -L@var{dir} -specs=@var{file} -I- @gol - --sysroot=@var{dir} --no-sysroot-suffix} -@@ -3568,11 +3577,11 @@ - to be stored.''. If a program breaks these rules, the results on any - particular implementation are entirely unpredictable. - --Examples of code with undefined behavior are @code{a = a++;}, @code{a[n] --= b[n++]} and @code{a[i++] = i;}. Some more complicated cases are not --diagnosed by this option, and it may give an occasional false positive --result, but in general it has been found fairly effective at detecting --this sort of problem in programs. -+Examples of code with undefined behavior are @code{a = a++;}, -+@code{a[n] = b[n++]} and @code{a[i++] = i;}. Some more complicated cases -+are not diagnosed by this option, and it may give an occasional false -+positive result, but in general it has been found fairly effective at -+detecting this sort of problem in programs. - - The standard is worded confusingly, therefore there is some debate - over the precise meaning of the sequence point rules in subtle cases. -@@ -10111,6 +10120,12 @@ - "@var{file}"}; they are not searched for @samp{#include <@var{file}>}, - otherwise just like @option{-I}. - -+@item -iremap @var{src}:@var{dst} -+@opindex iremap -+Replace the prefix @var{src} in __FILE__ with @var{dst} at expansion time. -+This option can be specified more than once. Processing stops at the first -+match. -+ - @item -L@var{dir} - @opindex L - Add directory @var{dir} to the list of directories to be searched -@@ -14177,7 +14192,7 @@ - Streaming SIMD Extension (SSE) data type @code{__m128} may not work - properly if it is not 16-byte aligned. - --To ensure proper alignment of this values on the stack, the stack boundary -+To ensure proper alignment of these values on the stack, the stack boundary - must be as aligned as that required by any value stored on the stack. - Further, every function must be generated such that it keeps the stack - aligned. Thus calling a function compiled with a higher preferred -diff -rNU3 dist.orig/gcc/dse.c dist/gcc/dse.c ---- dist.orig/gcc/dse.c 2015-02-20 13:04:21.000000000 +0100 -+++ dist/gcc/dse.c 2015-10-18 13:19:51.000000000 +0200 -@@ -290,6 +290,9 @@ - lowpart_bitmask (int n) - { - unsigned HOST_WIDE_INT mask = ~(unsigned HOST_WIDE_INT) 0; -+ gcc_assert(n >= 0 && n <= HOST_BITS_PER_WIDE_INT); -+ if (n == 0) -+ return 0; - return mask >> (HOST_BITS_PER_WIDE_INT - n); - } - -diff -rNU3 dist.orig/gcc/expr.c dist/gcc/expr.c ---- dist.orig/gcc/expr.c 2015-06-03 23:35:25.000000000 +0200 -+++ dist/gcc/expr.c 2015-10-18 13:19:51.000000000 +0200 -@@ -4055,7 +4055,8 @@ - xinner = x; - - if (mode == BLKmode -- || (STRICT_ALIGNMENT && align < GET_MODE_ALIGNMENT (mode))) -+ || (STRICT_ALIGNMENT && align < GET_MODE_ALIGNMENT (mode) -+ && type != NULL_TREE)) - { - /* Copy a block into the stack, entirely or partially. */ - -diff -rNU3 dist.orig/gcc/gcc.c dist/gcc/gcc.c ---- dist.orig/gcc/gcc.c 2015-06-23 09:35:08.000000000 +0200 -+++ dist/gcc/gcc.c 2015-10-18 13:19:51.000000000 +0200 -@@ -1365,7 +1365,7 @@ - static_name, " --as-needed ", shared_name, " --no-as-needed" - "}" - "%{shared-libgcc:", -- shared_name, "%{!shared: ", static_name, "}" -+ "--as-needed ", shared_name, " --no-as-needed ", static_name, - "}" - #else - "%{!shared:" -@@ -3713,6 +3713,10 @@ - /* FIXME: make_relative_prefix doesn't yet work for VMS. */ - if (!gcc_exec_prefix) - { -+#ifdef NETBSD_NATIVE -+ add_prefix (&exec_prefixes, standard_libexec_prefix, "GCC", -+ PREFIX_PRIORITY_LAST, 0, 0); -+#else - gcc_exec_prefix = get_relative_prefix (decoded_options[0].arg, - standard_bindir_prefix, - standard_exec_prefix); -@@ -3721,6 +3725,7 @@ - standard_libexec_prefix); - if (gcc_exec_prefix) - xputenv (concat ("GCC_EXEC_PREFIX=", gcc_exec_prefix, NULL)); -+#endif - } - else - { -@@ -6412,6 +6417,7 @@ - else - init_spec (); - -+#ifndef NETBSD_NATIVE - /* We need to check standard_exec_prefix/just_machine_suffix/specs - for any override of as, ld and libraries. */ - specs_file = (char *) alloca (strlen (standard_exec_prefix) -@@ -6422,6 +6428,7 @@ - strcat (specs_file, "specs"); - if (access (specs_file, R_OK) == 0) - read_specs (specs_file, true, false); -+#endif - - /* Process any configure-time defaults specified for the command line - options, via OPTION_DEFAULT_SPECS. */ -@@ -6517,14 +6524,18 @@ - PREFIX_PRIORITY_LAST, 0, 1); - else if (*cross_compile == '0') - { -+/* XXXMRG not sure this one is right? */ -+#if !defined(NETBSD_NATIVE) && !defined(NETBSD_TOOLS) - add_prefix (&startfile_prefixes, - concat (gcc_exec_prefix - ? gcc_exec_prefix : standard_exec_prefix, - machine_suffix, - standard_startfile_prefix, NULL), - NULL, PREFIX_PRIORITY_LAST, 0, 1); -+#endif /* NETBSD_NATIVE */ - } - -+#if !defined(NETBSD_NATIVE) && !defined(NETBSD_TOOLS) - /* Sysrooted prefixes are relocated because target_system_root is - also relocated by gcc_exec_prefix. */ - if (*standard_startfile_prefix_1) -@@ -6535,6 +6546,7 @@ - add_sysrooted_prefix (&startfile_prefixes, - standard_startfile_prefix_2, "BINUTILS", - PREFIX_PRIORITY_LAST, 0, 1); -+#endif /* NETBSD_NATIVE */ - } - - /* Process any user specified specs in the order given on the command -diff -rNU3 dist.orig/gcc/gcc.h dist/gcc/gcc.h ---- dist.orig/gcc/gcc.h 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/gcc.h 2015-10-18 13:19:51.000000000 +0200 -@@ -31,6 +31,32 @@ - const char *(*func) (int, const char **); - }; - -+/* This defines which switch letters take arguments. */ -+ -+#define DEFAULT_SWITCH_TAKES_ARG(CHAR) \ -+ ((CHAR) == 'D' || (CHAR) == 'U' || (CHAR) == 'o' \ -+ || (CHAR) == 'e' || (CHAR) == 'T' || (CHAR) == 'u' \ -+ || (CHAR) == 'I' || (CHAR) == 'J' || (CHAR) == 'm' \ -+ || (CHAR) == 'x' || (CHAR) == 'L' || (CHAR) == 'A' \ -+ || (CHAR) == 'V' || (CHAR) == 'B' || (CHAR) == 'b') -+ -+/* This defines which multi-letter switches take arguments. */ -+ -+#define DEFAULT_WORD_SWITCH_TAKES_ARG(STR) \ -+ (!strcmp (STR, "Tdata") || !strcmp (STR, "Ttext") \ -+ || !strcmp (STR, "Tbss") || !strcmp (STR, "include") \ -+ || !strcmp (STR, "imacros") || !strcmp (STR, "aux-info") \ -+ || !strcmp (STR, "idirafter") || !strcmp (STR, "iprefix") \ -+ || !strcmp (STR, "iwithprefix") || !strcmp (STR, "iwithprefixbefore") \ -+ || !strcmp (STR, "iquote") || !strcmp (STR, "isystem") \ -+ || !strcmp (STR, "isysroot") \ -+ || !strcmp (STR, "cxx-isystem") || !strcmp (STR, "-iremap") \ -+ || !strcmp (STR, "-param") || !strcmp (STR, "specs") \ -+ || !strcmp (STR, "MF") || !strcmp (STR, "MT") || !strcmp (STR, "MQ") \ -+ || !strcmp (STR, "fintrinsic-modules-path") \ -+ || !strcmp (STR, "dumpbase") || !strcmp (STR, "dumpdir")) -+ -+ - /* These are exported by gcc.c. */ - extern int do_spec (const char *); - extern void record_temp_file (const char *, int, int); -diff -rNU3 dist.orig/gcc/genemit.c dist/gcc/genemit.c ---- dist.orig/gcc/genemit.c 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/genemit.c 2015-10-18 13:19:51.000000000 +0200 -@@ -196,9 +196,9 @@ - printf ("const_true_rtx"); - else - { -- printf ("GEN_INT ("); -- printf (HOST_WIDE_INT_PRINT_DEC_C, INTVAL (x)); -- printf (")"); -+ printf ("GEN_INT (HOST_WIDE_INT_CONSTANT ("); -+ printf (HOST_WIDE_INT_PRINT_DEC, INTVAL (x)); -+ printf ("))"); - } - return; - -diff -rNU3 dist.orig/gcc/genmultilib dist/gcc/genmultilib ---- dist.orig/gcc/genmultilib 2013-03-14 09:52:13.000000000 +0100 -+++ dist/gcc/genmultilib 2015-10-18 13:19:51.000000000 +0200 -@@ -154,8 +154,10 @@ - # Since not all versions of sh support functions, we achieve recursion - # by creating a temporary shell script which invokes itself. - rm -f tmpmultilib --cat >tmpmultilib <<\EOF --#!/bin/sh -+cat >tmpmultilib <>tmpmultilib <<\EOF - # This recursive script basically outputs all combinations of its - # input arguments, handling mutually exclusive sets of options by - # repetition. When the script is called, ${initial} is the list of -@@ -190,8 +192,10 @@ - - # If there exceptions, weed them out now - if [ -n "${exceptions}" ]; then -- cat >tmpmultilib2 <<\EOF --#!/bin/sh -+ cat >tmpmultilib2 <>tmpmultilib2 <<\EOF - # This recursive script weeds out any combination of multilib - # switches that should not be generated. The output looks like - # a list of subdirectory names with leading and trailing slashes. -@@ -330,8 +334,10 @@ - # opt1/opt2 nopt1 nopt2 - # In other words, we must output all combinations of matches. - rm -f tmpmultilib2 --cat >tmpmultilib2 <<\EOF --#!/bin/sh -+cat >tmpmultilib2 <>tmpmultilib2 <<\EOF - # The positional parameters are a list of matches to consider. - # ${dirout} is the directory name and ${optout} is the current list of - # options. -diff -rNU3 dist.orig/gcc/genrecog.c dist/gcc/genrecog.c ---- dist.orig/gcc/genrecog.c 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/genrecog.c 2015-10-18 13:19:51.000000000 +0200 -@@ -1634,11 +1634,13 @@ - static void - print_host_wide_int (HOST_WIDE_INT val) - { -+ /* XXX: the "min" below is computed for build, not host!!! */ - HOST_WIDE_INT min = (unsigned HOST_WIDE_INT)1 << (HOST_BITS_PER_WIDE_INT-1); - if (val == min) -- printf ("(" HOST_WIDE_INT_PRINT_DEC_C "-1)", val + 1); -+ printf ("(HOST_WIDE_INT_CONSTANT (" HOST_WIDE_INT_PRINT_DEC ")-1)", -+ val + 1); - else -- printf (HOST_WIDE_INT_PRINT_DEC_C, val); -+ printf ("HOST_WIDE_INT_CONSTANT (" HOST_WIDE_INT_PRINT_DEC")", val); - } - - /* Emit a switch statement, if possible, for an initial sequence of -diff -rNU3 dist.orig/gcc/ggc-common.c dist/gcc/ggc-common.c ---- dist.orig/gcc/ggc-common.c 2013-03-05 16:51:48.000000000 +0100 -+++ dist/gcc/ggc-common.c 2015-10-18 13:19:51.000000000 +0200 -@@ -666,6 +666,8 @@ - size_t i; - struct mmap_info mmi; - int result; -+ struct line_maps * old_line_table = line_table; -+ location_t old_input_loc = input_location; - - /* Delete any deletable objects. This makes ggc_pch_read much - faster, as it can be sure that no GCable objects remain other -@@ -677,39 +679,60 @@ - /* Read in all the scalar variables. */ - for (rt = gt_pch_scalar_rtab; *rt; rt++) - for (rti = *rt; rti->base != NULL; rti++) -- if (fread (rti->base, rti->stride, 1, f) != 1) -+ if (fread (rti->base, rti->stride, 1, f) != 1) { -+ line_table = old_line_table; -+ input_location = old_input_loc; - fatal_error ("can%'t read PCH file: %m"); -+ } - - /* Read in all the global pointers, in 6 easy loops. */ - for (rt = gt_ggc_rtab; *rt; rt++) - for (rti = *rt; rti->base != NULL; rti++) - for (i = 0; i < rti->nelt; i++) - if (fread ((char *)rti->base + rti->stride * i, -- sizeof (void *), 1, f) != 1) -+ sizeof (void *), 1, f) != 1) { -+ line_table = old_line_table; -+ input_location = old_input_loc; - fatal_error ("can%'t read PCH file: %m"); -+ } - - for (rt = gt_pch_cache_rtab; *rt; rt++) - for (rti = *rt; rti->base != NULL; rti++) - for (i = 0; i < rti->nelt; i++) - if (fread ((char *)rti->base + rti->stride * i, -- sizeof (void *), 1, f) != 1) -+ sizeof (void *), 1, f) != 1) { -+ line_table = old_line_table; -+ input_location = old_input_loc; - fatal_error ("can%'t read PCH file: %m"); -+ } - -- if (fread (&mmi, sizeof (mmi), 1, f) != 1) -+ if (fread (&mmi, sizeof (mmi), 1, f) != 1) { -+ line_table = old_line_table; -+ input_location = old_input_loc; - fatal_error ("can%'t read PCH file: %m"); -+ } - - result = host_hooks.gt_pch_use_address (mmi.preferred_base, mmi.size, - fileno (f), mmi.offset); -- if (result < 0) -+ if (result < 0) { -+ line_table = old_line_table; -+ input_location = old_input_loc; - fatal_error ("had to relocate PCH"); -+ } - if (result == 0) - { - if (fseek (f, mmi.offset, SEEK_SET) != 0 -- || fread (mmi.preferred_base, mmi.size, 1, f) != 1) -+ || fread (mmi.preferred_base, mmi.size, 1, f) != 1) { -+ line_table = old_line_table; -+ input_location = old_input_loc; - fatal_error ("can%'t read PCH file: %m"); -+ } - } -- else if (fseek (f, mmi.offset + mmi.size, SEEK_SET) != 0) -+ else if (fseek (f, mmi.offset + mmi.size, SEEK_SET) != 0) { -+ line_table = old_line_table; -+ input_location = old_input_loc; - fatal_error ("can%'t read PCH file: %m"); -+ } - - ggc_pch_read (f, mmi.preferred_base); - -diff -rNU3 dist.orig/gcc/ginclude/stddef.h dist/gcc/ginclude/stddef.h ---- dist.orig/gcc/ginclude/stddef.h 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/ginclude/stddef.h 2015-10-18 13:19:51.000000000 +0200 -@@ -49,8 +49,10 @@ - /* On 4.3bsd-net2, make sure ansi.h is included, so we have - one less case to deal with in the following. */ - #if defined (__BSD_NET2__) || defined (____386BSD____) || (defined (__FreeBSD__) && (__FreeBSD__ < 5)) || defined(__NetBSD__) -+#ifndef inhibit_libc - #include - #endif -+#endif - /* On FreeBSD 5, machine/ansi.h does not exist anymore... */ - #if defined (__FreeBSD__) && (__FreeBSD__ >= 5) - #include -diff -rNU3 dist.orig/gcc/ginclude/unwind-arm-common.h dist/gcc/ginclude/unwind-arm-common.h ---- dist.orig/gcc/ginclude/unwind-arm-common.h 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/ginclude/unwind-arm-common.h 2015-10-18 13:19:51.000000000 +0200 -@@ -183,7 +183,7 @@ - #define _Unwind_Exception _Unwind_Control_Block - typedef char _Unwind_Exception_Class[8]; - -- void * _Unwind_GetLanguageSpecificData (_Unwind_Context *); -+ _Unwind_Ptr _Unwind_GetLanguageSpecificData (_Unwind_Context *); - _Unwind_Ptr _Unwind_GetRegionStart (_Unwind_Context *); - - _Unwind_Ptr _Unwind_GetDataRelBase (_Unwind_Context *); -@@ -234,7 +234,7 @@ - } - - _Unwind_Ptr _Unwind_GetRegionStart (_Unwind_Context *); -- void * _Unwind_GetLanguageSpecificData (_Unwind_Context *); -+ _Unwind_Ptr _Unwind_GetLanguageSpecificData (_Unwind_Context *); - - /* leb128 type numbers have a potentially unlimited size. - The target of the following definitions of _sleb128_t and _uleb128_t -diff -rNU3 dist.orig/gcc/hwint.h dist/gcc/hwint.h ---- dist.orig/gcc/hwint.h 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/hwint.h 2015-10-18 13:19:51.000000000 +0200 -@@ -88,6 +88,7 @@ - #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG - # define HOST_WIDE_INT_PRINT HOST_LONG_FORMAT - # define HOST_WIDE_INT_PRINT_C "L" -+# define HOST_WIDE_INT_CONSTANT(x) x ## L - /* 'long' might be 32 or 64 bits, and the number of leading zeroes - must be tweaked accordingly. */ - # if HOST_BITS_PER_WIDE_INT == 64 -@@ -100,6 +101,7 @@ - #else - # define HOST_WIDE_INT_PRINT HOST_LONG_LONG_FORMAT - # define HOST_WIDE_INT_PRINT_C "LL" -+# define HOST_WIDE_INT_CONSTANT(x) x ## LL - /* We can assume that 'long long' is at least 64 bits. */ - # define HOST_WIDE_INT_PRINT_DOUBLE_HEX \ - "0x%" HOST_LONG_LONG_FORMAT "x%016" HOST_LONG_LONG_FORMAT "x" -diff -rNU3 dist.orig/gcc/objc/Make-lang.in dist/gcc/objc/Make-lang.in ---- dist.orig/gcc/objc/Make-lang.in 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/objc/Make-lang.in 2015-10-18 13:19:51.000000000 +0200 -@@ -63,7 +63,7 @@ - $(OBJC_OBJS) $(C_AND_OBJC_OBJS) $(BACKEND) $(LIBDEPS) - build/genchecksum$(build_exeext) $(OBJC_OBJS) $(C_AND_OBJC_OBJS) \ - $(BACKEND) $(LIBDEPS) checksum-options > cc1obj-checksum.c.tmp && \ -- $(srcdir)/../move-if-change cc1obj-checksum.c.tmp cc1obj-checksum.c -+ $(SHELL) $(srcdir)/../move-if-change cc1obj-checksum.c.tmp cc1obj-checksum.c - - cc1obj-checksum.o : cc1obj-checksum.c $(CONFIG_H) $(SYSTEM_H) - -diff -rNU3 dist.orig/gcc/objcp/Make-lang.in dist/gcc/objcp/Make-lang.in ---- dist.orig/gcc/objcp/Make-lang.in 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/objcp/Make-lang.in 2015-10-18 13:19:51.000000000 +0200 -@@ -66,7 +66,7 @@ - $(OBJCXX_OBJS) $(BACKEND) $(LIBDEPS) - build/genchecksum$(build_exeext) $(OBJCXX_OBJS) $(BACKEND) \ - $(LIBDEPS) checksum-options > cc1objplus-checksum.c.tmp && \ -- $(srcdir)/../move-if-change cc1objplus-checksum.c.tmp \ -+ $(SHELL) $(srcdir)/../move-if-change cc1objplus-checksum.c.tmp \ - cc1objplus-checksum.c - - cc1objplus-checksum.o : cc1objplus-checksum.c $(CONFIG_H) $(SYSTEM_H) -diff -rNU3 dist.orig/gcc/reload.c dist/gcc/reload.c ---- dist.orig/gcc/reload.c 2013-02-04 17:23:38.000000000 +0100 -+++ dist/gcc/reload.c 2015-10-18 13:19:51.000000000 +0200 -@@ -846,6 +846,7 @@ - reload_inner_reg_of_subreg (rtx x, enum machine_mode mode, bool output) - { - rtx inner; -+ int regno; - - /* Only SUBREGs are problematical. */ - if (GET_CODE (x) != SUBREG) -@@ -857,10 +858,20 @@ - if (CONSTANT_P (inner) || GET_CODE (inner) == PLUS) - return true; - -- /* If INNER is not a hard register, then INNER will not need reloading. */ -- if (!(REG_P (inner) && HARD_REGISTER_P (inner))) -+ /* If INNER is not a register, then INNER will not need reloading. */ -+ if (!REG_P (inner)) - return false; - -+ regno = REGNO (inner); -+ -+ /* If INNER is not a hard register, then INNER will not need reloading -+ unless it's a mode dependent memory reference. */ -+ if (regno >= FIRST_PSEUDO_REGISTER) -+ return !output -+ && reg_equiv_mem (regno) != 0 -+ && mode_dependent_address_p (XEXP (reg_equiv_mem (regno), 0), -+ MEM_ADDR_SPACE (reg_equiv_mem (regno))); -+ - /* If INNER is not ok for MODE, then INNER will need reloading. */ - if (!HARD_REGNO_MODE_OK (subreg_regno (x), mode)) - return true; -@@ -1142,7 +1153,7 @@ - - if (in != 0 && reload_inner_reg_of_subreg (in, inmode, false)) - { -- if (REG_P (SUBREG_REG (in))) -+ if (REG_P (SUBREG_REG (in)) && HARD_REGISTER_P (SUBREG_REG (in))) - subreg_in_class - = find_valid_class (inmode, GET_MODE (SUBREG_REG (in)), - subreg_regno_offset (REGNO (SUBREG_REG (in)), -@@ -1150,7 +1161,8 @@ - SUBREG_BYTE (in), - GET_MODE (in)), - REGNO (SUBREG_REG (in))); -- else if (GET_CODE (SUBREG_REG (in)) == SYMBOL_REF) -+ else if (REG_P (SUBREG_REG (in)) -+ || GET_CODE (SUBREG_REG (in)) == SYMBOL_REF) - subreg_in_class = find_valid_class_1 (inmode, - GET_MODE (SUBREG_REG (in)), - rclass); -diff -rNU3 dist.orig/gcc/system.h dist/gcc/system.h ---- dist.orig/gcc/system.h 2013-01-15 16:54:05.000000000 +0100 -+++ dist/gcc/system.h 2015-10-18 13:19:51.000000000 +0200 -@@ -37,6 +37,12 @@ - # include - #endif - -+#ifndef GENERATOR_FILE -+#ifdef __cplusplus -+# include -+#endif -+#endif -+ - #include - - /* Define a generic NULL if one hasn't already been defined. */ -@@ -201,9 +207,11 @@ - extern int errno; - #endif - -+#ifndef GENERATOR_FILE - #ifdef __cplusplus - # include - #endif -+#endif - - /* Some of glibc's string inlines cause warnings. Plus we'd rather - rely on (and therefore test) GCC's string builtins. */ -diff -rNU3 dist.orig/gcc/targhooks.c dist/gcc/targhooks.c ---- dist.orig/gcc/targhooks.c 2013-01-10 21:38:27.000000000 +0100 -+++ dist/gcc/targhooks.c 2015-10-18 13:19:51.000000000 +0200 -@@ -714,7 +714,17 @@ - DECL_ARTIFICIAL (t) = 1; - DECL_IGNORED_P (t) = 1; - DECL_VISIBILITY_SPECIFIED (t) = 1; -+#if 1 -+ /* -+ * This is a hack: -+ * It appears that our gas does not generate @PLT for hidden -+ * symbols. It could be that we need a newer version, or that -+ * this local function is handled differently on linux. -+ */ -+ DECL_VISIBILITY (t) = VISIBILITY_DEFAULT; -+#else - DECL_VISIBILITY (t) = VISIBILITY_HIDDEN; -+#endif - - stack_chk_fail_decl = t; - } -diff -rNU3 dist.orig/gcc/tree-cfg.c dist/gcc/tree-cfg.c ---- dist.orig/gcc/tree-cfg.c 2015-06-03 23:36:26.000000000 +0200 -+++ dist/gcc/tree-cfg.c 2015-10-18 13:19:51.000000000 +0200 -@@ -7800,7 +7800,11 @@ - } - if (location == UNKNOWN_LOCATION) - location = cfun->function_end_locus; -- warning_at (location, 0, "% function does return"); -+ -+#ifdef notyet -+ if (warn_missing_noreturn) -+ warning_at (location, 0, "% function does return"); -+#endif - } - - /* If we see "return;" in some basic block, then we do reach the end -diff -rNU3 dist.orig/gcc/tree-ssa-ccp.c dist/gcc/tree-ssa-ccp.c ---- dist.orig/gcc/tree-ssa-ccp.c 2013-09-23 18:12:27.000000000 +0200 -+++ dist/gcc/tree-ssa-ccp.c 2015-10-18 13:19:51.000000000 +0200 -@@ -2529,3 +2529,42 @@ - | TODO_update_ssa /* todo_flags_finish */ - } - }; -+ -+#if defined(__NetBSD__) && defined(NETBSD_NATIVE) -+/* -+ * This is a big, ugly, temporary hack: -+ * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59958 -+ * To make sure we have configured all our targets correctly, mimic the -+ * #ifdef cascade from src/lib/libc/stdlib/jemalloc.c here and compile -+ * time assert that the value matches gcc's MALLOC_ABI_ALIGNMENT here. -+ */ -+ -+#if defined(__alpha__) || defined(__amd64__) || defined(__sparc64__) \ -+ || (defined(__arm__) && defined(__ARM_EABI)) || defined(__powerpc__) \ -+ || ((defined(__mips__) || defined(__riscv__)) && defined(_LP64)) -+#define JEMALLOC_TINY_MIN_2POW 3 -+#endif -+ -+#ifndef JEMALLOC_TINY_MIN_2POW -+#define JEMALLOC_TINY_MIN_2POW 2 -+#endif -+ -+/* make sure we test the (native) 64bit variant for targets supporting -m32 */ -+#undef TARGET_64BIT -+#ifdef _LP64 -+#define TARGET_64BIT 1 -+#else -+#ifdef __sh__ -+#undef UNITS_PER_WORD -+#define UNITS_PER_WORD 4 /* original definition varies depending on cpu */ -+#endif -+#define TARGET_64BIT 0 -+#endif -+ -+#ifdef __CTASSERT -+__CTASSERT((8< localedir.new -- $(srcdir)/../move-if-change localedir.new localedir.h -+ $(SHELL) $(srcdir)/../move-if-change localedir.new localedir.h - echo timestamp > localedir.hs - - # Installation rules and other phony targets -diff -rNU3 dist.orig/libcpp/configure dist/libcpp/configure ---- dist.orig/libcpp/configure 2015-06-23 09:55:27.000000000 +0200 -+++ dist/libcpp/configure 2015-10-18 13:19:51.000000000 +0200 -@@ -2515,7 +2515,7 @@ - for ac_t in install-sh install.sh shtool; do - if test -f "$ac_dir/$ac_t"; then - ac_aux_dir=$ac_dir -- ac_install_sh="$ac_aux_dir/$ac_t -c" -+ ac_install_sh="$SHELL $ac_aux_dir/$ac_t -c" - break 2 - fi - done -@@ -7152,9 +7152,7 @@ - case $target in - aarch64*-*-* | \ - alpha*-*-* | \ -- arm*-*-*eabi* | \ -- arm*-*-rtems* | \ -- arm*-*-symbianelf* | \ -+ arm*-*-* | \ - x86_64-*-* | \ - ia64-*-* | \ - hppa*64*-*-* | \ -diff -rNU3 dist.orig/libcpp/configure.ac dist/libcpp/configure.ac ---- dist.orig/libcpp/configure.ac 2013-04-03 17:13:33.000000000 +0200 -+++ dist/libcpp/configure.ac 2015-10-18 13:19:51.000000000 +0200 -@@ -184,9 +184,7 @@ - case $target in - aarch64*-*-* | \ - alpha*-*-* | \ -- arm*-*-*eabi* | \ -- arm*-*-rtems* | \ -- arm*-*-symbianelf* | \ -+ arm*-*-* | \ - x86_64-*-* | \ - ia64-*-* | \ - hppa*64*-*-* | \ -diff -rNU3 dist.orig/libcpp/files.c dist/libcpp/files.c ---- dist.orig/libcpp/files.c 2015-06-12 13:56:39.000000000 +0200 -+++ dist/libcpp/files.c 2015-10-18 13:19:51.000000000 +0200 -@@ -28,6 +28,7 @@ - #include "obstack.h" - #include "hashtab.h" - #include "md5.h" -+#include "../gcc/defaults.h" - #include - - /* Variable length record files on VMS will have a stat size that includes -@@ -220,20 +221,32 @@ - static bool - open_file (_cpp_file *file) - { -+ const char *cpp_restricted; -+ -+ cpp_restricted = getenv ("CPP_RESTRICTED"); -+ - if (file->path[0] == '\0') - { - file->fd = 0; - set_stdin_to_binary_mode (); - } - else -- file->fd = open (file->path, O_RDONLY | O_NOCTTY | O_BINARY, 0666); -+ file->fd = open (file->path, O_RDONLY | O_NOCTTY | O_BINARY -+ | (cpp_restricted != NULL) ? O_NONBLOCK : 0, 0666); -+ - - if (file->fd != -1) - { - if (fstat (file->fd, &file->st) == 0) - { - if (!S_ISDIR (file->st.st_mode)) -+ if (cpp_restricted != NULL -+ ? S_ISREG (file->st.st_mode) : !S_ISDIR (file->st.st_mode)) -+ - { -+ if (cpp_restricted) -+ fcntl(file->fd, F_SETFL, -+ fcntl(file->fd, F_GETFL, 0) & ~O_NONBLOCK); - file->err_no = 0; - return true; - } -diff -rNU3 dist.orig/libcpp/include/cpplib.h dist/libcpp/include/cpplib.h ---- dist.orig/libcpp/include/cpplib.h 2013-01-14 19:13:59.000000000 +0100 -+++ dist/libcpp/include/cpplib.h 2015-10-18 13:19:51.000000000 +0200 -@@ -715,6 +715,9 @@ - /* Set the include paths. */ - extern void cpp_set_include_chains (cpp_reader *, cpp_dir *, cpp_dir *, int); - -+/* Provide src:dst pair for __FILE__ remapping. */ -+extern void add_cpp_remap_path (const char *); -+ - /* Call these to get pointers to the options, callback, and deps - structures for a given reader. These pointers are good until you - call cpp_finish on that reader. You can either edit the callbacks -diff -rNU3 dist.orig/libcpp/internal.h dist/libcpp/internal.h ---- dist.orig/libcpp/internal.h 2013-03-06 17:18:40.000000000 +0100 -+++ dist/libcpp/internal.h 2015-10-18 13:19:51.000000000 +0200 -@@ -226,6 +226,9 @@ - /* Nonzero if first token on line is CPP_HASH. */ - unsigned char in_directive; - -+ /* Nonzero if we are collecting macro arguments */ -+ unsigned char collecting_args; -+ - /* Nonzero if in a directive that will handle padding tokens itself. - #include needs this to avoid problems with computed include and - spacing between tokens. */ -diff -rNU3 dist.orig/libcpp/lex.c dist/libcpp/lex.c ---- dist.orig/libcpp/lex.c 2014-10-13 03:42:03.000000000 +0200 -+++ dist/libcpp/lex.c 2015-10-18 13:19:51.000000000 +0200 -@@ -1876,6 +1876,8 @@ - { - unsigned char *buffer; - unsigned int len, clen, i; -+ int convert_to_c = (pfile->state.in_directive || pfile->state.parsing_args) -+ && type == '/'; - - len = pfile->buffer->cur - from + 1; /* + 1 for the initial '/'. */ - -@@ -1890,8 +1892,7 @@ - - Note that the only time we encounter a directive here is - when we are saving comments in a "#define". */ -- clen = ((pfile->state.in_directive || pfile->state.parsing_args) -- && type == '/') ? len + 2 : len; -+ clen = convert_to_c ? len + 2 : len; - - buffer = _cpp_unaligned_alloc (pfile, clen); - -@@ -1903,7 +1904,7 @@ - memcpy (buffer + 1, from, len - 1); - - /* Finish conversion to a C comment, if necessary. */ -- if ((pfile->state.in_directive || pfile->state.parsing_args) && type == '/') -+ if (convert_to_c) - { - buffer[1] = '*'; - buffer[clen - 2] = '*'; -diff -rNU3 dist.orig/libcpp/macro.c dist/libcpp/macro.c ---- dist.orig/libcpp/macro.c 2014-03-06 09:10:08.000000000 +0100 -+++ dist/libcpp/macro.c 2015-10-18 13:19:51.000000000 +0200 -@@ -215,6 +215,61 @@ - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" - }; - -+static size_t remap_pairs; -+static char **remap_src; -+static char **remap_dst; -+ -+void -+add_cpp_remap_path (const char *arg) -+{ -+ const char *arg_dst; -+ size_t len; -+ -+ arg_dst = strchr(arg, ':'); -+ if (arg_dst == NULL) { -+ fprintf(stderr, "Invalid argument for -iremap"); -+ exit(1); -+ } -+ len = arg_dst - arg; -+ ++arg_dst; -+ -+ remap_src = (char **) xrealloc(remap_src, sizeof(char *) * (remap_pairs + 1)); -+ remap_dst = (char **) xrealloc(remap_dst, sizeof(char *) * (remap_pairs + 1)); -+ -+ remap_src[remap_pairs] = (char *) xmalloc(len + 1); -+ memcpy(remap_src[remap_pairs], arg, len); -+ remap_src[remap_pairs][len] = '\0'; -+ remap_dst[remap_pairs] = xstrdup(arg_dst); -+ ++remap_pairs; -+} -+ -+static const char * -+cpp_remap_file (const char *arg, char **tmp_name) -+{ -+ char *result; -+ size_t i, len; -+ -+ for (i = 0; i < remap_pairs; ++i) { -+ len = strlen (remap_src[i]); -+ if (strncmp (remap_src[i], arg, len)) -+ continue; -+ if (arg[len] == '\0') -+ return remap_dst[i]; -+ if (arg[len] != '/') -+ continue; -+ arg += len; -+ len = strlen (remap_dst[i]); -+ result = (char *) xmalloc (len + strlen (arg) + 1); -+ memcpy(result, remap_dst[i], len); -+ strcpy(result + len, arg); -+ *tmp_name = result; -+ -+ return result; -+ } -+ -+ return arg; -+} -+ - /* Helper function for builtin_macro. Returns the text generated by - a builtin macro. */ - const uchar * -@@ -273,6 +328,7 @@ - { - unsigned int len; - const char *name; -+ char *tmp_name; - uchar *buf; - - if (node->value.builtin == BT_FILE) -@@ -284,11 +340,14 @@ - if (!name) - abort (); - } -+ tmp_name = NULL; -+ name = cpp_remap_file (name, &tmp_name); - len = strlen (name); - buf = _cpp_unaligned_alloc (pfile, len * 2 + 3); - result = buf; - *buf = '"'; - buf = cpp_quote_string (buf + 1, (const unsigned char *) name, len); -+ free (tmp_name); - *buf++ = '"'; - *buf = '\0'; - } -@@ -775,6 +834,7 @@ - memset (args, 0, argc * sizeof (macro_arg)); - buff->cur = (unsigned char *) &args[argc]; - arg = args, argc = 0; -+ pfile->state.collecting_args = 1; - - /* Collect the tokens making up each argument. We don't yet know - how many arguments have been supplied, whether too many or too -@@ -910,6 +970,7 @@ - } - } - while (token->type != CPP_CLOSE_PAREN && token->type != CPP_EOF); -+ pfile->state.collecting_args = 0; - - if (token->type == CPP_EOF) - { -diff -rNU3 dist.orig/libdecnumber/.gitignore dist/libdecnumber/.gitignore ---- dist.orig/libdecnumber/.gitignore 2011-03-29 03:58:42.000000000 +0200 -+++ dist/libdecnumber/.gitignore 1970-01-01 01:00:00.000000000 +0100 -@@ -1 +0,0 @@ --/gstdint.h -diff -rNU3 dist.orig/libdecnumber/configure dist/libdecnumber/configure ---- dist.orig/libdecnumber/configure 2012-11-05 00:08:42.000000000 +0100 -+++ dist/libdecnumber/configure 2015-10-18 13:19:51.000000000 +0200 -@@ -4463,7 +4463,7 @@ - for ac_t in install-sh install.sh shtool; do - if test -f "$ac_dir/$ac_t"; then - ac_aux_dir=$ac_dir -- ac_install_sh="$ac_aux_dir/$ac_t -c" -+ ac_install_sh="$SHELL $ac_aux_dir/$ac_t -c" - break 2 - fi - done -diff -rNU3 dist.orig/libgcc/Makefile.in dist/libgcc/Makefile.in ---- dist.orig/libgcc/Makefile.in 2013-02-04 20:06:20.000000000 +0100 -+++ dist/libgcc/Makefile.in 2015-10-18 13:19:52.000000000 +0200 -@@ -1010,7 +1010,7 @@ - dest=$(gcc_objdir)/include/tmp$$$$-unwind.h; \ - cp unwind.h $$dest; \ - chmod a+r $$dest; \ -- sh $(srcdir)/../move-if-change $$dest $(gcc_objdir)/include/unwind.h -+ $(SHELL) $(srcdir)/../move-if-change $$dest $(gcc_objdir)/include/unwind.h - - # Copy unwind.h to the place where gcc will look at run-time, once installed - # -diff -rNU3 dist.orig/libgcc/config/arm/pr-support.c dist/libgcc/config/arm/pr-support.c ---- dist.orig/libgcc/config/arm/pr-support.c 2013-02-04 20:06:20.000000000 +0100 -+++ dist/libgcc/config/arm/pr-support.c 2015-10-18 13:19:51.000000000 +0200 -@@ -352,7 +352,7 @@ - - /* Find the Language specific exception data. */ - --void * -+_Unwind_Ptr - _Unwind_GetLanguageSpecificData (_Unwind_Context * context) - { - _Unwind_Control_Block *ucbp; -@@ -366,7 +366,7 @@ - /* Skip the unwind opcodes. */ - ptr += (((*ptr) >> 24) & 0xff) + 1; - -- return ptr; -+ return (_Unwind_Ptr) ptr; - } - - -diff -rNU3 dist.orig/libgcc/config/arm/t-netbsd dist/libgcc/config/arm/t-netbsd ---- dist.orig/libgcc/config/arm/t-netbsd 2011-11-02 16:23:48.000000000 +0100 -+++ dist/libgcc/config/arm/t-netbsd 2015-10-18 13:19:51.000000000 +0200 -@@ -1,7 +1,18 @@ -+# This list is from t-elf, but with some things removed. -+LIB1ASMFUNCS += _udivsi3 _divsi3 _umodsi3 _modsi3 _dvmd_tls _bb_init_func \ -+ _call_via_rX _interwork_call_via_rX \ -+ _arm_fixunsdfsi _arm_fixunssfsi \ -+ _arm_floatdidf _arm_floatdisf _arm_floatundidf _arm_floatundisf \ -+ _lshrdi3 _ashrdi3 _ashldi3 \ -+ _clzsi2 _clzdi2 _ctzsi2 -+ - # Just for these, we omit the frame pointer since it makes such a big - # difference. It is then pointless adding debugging. - HOST_LIBGCC2_CFLAGS += -fomit-frame-pointer - --LIBGCC2_DEBUG_CFLAGS = -g0 -- - LIB2ADD += $(srcdir)/floatunsidf.c $(srcdir)/floatunsisf.c -+ -+# Currently there is a bug somewhere in GCC's alias analysis -+# or scheduling code that is breaking _fpmul_parts in fp-bit.c. -+# Disabling function inlining is a workaround for this problem. -+HOST_LIBGCC2_CFLAGS += -fno-inline -diff -rNU3 dist.orig/libgcc/config/arm/t-netbsd-eabi dist/libgcc/config/arm/t-netbsd-eabi ---- dist.orig/libgcc/config/arm/t-netbsd-eabi 1970-01-01 01:00:00.000000000 +0100 -+++ dist/libgcc/config/arm/t-netbsd-eabi 2015-10-18 13:19:51.000000000 +0200 -@@ -0,0 +1,19 @@ -+# This list is from t-elf, but with lots removed. -+LIB1ASMFUNCS += _dvmd_tls _bb_init_func _call_via_rX _interwork_call_via_rX \ -+ _clzsi2 _clzdi2 _ctzsi2 -+ -+# Derived from t-bpabi -+# Add the BPABI C functions. -+LIB2ADD += $(srcdir)/config/arm/unaligned-funcs.c -+ -+LIB2ADDEH = $(srcdir)/config/arm/unwind-arm.c \ -+ $(srcdir)/config/arm/libunwind.S \ -+ $(srcdir)/config/arm/pr-support.c $(srcdir)/unwind-c.c -+ -+# Add the BPABI names. -+SHLIB_MAPFILES += $(srcdir)/config/arm/libgcc-bpabi.ver -+ -+# On ARM, specifying -fnon-call-exceptions will needlessly pull in -+# the unwinder in simple programs which use 64-bit division. Omitting -+# the option is safe. -+LIB2_DIVMOD_EXCEPTION_FLAGS := -fexceptions -diff -rNU3 dist.orig/libgcc/config/c6x/pr-support.c dist/libgcc/config/c6x/pr-support.c ---- dist.orig/libgcc/config/c6x/pr-support.c 2013-02-04 20:06:20.000000000 +0100 -+++ dist/libgcc/config/c6x/pr-support.c 2015-10-18 13:19:51.000000000 +0200 -@@ -518,7 +518,7 @@ - return (_Unwind_Ptr) ucbp->pr_cache.fnstart; - } - --void * -+_Unwind_Ptr - _Unwind_GetLanguageSpecificData (_Unwind_Context *context) - { - _Unwind_Control_Block *ucbp; -@@ -531,5 +531,5 @@ - /* Skip the unwind opcodes. */ - ptr += (((*ptr) >> 24) & 0xff) + 1; - -- return ptr; -+ return (_Unwind_Ptr) ptr; - } -diff -rNU3 dist.orig/libgcc/config/cr16/unwind-cr16.c dist/libgcc/config/cr16/unwind-cr16.c ---- dist.orig/libgcc/config/cr16/unwind-cr16.c 2013-02-04 20:06:20.000000000 +0100 -+++ dist/libgcc/config/cr16/unwind-cr16.c 2015-10-18 13:19:51.000000000 +0200 -@@ -347,7 +347,7 @@ - context->ra = (void *) val; - } - --void * -+_Unwind_Ptr - _Unwind_GetLanguageSpecificData (struct _Unwind_Context *context) - { - return context->lsda; -diff -rNU3 dist.orig/libgcc/config/ia64/unwind-ia64.c dist/libgcc/config/ia64/unwind-ia64.c ---- dist.orig/libgcc/config/ia64/unwind-ia64.c 2013-02-04 20:06:20.000000000 +0100 -+++ dist/libgcc/config/ia64/unwind-ia64.c 2015-10-18 13:19:52.000000000 +0200 -@@ -1715,10 +1715,10 @@ - context->rp = val; - } - --void * -+_Unwind_Ptr - _Unwind_GetLanguageSpecificData (struct _Unwind_Context *context) - { -- return context->lsda; -+ return (_Unwind_Ptr)context->lsda; - } - - _Unwind_Ptr -@@ -2445,6 +2445,16 @@ - return _Unwind_GetIP (context); - } - -+#ifdef __NetBSD__ -+/* dummy for bootstrapping purposes */ -+struct unw_table_entry * -+_Unwind_FindTableEntry (void *pc, unw_word *segment_base, -+ unw_word *gp, struct unw_table_entry *ent) -+{ -+ return NULL; -+} -+#endif -+ - #include "unwind.inc" - - #if defined (USE_GAS_SYMVER) && defined (SHARED) && defined (USE_LIBUNWIND_EXCEPTIONS) -diff -rNU3 dist.orig/libgcc/config/m68k/fpgnulib.c dist/libgcc/config/m68k/fpgnulib.c ---- dist.orig/libgcc/config/m68k/fpgnulib.c 2011-11-02 16:23:48.000000000 +0100 -+++ dist/libgcc/config/m68k/fpgnulib.c 2015-10-18 13:19:52.000000000 +0200 -@@ -395,6 +395,7 @@ - float __truncdfsf2 (double); - long __fixdfsi (double); - long __fixsfsi (float); -+long __cmpdf2 (double, double); - - int - __unordxf2(long double a, long double b) -diff -rNU3 dist.orig/libgcc/config/m68k/t-floatlib dist/libgcc/config/m68k/t-floatlib ---- dist.orig/libgcc/config/m68k/t-floatlib 2011-11-02 16:23:48.000000000 +0100 -+++ dist/libgcc/config/m68k/t-floatlib 2015-10-18 13:19:52.000000000 +0200 -@@ -1,6 +1,6 @@ - LIB1ASMSRC = m68k/lb1sf68.S - LIB1ASMFUNCS = _mulsi3 _udivsi3 _divsi3 _umodsi3 _modsi3 \ -- _double _float _floatex \ -+ _floatex _float _double \ - _eqdf2 _nedf2 _gtdf2 _gedf2 _ltdf2 _ledf2 \ - _eqsf2 _nesf2 _gtsf2 _gesf2 _ltsf2 _lesf2 - -diff -rNU3 dist.orig/libgcc/config/m68k/t-netbsd-m68010 dist/libgcc/config/m68k/t-netbsd-m68010 ---- dist.orig/libgcc/config/m68k/t-netbsd-m68010 1970-01-01 01:00:00.000000000 +0100 -+++ dist/libgcc/config/m68k/t-netbsd-m68010 2015-10-18 13:19:52.000000000 +0200 -@@ -0,0 +1,5 @@ -+LIB1ASMSRC = m68k/lb1sf68.S -+LIB1ASMFUNCS = _mulsi3 _udivsi3 _divsi3 _umodsi3 _modsi3 \ -+ _double _float _floatex \ -+ _eqdf2 _nedf2 _gtdf2 _gedf2 _ltdf2 _ledf2 \ -+ _eqsf2 _nesf2 _gtsf2 _gesf2 _ltsf2 _lesf2 -diff -rNU3 dist.orig/libgcc/config/or1k/crti.S dist/libgcc/config/or1k/crti.S ---- dist.orig/libgcc/config/or1k/crti.S 1970-01-01 01:00:00.000000000 +0100 -+++ dist/libgcc/config/or1k/crti.S 2015-10-18 13:19:52.000000000 +0200 -@@ -0,0 +1,36 @@ -+# Start .init and .fini sections. -+# Copyright (C) 2010 Embecosm Limited -+# -+# This file is free software; you can redistribute it and/or modify it -+# under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3, or (at your option) -+# any later version. -+# -+# GCC is distributed in the hope that it will be useful, but WITHOUT ANY -+# WARRANTY; without even the implied warranty of MERCHANTABILITY or -+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -+# for more details. -+# -+# Under Section 7 of GPL version 3, you are granted additional -+# permissions described in the GCC Runtime Library Exception, version -+# 3.1, as published by the Free Software Foundation. -+# -+# You should have received a copy of the GNU General Public License and -+# a copy of the GCC Runtime Library Exception along with this program; -+# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -+# . -+ -+#include "or1k-asm.h" -+ -+ .section .init -+ .global _init -+ l.nop # So _init doesn't start at 0 -+_init: -+ l.addi r1,r1,-4 -+ l.sw 0(r1),r9 -+ -+ .section .fini -+ .global _fini -+_fini: -+ l.addi r1,r1,-4 -+ l.sw 0(r1),r9 -diff -rNU3 dist.orig/libgcc/config/or1k/crtn.S dist/libgcc/config/or1k/crtn.S ---- dist.orig/libgcc/config/or1k/crtn.S 1970-01-01 01:00:00.000000000 +0100 -+++ dist/libgcc/config/or1k/crtn.S 2015-10-18 13:19:52.000000000 +0200 -@@ -0,0 +1,37 @@ -+# End .init and .fini sections. -+# Copyright (C) 2010 Embecosm Limited -+# -+# This file is free software; you can redistribute it and/or modify it -+# under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3, or (at your option) -+# any later version. -+# -+# GCC is distributed in the hope that it will be useful, but WITHOUT ANY -+# WARRANTY; without even the implied warranty of MERCHANTABILITY or -+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -+# for more details. -+# -+# Under Section 7 of GPL version 3, you are granted additional -+# permissions described in the GCC Runtime Library Exception, version -+# 3.1, as published by the Free Software Foundation. -+# -+# You should have received a copy of the GNU General Public License and -+# a copy of the GCC Runtime Library Exception along with this program; -+# see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -+# . -+ -+#include "or1k-asm.h" -+ -+ .section .init -+ l.lwz r9,0(r1) -+ OR1K_DELAYED( -+ OR1K_INST(l.addi r1,r1,4), -+ OR1K_INST(l.jr r9) -+ ) -+ -+ .section .fini -+ l.lwz r9,0(r1) -+ OR1K_DELAYED( -+ OR1K_INST(l.addi r1,r1,4), -+ OR1K_INST(l.jr r9) -+ ) -diff -rNU3 dist.orig/libgcc/config/or1k/linux-unwind.h dist/libgcc/config/or1k/linux-unwind.h ---- dist.orig/libgcc/config/or1k/linux-unwind.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/libgcc/config/or1k/linux-unwind.h 2015-10-18 13:19:52.000000000 +0200 -@@ -0,0 +1,77 @@ -+/* DWARF2 EH unwinding support for OpenRISC. -+ Copyright (C) 2011, 2012 -+ Free Software Foundation, Inc. -+ -+This file is part of GCC. -+ -+GCC is free software; you can redistribute it and/or modify -+it under the terms of the GNU General Public License as published by -+the Free Software Foundation; either version 3, or (at your option) -+any later version. -+ -+GCC is distributed in the hope that it will be useful, -+but WITHOUT ANY WARRANTY; without even the implied warranty of -+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+GNU General Public License for more details. -+ -+Under Section 7 of GPL version 3, you are granted additional -+permissions described in the GCC Runtime Library Exception, version -+3.1, as published by the Free Software Foundation. -+ -+You should have received a copy of the GNU General Public License and -+a copy of the GCC Runtime Library Exception along with this program; -+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -+. */ -+ -+#ifndef inhibit_libc -+ -+#include -+#include -+#include -+ -+#define MD_FALLBACK_FRAME_STATE_FOR or1k_fallback_frame_state -+ -+static _Unwind_Reason_Code -+or1k_fallback_frame_state (struct _Unwind_Context *context, -+ _Unwind_FrameState *fs) -+{ -+ struct rt_sigframe { -+ siginfo_t info; -+ struct ucontext uc; -+ } *frame = context->cfa; -+ -+ struct sigcontext *sc; -+ unsigned char *pc = context->ra; -+ long new_cfa; -+ int i; -+ -+ /* -+ * Note: These have to be the same as in the kernel. -+ * Please see arch/openrisc/kernel/signal.c -+ */ -+ if (!(*(unsigned short *)(pc + 0) == 0xa960 -+ && *(unsigned short *)(pc + 2) == __NR_rt_sigreturn -+ && *(unsigned long *)(pc + 4) == 0x20000001 -+ && *(unsigned long *)(pc + 8) == 0x15000000)) -+ return _URC_END_OF_STACK; -+ -+ sc = (struct sigcontext *) &frame->uc.uc_mcontext; -+ -+ new_cfa = sc->regs.gpr[1]; -+ fs->regs.cfa_how = CFA_REG_OFFSET; -+ fs->regs.cfa_reg = STACK_POINTER_REGNUM; -+ fs->regs.cfa_offset = new_cfa - (long) context->cfa; -+ -+ for (i = 0; i < 32; ++i) -+ { -+ fs->regs.reg[i].how = REG_SAVED_OFFSET; -+ fs->regs.reg[i].loc.offset = (long)&sc->regs.gpr[i] - new_cfa; -+ } -+ -+ fs->retaddr_column = 9; -+ fs->signal_frame = 1; -+ -+ return _URC_NO_REASON; -+} -+ -+#endif /* ifdef inhibit_libc */ -diff -rNU3 dist.orig/libgcc/config/or1k/or1k-asm.h dist/libgcc/config/or1k/or1k-asm.h ---- dist.orig/libgcc/config/or1k/or1k-asm.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/libgcc/config/or1k/or1k-asm.h 2015-10-18 13:19:52.000000000 +0200 -@@ -0,0 +1,20 @@ -+#ifndef OR1K_ASM_H -+#define OR1K_ASM_H -+ -+#define OR1K_INST(...) __VA_ARGS__ -+ -+#if defined(__OR1K_NODELAY__) -+#define OR1K_DELAYED(a, b) a; b -+#define OR1K_DELAYED_NOP(a) a -+.nodelay -+#elif defined(__OR1K_DELAY__) -+#define OR1K_DELAYED(a, b) b; a -+#define OR1K_DELAYED_NOP(a) a; l.nop -+#elif defined(__OR1K_DELAY_COMPAT__) -+#define OR1K_DELAYED(a, b) a; b; l.nop -+#define OR1K_DELAYED_NOP(a) a; l.nop -+#else -+#error One of __OR1K_NODELAY__, __OR1K_DELAY__, or __OR1K_DELAY_COMPAT__ must be defined -+#endif -+ -+#endif -diff -rNU3 dist.orig/libgcc/config/or1k/or1k.S dist/libgcc/config/or1k/or1k.S ---- dist.orig/libgcc/config/or1k/or1k.S 1970-01-01 01:00:00.000000000 +0100 -+++ dist/libgcc/config/or1k/or1k.S 2015-10-18 13:19:52.000000000 +0200 -@@ -0,0 +1,237 @@ -+#include "or1k-asm.h" -+/* -+ * Assembly functions for software multiplication and devision. -+ */ -+ -+#define ENTRY(symbol) \ -+ .align 4 ;\ -+ .global symbol ;\ -+ .type symbol, @function ;\ -+symbol: -+ -+#ifdef L__mulsi3 -+ENTRY(__mulsi3) -+ l.addi r11,r0,0x0 -+ l.sfne r3,r11 -+OR1K_DELAYED( -+ OR1K_INST(l.ori r5,r3,0x0), -+ OR1K_INST(l.bnf 3f) -+) -+ l.addi r6,r0,0x0 -+1: -+ l.andi r3,r5,0x1 -+ l.sfeq r3,r6 -+OR1K_DELAYED( -+ OR1K_INST(l.srli r5,r5,0x1), -+ OR1K_INST(l.bf 2f) -+) -+ l.add r11,r11,r4 -+2: -+ l.sfne r5,r6 -+OR1K_DELAYED( -+ OR1K_INST(l.slli r4,r4,0x1), -+ OR1K_INST(l.bf 1b) -+) -+3: -+OR1K_DELAYED_NOP( -+ OR1K_INST(l.jr r9) -+) -+.size __mulsi3,.-__mulsi3 -+#endif -+ -+#ifdef L__udivsi3 -+.global __udivsi3_internal -+.hidden __udivsi3_internal -+__udivsi3_internal: -+ENTRY(__udivsi3) -+ l.addi r1,r1,-4 -+ l.sw 0(r1),r9 -+ l.addi r11,r0,0 -+ l.addi r8,r4,0 -+ l.addi r5,r3,0 -+ l.sfne r8,r11 -+OR1K_DELAYED( -+ OR1K_INST(l.addi r7,r0,0), -+ OR1K_INST(l.bnf 4f) -+) -+ /* The following work equally on delay and no-delay implementations */ -+ l.sfgtu r8,r5 -+ l.bf 5f -+ l.sfeq r8,r5 -+ l.bf 6f -+ l.sfltu r11,r8 -+ -+OR1K_DELAYED( -+ OR1K_INST(l.addi r13,r0,32), -+ OR1K_INST(l.bnf 2f) -+) -+ l.movhi r9,hi(0x80000000) -+ l.addi r6,r0,-1 -+1: -+ l.and r3,r5,r9 -+ l.slli r4,r7,1 -+ l.addi r15,r5,0 -+ l.srli r3,r3,31 -+ l.add r13,r13,r6 -+ l.or r7,r4,r3 -+ l.sfltu r7,r8 -+OR1K_DELAYED( -+ OR1K_INST(l.slli r5,r5,1), -+ OR1K_INST(l.bf 1b) -+) -+2: -+ l.srli r7,r7,1 -+ l.addi r13,r13,1 -+ l.addi r9,r0,0 -+ l.sfltu r9,r13 -+OR1K_DELAYED( -+ OR1K_INST(l.addi r5,r15,0), -+ OR1K_INST(l.bnf 4f) -+) -+ l.movhi r15,hi(0x80000000) -+ l.addi r17,r0,0 -+3: -+ l.and r3,r5,r15 -+ l.slli r4,r7,1 -+ l.srli r3,r3,31 -+ l.or r7,r4,r3 -+ l.sub r6,r7,r8 -+ l.and r3,r6,r15 -+ l.srli r3,r3,31 -+ l.addi r4,r0,0 -+ l.sfne r3,r4 -+OR1K_DELAYED( -+ OR1K_INST(l.slli r3,r11,1), -+ OR1K_INST(l.bf 1f) -+) -+ l.addi r4,r0,1 -+1: -+ l.slli r5,r5,1 -+ l.sfne r4,r17 -+OR1K_DELAYED( -+ OR1K_INST(l.or r11,r3,r4), -+ OR1K_INST(l.bnf 2f) -+) -+ l.addi r7,r6,0 -+2: -+ l.addi r9,r9,1 -+ l.sfltu r9,r13 -+OR1K_DELAYED_NOP( -+ OR1K_INST(l.bf 3b) -+) -+OR1K_DELAYED_NOP( -+ OR1K_INST(l.j 4f) -+) -+6: -+OR1K_DELAYED( -+ OR1K_INST(l.addi r11,r0,1), -+ OR1K_INST(l.j 4f) -+) -+5: -+ l.addi r7,r5,0 -+4: -+ l.lwz r9,0(r1) -+OR1K_DELAYED( -+ OR1K_INST(l.addi r1,r1,4), -+ OR1K_INST(l.jr r9) -+) -+.size __udivsi3,.-__udivsi3 -+#endif -+ -+ -+#ifdef L__divsi3 -+ENTRY(__divsi3) -+ l.addi r1,r1,-8 -+ l.sw 0(r1),r9 -+ l.sw 4(r1),r14 -+ l.addi r5,r3,0 -+ l.addi r14,r0,0 -+ l.sflts r5,r0 -+OR1K_DELAYED( -+ OR1K_INST(l.addi r3,r0,0), -+ OR1K_INST(l.bnf 1f) -+) -+ l.addi r14,r0,1 -+ l.sub r5,r0,r5 -+1: -+ l.sflts r4,r0 -+OR1K_DELAYED_NOP( -+ OR1K_INST(l.bnf 1f) -+) -+ l.addi r14,r14,1 -+ l.sub r4,r0,r4 -+1: -+OR1K_DELAYED( -+ OR1K_INST(l.addi r3,r5,0), -+ OR1K_INST(l.jal __udivsi3_internal) -+) -+ l.sfeqi r14,1 -+OR1K_DELAYED_NOP( -+ OR1K_INST(l.bnf 1f) -+) -+ l.sub r11,r0,r11 -+1: -+ l.lwz r9,0(r1) -+ l.lwz r14,4(r1) -+OR1K_DELAYED( -+ OR1K_INST(l.addi r1,r1,8), -+ OR1K_INST(l.jr r9) -+) -+.size __divsi3,.-__divsi3 -+#endif -+ -+ -+#ifdef L__umodsi3 -+ENTRY(__umodsi3) -+ l.addi r1,r1,-4 -+ l.sw 0(r1),r9 -+OR1K_DELAYED_NOP( -+ OR1K_INST(l.jal __udivsi3_internal) -+) -+ l.addi r11,r7,0 -+ l.lwz r9,0(r1) -+OR1K_DELAYED( -+ OR1K_INST(l.addi r1,r1,4), -+ OR1K_INST(l.jr r9) -+) -+.size __umodsi3,.-__umodsi3 -+#endif -+ -+ -+#ifdef L__modsi3 -+ENTRY(__modsi3) -+ l.addi r1,r1,-8 -+ l.sw 0(r1),r9 -+ l.sw 4(r1),r14 -+ l.addi r14,r0,0 -+ l.sflts r3,r0 -+OR1K_DELAYED_NOP( -+ OR1K_INST(l.bnf 1f) -+) -+ l.addi r14,r0,1 -+ l.sub r3,r0,r3 -+1: -+ l.sflts r4,r0 -+OR1K_DELAYED_NOP( -+ OR1K_INST(l.bnf 1f) -+) -+ l.sub r4,r0,r4 -+1: -+OR1K_DELAYED_NOP( -+ OR1K_INST(l.jal __udivsi3_internal) -+) -+ l.sfeqi r14,1 -+OR1K_DELAYED( -+ OR1K_INST(l.addi r11,r7,0), -+ OR1K_INST(l.bnf 1f) -+) -+ l.sub r11,r0,r11 -+1: -+ l.lwz r9,0(r1) -+ l.lwz r14,4(r1) -+OR1K_DELAYED( -+ OR1K_INST(l.addi r1,r1,8), -+ OR1K_INST(l.jr r9) -+) -+.size __modsi3,.-__modsi3 -+#endif -diff -rNU3 dist.orig/libgcc/config/or1k/sfp-machine.h dist/libgcc/config/or1k/sfp-machine.h ---- dist.orig/libgcc/config/or1k/sfp-machine.h 1970-01-01 01:00:00.000000000 +0100 -+++ dist/libgcc/config/or1k/sfp-machine.h 2015-10-18 13:19:52.000000000 +0200 -@@ -0,0 +1,54 @@ -+#define _FP_W_TYPE_SIZE 32 -+#define _FP_W_TYPE unsigned long -+#define _FP_WS_TYPE signed long -+#define _FP_I_TYPE long -+ -+#define _FP_MUL_MEAT_S(R,X,Y) \ -+ _FP_MUL_MEAT_1_wide(_FP_WFRACBITS_S,R,X,Y,umul_ppmm) -+#define _FP_MUL_MEAT_D(R,X,Y) \ -+ _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm) -+#define _FP_MUL_MEAT_Q(R,X,Y) \ -+ _FP_MUL_MEAT_4_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm) -+ -+#define _FP_DIV_MEAT_S(R,X,Y) _FP_DIV_MEAT_1_loop(S,R,X,Y) -+#define _FP_DIV_MEAT_D(R,X,Y) _FP_DIV_MEAT_2_udiv(D,R,X,Y) -+#define _FP_DIV_MEAT_Q(R,X,Y) _FP_DIV_MEAT_4_udiv(Q,R,X,Y) -+ -+#define _FP_NANFRAC_S ((_FP_QNANBIT_S << 1) - 1) -+#define _FP_NANFRAC_D ((_FP_QNANBIT_D << 1) - 1), -1 -+#define _FP_NANFRAC_Q ((_FP_QNANBIT_Q << 1) - 1), -1, -1, -1 -+#define _FP_NANSIGN_S 0 -+#define _FP_NANSIGN_D 0 -+#define _FP_NANSIGN_Q 0 -+ -+#define _FP_KEEPNANFRACP 1 -+#define _FP_QNANNEGATEDP 0 -+ -+/* Someone please check this. */ -+#define _FP_CHOOSENAN(fs, wc, R, X, Y, OP) \ -+ do { \ -+ if ((_FP_FRAC_HIGH_RAW_##fs(X) & _FP_QNANBIT_##fs) \ -+ && !(_FP_FRAC_HIGH_RAW_##fs(Y) & _FP_QNANBIT_##fs)) \ -+ { \ -+ R##_s = Y##_s; \ -+ _FP_FRAC_COPY_##wc(R,Y); \ -+ } \ -+ else \ -+ { \ -+ R##_s = X##_s; \ -+ _FP_FRAC_COPY_##wc(R,X); \ -+ } \ -+ R##_c = FP_CLS_NAN; \ -+ } while (0) -+ -+#define __LITTLE_ENDIAN 1234 -+#define __BIG_ENDIAN 4321 -+ -+#define __BYTE_ORDER __BIG_ENDIAN -+ -+#define _FP_TININESS_AFTER_ROUNDING 0 -+ -+/* Define ALIASNAME as a strong alias for NAME. */ -+# define strong_alias(name, aliasname) _strong_alias(name, aliasname) -+# define _strong_alias(name, aliasname) \ -+ extern __typeof (name) aliasname __attribute__ ((alias (#name))); -diff -rNU3 dist.orig/libgcc/config/or1k/t-crtstuff dist/libgcc/config/or1k/t-crtstuff ---- dist.orig/libgcc/config/or1k/t-crtstuff 1970-01-01 01:00:00.000000000 +0100 -+++ dist/libgcc/config/or1k/t-crtstuff 2015-10-18 13:19:52.000000000 +0200 -@@ -0,0 +1,4 @@ -+# This will prevent gcc from appending data to .eh_frame. -+# Other archs use fno-asynchronous-unwind-tables but we do not have that flag. -+CRTSTUFF_T_CFLAGS += -fno-dwarf2-cfi-asm -+CRTSTUFF_T_CFLAGS_S += -fno-dwarf2-cfi-asm -diff -rNU3 dist.orig/libgcc/config/or1k/t-linux dist/libgcc/config/or1k/t-linux ---- dist.orig/libgcc/config/or1k/t-linux 1970-01-01 01:00:00.000000000 +0100 -+++ dist/libgcc/config/or1k/t-linux 2015-10-18 13:19:52.000000000 +0200 -@@ -0,0 +1,2 @@ -+MULTILIB_DIRNAMES = be -+EXTRA_MULTILIB_PARTS = crti.o crtbegin.o crtend.o crtn.o -diff -rNU3 dist.orig/libgcc/config/or1k/t-or1k dist/libgcc/config/or1k/t-or1k ---- dist.orig/libgcc/config/or1k/t-or1k 1970-01-01 01:00:00.000000000 +0100 -+++ dist/libgcc/config/or1k/t-or1k 2015-10-18 13:19:52.000000000 +0200 -@@ -0,0 +1,23 @@ -+# t-or1k is a Makefile fragment to be included when -+# building gcc for the or1k target -+ -+# Copyright (C) 2010 Embecosm Limited -+ -+# This file is part of GCC. -+# -+# GCC is free software; you can redistribute it and/or modify -+# it under the terms of the GNU General Public License as published by -+# the Free Software Foundation; either version 3, or (at your option) -+# any later version. -+# -+# GCC is distributed in the hope that it will be useful, -+# but WITHOUT ANY WARRANTY; without even the implied warranty of -+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -+# GNU General Public License for more details. -+# -+# You should have received a copy of the GNU General Public License -+# along with GCC; see the file COPYING3. If not see -+# . -+ -+LIB1ASMSRC = or1k/or1k.S -+LIB1ASMFUNCS = __mulsi3 __udivsi3 __divsi3 __umodsi3 __modsi3 -diff -rNU3 dist.orig/libgcc/config/pa/t-netbsd dist/libgcc/config/pa/t-netbsd ---- dist.orig/libgcc/config/pa/t-netbsd 1970-01-01 01:00:00.000000000 +0100 -+++ dist/libgcc/config/pa/t-netbsd 2015-10-18 13:19:52.000000000 +0200 -@@ -0,0 +1,9 @@ -+#Plug millicode routines into libgcc.a We want these on both native and -+#cross compiles. We use the "64-bit" routines because the "32-bit" code -+#is broken for certain corner cases. -+LIB1ASMSRC = pa/milli64.S -+LIB1ASMFUNCS = _divI _divU _remI _remU _div_const _mulI _dyncall -+ -+HOST_LIBGCC2_CFLAGS += -DELF=1 -DLINUX=1 -+ -+LIB2ADD = $(srcdir)/config/pa/fptr.c -diff -rNU3 dist.orig/libgcc/config/riscv/crti.S dist/libgcc/config/riscv/crti.S ---- dist.orig/libgcc/config/riscv/crti.S 1970-01-01 01:00:00.000000000 +0100 -+++ dist/libgcc/config/riscv/crti.S 2015-10-18 13:19:52.000000000 +0200 -@@ -0,0 +1 @@ -+/* crti.S is empty because .init_array/.fini_array are used exclusively. */ -diff -rNU3 dist.orig/libgcc/config/riscv/crtn.S dist/libgcc/config/riscv/crtn.S ---- dist.orig/libgcc/config/riscv/crtn.S 1970-01-01 01:00:00.000000000 +0100 -+++ dist/libgcc/config/riscv/crtn.S 2015-10-18 13:19:52.000000000 +0200 -@@ -0,0 +1 @@ -+/* crtn.S is empty because .init_array/.fini_array are used exclusively. */ -diff -rNU3 dist.orig/libgcc/config/riscv/riscv-fp.c dist/libgcc/config/riscv/riscv-fp.c ---- dist.orig/libgcc/config/riscv/riscv-fp.c 1970-01-01 01:00:00.000000000 +0100 -+++ dist/libgcc/config/riscv/riscv-fp.c 2015-10-18 13:19:52.000000000 +0200 -@@ -0,0 +1,178 @@ -+/* Functions needed for soft-float on riscv-linux. Based on -+ rs6000/ppc64-fp.c with TF types removed. -+ -+ Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -+ 2000, 2001, 2002, 2003, 2004, 2006, 2009 Free Software Foundation, -+ Inc. -+ -+This file is part of GCC. -+ -+GCC is free software; you can redistribute it and/or modify it under -+the terms of the GNU General Public License as published by the Free -+Software Foundation; either version 3, or (at your option) any later -+version. -+ -+GCC is distributed in the hope that it will be useful, but WITHOUT ANY -+WARRANTY; without even the implied warranty of MERCHANTABILITY or -+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -+for more details. -+ -+Under Section 7 of GPL version 3, you are granted additional -+permissions described in the GCC Runtime Library Exception, version -+3.1, as published by the Free Software Foundation. -+ -+You should have received a copy of the GNU General Public License and -+a copy of the GCC Runtime Library Exception along with this program; -+see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -+. */ -+ -+#if defined(__riscv64) -+#include "fp-bit.h" -+ -+extern DItype __fixdfdi (DFtype); -+extern DItype __fixsfdi (SFtype); -+extern USItype __fixunsdfsi (DFtype); -+extern USItype __fixunssfsi (SFtype); -+extern DFtype __floatdidf (DItype); -+extern DFtype __floatundidf (UDItype); -+extern SFtype __floatdisf (DItype); -+extern SFtype __floatundisf (UDItype); -+ -+static DItype local_fixunssfdi (SFtype); -+static DItype local_fixunsdfdi (DFtype); -+ -+DItype -+__fixdfdi (DFtype a) -+{ -+ if (a < 0) -+ return - local_fixunsdfdi (-a); -+ return local_fixunsdfdi (a); -+} -+ -+DItype -+__fixsfdi (SFtype a) -+{ -+ if (a < 0) -+ return - local_fixunssfdi (-a); -+ return local_fixunssfdi (a); -+} -+ -+USItype -+__fixunsdfsi (DFtype a) -+{ -+ if (a >= - (DFtype) (- ((SItype)(((USItype)1 << ((4 * 8) - 1)) - 1)) - 1)) -+ return (SItype) (a + (- ((SItype)(((USItype)1 << ((4 * 8) - 1)) - 1)) - 1)) -+ - (- ((SItype)(((USItype)1 << ((4 * 8) - 1)) - 1)) - 1); -+ return (SItype) a; -+} -+ -+USItype -+__fixunssfsi (SFtype a) -+{ -+ if (a >= - (SFtype) (- ((SItype)(((USItype)1 << ((4 * 8) - 1)) - 1)) - 1)) -+ return (SItype) (a + (- ((SItype)(((USItype)1 << ((4 * 8) - 1)) - 1)) - 1)) -+ - (- ((SItype)(((USItype)1 << ((4 * 8) - 1)) - 1)) - 1); -+ return (SItype) a; -+} -+ -+DFtype -+__floatdidf (DItype u) -+{ -+ DFtype d; -+ -+ d = (SItype) (u >> (sizeof (SItype) * 8)); -+ d *= 2.0 * (((UDItype) 1) << ((sizeof (SItype) * 8) - 1)); -+ d += (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1)); -+ -+ return d; -+} -+ -+DFtype -+__floatundidf (UDItype u) -+{ -+ DFtype d; -+ -+ d = (USItype) (u >> (sizeof (SItype) * 8)); -+ d *= 2.0 * (((UDItype) 1) << ((sizeof (SItype) * 8) - 1)); -+ d += (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1)); -+ -+ return d; -+} -+ -+SFtype -+__floatdisf (DItype u) -+{ -+ DFtype f; -+ -+ if (53 < (sizeof (DItype) * 8) -+ && 53 > ((sizeof (DItype) * 8) - 53 + 24)) -+ { -+ if (! (- ((DItype) 1 << 53) < u -+ && u < ((DItype) 1 << 53))) -+ { -+ if ((UDItype) u & (((UDItype) 1 << ((sizeof (DItype) * 8) - 53)) - 1)) -+ { -+ u &= ~ (((UDItype) 1 << ((sizeof (DItype) * 8) - 53)) - 1); -+ u |= ((UDItype) 1 << ((sizeof (DItype) * 8) - 53)); -+ } -+ } -+ } -+ f = (SItype) (u >> (sizeof (SItype) * 8)); -+ f *= 2.0 * (((UDItype) 1) << ((sizeof (SItype) * 8) - 1)); -+ f += (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1)); -+ -+ return (SFtype) f; -+} -+ -+SFtype -+__floatundisf (UDItype u) -+{ -+ DFtype f; -+ -+ if (53 < (sizeof (DItype) * 8) -+ && 53 > ((sizeof (DItype) * 8) - 53 + 24)) -+ { -+ if (u >= ((UDItype) 1 << 53)) -+ { -+ if ((UDItype) u & (((UDItype) 1 << ((sizeof (DItype) * 8) - 53)) - 1)) -+ { -+ u &= ~ (((UDItype) 1 << ((sizeof (DItype) * 8) - 53)) - 1); -+ u |= ((UDItype) 1 << ((sizeof (DItype) * 8) - 53)); -+ } -+ } -+ } -+ f = (USItype) (u >> (sizeof (SItype) * 8)); -+ f *= 2.0 * (((UDItype) 1) << ((sizeof (SItype) * 8) - 1)); -+ f += (USItype) (u & ((((UDItype) 1) << (sizeof (SItype) * 8)) - 1)); -+ -+ return (SFtype) f; -+} -+ -+/* This version is needed to prevent recursion; fixunsdfdi in libgcc -+ calls fixdfdi, which in turn calls calls fixunsdfdi. */ -+ -+static DItype -+local_fixunsdfdi (DFtype a) -+{ -+ USItype hi, lo; -+ -+ hi = a / (((UDItype) 1) << (sizeof (SItype) * 8)); -+ lo = (a - ((DFtype) hi) * (((UDItype) 1) << (sizeof (SItype) * 8))); -+ return ((UDItype) hi << (sizeof (SItype) * 8)) | lo; -+} -+ -+/* This version is needed to prevent recursion; fixunssfdi in libgcc -+ calls fixsfdi, which in turn calls calls fixunssfdi. */ -+ -+static DItype -+local_fixunssfdi (SFtype original_a) -+{ -+ DFtype a = original_a; -+ USItype hi, lo; -+ -+ hi = a / (((UDItype) 1) << (sizeof (SItype) * 8)); -+ lo = (a - ((DFtype) hi) * (((UDItype) 1) << (sizeof (SItype) * 8))); -+ return ((UDItype) hi << (sizeof (SItype) * 8)) | lo; -+} -+ -+#endif -diff -rNU3 dist.orig/libgcc/config/riscv/t-dpbit dist/libgcc/config/riscv/t-dpbit ---- dist.orig/libgcc/config/riscv/t-dpbit 1970-01-01 01:00:00.000000000 +0100 -+++ dist/libgcc/config/riscv/t-dpbit 2015-10-18 13:19:52.000000000 +0200 -@@ -0,0 +1,4 @@ -+LIB2ADD += dp-bit.c -+ -+dp-bit.c: $(srcdir)/fp-bit.c -+ cat $(srcdir)/fp-bit.c > dp-bit.c -diff -rNU3 dist.orig/libgcc/config/riscv/t-elf dist/libgcc/config/riscv/t-elf ---- dist.orig/libgcc/config/riscv/t-elf 1970-01-01 01:00:00.000000000 +0100 -+++ dist/libgcc/config/riscv/t-elf 2015-10-18 13:19:52.000000000 +0200 -@@ -0,0 +1,2 @@ -+# Assemble startup files. -+LIB2ADD += $(srcdir)/config/riscv/riscv-fp.c -diff -rNU3 dist.orig/libgcc/config/riscv/t-fpbit dist/libgcc/config/riscv/t-fpbit ---- dist.orig/libgcc/config/riscv/t-fpbit 1970-01-01 01:00:00.000000000 +0100 -+++ dist/libgcc/config/riscv/t-fpbit 2015-10-18 13:19:52.000000000 +0200 -@@ -0,0 +1,5 @@ -+LIB2ADD += fp-bit.c -+ -+fp-bit.c: $(srcdir)/fp-bit.c -+ echo '#define FLOAT' > fp-bit.c -+ cat $(srcdir)/fp-bit.c >> fp-bit.c -diff -rNU3 dist.orig/libgcc/config/riscv/t-linux dist/libgcc/config/riscv/t-linux ---- dist.orig/libgcc/config/riscv/t-linux 1970-01-01 01:00:00.000000000 +0100 -+++ dist/libgcc/config/riscv/t-linux 2015-10-18 13:19:52.000000000 +0200 -@@ -0,0 +1 @@ -+LIB2ADD += $(srcdir)/config/riscv/riscv-fp.c -diff -rNU3 dist.orig/libgcc/config/riscv/t-tpbit dist/libgcc/config/riscv/t-tpbit ---- dist.orig/libgcc/config/riscv/t-tpbit 1970-01-01 01:00:00.000000000 +0100 -+++ dist/libgcc/config/riscv/t-tpbit 2015-10-18 13:19:52.000000000 +0200 -@@ -0,0 +1,10 @@ -+LIB2ADD += tp-bit.c -+ -+tp-bit.c: $(srcdir)/fp-bit.c -+ echo '#ifdef _RISCVEL' > tp-bit.c -+ echo '# define FLOAT_BIT_ORDER_MISMATCH' >> tp-bit.c -+ echo '#endif' >> tp-bit.c -+ echo '#if __LDBL_MANT_DIG__ == 113' >> tp-bit.c -+ echo '# define TFLOAT' >> tp-bit.c -+ cat $(srcdir)/fp-bit.c >> tp-bit.c -+ echo '#endif' >> tp-bit.c -diff -rNU3 dist.orig/libgcc/config/xtensa/unwind-dw2-xtensa.c dist/libgcc/config/xtensa/unwind-dw2-xtensa.c ---- dist.orig/libgcc/config/xtensa/unwind-dw2-xtensa.c 2013-02-04 20:06:20.000000000 +0100 -+++ dist/libgcc/config/xtensa/unwind-dw2-xtensa.c 2015-10-18 13:19:52.000000000 +0200 -@@ -172,7 +172,7 @@ - context->ra = (void *) val; - } - --void * -+_Unwind_Ptr - _Unwind_GetLanguageSpecificData (struct _Unwind_Context *context) - { - return context->lsda; -diff -rNU3 dist.orig/libgcc/config.host dist/libgcc/config.host ---- dist.orig/libgcc/config.host 2014-03-20 17:12:30.000000000 +0100 -+++ dist/libgcc/config.host 2015-10-18 13:19:52.000000000 +0200 -@@ -137,9 +137,15 @@ - cpu_type=mips - tmake_file=mips/t-mips - ;; -+or1k-*-* | or1knd-*-*) -+ cpu_type=or1k -+ ;; - powerpc*-*-*) - cpu_type=rs6000 - ;; -+riscv*-*-*) -+ cpu_type=riscv -+ ;; - rs6000*-*-*) - ;; - score*-*-*) -@@ -204,7 +210,7 @@ - extra_parts="crtbegin.o crtbeginS.o crtend.o crtendS.o" - ;; - *-*-netbsd*) -- tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-slibgcc t-slibgcc-gld t-slibgcc-elf-ver" -+ tmake_file="$tmake_file t-crtstuff-pic t-libgcc-pic t-eh-dw2-dip t-slibgcc t-slibgcc-gld t-slibgcc-elf-ver" - # NetBSD 1.7 and later are set up to use GCC's crtstuff for - # ELF configurations. We will clear extra_parts in the - # a.out configurations. -@@ -320,7 +326,16 @@ - extra_parts="$extra_parts crti.o crtn.o" - ;; - arm*-*-netbsdelf*) -- tmake_file="$tmake_file arm/t-arm arm/t-netbsd t-slibgcc-gld-nover" -+ tmake_file="$tmake_file arm/t-arm" -+ case ${host} in -+ arm*-*-netbsdelf-*eabi*) -+ tmake_file="${tmake_file} arm/t-netbsd-eabi" -+ unwind_header=config/arm/unwind-arm.h -+ ;; -+ *) -+ tmake_file="${tmake_file} arm/t-netbsd t-slibgcc-gld-nover" -+ ;; -+ esac - ;; - arm*-*-linux*) # ARM GNU/Linux with ELF - tmake_file="${tmake_file} arm/t-arm t-fixedpoint-gnu-prefix" -@@ -485,6 +500,9 @@ - hppa*-*-openbsd*) - tmake_file="$tmake_file pa/t-openbsd" - ;; -+hppa*-*-netbsd*) -+ tmake_file="$tmake_file pa/t-netbsd" -+ ;; - i[34567]86-*-darwin*) - tmake_file="$tmake_file i386/t-crtpc i386/t-crtfm" - tm_file="$tm_file i386/darwin-lib.h" -@@ -640,6 +658,10 @@ - fi - md_unwind_header=ia64/linux-unwind.h - ;; -+ia64*-*-netbsd*) -+ extra_parts="${extra_parts} crtfastmath.o" -+ tmake_file="${tmake_file} ia64/t-ia64 ia64/t-ia64-elf ia64/t-eh-ia64 t-crtfm" -+ ;; - ia64*-*-hpux*) - tmake_file="ia64/t-ia64 ia64/t-ia64-elf ia64/t-hpux t-slibgcc ia64/t-slibgcc-hpux t-slibgcc-hpux" - ;; -@@ -684,7 +706,10 @@ - m68k-*-elf* | fido-*-elf) - tmake_file="$tmake_file m68k/t-floatlib" - ;; --m68k*-*-netbsdelf*) -+m5407-*-netbsdelf*) -+ ;; -+m68k*-*-netbsdelf* | m68010-*-netbsdelf*) -+ tmake_file="$tmake_file m68k/t-floatlib" - ;; - m68k*-*-openbsd*) - ;; -@@ -801,6 +826,17 @@ - # Don't use default. - extra_parts= - ;; -+or1k*-*-linux* | or1k*-*-uclinux*) -+ tmake_file="$tmake_file or1k/t-or1k or1k/t-linux or1k/t-crtstuff t-softfp-sfdf t-softfp" -+ md_unwind_header=or1k/linux-unwind.h -+ ;; -+or1k*-*-netbsd*) -+ tmake_file="$tmake_file or1k/t-or1k" -+ ;; -+or1k*-*-*) -+ tmake_file="$tmake_file or1k/t-or1k or1k/t-linux or1k/t-crtstuff t-softfp-sfdf t-softfp" -+ extra_parts="crtbegin.o crtbeginS.o crtbeginT.o crtend.o crtendS.o crti.o crtn.o" -+ ;; - pdp11-*-*) - tmake_file="pdp11/t-pdp11 t-fdpbit" - ;; -@@ -834,8 +870,8 @@ - ;; - esac - ;; --powerpc-*-netbsd*) -- tmake_file="$tmake_file rs6000/t-netbsd rs6000/t-crtstuff" -+powerpc*-*-netbsd*) -+ tmake_file="${tmake_file} rs6000/t-netbsd rs6000/t-crtstuff" - ;; - powerpc-*-eabispe*) - tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-savresfgpr rs6000/t-crtstuff t-crtstuff-pic t-fdpbit" -@@ -892,6 +928,17 @@ - tmake_file="${tmake_file} rs6000/t-ppccomm rs6000/t-crtstuff t-crtstuff-pic t-fdpbit" - extra_parts="$extra_parts crtbegin.o crtend.o crtbeginS.o crtendS.o crtbeginT.o ecrti.o ecrtn.o ncrti.o ncrtn.o" - ;; -+riscv*-*-linux*) -+ tmake_file="${tmake_file} riscv/t-fpbit riscv/t-dpbit riscv/t-tpbit riscv/t-linux" -+ extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o crtendS.o crtbeginT.o" -+ ;; -+riscv*-*-netbsd*) -+ # nothing needed for NetBSD -+ ;; -+riscv*-*-*) -+ tmake_file="${tmake_file} riscv/t-fpbit riscv/t-dpbit riscv/t-elf" -+ extra_parts="$extra_parts crtbegin.o crtend.o crti.o crtn.o" -+ ;; - rs6000-ibm-aix4.[3456789]* | powerpc-ibm-aix4.[3456789]*) - md_unwind_header=rs6000/aix-unwind.h - tmake_file="t-fdpbit rs6000/t-ppc64-fp rs6000/t-slibgcc-aix rs6000/t-ibm-ldouble" -diff -rNU3 dist.orig/libgcc/configure dist/libgcc/configure ---- dist.orig/libgcc/configure 2012-11-05 00:08:42.000000000 +0100 -+++ dist/libgcc/configure 2015-10-18 13:19:52.000000000 +0200 -@@ -2096,7 +2096,7 @@ - for ac_t in install-sh install.sh shtool; do - if test -f "$ac_dir/$ac_t"; then - ac_aux_dir=$ac_dir -- ac_install_sh="$ac_aux_dir/$ac_t -c" -+ ac_install_sh="$SHELL $ac_aux_dir/$ac_t -c" - break 2 - fi - done -diff -rNU3 dist.orig/libgcc/unwind-compat.c dist/libgcc/unwind-compat.c ---- dist.orig/libgcc/unwind-compat.c 2013-02-04 20:06:20.000000000 +0100 -+++ dist/libgcc/unwind-compat.c 2015-10-18 13:19:52.000000000 +0200 -@@ -137,10 +137,10 @@ - return __libunwind_Unwind_GetIP (context); - } - --extern void *__libunwind_Unwind_GetLanguageSpecificData -+extern _Unwind_Ptr __libunwind_Unwind_GetLanguageSpecificData - (struct _Unwind_Context *); - --void * -+_Unwind_Ptr - _Unwind_GetLanguageSpecificData (struct _Unwind_Context *context) - { - return __libunwind_Unwind_GetLanguageSpecificData (context); -diff -rNU3 dist.orig/libgcc/unwind-dw2-fde-dip.c dist/libgcc/unwind-dw2-fde-dip.c ---- dist.orig/libgcc/unwind-dw2-fde-dip.c 2013-02-04 20:06:20.000000000 +0100 -+++ dist/libgcc/unwind-dw2-fde-dip.c 2015-10-18 13:19:52.000000000 +0200 -@@ -32,7 +32,7 @@ - - #include "tconfig.h" - #include "tsystem.h" --#if !defined(inhibit_libc) && !defined(__OpenBSD__) -+#if !defined(inhibit_libc) && defined(__GLIBC__) - #include /* Get DT_CONFIG. */ - #endif - #include "coretypes.h" -@@ -64,6 +64,12 @@ - #endif - - #if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \ -+ && defined(__NetBSD__) -+# define ElfW(type) Elf_##type -+# define USE_PT_GNU_EH_FRAME -+#endif -+ -+#if !defined(inhibit_libc) && defined(HAVE_LD_EH_FRAME_HDR) \ - && defined(__OpenBSD__) - # define ElfW(type) Elf_##type - # define USE_PT_GNU_EH_FRAME -diff -rNU3 dist.orig/libgcc/unwind-dw2-fde.c dist/libgcc/unwind-dw2-fde.c ---- dist.orig/libgcc/unwind-dw2-fde.c 2013-02-04 20:06:20.000000000 +0100 -+++ dist/libgcc/unwind-dw2-fde.c 2015-10-18 13:19:52.000000000 +0200 -@@ -213,7 +213,9 @@ - - out: - __gthread_mutex_unlock (&object_mutex); -+#if 0 - gcc_assert (ob); -+#endif - return (void *) ob; - } - -diff -rNU3 dist.orig/libgcc/unwind-dw2.c dist/libgcc/unwind-dw2.c ---- dist.orig/libgcc/unwind-dw2.c 2013-06-01 01:21:46.000000000 +0200 -+++ dist/libgcc/unwind-dw2.c 2015-10-18 13:19:52.000000000 +0200 -@@ -365,10 +365,10 @@ - context->ra = (void *) val; - } - --void * -+_Unwind_Ptr - _Unwind_GetLanguageSpecificData (struct _Unwind_Context *context) - { -- return context->lsda; -+ return (_Unwind_Ptr) context->lsda; - } - - _Unwind_Ptr -diff -rNU3 dist.orig/libgcc/unwind-generic.h dist/libgcc/unwind-generic.h ---- dist.orig/libgcc/unwind-generic.h 2013-02-04 20:06:20.000000000 +0100 -+++ dist/libgcc/unwind-generic.h 2015-10-18 13:19:52.000000000 +0200 -@@ -177,7 +177,7 @@ - /* @@@ Retrieve the CFA of the given context. */ - extern _Unwind_Word _Unwind_GetCFA (struct _Unwind_Context *); - --extern void *_Unwind_GetLanguageSpecificData (struct _Unwind_Context *); -+extern _Unwind_Ptr _Unwind_GetLanguageSpecificData (struct _Unwind_Context *); - - extern _Unwind_Ptr _Unwind_GetRegionStart (struct _Unwind_Context *); - -diff -rNU3 dist.orig/libgcc/unwind-seh.c dist/libgcc/unwind-seh.c ---- dist.orig/libgcc/unwind-seh.c 2014-02-18 18:04:38.000000000 +0100 -+++ dist/libgcc/unwind-seh.c 2015-10-18 13:19:52.000000000 +0200 -@@ -131,8 +131,8 @@ - c->ra = val; - } - --void * --_Unwind_GetLanguageSpecificData (struct _Unwind_Context *c) -+_Unwind_Ptr -+_Unwind_GetLanguageSpecificData (struct _Unwind_Context *c - { - return c->disp->HandlerData; - } -diff -rNU3 dist.orig/libgcc/unwind-sjlj.c dist/libgcc/unwind-sjlj.c ---- dist.orig/libgcc/unwind-sjlj.c 2013-02-04 20:06:20.000000000 +0100 -+++ dist/libgcc/unwind-sjlj.c 2015-10-18 13:19:52.000000000 +0200 -@@ -231,10 +231,10 @@ - context->fc->call_site = val - 1; - } - --void * -+_Unwind_Ptr - _Unwind_GetLanguageSpecificData (struct _Unwind_Context *context) - { -- return context->fc->lsda; -+ return (_Unwind_Ptr) context->fc->lsda; - } - - _Unwind_Ptr -diff -rNU3 dist.orig/libgomp/Makefile.am dist/libgomp/Makefile.am ---- dist.orig/libgomp/Makefile.am 2012-02-27 14:51:50.000000000 +0100 -+++ dist/libgomp/Makefile.am 2015-10-18 13:19:52.000000000 +0200 -@@ -1,7 +1,7 @@ - ## Process this file with automake to produce Makefile.in - - ACLOCAL_AMFLAGS = -I .. -I ../config --SUBDIRS = testsuite -+SUBDIRS = - - ## May be used by toolexeclibdir. - gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER) -diff -rNU3 dist.orig/libgomp/Makefile.in dist/libgomp/Makefile.in ---- dist.orig/libgomp/Makefile.in 2015-06-23 09:55:27.000000000 +0200 -+++ dist/libgomp/Makefile.in 2015-10-18 13:19:52.000000000 +0200 -@@ -288,7 +288,7 @@ - top_builddir = @top_builddir@ - top_srcdir = @top_srcdir@ - ACLOCAL_AMFLAGS = -I .. -I ../config --SUBDIRS = testsuite -+SUBDIRS = - gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER) - search_path = $(addprefix $(top_srcdir)/config/, $(config_path)) $(top_srcdir) - fincludedir = $(libdir)/gcc/$(target_alias)/$(gcc_version)/finclude -diff -rNU3 dist.orig/libgomp/configure dist/libgomp/configure ---- dist.orig/libgomp/configure 2015-06-23 09:55:27.000000000 +0200 -+++ dist/libgomp/configure 2015-10-18 13:19:52.000000000 +0200 -@@ -2620,7 +2620,7 @@ - for ac_t in install-sh install.sh shtool; do - if test -f "$ac_dir/$ac_t"; then - ac_aux_dir=$ac_dir -- ac_install_sh="$ac_aux_dir/$ac_t -c" -+ ac_install_sh="$SHELL $ac_aux_dir/$ac_t -c" - break 2 - fi - done -@@ -16268,7 +16268,7 @@ - - ac_config_files="$ac_config_files omp.h omp_lib.h omp_lib.f90 libgomp_f.h" - --ac_config_files="$ac_config_files Makefile testsuite/Makefile libgomp.spec" -+ac_config_files="$ac_config_files Makefile libgomp.spec" - - cat >confcache <<\_ACEOF - # This file is a shell script that caches the results of configure -@@ -17408,7 +17408,6 @@ - "omp_lib.f90") CONFIG_FILES="$CONFIG_FILES omp_lib.f90" ;; - "libgomp_f.h") CONFIG_FILES="$CONFIG_FILES libgomp_f.h" ;; - "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; -- "testsuite/Makefile") CONFIG_FILES="$CONFIG_FILES testsuite/Makefile" ;; - "libgomp.spec") CONFIG_FILES="$CONFIG_FILES libgomp.spec" ;; - - *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; -diff -rNU3 dist.orig/libgomp/configure.ac dist/libgomp/configure.ac ---- dist.orig/libgomp/configure.ac 2010-12-06 01:50:04.000000000 +0100 -+++ dist/libgomp/configure.ac 2015-10-18 13:19:52.000000000 +0200 -@@ -346,5 +346,5 @@ - CFLAGS="$save_CFLAGS" - - AC_CONFIG_FILES(omp.h omp_lib.h omp_lib.f90 libgomp_f.h) --AC_CONFIG_FILES(Makefile testsuite/Makefile libgomp.spec) -+AC_CONFIG_FILES(Makefile libgomp.spec) - AC_OUTPUT -diff -rNU3 dist.orig/libiberty/.gitignore dist/libiberty/.gitignore ---- dist.orig/libiberty/.gitignore 2011-01-18 06:06:50.000000000 +0100 -+++ dist/libiberty/.gitignore 1970-01-01 01:00:00.000000000 +0100 -@@ -1,2 +0,0 @@ --/required-list --/xhost-mkfrag -diff -rNU3 dist.orig/libiberty/Makefile.in dist/libiberty/Makefile.in ---- dist.orig/libiberty/Makefile.in 2013-01-02 03:04:42.000000000 +0100 -+++ dist/libiberty/Makefile.in 2015-10-18 13:19:52.000000000 +0200 -@@ -98,7 +98,7 @@ - "tooldir=$(tooldir)" - - # Subdirectories to recurse into. We need to override this during cleaning --SUBDIRS = testsuite -+SUBDIRS = - - # FIXME: add @BUILD_INFO@ once we're sure it works for everyone. - all: stamp-picdir $(TARGETLIB) required-list all-subdir -@@ -444,7 +444,6 @@ - @$(MULTICLEAN) multi-clean DO=distclean - -rm -f *~ Makefile config.cache config.status xhost-mkfrag TAGS multilib.out - -rm -f config.log -- -rmdir testsuite 2>/dev/null - maintainer-clean realclean: maintainer-clean-subdir - $(MAKE) SUBDIRS="" distclean - -diff -rNU3 dist.orig/libiberty/configure dist/libiberty/configure ---- dist.orig/libiberty/configure 2012-09-18 18:03:01.000000000 +0200 -+++ dist/libiberty/configure 2015-10-18 13:19:52.000000000 +0200 -@@ -2351,7 +2351,7 @@ - for ac_t in install-sh install.sh shtool; do - if test -f "$ac_dir/$ac_t"; then - ac_aux_dir=$ac_dir -- ac_install_sh="$ac_aux_dir/$ac_t -c" -+ ac_install_sh="$SHELL $ac_aux_dir/$ac_t -c" - break 2 - fi - done -@@ -6941,7 +6941,7 @@ - - - # We need multilib support, but only if configuring for the target. --ac_config_files="$ac_config_files Makefile testsuite/Makefile" -+ac_config_files="$ac_config_files Makefile" - - ac_config_commands="$ac_config_commands default" - -@@ -7645,7 +7645,6 @@ - case $ac_config_target in - "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h:config.in" ;; - "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; -- "testsuite/Makefile") CONFIG_FILES="$CONFIG_FILES testsuite/Makefile" ;; - "default") CONFIG_COMMANDS="$CONFIG_COMMANDS default" ;; - - *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; -diff -rNU3 dist.orig/libiberty/configure.ac dist/libiberty/configure.ac ---- dist.orig/libiberty/configure.ac 2012-09-18 18:03:01.000000000 +0200 -+++ dist/libiberty/configure.ac 2015-10-18 13:19:52.000000000 +0200 -@@ -695,7 +695,7 @@ - AC_SUBST(htmldir) - - # We need multilib support, but only if configuring for the target. --AC_CONFIG_FILES([Makefile testsuite/Makefile]) -+AC_CONFIG_FILES([Makefile]) - AC_CONFIG_COMMANDS([default], - [[test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h - if test -n "$CONFIG_FILES"; then -diff -rNU3 dist.orig/libiberty/floatformat.c dist/libiberty/floatformat.c ---- dist.orig/libiberty/floatformat.c 2012-08-17 23:56:48.000000000 +0200 -+++ dist/libiberty/floatformat.c 2015-10-18 13:19:52.000000000 +0200 -@@ -488,7 +488,11 @@ - if (nan) - dto = NAN; - else -+#ifdef __vax__ -+ dto = HUGE_VAL; -+#else - dto = INFINITY; -+#endif - - if (get_field (ufrom, fmt->byteorder, fmt->totalsize, fmt->sign_start, 1)) - dto = -dto; -diff -rNU3 dist.orig/libiberty/make-temp-file.c dist/libiberty/make-temp-file.c ---- dist.orig/libiberty/make-temp-file.c 2011-01-03 21:52:22.000000000 +0100 -+++ dist/libiberty/make-temp-file.c 2015-10-18 13:19:52.000000000 +0200 -@@ -130,10 +130,10 @@ - base = try_dir (P_tmpdir, base); - #endif - -- /* Try /var/tmp, /usr/tmp, then /tmp. */ -+ /* Try /tmp, /var/tmp, then /usr/tmp. */ -+ base = try_dir (tmp, base); - base = try_dir (vartmp, base); - base = try_dir (usrtmp, base); -- base = try_dir (tmp, base); - - /* If all else fails, use the current directory! */ - if (base == 0) -diff -rNU3 dist.orig/libiberty/strerror.c dist/libiberty/strerror.c ---- dist.orig/libiberty/strerror.c 2005-03-28 03:28:01.000000000 +0200 -+++ dist/libiberty/strerror.c 2015-10-18 13:19:52.000000000 +0200 -@@ -347,7 +347,7 @@ - ENTRY(EPROTOTYPE, "EPROTOTYPE", "Protocol wrong type for socket"), - #endif - #if defined (ENOPROTOOPT) -- ENTRY(ENOPROTOOPT, "ENOPROTOOPT", "Protocol not available"), -+ ENTRY(ENOPROTOOPT, "ENOPROTOOPT", "Protocol option not available"), - #endif - #if defined (EPROTONOSUPPORT) - ENTRY(EPROTONOSUPPORT, "EPROTONOSUPPORT", "Protocol not supported"), -diff -rNU3 dist.orig/libitm/Makefile.am dist/libitm/Makefile.am ---- dist.orig/libitm/Makefile.am 2012-02-14 14:14:27.000000000 +0100 -+++ dist/libitm/Makefile.am 2015-10-18 13:19:52.000000000 +0200 -@@ -1,7 +1,7 @@ - ## Process this file with automake to produce Makefile.in - - ACLOCAL_AMFLAGS = -I .. -I ../config --SUBDIRS = testsuite -+SUBDIRS = - - ## May be used by toolexeclibdir. - gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER) -diff -rNU3 dist.orig/libitm/Makefile.in dist/libitm/Makefile.in ---- dist.orig/libitm/Makefile.in 2015-06-23 09:55:27.000000000 +0200 -+++ dist/libitm/Makefile.in 2015-10-18 13:19:52.000000000 +0200 -@@ -302,7 +302,7 @@ - top_builddir = @top_builddir@ - top_srcdir = @top_srcdir@ - ACLOCAL_AMFLAGS = -I .. -I ../config --SUBDIRS = testsuite -+SUBDIRS = - gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER) - abi_version = -fabi-version=4 - search_path = $(addprefix $(top_srcdir)/config/, $(config_path)) $(top_srcdir) -diff -rNU3 dist.orig/libitm/configure dist/libitm/configure ---- dist.orig/libitm/configure 2015-06-23 09:55:27.000000000 +0200 -+++ dist/libitm/configure 2015-10-18 13:19:52.000000000 +0200 -@@ -2707,7 +2707,7 @@ - for ac_t in install-sh install.sh shtool; do - if test -f "$ac_dir/$ac_t"; then - ac_aux_dir=$ac_dir -- ac_install_sh="$ac_aux_dir/$ac_t -c" -+ ac_install_sh="$SHELL $ac_aux_dir/$ac_t -c" - break 2 - fi - done -@@ -17631,7 +17631,7 @@ - fi - - --ac_config_files="$ac_config_files Makefile testsuite/Makefile libitm.spec" -+ac_config_files="$ac_config_files Makefile libitm.spec" - - cat >confcache <<\_ACEOF - # This file is a shell script that caches the results of configure -@@ -18792,7 +18792,6 @@ - "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; - "gstdint.h") CONFIG_COMMANDS="$CONFIG_COMMANDS gstdint.h" ;; - "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; -- "testsuite/Makefile") CONFIG_FILES="$CONFIG_FILES testsuite/Makefile" ;; - "libitm.spec") CONFIG_FILES="$CONFIG_FILES libitm.spec" ;; - - *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; -diff -rNU3 dist.orig/libitm/configure.ac dist/libitm/configure.ac ---- dist.orig/libitm/configure.ac 2013-08-02 17:41:10.000000000 +0200 -+++ dist/libitm/configure.ac 2015-10-18 13:19:52.000000000 +0200 -@@ -286,5 +286,5 @@ - AM_CONDITIONAL([ARCH_X86_AVX], [test "$libitm_cv_as_avx" = yes]) - AM_CONDITIONAL([ARCH_FUTEX], [test $enable_linux_futex = yes]) - --AC_CONFIG_FILES(Makefile testsuite/Makefile libitm.spec) -+AC_CONFIG_FILES(Makefile libitm.spec) - AC_OUTPUT -diff -rNU3 dist.orig/libmudflap/Makefile.am dist/libmudflap/Makefile.am ---- dist.orig/libmudflap/Makefile.am 2013-02-03 18:48:05.000000000 +0100 -+++ dist/libmudflap/Makefile.am 2015-10-18 13:19:52.000000000 +0200 -@@ -6,7 +6,7 @@ - AUTOMAKE_OPTIONS = 1.8 foreign - ACLOCAL_AMFLAGS = -I .. -I ../config - MAINT_CHARSET = latin1 --SUBDIRS = testsuite -+SUBDIRS = - - # May be used by various substitution variables. - gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER) -diff -rNU3 dist.orig/libmudflap/Makefile.in dist/libmudflap/Makefile.in ---- dist.orig/libmudflap/Makefile.in 2010-05-04 20:58:11.000000000 +0200 -+++ dist/libmudflap/Makefile.in 2015-10-18 13:19:52.000000000 +0200 -@@ -261,7 +261,7 @@ - AUTOMAKE_OPTIONS = 1.8 foreign - ACLOCAL_AMFLAGS = -I .. -I ../config - MAINT_CHARSET = latin1 --SUBDIRS = testsuite -+SUBDIRS = - - # May be used by various substitution variables. - gcc_version := $(shell cat $(top_srcdir)/../gcc/BASE-VER) -diff -rNU3 dist.orig/libmudflap/configure dist/libmudflap/configure ---- dist.orig/libmudflap/configure 2014-04-04 15:53:39.000000000 +0200 -+++ dist/libmudflap/configure 2015-10-18 13:19:52.000000000 +0200 -@@ -2182,7 +2182,7 @@ - for ac_t in install-sh install.sh shtool; do - if test -f "$ac_dir/$ac_t"; then - ac_aux_dir=$ac_dir -- ac_install_sh="$ac_aux_dir/$ac_t -c" -+ ac_install_sh="$SHELL $ac_aux_dir/$ac_t -c" - break 2 - fi - done -@@ -11687,7 +11687,7 @@ - - fi - --ac_config_files="$ac_config_files Makefile testsuite/Makefile testsuite/mfconfig.exp" -+ac_config_files="$ac_config_files Makefile" - - cat >confcache <<\_ACEOF - # This file is a shell script that caches the results of configure -@@ -12682,8 +12682,6 @@ - "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; - "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;; - "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; -- "testsuite/Makefile") CONFIG_FILES="$CONFIG_FILES testsuite/Makefile" ;; -- "testsuite/mfconfig.exp") CONFIG_FILES="$CONFIG_FILES testsuite/mfconfig.exp" ;; - - *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; - esac -diff -rNU3 dist.orig/libmudflap/configure.ac dist/libmudflap/configure.ac ---- dist.orig/libmudflap/configure.ac 2011-07-13 16:57:29.000000000 +0200 -+++ dist/libmudflap/configure.ac 2015-10-18 13:19:52.000000000 +0200 -@@ -266,5 +266,5 @@ - GCC_CHECK_TLS - GCC_CHECK_EMUTLS - --AC_CONFIG_FILES([Makefile testsuite/Makefile testsuite/mfconfig.exp]) -+AC_CONFIG_FILES([Makefile]) - AC_OUTPUT -diff -rNU3 dist.orig/libmudflap/mf-hooks1.c dist/libmudflap/mf-hooks1.c ---- dist.orig/libmudflap/mf-hooks1.c 2013-02-03 18:48:05.000000000 +0100 -+++ dist/libmudflap/mf-hooks1.c 2015-10-18 13:19:52.000000000 +0200 -@@ -33,7 +33,7 @@ - - /* These attempt to coax various unix flavours to declare all our - needed tidbits in the system headers. */ --#if !defined(__FreeBSD__) && !defined(__APPLE__) -+#if !defined(__FreeBSD__) && !defined(__APPLE__) && !defined(__NetBSD__) - #define _POSIX_SOURCE - #endif /* Some BSDs break if this is defined. */ - #define _GNU_SOURCE -diff -rNU3 dist.orig/libmudflap/mf-hooks2.c dist/libmudflap/mf-hooks2.c ---- dist.orig/libmudflap/mf-hooks2.c 2013-02-03 18:48:05.000000000 +0100 -+++ dist/libmudflap/mf-hooks2.c 2015-10-18 13:19:52.000000000 +0200 -@@ -32,9 +32,10 @@ - - /* These attempt to coax various unix flavours to declare all our - needed tidbits in the system headers. */ --#if !defined(__FreeBSD__) && !defined(__APPLE__) -+#if !defined(__FreeBSD__) && !defined(__APPLE__) && !defined(__NetBSD__) - #define _POSIX_SOURCE - #endif /* Some BSDs break if this is defined. */ -+#define _NETBSD_SOURCE - #define _GNU_SOURCE - #define _XOPEN_SOURCE - #define _BSD_TYPES -diff -rNU3 dist.orig/libmudflap/mf-impl.h dist/libmudflap/mf-impl.h ---- dist.orig/libmudflap/mf-impl.h 2013-02-03 18:48:05.000000000 +0100 -+++ dist/libmudflap/mf-impl.h 2015-10-18 13:19:52.000000000 +0200 -@@ -276,12 +276,12 @@ - #ifdef LIBMUDFLAPTH - #define VERBOSE_TRACE(...) \ - do { if (UNLIKELY (__mf_opts.verbose_trace)) { \ -- fprintf (stderr, "mf(%u): ", (unsigned) pthread_self ()); \ -+ fprintf (stderr, "mf(%ju): ", (intmax_t)(intptr_t) pthread_self ()); \ - fprintf (stderr, __VA_ARGS__); \ - } } while (0) - #define TRACE(...) \ - do { if (UNLIKELY (__mf_opts.trace_mf_calls)) { \ -- fprintf (stderr, "mf(%u): ", (unsigned) pthread_self ()); \ -+ fprintf (stderr, "mf(%ju): ", (intmax_t)(intptr_t) pthread_self ()); \ - fprintf (stderr, __VA_ARGS__); \ - } } while (0) - #else -@@ -399,6 +399,29 @@ - TRACE ("%s\n", __PRETTY_FUNCTION__); \ - } - -+#define BEGIN_PROTECTV(fname, ...) \ -+ if (UNLIKELY (__mf_starting_p)) \ -+ { \ -+ CALL_BACKUP(fname, __VA_ARGS__); \ -+ return; \ -+ } \ -+ else if (UNLIKELY (__mf_get_state () == reentrant)) \ -+ { \ -+ extern unsigned long __mf_reentrancy; \ -+ __mf_reentrancy ++; \ -+ CALL_REAL(fname, __VA_ARGS__); \ -+ return; \ -+ } \ -+ else if (UNLIKELY (__mf_get_state () == in_malloc)) \ -+ { \ -+ CALL_REAL(fname, __VA_ARGS__); \ -+ return; \ -+ } \ -+ else \ -+ { \ -+ TRACE ("%s\n", __PRETTY_FUNCTION__); \ -+ } -+ - /* There is an assumption here that these will only be called in routines - that call BEGIN_PROTECT at the start, and hence the state must always - be active when BEGIN_MALLOC_PROTECT is called. */ -diff -rNU3 dist.orig/libmudflap/mf-runtime.c dist/libmudflap/mf-runtime.c ---- dist.orig/libmudflap/mf-runtime.c 2013-02-03 18:48:05.000000000 +0100 -+++ dist/libmudflap/mf-runtime.c 2015-10-18 13:19:52.000000000 +0200 -@@ -30,9 +30,10 @@ - - /* These attempt to coax various unix flavours to declare all our - needed tidbits in the system headers. */ --#if !defined(__FreeBSD__) && !defined(__APPLE__) -+#if !defined(__FreeBSD__) && !defined(__APPLE__) && !defined(__NetBSD__) - #define _POSIX_SOURCE - #endif /* Some BSDs break if this is defined. */ -+#define _NETBSD_SOURCE - #define _GNU_SOURCE - #define _XOPEN_SOURCE - #define _BSD_TYPES -@@ -164,7 +165,7 @@ - #define LOOKUP_CACHE_SHIFT_DFL 2 - - struct __mf_cache __mf_lookup_cache [LOOKUP_CACHE_SIZE_MAX]; --uintptr_t __mf_lc_mask = LOOKUP_CACHE_MASK_DFL; -+__mf_uintptr_t __mf_lc_mask = LOOKUP_CACHE_MASK_DFL; - unsigned char __mf_lc_shift = LOOKUP_CACHE_SHIFT_DFL; - #define LOOKUP_CACHE_SIZE (__mf_lc_mask + 1) - -@@ -191,12 +192,18 @@ - /* Use HAVE_PTHREAD_H here instead of LIBMUDFLAPTH, so that even - the libmudflap.la (no threading support) can diagnose whether - the application is linked with -lpthread. See __mf_usage() below. */ --#if HAVE_PTHREAD_H --#ifdef _POSIX_THREADS --#pragma weak pthread_join -+#ifdef LIBMUDFLAPTH -+# if HAVE_PTHREAD_H -+# ifdef _POSIX_THREADS -+# include -+# else -+# define pthread_join NULL -+# endif -+# else -+# define pthread_join NULL -+# endif - #else --#define pthread_join NULL --#endif -+# define pthread_join NULL - #endif - - -@@ -1774,7 +1781,7 @@ - "bounds=[%p,%p] size=%lu area=%s check=%ur/%uw liveness=%u%s\n" - "alloc time=%lu.%06lu pc=%p" - #ifdef LIBMUDFLAPTH -- " thread=%u" -+ " thread=%ju" - #endif - "\n", - (obj->deallocated_p ? "dead " : ""), -@@ -1793,7 +1800,7 @@ - obj->alloc_time.tv_sec, obj->alloc_time.tv_usec, - (void *) obj->alloc_pc - #ifdef LIBMUDFLAPTH -- , (unsigned) obj->alloc_thread -+ , (intmax_t)(intptr_t)obj->alloc_thread - #endif - ); - -@@ -1810,13 +1817,13 @@ - { - fprintf (stderr, "dealloc time=%lu.%06lu pc=%p" - #ifdef LIBMUDFLAPTH -- " thread=%u" -+ " thread=%ju" - #endif - "\n", - obj->dealloc_time.tv_sec, obj->dealloc_time.tv_usec, - (void *) obj->dealloc_pc - #ifdef LIBMUDFLAPTH -- , (unsigned) obj->dealloc_thread -+ , (intmax_t)(intptr_t)obj->dealloc_thread - #endif - ); - -@@ -2330,7 +2337,7 @@ - #ifndef NDEBUG - - static void --write_itoa (int fd, unsigned n) -+write_itoa (int fd, intmax_t n) - { - enum x { bufsize = sizeof(n)*4 }; - char buf [bufsize]; -@@ -2359,7 +2366,7 @@ - write2("mf"); - #ifdef LIBMUDFLAPTH - write2("("); -- write_itoa (2, (unsigned) pthread_self ()); -+ write_itoa (2, (intmax_t)(intptr_t)pthread_self ()); - write2(")"); - #endif - write2(": assertion failure: `"); -diff -rNU3 dist.orig/libmudflap/mf-runtime.h dist/libmudflap/mf-runtime.h ---- dist.orig/libmudflap/mf-runtime.h 2013-02-03 18:48:05.000000000 +0100 -+++ dist/libmudflap/mf-runtime.h 2015-10-18 13:19:52.000000000 +0200 -@@ -31,7 +31,7 @@ - #define MF_RUNTIME_H - - typedef void *__mf_ptr_t; --typedef unsigned int __mf_uintptr_t __attribute__ ((__mode__ (__pointer__))); -+typedef unsigned long __mf_uintptr_t __attribute__ ((__mode__ (__pointer__))); - typedef __SIZE_TYPE__ __mf_size_t; - - /* Global declarations used by instrumentation. When _MUDFLAP is -@@ -81,11 +81,11 @@ - #endif - - extern void __mf_check (void *ptr, __mf_size_t sz, int type, const char *location) -- __attribute((nothrow)); -+ __attribute__((nothrow)); - extern void __mf_register (void *ptr, __mf_size_t sz, int type, const char *name) -- __attribute((nothrow)); -+ __attribute__((nothrow)); - extern void __mf_unregister (void *ptr, __mf_size_t sz, int type) -- __attribute((nothrow)); -+ __attribute__((nothrow)); - extern unsigned __mf_watch (void *ptr, __mf_size_t sz); - extern unsigned __mf_unwatch (void *ptr, __mf_size_t sz); - extern void __mf_report (); -diff -rNU3 dist.orig/libobjc/configure dist/libobjc/configure ---- dist.orig/libobjc/configure 2014-04-04 15:53:39.000000000 +0200 -+++ dist/libobjc/configure 2015-10-18 13:19:52.000000000 +0200 -@@ -2169,7 +2169,7 @@ - for ac_t in install-sh install.sh shtool; do - if test -f "$ac_dir/$ac_t"; then - ac_aux_dir=$ac_dir -- ac_install_sh="$ac_aux_dir/$ac_t -c" -+ ac_install_sh="$SHELL $ac_aux_dir/$ac_t -c" - break 2 - fi - done -diff -rNU3 dist.orig/libobjc/encoding.c dist/libobjc/encoding.c ---- dist.orig/libobjc/encoding.c 2014-07-28 16:33:20.000000000 +0200 -+++ dist/libobjc/encoding.c 2015-10-18 13:19:52.000000000 +0200 -@@ -645,7 +645,11 @@ - return ROUND (size, wordsize); - } - --inline -+/* -+ Skip type qualifiers. These may eventually precede typespecs -+ occurring in method prototype encodings. -+*/ -+ - const char * - objc_skip_type_qualifiers (const char *type) - { -@@ -663,7 +667,6 @@ - return type; - } - --inline - const char * - objc_skip_typespec (const char *type) - { -@@ -794,7 +797,10 @@ - } - } - --inline -+/* -+ Skip an offset as part of a method encoding. This is prepended by a -+ '+' if the argument is passed in registers. -+*/ - const char * - objc_skip_offset (const char *type) - { -diff -rNU3 dist.orig/libobjc/hash.c dist/libobjc/hash.c ---- dist.orig/libobjc/hash.c 2013-02-03 12:16:21.000000000 +0100 -+++ dist/libobjc/hash.c 2015-10-18 13:19:52.000000000 +0200 -@@ -151,8 +151,8 @@ - (*cachep)->hash_func, - (*cachep)->compare_func); - -- DEBUG_PRINTF ("Expanding cache %#x from %d to %d\n", -- (int) *cachep, (*cachep)->size, new->size); -+ DEBUG_PRINTF ("Expanding cache %p from %d to %d\n", -+ *cachep, (*cachep)->size, new->size); - - /* Copy the nodes from the first hash table to the new one. */ - while ((node1 = objc_hash_next (*cachep, node1))) -diff -rNU3 dist.orig/libobjc/objects.c dist/libobjc/objects.c ---- dist.orig/libobjc/objects.c 2013-02-03 12:16:21.000000000 +0100 -+++ dist/libobjc/objects.c 2015-10-18 13:19:52.000000000 +0200 -@@ -36,7 +36,6 @@ - #endif - - /* FIXME: The semantics of extraBytes are not really clear. */ --inline - id - class_createInstance (Class class, size_t extraBytes) - { -diff -rNU3 dist.orig/libobjc/sendmsg.c dist/libobjc/sendmsg.c ---- dist.orig/libobjc/sendmsg.c 2013-02-03 12:16:21.000000000 +0100 -+++ dist/libobjc/sendmsg.c 2015-10-18 13:19:52.000000000 +0200 -@@ -105,7 +105,6 @@ - id nil_method (id, SEL); - - /* Given a selector, return the proper forwarding implementation. */ --inline - IMP - __objc_get_forward_imp (id rcv, SEL sel) - { -@@ -320,7 +319,6 @@ - return res; - } - --inline - IMP - get_imp (Class class, SEL sel) - { -@@ -364,7 +362,6 @@ - method can be forwarded. Since this requires the dispatch table to - installed, this function will implicitly invoke +initialize for the - class of OBJECT if it hasn't been invoked yet. */ --inline - BOOL - __objc_responds_to (id object, SEL sel) - { -diff -rNU3 dist.orig/libsanitizer/asan/asan_intercepted_functions.h dist/libsanitizer/asan/asan_intercepted_functions.h ---- dist.orig/libsanitizer/asan/asan_intercepted_functions.h 2013-02-21 11:57:10.000000000 +0100 -+++ dist/libsanitizer/asan/asan_intercepted_functions.h 2015-10-18 13:19:52.000000000 +0200 -@@ -41,7 +41,7 @@ - # define ASAN_INTERCEPT_MLOCKX 0 - #endif - --#if defined(__linux__) -+#if defined(__linux__) || defined(__NetBSD__) - # define ASAN_USE_ALIAS_ATTRIBUTE_FOR_INDEX 1 - #else - # define ASAN_USE_ALIAS_ATTRIBUTE_FOR_INDEX 0 -@@ -53,7 +53,7 @@ - # define ASAN_INTERCEPT_STRNLEN 0 - #endif - --#if defined(__linux__) && !defined(ANDROID) -+#if (defined(__linux__) || defined(__NetBSD__)) && !defined(ANDROID) - # define ASAN_INTERCEPT_SWAPCONTEXT 1 - #else - # define ASAN_INTERCEPT_SWAPCONTEXT 0 -diff -rNU3 dist.orig/libsanitizer/asan/asan_internal.h dist/libsanitizer/asan/asan_internal.h ---- dist.orig/libsanitizer/asan/asan_internal.h 2013-02-21 11:57:10.000000000 +0100 -+++ dist/libsanitizer/asan/asan_internal.h 2015-10-18 13:19:52.000000000 +0200 -@@ -19,13 +19,13 @@ - #include "sanitizer_common/sanitizer_stacktrace.h" - #include "sanitizer_common/sanitizer_libc.h" - --#if !defined(__linux__) && !defined(__APPLE__) && !defined(_WIN32) -+#if !defined(__linux__) && !defined(__APPLE__) && !defined(_WIN32) && !defined(__NetBSD__) - # error "This operating system is not supported by AddressSanitizer" - #endif - - #define ASAN_DEFAULT_FAILURE_EXITCODE 1 - --#if defined(__linux__) -+#if defined(__linux__) || defined(__NetBSD__) - # define ASAN_LINUX 1 - #else - # define ASAN_LINUX 0 -diff -rNU3 dist.orig/libsanitizer/asan/asan_linux.cc dist/libsanitizer/asan/asan_linux.cc ---- dist.orig/libsanitizer/asan/asan_linux.cc 2013-01-23 12:41:33.000000000 +0100 -+++ dist/libsanitizer/asan/asan_linux.cc 2015-10-18 13:19:52.000000000 +0200 -@@ -9,7 +9,7 @@ - // - // Linux-specific details. - //===----------------------------------------------------------------------===// --#ifdef __linux__ -+#if defined(__linux__) || defined(__NetBSD__) - - #include "asan_interceptors.h" - #include "asan_internal.h" -@@ -25,6 +25,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -48,7 +49,42 @@ - } - - void GetPcSpBp(void *context, uptr *pc, uptr *sp, uptr *bp) { --#if ASAN_ANDROID -+#ifdef __NetBSD__ -+# define __UC_MACHINE_FP(ucontext, r) \ -+ (ucontext)->uc_mcontext.__gregs[(r)] -+/* -+ * Unfortunately we don't have a portable frame pointer (yet) -+ */ -+# if defined(__alpha__) -+# define _UC_MACHINE_FP(ucontext) __UC_MACHINE_FP(ucontext, _REG_S6) -+# elif defined(__arm__) -+# define _UC_MACHINE_FP(ucontext) __UC_MACHINE_FP(ucontext, _REG_FP) -+# elif defined(__x86_64__) -+# define _UC_MACHINE_FP(ucontext) __UC_MACHINE_FP(ucontext, _REG_RBP) -+# elif defined(__i386__) -+# define _UC_MACHINE_FP(ucontext) __UC_MACHINE_FP(ucontext, _REG_EBP) -+# elif defined(__m68k__) -+# define _UC_MACHINE_FP(ucontext) __UC_MACHINE_FP(ucontext, _REG_A6) -+# elif defined(__mips__) -+# define _UC_MACHINE_FP(ucontext) __UC_MACHINE_FP(ucontext, _REG_S8) -+# elif defined(__powerpc__) || defined(__powerpc64__) -+# define _UC_MACHINE_FP(ucontext) __UC_MACHINE_FP(ucontext, _REG_R1) -+# elif defined(__riscv__) -+# define _UC_MACHINE_FP(ucontext) __UC_MACHINE_FP(ucontext, _REG_S0) -+# elif defined(__sparc__) -+# define _UC_MACHINE_FP(ucontext) sp[15] -+# elif defined(__sh3__) -+# define _UC_MACHINE_FP(ucontext) __UC_MACHINE_FP(ucontext, _REG_R14) -+# elif defined(__vax__) -+# define _UC_MACHINE_FP(ucontext) __UC_MACHINE_FP(ucontext, _REG_FP) -+# else -+# define _UC_MACHINE_FP(ucontext) 0 -+# endif -+ ucontext_t *ucontext = (ucontext_t*)context; -+ *pc = _UC_MACHINE_PC(ucontext); -+ *sp = _UC_MACHINE_SP(ucontext); -+ *bp = _UC_MACHINE_FP(ucontext); -+#elif ASAN_ANDROID - *pc = *sp = *bp = 0; - #elif defined(__arm__) - ucontext_t *ucontext = (ucontext_t*)context; -@@ -72,6 +108,11 @@ - // The powerpc{,64}-linux ABIs do not specify r31 as the frame - // pointer, but GCC always uses r31 when we need a frame pointer. - *bp = ucontext->uc_mcontext.regs->gpr[PT_R31]; -+# elif defined(__riscv__) -+ ucontext_t *ucontext = (ucontext_t*)context; -+ *pc = ucontext->uc_mcontext.gregs[REG_PC]; -+ *bp = ucontext->uc_mcontext.gregs[REG_S0]; -+ *sp = ucontext->uc_mcontext.gregs[REG_SP]; - # elif defined(__sparc__) - ucontext_t *ucontext = (ucontext_t*)context; - uptr *stk_ptr; -@@ -131,4 +172,4 @@ - - } // namespace __asan - --#endif // __linux__ -+#endif // __linux__ || __NetBSD__ -diff -rNU3 dist.orig/libsanitizer/asan/asan_malloc_linux.cc dist/libsanitizer/asan/asan_malloc_linux.cc ---- dist.orig/libsanitizer/asan/asan_malloc_linux.cc 2013-02-13 11:46:01.000000000 +0100 -+++ dist/libsanitizer/asan/asan_malloc_linux.cc 2015-10-18 13:19:52.000000000 +0200 -@@ -11,7 +11,7 @@ - // We simply define functions like malloc, free, realloc, etc. - // They will replace the corresponding libc functions automagically. - //===----------------------------------------------------------------------===// --#ifdef __linux__ -+#if defined(__linux__) || defined(__NetBSD__) - - #include "asan_allocator.h" - #include "asan_interceptors.h" -@@ -144,4 +144,4 @@ - __asan_print_accumulated_stats(); - } - --#endif // __linux__ -+#endif // __linux__ || __NetBSD__ -diff -rNU3 dist.orig/libsanitizer/asan/asan_posix.cc dist/libsanitizer/asan/asan_posix.cc ---- dist.orig/libsanitizer/asan/asan_posix.cc 2012-11-12 16:53:47.000000000 +0100 -+++ dist/libsanitizer/asan/asan_posix.cc 2015-10-18 13:19:52.000000000 +0200 -@@ -9,7 +9,7 @@ - // - // Posix-specific details. - //===----------------------------------------------------------------------===// --#if defined(__linux__) || defined(__APPLE__) -+#if defined(__linux__) || defined(__APPLE__) || defined(__NetBSD__) - - #include "asan_internal.h" - #include "asan_interceptors.h" -@@ -115,4 +115,4 @@ - - } // namespace __asan - --#endif // __linux__ || __APPLE_ -+#endif // __linux__ || __APPLE_ || __NetBSD__ -diff -rNU3 dist.orig/libsanitizer/configure dist/libsanitizer/configure ---- dist.orig/libsanitizer/configure 2015-06-23 09:55:27.000000000 +0200 -+++ dist/libsanitizer/configure 2015-10-18 13:19:52.000000000 +0200 -@@ -2478,7 +2478,7 @@ - for ac_t in install-sh install.sh shtool; do - if test -f "$ac_dir/$ac_t"; then - ac_aux_dir=$ac_dir -- ac_install_sh="$ac_aux_dir/$ac_t -c" -+ ac_install_sh="$SHELL $ac_aux_dir/$ac_t -c" - break 2 - fi - done -diff -rNU3 dist.orig/libsanitizer/configure.tgt dist/libsanitizer/configure.tgt ---- dist.orig/libsanitizer/configure.tgt 2014-04-04 16:39:26.000000000 +0200 -+++ dist/libsanitizer/configure.tgt 2015-10-18 13:19:52.000000000 +0200 -@@ -20,6 +20,14 @@ - - # Filter out unsupported systems. - case "${target}" in -+ *-netbsd*) -+ # There is only glue for amd64 -+ case "${target}" in -+ x86_64-*) -+ TSAN_SUPPORTED=yes -+ ;; -+ esac -+ ;; - x86_64-*-linux* | i?86-*-linux*) - if test x$ac_cv_sizeof_void_p = x8; then - TSAN_SUPPORTED=yes -diff -rNU3 dist.orig/libsanitizer/interception/interception.h dist/libsanitizer/interception/interception.h ---- dist.orig/libsanitizer/interception/interception.h 2013-02-14 17:54:01.000000000 +0100 -+++ dist/libsanitizer/interception/interception.h 2015-10-18 13:19:52.000000000 +0200 -@@ -13,7 +13,7 @@ - #ifndef INTERCEPTION_H - #define INTERCEPTION_H - --#if !defined(__linux__) && !defined(__APPLE__) && !defined(_WIN32) -+#if !defined(__linux__) && !defined(__APPLE__) && !defined(_WIN32) && !defined(__NetBSD__) - # error "Interception doesn't work on this operating system." - #endif - -@@ -29,7 +29,7 @@ - // _FILE_OFFSET_BITS. This definition of OFF_T matches the ABI of system calls - // like pread and mmap, as opposed to pread64 and mmap64. - // Mac and Linux/x86-64 are special. --#if defined(__APPLE__) || (defined(__linux__) && defined(__x86_64__)) -+#if defined(__APPLE__) || (defined(__linux__) && defined(__x86_64__)) || defined(__NetBSD__) - typedef __sanitizer::u64 OFF_T; - #else - typedef __sanitizer::uptr OFF_T; -@@ -176,7 +176,7 @@ - - #define INCLUDED_FROM_INTERCEPTION_LIB - --#if defined(__linux__) -+#if defined(__linux__) || defined(__NetBSD__) - # include "interception_linux.h" - # define INTERCEPT_FUNCTION(func) INTERCEPT_FUNCTION_LINUX(func) - #elif defined(__APPLE__) -diff -rNU3 dist.orig/libsanitizer/interception/interception_linux.cc dist/libsanitizer/interception/interception_linux.cc ---- dist.orig/libsanitizer/interception/interception_linux.cc 2012-11-12 16:53:47.000000000 +0100 -+++ dist/libsanitizer/interception/interception_linux.cc 2015-10-18 13:19:52.000000000 +0200 -@@ -10,19 +10,34 @@ - // Linux-specific interception methods. - //===----------------------------------------------------------------------===// - --#ifdef __linux__ -+#if defined(__linux__) || defined(__NetBSD__) - #include "interception.h" - - #include // for NULL - #include // for dlsym - -+#ifdef __NetBSD__ -+static int mystrcmp(const char *s1, const char *s2) { -+ while (*s1 == *s2++) -+ if (*s1++ == 0) -+ return (0); -+ return (*(const unsigned char *)s1 - *(const unsigned char *)--s2); -+} -+#endif -+ -+ - namespace __interception { - bool GetRealFunctionAddress(const char *func_name, uptr *func_addr, - uptr real, uptr wrapper) { -+#ifdef __NetBSD__ -+ // XXX: Until I come up with something better to deal with renames. -+ if (mystrcmp(func_name, "sigaction") == 0) -+ func_name = "__sigaction14"; -+#endif - *func_addr = (uptr)dlsym(RTLD_NEXT, func_name); - return real == wrapper; - } - } // namespace __interception - - --#endif // __linux__ -+#endif // __linux__ || __NetBSD__ -diff -rNU3 dist.orig/libsanitizer/interception/interception_linux.h dist/libsanitizer/interception/interception_linux.h ---- dist.orig/libsanitizer/interception/interception_linux.h 2012-11-12 16:53:47.000000000 +0100 -+++ dist/libsanitizer/interception/interception_linux.h 2015-10-18 13:19:52.000000000 +0200 -@@ -10,7 +10,7 @@ - // Linux-specific interception methods. - //===----------------------------------------------------------------------===// - --#ifdef __linux__ -+#if defined(__linux__) || defined(__NetBSD__) - - #if !defined(INCLUDED_FROM_INTERCEPTION_LIB) - # error "interception_linux.h should be included from interception library only" -@@ -32,4 +32,4 @@ - (::__interception::uptr)&WRAP(func)) - - #endif // INTERCEPTION_LINUX_H --#endif // __linux__ -+#endif // __linux__ || __NetBSD__ -diff -rNU3 dist.orig/libsanitizer/interception/interception_type_test.cc dist/libsanitizer/interception/interception_type_test.cc ---- dist.orig/libsanitizer/interception/interception_type_test.cc 2013-02-13 11:46:01.000000000 +0100 -+++ dist/libsanitizer/interception/interception_type_test.cc 2015-10-18 13:19:52.000000000 +0200 -@@ -10,7 +10,7 @@ - // Compile-time tests of the internal type definitions. - //===----------------------------------------------------------------------===// - --#if defined(__linux__) || defined(__APPLE__) -+#if defined(__linux__) || defined(__APPLE__) || defined(__NetBSD__) - - #include "interception.h" - #include -@@ -22,7 +22,7 @@ - COMPILER_CHECK(sizeof(PTRDIFF_T) == sizeof(ptrdiff_t)); - COMPILER_CHECK(sizeof(INTMAX_T) == sizeof(intmax_t)); - --#ifndef __APPLE__ -+#if !defined(__APPLE__) && !defined(__NetBSD__) - COMPILER_CHECK(sizeof(OFF64_T) == sizeof(off64_t)); - #endif - -diff -rNU3 dist.orig/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc dist/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc ---- dist.orig/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc 2013-02-21 11:57:10.000000000 +0100 -+++ dist/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc 2015-10-18 13:19:52.000000000 +0200 -@@ -296,6 +296,14 @@ - INTERCEPTOR(int, sscanf, const char *str, const char *format, ...) - SCANF_INTERCEPTOR_IMPL(sscanf, vsscanf, str, format) - -+#define INIT_SCANF_NORMAL \ -+ INTERCEPT_FUNCTION(scanf); \ -+ INTERCEPT_FUNCTION(sscanf); \ -+ INTERCEPT_FUNCTION(fscanf); \ -+ INTERCEPT_FUNCTION(vscanf); \ -+ INTERCEPT_FUNCTION(vsscanf); \ -+ INTERCEPT_FUNCTION(vfscanf); \ -+ - #if SANITIZER_INTERCEPT_ISOC99_SCANF - INTERCEPTOR(int, __isoc99_scanf, const char *format, ...) - SCANF_INTERCEPTOR_IMPL(__isoc99_scanf, __isoc99_vscanf, format) -@@ -305,21 +313,22 @@ - - INTERCEPTOR(int, __isoc99_sscanf, const char *str, const char *format, ...) - SCANF_INTERCEPTOR_IMPL(__isoc99_sscanf, __isoc99_vsscanf, str, format) --#endif - --#define INIT_SCANF \ -- INTERCEPT_FUNCTION(scanf); \ -- INTERCEPT_FUNCTION(sscanf); \ -- INTERCEPT_FUNCTION(fscanf); \ -- INTERCEPT_FUNCTION(vscanf); \ -- INTERCEPT_FUNCTION(vsscanf); \ -- INTERCEPT_FUNCTION(vfscanf); \ -+ -+#define INIT_SCANF_ISOC99 \ - INTERCEPT_FUNCTION(__isoc99_scanf); \ - INTERCEPT_FUNCTION(__isoc99_sscanf); \ - INTERCEPT_FUNCTION(__isoc99_fscanf); \ - INTERCEPT_FUNCTION(__isoc99_vscanf); \ - INTERCEPT_FUNCTION(__isoc99_vsscanf); \ - INTERCEPT_FUNCTION(__isoc99_vfscanf); -+#else -+#define INIT_SCANF_ISOC99 -+#endif -+ -+#define INIT_SCANF \ -+ INIT_SCANF_NORMAL \ -+ INIT_SCANF_ISOC99 - - #else - #define INIT_SCANF -diff -rNU3 dist.orig/libsanitizer/sanitizer_common/sanitizer_internal_defs.h dist/libsanitizer/sanitizer_common/sanitizer_internal_defs.h ---- dist.orig/libsanitizer/sanitizer_common/sanitizer_internal_defs.h 2013-02-21 11:57:10.000000000 +0100 -+++ dist/libsanitizer/sanitizer_common/sanitizer_internal_defs.h 2015-10-18 13:19:52.000000000 +0200 -@@ -116,7 +116,11 @@ - # define USED - # define PREFETCH(x) /* _mm_prefetch(x, _MM_HINT_NTA) */ - #else // _MSC_VER --# define ALWAYS_INLINE __attribute__((always_inline)) -+# ifdef __NetBSD__ -+# define ALWAYS_INLINE // __attribute__((always_inline)) -+# else -+# define ALWAYS_INLINE __attribute__((always_inline)) -+# endif - # define ALIAS(x) __attribute__((alias(x))) - # define ALIGNED(x) __attribute__((aligned(x))) - # define FORMAT(f, a) __attribute__((format(printf, f, a))) -diff -rNU3 dist.orig/libsanitizer/sanitizer_common/sanitizer_netbsd.cc dist/libsanitizer/sanitizer_common/sanitizer_netbsd.cc ---- dist.orig/libsanitizer/sanitizer_common/sanitizer_netbsd.cc 1970-01-01 01:00:00.000000000 +0100 -+++ dist/libsanitizer/sanitizer_common/sanitizer_netbsd.cc 2015-10-18 13:19:52.000000000 +0200 -@@ -0,0 +1,479 @@ -+//===-- sanitizer_netbsd.cc -----------------------------------------------===// -+// -+// This file is distributed under the University of Illinois Open Source -+// License. See LICENSE.TXT for details. -+// -+//===----------------------------------------------------------------------===// -+// -+// This file is shared between AddressSanitizer and ThreadSanitizer -+// run-time libraries and implements linux-specific functions from -+// sanitizer_libc.h. -+//===----------------------------------------------------------------------===// -+#ifdef __NetBSD__ -+ -+#include "sanitizer_common.h" -+#include "sanitizer_internal_defs.h" -+#include "sanitizer_libc.h" -+#include "sanitizer_mutex.h" -+#include "sanitizer_placement_new.h" -+#include "sanitizer_procmaps.h" -+#include "sanitizer_stacktrace.h" -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+namespace __sanitizer { -+ -+// --------------- sanitizer_libc.h -+void *internal_mmap(void *addr, uptr length, int prot, int flags, -+ int fd, u64 offset) { -+ return (void *)__syscall(SYS_mmap, addr, length, prot, flags, -+ fd, 0, offset); -+} -+ -+int internal_munmap(void *addr, uptr length) { -+ return syscall(SYS_munmap, addr, length); -+} -+ -+int internal_close(fd_t fd) { -+ return syscall(SYS_close, fd); -+} -+ -+fd_t internal_open(const char *filename, int flags) { -+ return syscall(SYS_open, filename, flags); -+} -+ -+fd_t internal_open(const char *filename, int flags, u32 mode) { -+ return syscall(SYS_open, filename, flags, mode); -+} -+ -+fd_t OpenFile(const char *filename, bool write) { -+ return internal_open(filename, -+ write ? O_WRONLY | O_CREAT /*| O_CLOEXEC*/ : O_RDONLY, 0660); -+} -+ -+uptr internal_read(fd_t fd, void *buf, uptr count) { -+ sptr res; -+ HANDLE_EINTR(res, (sptr)syscall(SYS_read, fd, buf, count)); -+ return res; -+} -+ -+uptr internal_write(fd_t fd, const void *buf, uptr count) { -+ sptr res; -+ HANDLE_EINTR(res, (sptr)syscall(SYS_write, fd, buf, count)); -+ return res; -+} -+ -+int internal_stat(const char *path, void *buf) { -+ return syscall(SYS___stat50, path, buf); -+} -+ -+int internal_lstat(const char *path, void *buf) { -+ return syscall(SYS___lstat50, path, buf); -+} -+ -+int internal_fstat(fd_t fd, void *buf) { -+ return syscall(SYS___fstat50, fd, buf); -+} -+ -+uptr internal_filesize(fd_t fd) { -+ struct stat st; -+ if (internal_fstat(fd, &st)) -+ return -1; -+ return (uptr)st.st_size; -+} -+ -+int internal_dup2(int oldfd, int newfd) { -+ return syscall(SYS_dup2, oldfd, newfd); -+} -+ -+uptr internal_readlink(const char *path, char *buf, uptr bufsize) { -+ return (uptr)syscall(SYS_readlink, path, buf, bufsize); -+} -+ -+int internal_sched_yield() { -+ return syscall(SYS_sched_yield); -+} -+ -+void internal__exit(int exitcode) { -+ syscall(SYS_exit, exitcode); -+ Die(); // Unreachable. -+} -+ -+// ----------------- sanitizer_common.h -+bool FileExists(const char *filename) { -+ struct stat st; -+ if (syscall(SYS___stat50, filename, &st)) -+ return false; -+ // Sanity check: filename is a regular file. -+ return S_ISREG(st.st_mode); -+} -+ -+uptr GetTid() { -+ // XXX! -+ return syscall(SYS_getpid); -+} -+ -+void GetThreadStackTopAndBottom(bool at_initialization, uptr *stack_top, -+ uptr *stack_bottom) { -+ static const uptr kMaxThreadStackSize = 256 * (1 << 20); // 256M -+ CHECK(stack_top); -+ CHECK(stack_bottom); -+ if (at_initialization) { -+ // This is the main thread. Libpthread may not be initialized yet. -+ struct rlimit rl; -+ CHECK_EQ(getrlimit(RLIMIT_STACK, &rl), 0); -+ -+ // Find the mapping that contains a stack variable. -+ MemoryMappingLayout proc_maps; -+ uptr start, end, offset; -+ uptr prev_end = 0; -+ while (proc_maps.Next(&start, &end, &offset, 0, 0)) { -+ if ((uptr)&rl < end) -+ break; -+ prev_end = end; -+ } -+ CHECK((uptr)&rl >= start && (uptr)&rl < end); -+ -+ // Get stacksize from rlimit, but clip it so that it does not overlap -+ // with other mappings. -+ uptr stacksize = rl.rlim_cur; -+ if (stacksize > end - prev_end) -+ stacksize = end - prev_end; -+ // When running with unlimited stack size, we still want to set some limit. -+ // The unlimited stack size is caused by 'ulimit -s unlimited'. -+ // Also, for some reason, GNU make spawns subprocesses with unlimited stack. -+ if (stacksize > kMaxThreadStackSize) -+ stacksize = kMaxThreadStackSize; -+ *stack_top = end; -+ *stack_bottom = end - stacksize; -+ return; -+ } -+ pthread_attr_t attr; -+ CHECK_EQ(pthread_getattr_np(pthread_self(), &attr), 0); -+ uptr stacksize = 0; -+ void *stackaddr = 0; -+ pthread_attr_getstack(&attr, &stackaddr, (size_t*)&stacksize); -+ pthread_attr_destroy(&attr); -+ -+ *stack_top = (uptr)stackaddr + stacksize; -+ *stack_bottom = (uptr)stackaddr; -+ CHECK(stacksize < kMaxThreadStackSize); // Sanity check. -+} -+ -+// Like getenv, but reads env directly from /proc and does not use libc. -+// This function should be called first inside __asan_init. -+extern "C" char **environ; -+const char *GetEnv(const char *name) { -+ -+ uptr namelen = internal_strlen(name); -+ for (char **p = environ; *p; p++) { -+ if (!internal_memcmp(*p, name, namelen) && (*p)[namelen] == '=') // Match. -+ return *p + namelen + 1; // point after = -+ } -+ return 0; // Not found. -+} -+ -+#ifdef __GLIBC__ -+ -+extern "C" { -+ extern void *__libc_stack_end; -+} -+ -+static void GetArgsAndEnv(char ***argv, char ***envp) { -+ uptr *stack_end = (uptr *)__libc_stack_end; -+ int argc = *stack_end; -+ *argv = (char**)(stack_end + 1); -+ *envp = (char**)(stack_end + argc + 2); -+} -+ -+#else // __GLIBC__ -+ -+static void ReadNullSepFileToArray(const char *path, char ***arr, -+ int arr_size) { -+ char *buff; -+ uptr buff_size = 0; -+ *arr = (char **)MmapOrDie(arr_size * sizeof(char *), "NullSepFileArray"); -+ ReadFileToBuffer(path, &buff, &buff_size, 1024 * 1024); -+ (*arr)[0] = buff; -+ int count, i; -+ for (count = 1, i = 1; ; i++) { -+ if (buff[i] == 0) { -+ if (buff[i+1] == 0) break; -+ (*arr)[count] = &buff[i+1]; -+ CHECK_LE(count, arr_size - 1); // FIXME: make this more flexible. -+ count++; -+ } -+ } -+ (*arr)[count] = 0; -+} -+ -+static void GetArgsAndEnv(char ***argv, char ***envp) { -+ static const int kMaxArgv = 2000, kMaxEnvp = 2000; -+ ReadNullSepFileToArray("/proc/self/cmdline", argv, kMaxArgv); -+ ReadNullSepFileToArray("/proc/self/environ", envp, kMaxEnvp); -+} -+ -+#endif // __GLIBC__ -+ -+void ReExec() { -+ char **argv, **envp; -+ GetArgsAndEnv(&argv, &envp); -+ execve("/proc/self/exe", argv, envp); -+ Printf("execve failed, errno %d\n", errno); -+ Die(); -+} -+ -+void PrepareForSandboxing() { -+ // Some kinds of sandboxes may forbid filesystem access, so we won't be able -+ // to read the file mappings from /proc/self/maps. Luckily, neither the -+ // process will be able to load additional libraries, so it's fine to use the -+ // cached mappings. -+ MemoryMappingLayout::CacheMemoryMappings(); -+} -+ -+// ----------------- sanitizer_procmaps.h -+// Linker initialized. -+ProcSelfMapsBuff MemoryMappingLayout::cached_proc_self_maps_; -+StaticSpinMutex MemoryMappingLayout::cache_lock_; // Linker initialized. -+ -+MemoryMappingLayout::MemoryMappingLayout() { -+ proc_self_maps_.len = -+ ReadFileToBuffer("/proc/self/maps", &proc_self_maps_.data, -+ &proc_self_maps_.mmaped_size, 1 << 26); -+ if (proc_self_maps_.mmaped_size == 0) { -+ LoadFromCache(); -+ CHECK_GT(proc_self_maps_.len, 0); -+ } -+ // internal_write(2, proc_self_maps_.data, proc_self_maps_.len); -+ Reset(); -+ // FIXME: in the future we may want to cache the mappings on demand only. -+ CacheMemoryMappings(); -+} -+ -+MemoryMappingLayout::~MemoryMappingLayout() { -+ // Only unmap the buffer if it is different from the cached one. Otherwise -+ // it will be unmapped when the cache is refreshed. -+ if (proc_self_maps_.data != cached_proc_self_maps_.data) { -+ UnmapOrDie(proc_self_maps_.data, proc_self_maps_.mmaped_size); -+ } -+} -+ -+void MemoryMappingLayout::Reset() { -+ current_ = proc_self_maps_.data; -+} -+ -+// static -+void MemoryMappingLayout::CacheMemoryMappings() { -+ SpinMutexLock l(&cache_lock_); -+ // Don't invalidate the cache if the mappings are unavailable. -+ ProcSelfMapsBuff old_proc_self_maps; -+ old_proc_self_maps = cached_proc_self_maps_; -+ cached_proc_self_maps_.len = -+ ReadFileToBuffer("/proc/self/maps", &cached_proc_self_maps_.data, -+ &cached_proc_self_maps_.mmaped_size, 1 << 26); -+ if (cached_proc_self_maps_.mmaped_size == 0) { -+ cached_proc_self_maps_ = old_proc_self_maps; -+ } else { -+ if (old_proc_self_maps.mmaped_size) { -+ UnmapOrDie(old_proc_self_maps.data, -+ old_proc_self_maps.mmaped_size); -+ } -+ } -+} -+ -+void MemoryMappingLayout::LoadFromCache() { -+ SpinMutexLock l(&cache_lock_); -+ if (cached_proc_self_maps_.data) { -+ proc_self_maps_ = cached_proc_self_maps_; -+ } -+} -+ -+// Parse a hex value in str and update str. -+static uptr ParseHex(char **str) { -+ uptr x = 0; -+ char *s; -+ for (s = *str; ; s++) { -+ char c = *s; -+ uptr v = 0; -+ if (c >= '0' && c <= '9') -+ v = c - '0'; -+ else if (c >= 'a' && c <= 'f') -+ v = c - 'a' + 10; -+ else if (c >= 'A' && c <= 'F') -+ v = c - 'A' + 10; -+ else -+ break; -+ x = x * 16 + v; -+ } -+ *str = s; -+ return x; -+} -+ -+static bool IsOnOf(char c, char c1, char c2) { -+ return c == c1 || c == c2; -+} -+ -+static bool IsDecimal(char c) { -+ return c >= '0' && c <= '9'; -+} -+ -+bool MemoryMappingLayout::Next(uptr *start, uptr *end, uptr *offset, -+ char filename[], uptr filename_size) { -+ char *last = proc_self_maps_.data + proc_self_maps_.len; -+ if (current_ >= last) return false; -+ uptr dummy; -+ if (!start) start = &dummy; -+ if (!end) end = &dummy; -+ if (!offset) offset = &dummy; -+ char *next_line = (char*)internal_memchr(current_, '\n', last - current_); -+ if (next_line == 0) -+ next_line = last; -+ // Example: 08048000-08056000 r-xp 00000000 03:0c 64593 /foo/bar -+ *start = ParseHex(¤t_); -+ CHECK_EQ(*current_++, '-'); -+ *end = ParseHex(¤t_); -+ CHECK_EQ(*current_++, ' '); -+ CHECK(IsOnOf(*current_++, '-', 'r')); -+ CHECK(IsOnOf(*current_++, '-', 'w')); -+ CHECK(IsOnOf(*current_++, '-', 'x')); -+ CHECK(IsOnOf(*current_++, 's', 'p')); -+ CHECK_EQ(*current_++, ' '); -+ *offset = ParseHex(¤t_); -+ CHECK_EQ(*current_++, ' '); -+ ParseHex(¤t_); -+ CHECK_EQ(*current_++, ':'); -+ ParseHex(¤t_); -+ CHECK_EQ(*current_++, ' '); -+ while (IsDecimal(*current_)) -+ current_++; -+ CHECK_EQ(*current_++, ' '); -+ // Skip spaces. -+ while (current_ < next_line && *current_ == ' ') -+ current_++; -+ // Fill in the filename. -+ uptr i = 0; -+ while (current_ < next_line) { -+ if (filename && i < filename_size - 1) -+ filename[i++] = *current_; -+ current_++; -+ } -+ if (filename && i < filename_size) -+ filename[i] = 0; -+ current_ = next_line + 1; -+ return true; -+} -+ -+// Gets the object name and the offset by walking MemoryMappingLayout. -+bool MemoryMappingLayout::GetObjectNameAndOffset(uptr addr, uptr *offset, -+ char filename[], -+ uptr filename_size) { -+ return IterateForObjectNameAndOffset(addr, offset, filename, filename_size); -+} -+ -+bool SanitizerSetThreadName(const char *name) { -+ return 0 == pthread_setname_np(pthread_self(), "%s", (void *)(intptr_t)name); -+} -+ -+bool SanitizerGetThreadName(char *name, int max_len) { -+ return 0 == pthread_getname_np(pthread_self(), name, max_len); -+} -+ -+#ifndef SANITIZER_GO -+//------------------------- SlowUnwindStack ----------------------------------- -+#if defined(__arm__) && defined(__ARM_EABI__) && !defined(__ARM_DWARF_EH__) -+#include "unwind-arm-common.h" -+#define UNWIND_STOP _URC_END_OF_STACK -+#define UNWIND_CONTINUE _URC_NO_REASON -+#else -+#include -+#define UNWIND_STOP _URC_NORMAL_STOP -+#define UNWIND_CONTINUE _URC_NO_REASON -+#endif -+ -+uptr Unwind_GetIP(struct _Unwind_Context *ctx) { -+#if defined(__arm__) && defined(__ARM_EABI__) && !defined(__ARM_DWARF_EH__) -+ uptr val; -+ _Unwind_VRS_Result res = _Unwind_VRS_Get(ctx, _UVRSC_CORE, -+ 15 /* r15 = PC */, _UVRSD_UINT32, &val); -+ CHECK(res == _UVRSR_OK && "_Unwind_VRS_Get failed"); -+ // Clear the Thumb bit. -+ return val & ~(uptr)1; -+#else -+ return (uptr)_Unwind_GetIP(ctx); -+#endif -+} -+ -+_Unwind_Reason_Code Unwind_Trace(struct _Unwind_Context *ctx, void *param) { -+ StackTrace *b = (StackTrace*)param; -+ CHECK(b->size < b->max_size); -+ uptr pc = Unwind_GetIP(ctx); -+ b->trace[b->size++] = pc; -+ if (b->size == b->max_size) return UNWIND_STOP; -+ return UNWIND_CONTINUE; -+} -+ -+static bool MatchPc(uptr cur_pc, uptr trace_pc) { -+ return cur_pc - trace_pc <= 64 || trace_pc - cur_pc <= 64; -+} -+ -+void StackTrace::SlowUnwindStack(uptr pc, uptr max_depth) { -+ this->size = 0; -+ this->max_size = max_depth; -+ if (max_depth > 1) { -+ _Unwind_Backtrace(Unwind_Trace, this); -+ // We need to pop a few frames so that pc is on top. -+ // trace[0] belongs to the current function so we always pop it. -+ int to_pop = 1; -+ /**/ if (size > 1 && MatchPc(pc, trace[1])) to_pop = 1; -+ else if (size > 2 && MatchPc(pc, trace[2])) to_pop = 2; -+ else if (size > 3 && MatchPc(pc, trace[3])) to_pop = 3; -+ else if (size > 4 && MatchPc(pc, trace[4])) to_pop = 4; -+ else if (size > 5 && MatchPc(pc, trace[5])) to_pop = 5; -+ this->PopStackFrames(to_pop); -+ } -+ this->trace[0] = pc; -+} -+ -+#endif // #ifndef SANITIZER_GO -+ -+enum MutexState { -+ MtxUnlocked = 0, -+ MtxLocked = 1, -+ MtxSleeping = 2 -+}; -+ -+BlockingMutex::BlockingMutex(LinkerInitialized) { -+ CHECK_EQ(owner_, 0); -+} -+ -+void BlockingMutex::Lock() { -+ atomic_uint32_t *m = reinterpret_cast(&opaque_storage_); -+ if (atomic_exchange(m, MtxLocked, memory_order_acquire) == MtxUnlocked) -+ return; -+ while (atomic_exchange(m, MtxSleeping, memory_order_acquire) != MtxUnlocked) -+ syscall(SYS_sched_yield); -+} -+ -+void BlockingMutex::Unlock() { -+ atomic_uint32_t *m = reinterpret_cast(&opaque_storage_); -+ u32 v = atomic_exchange(m, MtxUnlocked, memory_order_relaxed); -+ CHECK_NE(v, MtxUnlocked); -+#if 0 -+ if (v == MtxSleeping) -+ syscall(__NR_futex, m, FUTEX_WAKE, 1, 0, 0, 0); -+#endif -+} -+ -+} // namespace __sanitizer -+ -+#endif // __NetBSD__ -diff -rNU3 dist.orig/libsanitizer/sanitizer_common/sanitizer_placement_new.h dist/libsanitizer/sanitizer_common/sanitizer_placement_new.h ---- dist.orig/libsanitizer/sanitizer_common/sanitizer_placement_new.h 2012-11-23 15:46:25.000000000 +0100 -+++ dist/libsanitizer/sanitizer_common/sanitizer_placement_new.h 2015-10-18 13:19:52.000000000 +0200 -@@ -15,6 +15,7 @@ - #define SANITIZER_PLACEMENT_NEW_H - - #include "sanitizer_internal_defs.h" -+#include - - namespace __sanitizer { - #if (SANITIZER_WORDSIZE == 64) || defined(__APPLE__) -@@ -24,7 +25,7 @@ - #endif - } // namespace __sanitizer - --inline void *operator new(__sanitizer::operator_new_ptr_type sz, void *p) { -+inline void *operator new(std::size_t sz, void *p) { - return p; - } - -diff -rNU3 dist.orig/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc ---- dist.orig/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc 2013-02-21 11:57:10.000000000 +0100 -+++ dist/libsanitizer/sanitizer_common/sanitizer_platform_limits_posix.cc 2015-10-18 13:19:52.000000000 +0200 -@@ -10,7 +10,7 @@ - // Sizes and layouts of platform-specific POSIX data structures. - //===----------------------------------------------------------------------===// - --#if defined(__linux__) || defined(__APPLE__) -+#if defined(__linux__) || defined(__APPLE__) || defined(__NetBSD__) - - #include "sanitizer_internal_defs.h" - #include "sanitizer_platform_limits_posix.h" -@@ -32,7 +32,9 @@ - namespace __sanitizer { - unsigned struct_utsname_sz = sizeof(struct utsname); - unsigned struct_stat_sz = sizeof(struct stat); -+#if defined(__linux__) || defined(__APPLE__) - unsigned struct_stat64_sz = sizeof(struct stat64); -+#endif - unsigned struct_rusage_sz = sizeof(struct rusage); - unsigned struct_tm_sz = sizeof(struct tm); - -@@ -65,4 +67,4 @@ - } - } // namespace __sanitizer - --#endif // __linux__ || __APPLE__ -+#endif // __linux__ || __APPLE__ || __NetBSD__ -diff -rNU3 dist.orig/libsanitizer/sanitizer_common/sanitizer_posix.cc dist/libsanitizer/sanitizer_common/sanitizer_posix.cc ---- dist.orig/libsanitizer/sanitizer_common/sanitizer_posix.cc 2013-02-21 11:57:10.000000000 +0100 -+++ dist/libsanitizer/sanitizer_common/sanitizer_posix.cc 2015-10-18 13:19:52.000000000 +0200 -@@ -9,7 +9,7 @@ - // run-time libraries and implements POSIX-specific functions from - // sanitizer_libc.h. - //===----------------------------------------------------------------------===// --#if defined(__linux__) || defined(__APPLE__) -+#if defined(__linux__) || defined(__APPLE__) || defined(__NetBSD__) - - #include "sanitizer_common.h" - #include "sanitizer_libc.h" -@@ -225,4 +225,4 @@ - - } // namespace __sanitizer - --#endif // __linux__ || __APPLE_ -+#endif // __linux__ || __APPLE_ || __NetBSD__ -diff -rNU3 dist.orig/libsanitizer/sanitizer_common/sanitizer_procmaps.h dist/libsanitizer/sanitizer_common/sanitizer_procmaps.h ---- dist.orig/libsanitizer/sanitizer_common/sanitizer_procmaps.h 2012-12-05 14:19:55.000000000 +0100 -+++ dist/libsanitizer/sanitizer_common/sanitizer_procmaps.h 2015-10-18 13:19:52.000000000 +0200 -@@ -28,13 +28,13 @@ - }; - - #else // _WIN32 --#if defined(__linux__) -+#if defined(__linux__) || defined(__NetBSD__) - struct ProcSelfMapsBuff { - char *data; - uptr mmaped_size; - uptr len; - }; --#endif // defined(__linux__) -+#endif // defined(__linux__) || defined(__NetBSD__) - - class MemoryMappingLayout { - public: -@@ -84,7 +84,7 @@ - return false; - } - --# if defined __linux__ -+# if defined __linux__ || defined(__NetBSD__) - ProcSelfMapsBuff proc_self_maps_; - char *current_; - -diff -rNU3 dist.orig/libsanitizer/sanitizer_common/sanitizer_symbolizer_linux.cc dist/libsanitizer/sanitizer_common/sanitizer_symbolizer_linux.cc ---- dist.orig/libsanitizer/sanitizer_common/sanitizer_symbolizer_linux.cc 2013-02-21 11:57:10.000000000 +0100 -+++ dist/libsanitizer/sanitizer_common/sanitizer_symbolizer_linux.cc 2015-10-18 13:19:52.000000000 +0200 -@@ -9,7 +9,7 @@ - // run-time libraries. - // Linux-specific implementation of symbolizer parts. - //===----------------------------------------------------------------------===// --#ifdef __linux__ -+#if defined(__linux__) || defined(__NetBSD__) - #include "sanitizer_common.h" - #include "sanitizer_internal_defs.h" - #include "sanitizer_libc.h" -@@ -124,7 +124,9 @@ - UNIMPLEMENTED(); - } - #else // ANDROID -+#ifdef ElfW - typedef ElfW(Phdr) Elf_Phdr; -+#endif - - struct DlIteratePhdrData { - LoadedModule *modules; -@@ -175,6 +177,10 @@ - } - #endif // ANDROID - -+const char *Demangle(const char *MangledName) { -+ return MangledName; -+} -+ - } // namespace __sanitizer - --#endif // __linux__ -+#endif // __linux__ || __NetBSD__ -diff -rNU3 dist.orig/libsanitizer/tsan/tsan_rtl_amd64.S dist/libsanitizer/tsan/tsan_rtl_amd64.S ---- dist.orig/libsanitizer/tsan/tsan_rtl_amd64.S 2012-11-22 23:03:11.000000000 +0100 -+++ dist/libsanitizer/tsan/tsan_rtl_amd64.S 2015-10-18 13:19:52.000000000 +0200 -@@ -40,7 +40,11 @@ - shr $4, %rsp # clear 4 lsb, align to 16 - shl $4, %rsp - -+#ifdef __PIC__ -+ call __tsan_trace_switch@PLT -+#else - call __tsan_trace_switch -+#endif - - # Unalign stack frame back. - mov %rbx, %rsp # restore the original rsp -@@ -119,7 +123,11 @@ - shr $4, %rsp # clear 4 lsb, align to 16 - shl $4, %rsp - -+#ifdef __PIC__ -+ call __tsan_report_race@PLT -+#else - call __tsan_report_race -+#endif - - # Unalign stack frame back. - mov %rbx, %rsp # restore the original rsp -diff -rNU3 dist.orig/libsanitizer/tsan/tsan_symbolize_addr2line_linux.cc dist/libsanitizer/tsan/tsan_symbolize_addr2line_linux.cc ---- dist.orig/libsanitizer/tsan/tsan_symbolize_addr2line_linux.cc 2013-01-10 13:44:08.000000000 +0100 -+++ dist/libsanitizer/tsan/tsan_symbolize_addr2line_linux.cc 2015-10-18 13:19:52.000000000 +0200 -@@ -20,7 +20,7 @@ - #include - #include - #include --#include -+#include - #include - - namespace __tsan { -diff -rNU3 dist.orig/libssp/configure dist/libssp/configure ---- dist.orig/libssp/configure 2014-04-04 15:53:39.000000000 +0200 -+++ dist/libssp/configure 2015-10-18 13:19:52.000000000 +0200 -@@ -2187,7 +2187,7 @@ - for ac_t in install-sh install.sh shtool; do - if test -f "$ac_dir/$ac_t"; then - ac_aux_dir=$ac_dir -- ac_install_sh="$ac_aux_dir/$ac_t -c" -+ ac_install_sh="$SHELL $ac_aux_dir/$ac_t -c" - break 2 - fi - done -diff -rNU3 dist.orig/libstdc++-v3/Makefile.am dist/libstdc++-v3/Makefile.am ---- dist.orig/libstdc++-v3/Makefile.am 2013-02-03 18:54:05.000000000 +0100 -+++ dist/libstdc++-v3/Makefile.am 2015-10-18 13:19:54.000000000 +0200 -@@ -23,7 +23,7 @@ - include $(top_srcdir)/fragment.am - - if GLIBCXX_HOSTED -- hosted_source = src doc po testsuite -+ hosted_source = src doc po - endif - - ## Keep this list sync'd with acinclude.m4:GLIBCXX_CONFIGURE. -@@ -33,8 +33,8 @@ - ACLOCAL_AMFLAGS = -I . -I .. -I ../config - - # Testsuite/check forwarding targets. --check-%: -- cd testsuite && $(MAKE) $@ -+#check-%: -+# cd testsuite && $(MAKE) $@ - - # Documentation forwarding targets. - doc-%: -diff -rNU3 dist.orig/libstdc++-v3/Makefile.in dist/libstdc++-v3/Makefile.in ---- dist.orig/libstdc++-v3/Makefile.in 2012-10-15 15:10:30.000000000 +0200 -+++ dist/libstdc++-v3/Makefile.in 2015-10-18 13:19:54.000000000 +0200 -@@ -94,7 +94,7 @@ - $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS - ETAGS = etags - CTAGS = ctags --DIST_SUBDIRS = include libsupc++ src doc po testsuite python -+DIST_SUBDIRS = include libsupc++ src doc po python - ABI_TWEAKS_SRCDIR = @ABI_TWEAKS_SRCDIR@ - ACLOCAL = @ACLOCAL@ - ALLOCATOR_H = @ALLOCATOR_H@ -@@ -311,7 +311,7 @@ - - # -I/-D flags to pass when compiling. - AM_CPPFLAGS = $(GLIBCXX_INCLUDES) --@GLIBCXX_HOSTED_TRUE@hosted_source = src doc po testsuite -+@GLIBCXX_HOSTED_TRUE@hosted_source = src doc po - SUBDIRS = include libsupc++ $(hosted_source) python - ACLOCAL_AMFLAGS = -I . -I .. -I ../config - @BUILD_XML_FALSE@STAMP_XML = -@@ -669,8 +669,8 @@ - - - # Testsuite/check forwarding targets. --check-%: -- cd testsuite && $(MAKE) $@ -+#check-%: -+# cd testsuite && $(MAKE) $@ - - # Documentation forwarding targets. - doc-%: -diff -rNU3 dist.orig/libstdc++-v3/acinclude.m4 dist/libstdc++-v3/acinclude.m4 ---- dist.orig/libstdc++-v3/acinclude.m4 2013-11-22 14:17:55.000000000 +0100 -+++ dist/libstdc++-v3/acinclude.m4 2015-10-18 13:19:52.000000000 +0200 -@@ -49,7 +49,7 @@ - # Keep these sync'd with the list in Makefile.am. The first provides an - # expandable list at autoconf time; the second provides an expandable list - # (i.e., shell variable) at configure time. -- m4_define([glibcxx_SUBDIRS],[include libsupc++ python src src/c++98 src/c++11 doc po testsuite]) -+ m4_define([glibcxx_SUBDIRS],[include libsupc++ python src src/c++98 src/c++11 doc testsuite]) - SUBDIRS='glibcxx_SUBDIRS' - - # These need to be absolute paths, yet at the same time need to -diff -rNU3 dist.orig/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h dist/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h ---- dist.orig/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h 2013-02-03 18:54:05.000000000 +0100 -+++ dist/libstdc++-v3/config/os/bsd/netbsd/ctype_base.h 2015-10-18 13:19:53.000000000 +0200 -@@ -38,14 +38,16 @@ - /// @brief Base class for ctype. - struct ctype_base - { -- // Non-standard typedefs. -- typedef const unsigned char* __to_type; - - // NB: Offsets into ctype::_M_table force a particular size - // on the mask type. Because of this, we don't use an enum. -- typedef unsigned char mask; - - #ifndef _CTYPE_U -+ // Non-standard typedefs. -+ typedef const unsigned char* __to_type; -+ -+ typedef unsigned char mask; -+ - static const mask upper = _U; - static const mask lower = _L; - static const mask alpha = _U | _L; -@@ -58,17 +60,21 @@ - static const mask punct = _P; - static const mask alnum = _U | _L | _N; - #else -+ typedef const unsigned short* __to_type; -+ -+ typedef unsigned short mask; -+ - static const mask upper = _CTYPE_U; - static const mask lower = _CTYPE_L; -- static const mask alpha = _CTYPE_U | _CTYPE_L; -- static const mask digit = _CTYPE_N; -- static const mask xdigit = _CTYPE_N | _CTYPE_X; -+ static const mask alpha = _CTYPE_A; -+ static const mask digit = _CTYPE_D; -+ static const mask xdigit = _CTYPE_X; - static const mask space = _CTYPE_S; -- static const mask print = _CTYPE_P | _CTYPE_U | _CTYPE_L | _CTYPE_N | _CTYPE_B; -- static const mask graph = _CTYPE_P | _CTYPE_U | _CTYPE_L | _CTYPE_N; -+ static const mask print = _CTYPE_R; -+ static const mask graph = _CTYPE_G; - static const mask cntrl = _CTYPE_C; - static const mask punct = _CTYPE_P; -- static const mask alnum = _CTYPE_U | _CTYPE_L | _CTYPE_N; -+ static const mask alnum = _CTYPE_A | _CTYPE_D; - #endif - }; - -diff -rNU3 dist.orig/libstdc++-v3/config/os/bsd/netbsd/ctype_configure_char.cc dist/libstdc++-v3/config/os/bsd/netbsd/ctype_configure_char.cc ---- dist.orig/libstdc++-v3/config/os/bsd/netbsd/ctype_configure_char.cc 2013-02-03 18:54:05.000000000 +0100 -+++ dist/libstdc++-v3/config/os/bsd/netbsd/ctype_configure_char.cc 2015-10-18 13:19:53.000000000 +0200 -@@ -38,11 +38,9 @@ - - // Information as gleaned from /usr/include/ctype.h - -- extern "C" const u_int8_t _C_ctype_[]; -- - const ctype_base::mask* - ctype::classic_table() throw() -- { return _C_ctype_ + 1; } -+ { return _C_ctype_tab_ + 1; } - - ctype::ctype(__c_locale, const mask* __table, bool __del, - size_t __refs) -@@ -69,14 +67,14 @@ - - char - ctype::do_toupper(char __c) const -- { return ::toupper((int) __c); } -+ { return ::toupper((int)(unsigned char) __c); } - - const char* - ctype::do_toupper(char* __low, const char* __high) const - { - while (__low < __high) - { -- *__low = ::toupper((int) *__low); -+ *__low = ::toupper((int)(unsigned char) *__low); - ++__low; - } - return __high; -@@ -84,14 +82,14 @@ - - char - ctype::do_tolower(char __c) const -- { return ::tolower((int) __c); } -+ { return ::tolower((int)(unsigned char) __c); } - - const char* - ctype::do_tolower(char* __low, const char* __high) const - { - while (__low < __high) - { -- *__low = ::tolower((int) *__low); -+ *__low = ::tolower((int)(unsigned char) *__low); - ++__low; - } - return __high; -diff -rNU3 dist.orig/libstdc++-v3/config/os/bsd/netbsd/ctype_inline.h dist/libstdc++-v3/config/os/bsd/netbsd/ctype_inline.h ---- dist.orig/libstdc++-v3/config/os/bsd/netbsd/ctype_inline.h 2013-02-03 18:54:05.000000000 +0100 -+++ dist/libstdc++-v3/config/os/bsd/netbsd/ctype_inline.h 2015-10-18 13:19:53.000000000 +0200 -@@ -48,7 +48,7 @@ - is(const char* __low, const char* __high, mask* __vec) const - { - while (__low < __high) -- *__vec++ = _M_table[*__low++]; -+ *__vec++ = _M_table[(unsigned char)*__low++]; - return __high; - } - -diff -rNU3 dist.orig/libstdc++-v3/configure dist/libstdc++-v3/configure ---- dist.orig/libstdc++-v3/configure 2014-04-04 15:53:39.000000000 +0200 -+++ dist/libstdc++-v3/configure 2015-10-18 13:19:53.000000000 +0200 -@@ -2900,7 +2900,7 @@ - for ac_t in install-sh install.sh shtool; do - if test -f "$ac_dir/$ac_t"; then - ac_aux_dir=$ac_dir -- ac_install_sh="$ac_aux_dir/$ac_t -c" -+ ac_install_sh="$SHELL $ac_aux_dir/$ac_t -c" - break 2 - fi - done -@@ -3038,6 +3038,9 @@ - # We are being configured with some form of cross compiler. - GLIBCXX_IS_NATIVE=false - case "$host","$target" in -+ *-*-netbsd*,*-*-netbsd*) -+ GLIBCXX_IS_NATIVE=true -+ ;; - # Darwin crosses can use the host system's libraries and headers, - # because of the fat library support. Of course, it must be the - # same version of Darwin on both sides. Allow the user to -@@ -4877,7 +4880,7 @@ - # expandable list at autoconf time; the second provides an expandable list - # (i.e., shell variable) at configure time. - -- SUBDIRS='include libsupc++ python src src/c++98 src/c++11 doc po testsuite' -+ SUBDIRS='include libsupc++ python src src/c++98 src/c++11 doc po' - - # These need to be absolute paths, yet at the same time need to - # canonicalize only relative paths, because then amd will not unmount -@@ -73193,7 +73196,7 @@ - # append it here. Only modify Makefiles that have just been created. - # - # Also, get rid of this simulated-VPATH thing that automake does. --ac_config_files="$ac_config_files include/Makefile libsupc++/Makefile python/Makefile src/Makefile src/c++98/Makefile src/c++11/Makefile doc/Makefile po/Makefile testsuite/Makefile" -+ac_config_files="$ac_config_files include/Makefile libsupc++/Makefile python/Makefile src/Makefile src/c++98/Makefile src/c++11/Makefile doc/Makefile" - - - ac_config_commands="$ac_config_commands generate-headers" -@@ -74400,7 +74403,6 @@ - "src/c++11/Makefile") CONFIG_FILES="$CONFIG_FILES src/c++11/Makefile" ;; - "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; - "po/Makefile") CONFIG_FILES="$CONFIG_FILES po/Makefile" ;; -- "testsuite/Makefile") CONFIG_FILES="$CONFIG_FILES testsuite/Makefile" ;; - "generate-headers") CONFIG_COMMANDS="$CONFIG_COMMANDS generate-headers" ;; - - *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; -@@ -76266,17 +76268,6 @@ - . ${multi_basedir}/config-ml.in - { ml_norecursion=; unset ml_norecursion;} - ;; -- "testsuite/Makefile":F) cat > vpsed$$ << \_EOF --s!`test -f '$<' || echo '$(srcdir)/'`!! --_EOF -- sed -f vpsed$$ $ac_file > tmp$$ -- mv tmp$$ $ac_file -- rm vpsed$$ -- echo 'MULTISUBDIR =' >> $ac_file -- ml_norecursion=yes -- . ${multi_basedir}/config-ml.in -- { ml_norecursion=; unset ml_norecursion;} -- ;; - "generate-headers":C) (cd include && ${MAKE-make} pch_build= ) ;; - - esac -diff -rNU3 dist.orig/libstdc++-v3/configure.ac dist/libstdc++-v3/configure.ac ---- dist.orig/libstdc++-v3/configure.ac 2013-04-09 22:47:55.000000000 +0200 -+++ dist/libstdc++-v3/configure.ac 2015-10-18 13:19:53.000000000 +0200 -@@ -38,6 +38,9 @@ - # We are being configured with some form of cross compiler. - GLIBCXX_IS_NATIVE=false - case "$host","$target" in -+ *-*-netbsd*,*-*-netbsd*) -+ GLIBCXX_IS_NATIVE=true -+ ;; - # Darwin crosses can use the host system's libraries and headers, - # because of the fat library support. Of course, it must be the - # same version of Darwin on both sides. Allow the user to -diff -rNU3 dist.orig/libstdc++-v3/crossconfig.m4 dist/libstdc++-v3/crossconfig.m4 ---- dist.orig/libstdc++-v3/crossconfig.m4 2012-05-02 21:34:31.000000000 +0200 -+++ dist/libstdc++-v3/crossconfig.m4 2015-10-18 13:19:53.000000000 +0200 -@@ -159,14 +159,51 @@ - SECTION_FLAGS='-ffunction-sections -fdata-sections' - AC_SUBST(SECTION_FLAGS) - GLIBCXX_CHECK_LINKER_FEATURES -+ -+ AC_DEFINE(HAVE_ICONV) -+ AC_DEFINE(HAVE_ICONV_CLOSE) -+ AC_DEFINE(HAVE_ICONV_OPEN) -+ AC_DEFINE(HAVE_LC_MESSAGES) -+ -+ AC_DEFINE(HAVE_MMAP) -+ AC_DEFINE(HAVE_GETPAGESIZE) -+ AC_DEFINE(HAVE_SETENV) -+ AC_DEFINE(HAVE_SIGSETJMP) -+ - AC_DEFINE(HAVE_FINITEF) - AC_DEFINE(HAVE_FINITE) - AC_DEFINE(HAVE_FREXPF) -+ AC_DEFINE(HAVE_HYPOT) - AC_DEFINE(HAVE_HYPOTF) - AC_DEFINE(HAVE_ISINF) - AC_DEFINE(HAVE_ISINFF) - AC_DEFINE(HAVE_ISNAN) - AC_DEFINE(HAVE_ISNANF) -+ AC_DEFINE(HAVE_ACOSF) -+ AC_DEFINE(HAVE_ASINF) -+ AC_DEFINE(HAVE_ATAN2F) -+ AC_DEFINE(HAVE_ATANF) -+ AC_DEFINE(HAVE_CEILF) -+ AC_DEFINE(HAVE_COSF) -+ AC_DEFINE(HAVE_COSHF) -+ AC_DEFINE(HAVE_EXPF) -+ AC_DEFINE(HAVE_FABSF) -+ AC_DEFINE(HAVE_FLOORF) -+ AC_DEFINE(HAVE_FMODF) -+ AC_DEFINE(HAVE_FREXPF) -+ AC_DEFINE(HAVE_LDEXPF) -+ AC_DEFINE(HAVE_LOG10F) -+ AC_DEFINE(HAVE_LOGF) -+ AC_DEFINE(HAVE_MODF) -+ AC_DEFINE(HAVE_MODFF) -+ AC_DEFINE(HAVE_POWF) -+ AC_DEFINE(HAVE_SINF) -+ AC_DEFINE(HAVE_SINHF) -+ AC_DEFINE(HAVE_SQRTF) -+ AC_DEFINE(HAVE_STRTOF) -+ AC_DEFINE(HAVE_STRTOLD) -+ AC_DEFINE(HAVE_TANF) -+ AC_DEFINE(HAVE_TANHF) - if test x"long_double_math_on_this_cpu" = x"yes"; then - AC_DEFINE(HAVE_FINITEL) - AC_DEFINE(HAVE_ISINFL) -diff -rNU3 dist.orig/libstdc++-v3/include/bits/locale_facets.tcc dist/libstdc++-v3/include/bits/locale_facets.tcc ---- dist.orig/libstdc++-v3/include/bits/locale_facets.tcc 2013-02-03 18:54:05.000000000 +0100 -+++ dist/libstdc++-v3/include/bits/locale_facets.tcc 2015-10-18 13:19:53.000000000 +0200 -@@ -464,7 +464,7 @@ - bool __testfail = false; - bool __testoverflow = false; - const __unsigned_type __max = -- (__negative && __gnu_cxx::__numeric_traits<_ValueT>::__is_signed) -+ (__negative && __gnu_cxx::__numeric_traits<_ValueT>::__is_signed_val) - ? -__gnu_cxx::__numeric_traits<_ValueT>::__min - : __gnu_cxx::__numeric_traits<_ValueT>::__max; - const __unsigned_type __smax = __max / __base; -@@ -568,7 +568,7 @@ - else if (__testoverflow) - { - if (__negative -- && __gnu_cxx::__numeric_traits<_ValueT>::__is_signed) -+ && __gnu_cxx::__numeric_traits<_ValueT>::__is_signed_val) - __v = __gnu_cxx::__numeric_traits<_ValueT>::__min; - else - __v = __gnu_cxx::__numeric_traits<_ValueT>::__max; -@@ -891,7 +891,7 @@ - if (__v >= 0) - { - if (bool(__flags & ios_base::showpos) -- && __gnu_cxx::__numeric_traits<_ValueT>::__is_signed) -+ && __gnu_cxx::__numeric_traits<_ValueT>::__is_signed_val) - *--__cs = __lit[__num_base::_S_oplus], ++__len; - } - else -diff -rNU3 dist.orig/libstdc++-v3/include/bits/stl_algobase.h dist/libstdc++-v3/include/bits/stl_algobase.h ---- dist.orig/libstdc++-v3/include/bits/stl_algobase.h 2013-09-08 00:58:04.000000000 +0200 -+++ dist/libstdc++-v3/include/bits/stl_algobase.h 2015-10-18 13:19:53.000000000 +0200 -@@ -918,8 +918,8 @@ - typedef typename iterator_traits<_II2>::value_type _ValueType2; - const bool __simple = - (__is_byte<_ValueType1>::__value && __is_byte<_ValueType2>::__value -- && !__gnu_cxx::__numeric_traits<_ValueType1>::__is_signed -- && !__gnu_cxx::__numeric_traits<_ValueType2>::__is_signed -+ && !__gnu_cxx::__numeric_traits<_ValueType1>::__is_signed_val -+ && !__gnu_cxx::__numeric_traits<_ValueType2>::__is_signed_val - && __is_pointer<_II1>::__value - && __is_pointer<_II2>::__value); - -diff -rNU3 dist.orig/libstdc++-v3/include/ext/numeric_traits.h dist/libstdc++-v3/include/ext/numeric_traits.h ---- dist.orig/libstdc++-v3/include/ext/numeric_traits.h 2013-02-03 18:54:05.000000000 +0100 -+++ dist/libstdc++-v3/include/ext/numeric_traits.h 2015-10-18 13:19:53.000000000 +0200 -@@ -60,7 +60,7 @@ - - // NB: these two also available in std::numeric_limits as compile - // time constants, but is big and we avoid including it. -- static const bool __is_signed = __glibcxx_signed(_Value); -+ static const bool __is_signed_val = __glibcxx_signed(_Value); - static const int __digits = __glibcxx_digits(_Value); - }; - -@@ -71,7 +71,7 @@ - const _Value __numeric_traits_integer<_Value>::__max; - - template -- const bool __numeric_traits_integer<_Value>::__is_signed; -+ const bool __numeric_traits_integer<_Value>::__is_signed_val; - - template - const int __numeric_traits_integer<_Value>::__digits; -@@ -103,7 +103,7 @@ - static const int __max_digits10 = __glibcxx_max_digits10(_Value); - - // See above comment... -- static const bool __is_signed = true; -+ static const bool __is_signed_val = true; - static const int __digits10 = __glibcxx_digits10(_Value); - static const int __max_exponent10 = __glibcxx_max_exponent10(_Value); - }; -@@ -112,7 +112,7 @@ - const int __numeric_traits_floating<_Value>::__max_digits10; - - template -- const bool __numeric_traits_floating<_Value>::__is_signed; -+ const bool __numeric_traits_floating<_Value>::__is_signed_val; - - template - const int __numeric_traits_floating<_Value>::__digits10; -diff -rNU3 dist.orig/libstdc++-v3/libsupc++/atexit_arm.cc dist/libstdc++-v3/libsupc++/atexit_arm.cc ---- dist.orig/libstdc++-v3/libsupc++/atexit_arm.cc 2013-02-03 18:54:05.000000000 +0100 -+++ dist/libstdc++-v3/libsupc++/atexit_arm.cc 2015-10-18 13:19:54.000000000 +0200 -@@ -23,7 +23,7 @@ - - #include - --#if defined(__arm__) && defined(__ARM_EABI__) -+#if defined(__arm__) && defined(__ARM_EABI__) && !defined(__NetBSD__) - - namespace __aeabiv1 - { -diff -rNU3 dist.orig/libstdc++-v3/src/c++11/random.cc dist/libstdc++-v3/src/c++11/random.cc ---- dist.orig/libstdc++-v3/src/c++11/random.cc 2013-02-03 18:54:05.000000000 +0100 -+++ dist/libstdc++-v3/src/c++11/random.cc 2015-10-18 13:19:54.000000000 +0200 -@@ -54,7 +54,10 @@ - - #if (defined __i386__ || defined __x86_64__) && defined _GLIBCXX_X86_RDRAND - unsigned int -+ __attribute__ ((noinline)) -+# ifndef __clang__ - __attribute__ ((target("rdrnd"))) -+# endif - __x86_rdrand(void) - { - unsigned int retries = 100; -diff -rNU3 dist.orig/libstdc++-v3/src/c++98/locale-inst.cc dist/libstdc++-v3/src/c++98/locale-inst.cc ---- dist.orig/libstdc++-v3/src/c++98/locale-inst.cc 2013-02-03 18:54:05.000000000 +0100 -+++ dist/libstdc++-v3/src/c++98/locale-inst.cc 2015-10-18 13:19:54.000000000 +0200 -@@ -176,11 +176,21 @@ - template class messages_byname; - - // ctype -- inline template class __ctype_abstract_base; -+#ifdef __clang__ -+ extern -+#else -+ inline -+#endif -+ template class __ctype_abstract_base; - template class ctype_byname; - - // codecvt -- inline template class __codecvt_abstract_base; -+#ifdef __clang__ -+ extern -+#else -+ inline -+#endif -+ template class __codecvt_abstract_base; - template class codecvt_byname; - - // collate -diff -rNU3 dist.orig/lto-plugin/configure dist/lto-plugin/configure ---- dist.orig/lto-plugin/configure 2014-04-04 15:53:39.000000000 +0200 -+++ dist/lto-plugin/configure 2015-10-18 13:19:54.000000000 +0200 -@@ -2213,7 +2213,7 @@ - for ac_t in install-sh install.sh shtool; do - if test -f "$ac_dir/$ac_t"; then - ac_aux_dir=$ac_dir -- ac_install_sh="$ac_aux_dir/$ac_t -c" -+ ac_install_sh="$SHELL $ac_aux_dir/$ac_t -c" - break 2 - fi - done diff --git a/gnu/usr.bin/texinfo/patches/0000-texinfo-nbsd.patch b/gnu/usr.bin/texinfo/patches/0000-texinfo-nbsd.patch deleted file mode 100644 index 3990db3cc..000000000 --- a/gnu/usr.bin/texinfo/patches/0000-texinfo-nbsd.patch +++ /dev/null @@ -1,4158 +0,0 @@ -diff -rNU3 texinfo.orig/AUTHORS texinfo/AUTHORS ---- texinfo.orig/AUTHORS 2004-04-11 19:56:45.000000000 +0200 -+++ texinfo/AUTHORS 2015-10-18 11:13:23.000000000 +0200 -@@ -1,4 +1,4 @@ --$Id: AUTHORS,v 1.10 2004/04/11 17:56:45 karl Exp $ -+Id: AUTHORS,v 1.10 2004/04/11 17:56:45 karl Exp - Texinfo authors. - - Copyright (C) 2003 Free Software Foundation, Inc. -diff -rNU3 texinfo.orig/INSTALL texinfo/INSTALL ---- texinfo.orig/INSTALL 2004-11-19 14:08:47.000000000 +0100 -+++ texinfo/INSTALL 2015-10-18 11:13:23.000000000 +0200 -@@ -1,4 +1,4 @@ --$Id: INSTALL,v 1.5 2004/11/19 13:08:47 karl Exp $ -+Id: INSTALL,v 1.5 2004/11/19 13:08:47 karl Exp - - Copying and distribution of this file, with or without modification, - are permitted in any medium without royalty provided the copyright -diff -rNU3 texinfo.orig/INTRODUCTION texinfo/INTRODUCTION ---- texinfo.orig/INTRODUCTION 2004-04-11 19:56:45.000000000 +0200 -+++ texinfo/INTRODUCTION 2015-10-18 11:13:23.000000000 +0200 -@@ -1,4 +1,4 @@ --$Id: INTRODUCTION,v 1.3 2004/04/11 17:56:45 karl Exp $ -+Id: INTRODUCTION,v 1.3 2004/04/11 17:56:45 karl Exp - Getting started with Texinfo. - - Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 -diff -rNU3 texinfo.orig/Makefile.am texinfo/Makefile.am ---- texinfo.orig/Makefile.am 2004-12-15 19:14:56.000000000 +0100 -+++ texinfo/Makefile.am 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,5 @@ - # Makefile.am for texinfo. --# $Id: Makefile.am,v 1.13 2004/12/15 16:53:59 kasal Exp $ -+# Id: Makefile.am,v 1.13 2004/12/15 16:53:59 kasal Exp - # Process this file with automake to produce Makefile.in in all directories. - # - # This file is free software; as a special exception the author gives -diff -rNU3 texinfo.orig/Makefile.in texinfo/Makefile.in ---- texinfo.orig/Makefile.in 2004-12-31 19:01:49.000000000 +0100 -+++ texinfo/Makefile.in 2015-10-18 11:13:23.000000000 +0200 -@@ -15,7 +15,7 @@ - @SET_MAKE@ - - # Makefile.am for texinfo. --# $Id: Makefile.am,v 1.13 2004/12/15 16:53:59 kasal Exp $ -+# Id: Makefile.am,v 1.13 2004/12/15 16:53:59 kasal Exp - # Process this file with automake to produce Makefile.in in all directories. - # - # This file is free software; as a special exception the author gives -@@ -230,7 +230,7 @@ - # This is to prevent texinfo.tex from being included in the top-level - # distribution directory. - TEXINFO_TEX = doc/texinfo.tex --@TOOLS_ONLY_FALSE@SUBDIRS = $(native_tools) intl m4 lib info makeinfo po util doc -+@TOOLS_ONLY_FALSE@SUBDIRS = $(native_tools) intl m4 lib makeinfo po util doc - @TOOLS_ONLY_TRUE@SUBDIRS = lib info makeinfo util - - # for gettext. -diff -rNU3 texinfo.orig/NEWS texinfo/NEWS ---- texinfo.orig/NEWS 2004-12-31 19:01:29.000000000 +0100 -+++ texinfo/NEWS 2015-10-18 11:13:23.000000000 +0200 -@@ -1,4 +1,4 @@ --$Id: NEWS,v 1.103 2004/12/24 16:43:58 karl Exp $ -+Id: NEWS,v 1.103 2004/12/24 16:43:58 karl Exp - This file records noteworthy changes, very tersely. - See the manual for detailed information. - -diff -rNU3 texinfo.orig/README texinfo/README ---- texinfo.orig/README 2004-12-13 14:36:32.000000000 +0100 -+++ texinfo/README 2015-10-18 11:13:23.000000000 +0200 -@@ -1,4 +1,4 @@ --$Id: README,v 1.16 2004/12/13 13:36:32 karl Exp $ -+Id: README,v 1.16 2004/12/13 13:36:32 karl Exp - This is the README file for the GNU Texinfo distribution. Texinfo is - the preferred documentation format for GNU software. - -diff -rNU3 texinfo.orig/README.dev texinfo/README.dev ---- texinfo.orig/README.dev 2003-11-24 16:11:06.000000000 +0100 -+++ texinfo/README.dev 2015-10-18 11:13:23.000000000 +0200 -@@ -1,4 +1,4 @@ --$Id: README.dev,v 1.7 2003/11/24 15:11:06 karl Exp $ -+Id: README.dev,v 1.7 2003/11/24 15:11:06 karl Exp - README.dev - Texinfo developer information. - - Copyright (C) 2002, 2003 Free Software Foundation, Inc. -diff -rNU3 texinfo.orig/TODO texinfo/TODO ---- texinfo.orig/TODO 2004-11-23 00:57:32.000000000 +0100 -+++ texinfo/TODO 2015-10-18 11:13:23.000000000 +0200 -@@ -1,4 +1,4 @@ --$Id: TODO,v 1.26 2004/11/22 23:57:32 karl Exp $ -+Id: TODO,v 1.26 2004/11/22 23:57:32 karl Exp - This is the todo list for GNU Texinfo. - If you are interested in working on any of these, email bug-texinfo@gnu.org. - -diff -rNU3 texinfo.orig/config.guess texinfo/config.guess ---- texinfo.orig/config.guess 2004-11-14 14:10:31.000000000 +0100 -+++ texinfo/config.guess 2015-10-18 11:13:23.000000000 +0200 -@@ -780,7 +780,7 @@ - *:FreeBSD:*:*) - echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` - exit 0 ;; -- i*:CYGWIN*:*) -+ i*:CYGWIN*:* | x86*:CYGWIN*:*) - echo ${UNAME_MACHINE}-pc-cygwin - exit 0 ;; - i*:MINGW*:*) -@@ -923,6 +923,9 @@ - sparc:Linux:*:* | sparc64:Linux:*:*) - echo ${UNAME_MACHINE}-unknown-linux-gnu - exit 0 ;; -+ tile*:Linux:*:*) -+ echo ${UNAME_MACHINE}-unknown-linux-gnu -+ exit 0 ;; - x86_64:Linux:*:*) - echo x86_64-unknown-linux-gnu - exit 0 ;; -diff -rNU3 texinfo.orig/configure texinfo/configure ---- texinfo.orig/configure 2004-12-31 19:01:50.000000000 +0100 -+++ texinfo/configure 2015-10-18 11:13:23.000000000 +0200 -@@ -1771,6 +1771,30 @@ - - - -+echo "$as_me:$LINENO: checking whether to enable maintainer-specific portions of Makefiles" >&5 -+echo $ECHO_N "checking whether to enable maintainer-specific portions of Makefiles... $ECHO_C" >&6 -+ # Check whether --enable-maintainer-mode or --disable-maintainer-mode was given. -+if test "${enable_maintainer_mode+set}" = set; then -+ enableval="$enable_maintainer_mode" -+ USE_MAINTAINER_MODE=$enableval -+else -+ USE_MAINTAINER_MODE=no -+fi; -+ echo "$as_me:$LINENO: result: $USE_MAINTAINER_MODE" >&5 -+echo "${ECHO_T}$USE_MAINTAINER_MODE" >&6 -+ -+ -+if test $USE_MAINTAINER_MODE = yes; then -+ MAINTAINER_MODE_TRUE= -+ MAINTAINER_MODE_FALSE='#' -+else -+ MAINTAINER_MODE_TRUE='#' -+ MAINTAINER_MODE_FALSE= -+fi -+ -+ MAINT=$MAINTAINER_MODE_TRUE -+ -+ - - # When the Texinfo source is imported into other repositories - # (NetBSD and TeX Live), timestamps are generally not preserved. This -diff -rNU3 texinfo.orig/configure.ac texinfo/configure.ac ---- texinfo.orig/configure.ac 2004-12-31 19:00:48.000000000 +0100 -+++ texinfo/configure.ac 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,5 @@ - # Process this file with autoconf to produce a configure script. --# $Id: configure.ac,v 1.50 2004/12/22 13:29:44 karl Exp $ -+# Id: configure.ac,v 1.50 2004/12/22 13:29:44 karl Exp - # - # This file is free software; as a special exception the author gives - # unlimited permission to copy and/or distribute it, with or without -diff -rNU3 texinfo.orig/djgpp/README texinfo/djgpp/README ---- texinfo.orig/djgpp/README 2002-09-27 00:01:10.000000000 +0200 -+++ texinfo/djgpp/README 1970-01-01 01:00:00.000000000 +0100 -@@ -1,431 +0,0 @@ --Building and installing GNU Texinfo with DJGPP v2.x --=================================================== -- --This directory holds files required for building Texinfo with DJGPP --tools for MS-DOS and MS-Windows. If you got this file with a binary --distribution, look for the "Installation" section below. -- -- --1. Building Texinfo -- ---------------- -- -- a. To compile Texinfo, you will need the following tools: -- -- - basic DJGPP development environment: GCC, Binutils and djdev; -- - a DJGPP port of GNU Make version 3.78 or later; -- - a DJGPP port of Bash 2.04 or later; -- - a port of GNU Sed 3.02 or later; -- - DJGPP ports of Fileutils, Textutils, Sh-utils, Diffutils, -- Gawk and Grep; -- - etags (from the Emacs distribution) and mkid (from ID-utils) -- if you need the TAGS and ID targets of the Makefile's. -- -- All of the above are available from the DJGPP ftp sites on -- SimTel.NET mirrors, in the v2gnu directory. -- -- b. From the root of your DJGPP installation, unzip the source package: -- -- - if you are unpacking the official GNU source distribution: -- -- tar -xvzf texinfo-X.YZ.tar.gz -- -- or -- -- djtar -x texinfo-X.YZ.tar.gz -- -- where X.YZ is the version number. (Users of MS-DOS and -- MS-Windows 3.X, which don't support long file names, will need -- to rename the archive to something like texi-XYZ.tgz.) -- -- - if you are unpacking a source distribution from a DJGPP ftp -- site: -- -- unzip txiXYZs -- -- or -- -- pkunzip -d txiXYZs -- -- If you build Texinfo on Windows 9X, Windows ME, Windows 2000 or -- Windows XP, you are advised to use a version of Unzip which -- supports long filenames, so that the original long filenames of -- the source files will be preserved. Otherwise, the build -- procedure will most probably fail. -- -- Do NOT use an unzip program which supports long file names on -- Windows NT 4, as DJGPP doesn't support long names there. -- -- The program unzip32.exe, available from the SimTel.NET site, -- will deal correctly with long file names on any platform, so it -- is the recommended way of unzipping txiXYZs.zip archives. -- -- c. If the source distribution comes with a ready Makefile (this is -- usually the case with archives downloaded from the DJGPP sites), -- and all you need is to build Texinfo, you may skip the configure -- step below and go directly to step e. -- -- d. To build the official GNU distribution, or to configure Texinfo -- for any environment but stock DJGPP v2.x, run djgpp\config.bat -- first, like this: -- -- SRCDIR\djgpp\config SRCDIR -- -- Here SRCDIR is the directory where you unpacked the sources. If -- you are configuring from the source directory itself, you may -- omit the argument to the config.bat file. If you do supply the -- argument, you MUST use forward slashes in it, or else the batch -- file might fail. -- -- config.bat sets some environment variables, then invokes the -- configure script. The script will run for a few minutes and -- create Makefile's in all the directories, and the config.h file. -- -- e. Run `Make'. This builds the programs and the Info files. -- -- -- --2. Installation -- ------------ -- -- a. If you are installing the binary distribution, then go to your -- main DJGPP directory and unzip the files. For instance, if your -- DJGPP installation is rooted on C:\DJGPP, then type this (XYZ is -- the version number): -- -- cd c:\djgpp -- unzip txiXYZb -- -- or, if you prefer `pkunzip': -- -- pkunzip -d txiXYZb -- -- b. If you downloaded and built Texinfo from sources, install by -- invoking Make: -- -- make install -- -- This requires a port of Unix-like program `install.exe'. It is -- available from the DJGPP port of GNU Fileutils on SimTel.NET. -- -- c. Info needs a file named DIR with the top-level menu of all the -- Info files installed on your system. If you installed the DJGPP -- development environment (djdevNN.zip), then you already have -- this file in the info/ subdirectory of your DJGPP installation. -- Otherwise, you will need to create it. A minimal DIR file is -- available in this distribution under the name `dir-example', -- which you can use as a starting point. Copy it to the directory -- where you install the Info files from this distribution. -- -- Even if you already have a DIR file, you should review it to -- make sure it is consistent with the names of the Info file you -- are installing. Here's how your Texinfo-related entries in DIR -- should look like: -- -- * Info: (info). -- Documentation browsing system. This topic teaches you about -- how to use the online help information. -- -- * Info-Standalone: (info-stnd). -- This topic helps you use the standalone Info-Program (info.exe) -- -- * infokey: (info-stnd)Invoking infokey. -- Compile Info key customizations. -- -- * Makeinfo: (texinfo)Invoking makeinfo. -- Convert a .texinfo file (.txi) to an info file suitable for the -- info reader or Emacs, into plain ASCII, into HTML, into XML, -- or into DocBook. -- -- * Texinfo: (texinfo). -- With one source file, make either a printed manual (through TeX) -- or an on-line manual (through makeinfo). This topic includes -- a full description of the Texinfo language and related -- facilities, including Emacs commands to work with Texinfo files. -- -- * install-info: (texinfo)Invoking install-info. -- How to update info/dir entries when installing GNU packages. -- -- * texi2dvi: (texinfo)Format with texi2dvi. -- Printing Texinfo documentation with TeX. -- -- * texindex: (texinfo)Format with tex/texindex. -- Sorting Texinfo index files automatically. -- -- -- Note that the asterisk `*' should be flushed all the way to the -- left, it is indented here just to make reading more convenient. -- -- If your DIR file entries differ from these, I suggest to edit them -- so they are as shown above. Otherwise, Info might not be able to -- find some of the files. You HAVE been warned! -- -- d. Optionally, set up environment variables for Info. These are: -- -- * INFO_LINES -- screen size for Info. -- * INFO_COLORS -- screen colors for Info. -- -- (If you have DJGPP installed on your system, the file djgpp.env -- which comes with it already has entries for Info, see the [info] -- section there.) -- -- INFO_LINES can be one of 25 (the default), 28, 35, 40, 43, or 50 -- (that's if you have a VGA; EGAs only support 25, 35 and 43 lines). -- I recommend 40 if your monitor is 17" or larger, and at least 28 -- lines for smaller monitors (I work with 40 lines even on 14" -- monitors). -- -- INFO_COLORS should have the following syntax: -- -- set INFO_COLORS=XX.YY -- -- where XX is the text attribute for text displayed in the text -- windows and the echo area, and YY is the text attribute for the -- modeline (aka the status line). Each attribute is a numeric -- value of a byte which describes the desired combination of -- foreground and background colors. The individual bits in the -- attribute byte are defined as follows: -- -- bBBBFFFF -- -- where `b' is the blink bit, `BBB' are the 3 bits for background -- color and `FFFF' are the 4 bits for the foreground color. This is -- the usual PC text attribute byte structure, and is further explained -- in any standard reference on text-mode programming for the PC. -- -- My favorite setting for INFO_COLORS is `0x1e.0x31'. This makes -- Info use yellow foreground on blue background for the text and -- blue foreground on cyan background for the modelines. -- -- After you've played with these variables and have chosen the values -- you like, it's a good idea to put them on the DJGPP.ENV file, in the -- [info] section. -- -- e. Beginning with version 3.6, GNU Info can read Unix man pages. If -- you have a `man' clone on your system and would like to be able to -- read man pages with Info, read the chapter ``Reading Man Pages'' -- below. One such clone is available as v2apps/manXYb.zip from -- the DJGPP sites (XY is the version number). -- -- f. This port supports compressed Info files, like what Info under Unix -- gives you. For this to work, you will need to install a DOS port of -- GNU `Gzip' package and to observe certain rules of file naming, so -- that Info will find the compressed files working around the DOS 8.3 -- filename restriction. The chapter ``Compressed Info Files'' below -- explains the details of this. -- -- g. If you need to use the `print-node' command, read the chapter -- ``Printing Nodes'' below. -- -- h. That's it! You are now ready to use Info, Makeinfo, and Texindex. -- To learn about them, type `Info' and press [Enter]. You will be -- presented with the top-level menu of GNU/DJGPP hypertext -- documentation. If you are unfamiliar with Info, press `?' to see -- the available commands. Pressing `h' will cause Info to take you on -- a guided tour through its features (recommended for first-time -- users). -- -- i. If you are used to Info ports of versions before 3.6, you should -- know that the command bindings to PC-specific keys has changed: the -- numeric keypad keys invoke the same commands as their extended -- namesakes. That is, e.g., the key `PgUp' on the numeric keypad -- invokes the same command as the grey `PgUp' key on the extended -- keypad. This was done at DJ's request, because laptop machines -- don't have extended keys. Commands to move between nodes -- (previously bound to numeric keypad) are now bound to Ctrl- -- varieties of numeric keypad keys (e.g., `next-node' is on -- `Ctrl-PgDn', `prev-node' is on `Ctrl-PgUp', etc.). You can use -- the `Alt-x describe-key' command to see which command is invoked -- by a particular key. -- -- j. There are several MSDOS-specific changes in Texinfo, relative to -- previous Texinfo ports (for other changes, see the file NEWS): -- -- * Full support for both forward and backslashes in all file -- names. Previously, Info was sensitive to the style of -- slashes in directories mentioned in the INFOPATH environment -- variable. -- -- * The default operation of the `print-node' command has been -- changed so that it automatically prints to the local printer -- device connected to the PRN port. (If your printer is -- connected to another port, set the INFO_PRINT_COMMAND -- environment variable like this: -- -- set INFO_PRINT_COMMAND=>LPT2 -- -- In other words, if the value of INFO_PRINT_COMMAND begins -- wih a `>' character, Info will write to the file or device -- whose name follows the `>' character. (Don't leave any -- blanks between `>' and the device name!). -- -- Note that some old versions of stock DOS shell won't let you -- use the `>' character in environment variables set from the -- DOS prompt or batch files, but you can set it in the [info] -- section of your DJGPP.ENV file. -- -- * The `set-screen-height' command now actually changes the -- screen dimensions from within Info if you specify one of the -- sizes supported by your video hardware. -- -- * If you don't have a `man' clone installed, and you invoke -- Info with a name of a document which Info cannot find, it -- will no longer wait for 15 seconds. -- -- * Several bugs in handling of man pages were corrected. -- -- * Info opens the dribble and input files in BINARY mode. This -- allows to record keystrokes and restore them in another Info -- session, thus using dribble files as a startup or init file -- which changes default behavior, binds keys, etc. -- -- * Info recognizes a new DOS-specific command-line option `-b' -- or `--speech-friendly'. This option causes Info to use DOS -- I/O functions (`printf', `puts', etc.) instead of direct -- screen writes, which is required to enable speech -- synthesizer software (used by visually-impaired people) to -- grab the output. When this option is given, the screen -- colors defined by the `INFO_COLORS' environment variable and -- the visible-bell feature will be disabled, because stdio -- functions don't support neither color text nor inverting -- screen colors. This improvement was suggested and -- originally implemented by Hans-Bernhard Broeker -- . -- -- * Makeinfo now generates full .info-NN filenames when long -- filenames are supported (e.g. on Win9x) and short .iNN -- filenames otherwise. When the Texinfo source or the -- command-line parameter -o specify an output file with no -- extension (like `texinfo'), and long filenames aren't -- supported, Makeinfo will make sure the generated names will -- be unique (it will create e.g. `texinf-1', `texin-10' etc.). -- -- * The texi2dvi script is now fully compatible with -- MS-DOS/MS-Windows and with the DJGPP port of TeX. -- -- --3. Reading Man Pages -- ----------------- -- -- Yes, Info can now read man pages! This port supports that feature, -- but for it to work, you will have to make sure your `man' clone is -- set up correctly: -- -- a. You should have an executable file named `man.exe', `man.com' -- etc. somewhere on your PATH. -- -- b. When invoked with redirected stdout, that executable should -- print the contents of the file it gets as its argument to stdout -- and exit. If your man command calls some pager, that pager -- should have this behavior (various ports of Unix command `more' -- and the DJGPP port of GNU Less behave that way). -- -- One `man' clone is available as v2apps/manNNb.zip from the DJGPP -- sites on SimTel.NET. -- -- --4. Compressed Info Files -- --------------------- -- -- Info allows you to hold your Info files in compressed form, to save -- disk space. When a file Info wants cannot be found, it will -- automatically try to find that file in compressed form. Info does -- this by trying to find the original file with specific extensions. -- Each extension tells Info which program should be called to -- decompress the file. -- -- This port supports compression by the GNU Gzip program. When Info -- cannot find a file `foo', it will first try to find `foo.z' or -- `foo.gz'. If this fails, and the file has an extension, the last -- one or two characters of the extension are replaced by `z' and `gz' -- respectively, and Info tries again. If it finds any of these, it -- will call the `GUnzip' program to decompress the file, catch its -- output and display it. (The original compressed file stays -- intact.) -- -- So, to use this feature, compress your files with Gzip and call the -- compressed files using the following as guidelines: -- -- foo --> foo.gz -- foo.inf --> foo.igz -- foo.i5 --> foo.i5z -- foo.25 --> foo.25z -- -- If you have a package whose Info docs are split into more than 9 -- sub-files and you need to compress those files, you will have to -- rename the sub-files from `foo.iNN' to `foo.NN' so that there will -- be place for the trailing `z' in the compressed names. Don't -- forget to edit the indirect file table in the main Info file and -- change the sub-file filenames there too! -- -- An alternative for those packages which have more than 99 Info -- sub-files is to generate them from the Texinfo sources and force -- Makeinfo to produce files without the .iNN extensions, like this: -- -- makeinfo -o foo foo.txi -- -- This causes Makeinfo to generate file names like foo-1, foo-2, -- etc., which leave more place for the numeric index. If necessary, -- Makeinfo will automatically remove characters from the end of the -- argument to `-o'. For example, "-o texinfo" produces files -- texinf-1, ..., texin-10, ..., texi-100, etc. on platforms which -- only support 8+3 file names. -- -- Saying "@setfilename foo" near the beginning of the Texinfo source -- file is another way of forcing Makeinfo to produce files without -- the .iNN extensions. -- -- Using Makeinfo to produce files whose names are "compression-ready" -- is more convenient, since you don't need to edit the the indirect -- file table to reflect the changes in file names. -- -- On platforms which support long filenames, the usual Info behavior -- of appending `.gz' or `.Z' to the original filename also works; -- this is done *before* Info checks the above butchered names. -- -- Special considerations apply if you are installing Info on dual -- DOS/Windows 9X/ME/2K/XP system, where you'd like Info to work with -- the same files both in plain DOS and from the Windows DOS box. In -- this case, you should make sure your compressed Info files follow -- the 8+3 DOS naming conventions outlined above, even though Info -- supports long file names on Windows 9X. Also, you need to turn off -- the generation of numeric tails in short 8+3 aliases Windows -- creates for long names (if you don't know how, the DJGPP FAQ list -- explains it). -- -- Please note: for the automatic decompression to work, Info must be -- able to find the file it looks for with an extension which -- indicates that the file is compressed. Do NOT call the compressed -- files as the original uncompressed files were called, or Info -- won't be able to find them! File names like bison-1, gcc.i10 or -- make.info-3 have nothing in them to suggest that they are -- compressed, so don't expect Info to uncompress them. -- -- --5. Printing Nodes -- -------------- -- -- Info has a `print-node' command. It works by piping the contents of -- the current node through a program which is named by the environment -- variable INFO_PRINT_COMMAND. That command should read its standard -- input and write it to your printer. Find any such program, put its -- name into the above environment variable, and you can print nodes from -- within Info. -- -- If the value of INFO_PRINT_COMMAND begins with a redirection -- character `>', Info will write the contents of the node to the file -- whose name follows the `>' character. -- -- If INFO_PRINT_COMMAND is not defined, the DJGPP port will use -- ">PRN" as the default, which causes it to print to the local printer -- device, PRN. -- --6. Bug Reports -- ----------- -- -- If you see any bugs which seem specific to this DOS port, please tell -- me about them. -- -- -- Enjoy, -- -- Eli Zaretskii -diff -rNU3 texinfo.orig/djgpp/config.bat texinfo/djgpp/config.bat ---- texinfo.orig/djgpp/config.bat 2004-12-17 23:47:55.000000000 +0100 -+++ texinfo/djgpp/config.bat 1970-01-01 01:00:00.000000000 +0100 -@@ -1,240 +0,0 @@ --@echo off -- --echo Configuring GNU Texinfo for DJGPP v2.x... -- --Rem The small_env tests protect against fixed and too small size --Rem of the environment in stock DOS shell. -- --Rem Find out if NLS is wanted or not, if dependency-tracking is --Rem wanted or not, if cache is wanted or not, and where the sources are. --set ARGS= --set NLS=disabled --if not "%NLS%" == "disabled" goto small_env --set CACHE=enabled --if not "%CACHE%" == "enabled" goto small_env --set DEPTRAK=disabled --if not "%DEPTRAK%" == "disabled" goto small_env --set XSRC=. --if not "%XSRC%" == "." goto small_env -- --Rem Loop over all arguments. --Rem Special arguments are: NLS, XSRC CACHE and DEPS. --Rem All other arguments are stored into ARGS. --:arg_loop --set SPECARG=0 --if not "%SPECARG%" == "0" goto small_env --if not "%1" == "NLS" if not "%1" == "nls" goto cache_opt --if "%1" == "nls" set NLS=enabled --if "%1" == "NLS" set NLS=enabled --if not "%NLS%" == "enabled" goto small_env --set SPECARG=1 --if not "%SPECARG%" == "1" goto small_env --shift --:cache_opt --set SPECARG=0 --if not "%SPECARG%" == "0" goto small_env --if "%1" == "no-cache" goto cache_off --if "%1" == "no-CACHE" goto cache_off --if not "%1" == "NO-CACHE" goto dependency_opt --:cache_off --if "%1" == "no-cache" set CACHE=disabled --if "%1" == "no-CACHE" set CACHE=disabled --if "%1" == "NO-CACHE" set CACHE=disabled --if not "%CACHE%" == "disabled" goto small_env --set SPECARG=1 --if not "%SPECARG%" == "1" goto small_env --shift --:dependency_opt --set SPECARG=0 --if not "%SPECARG%" == "0" goto small_env --if "%1" == "dep" goto dep_off --if not "%1" == "DEP" goto src_dir_opt --:dep_off --if "%1" == "dep" set DEPTRAK=enabled --if "%1" == "DEP" set DEPTRAK=enabled --if not "%DEPTRAK%" == "enabled" goto small_env --set SPECARG=1 --if not "%SPECARG%" == "1" goto small_env --shift --:src_dir_opt --set SPECARG=0 --if not "%SPECARG%" == "0" goto small_env --echo %1 | grep -q "/" --if errorlevel 1 goto collect_arg --set XSRC=%1 --if not "%XSRC%" == "%1" goto small_env --set SPECARG=1 --if not "%SPECARG%" == "1" goto small_env --:collect_arg --if "%SPECARG%" == "0" set _ARGS=%ARGS% %1 --if "%SPECARG%" == "0" if not "%_ARGS%" == "%ARGS% %1" goto small_env --echo %_ARGS% | grep -q "[^ ]" --if not errorlevel 0 set ARGS=%_ARGS% --set _ARGS= --shift --if not "%1" == "" goto arg_loop --set SPECARG= -- --Rem Create a response file for the configure script. --echo --srcdir=%XSRC% > arguments --if "%CACHE%" == "enabled" echo --config-cache >>arguments --if "%DEPTRAK%" == "enabled" echo --enable-dependency-tracking >>arguments --if "%DEPTRAK%" == "disabled" echo --disable-dependency-tracking >>arguments --if not "%ARGS%" == "" echo %ARGS% >>arguments --set ARGS= --set CACHE= --set DEPTRAK= -- --if "%XSRC%" == "." goto in_place -- --:not_in_place --redir -e /dev/null update %XSRC%/configure.orig ./configure --test -f ./configure --if errorlevel 1 update %XSRC%/configure ./configure -- --:in_place --Rem Update configuration files --echo Updating configuration scripts... --test -f ./configure.orig --if errorlevel 1 update configure configure.orig --sed -f %XSRC%/djgpp/config.sed configure.orig > configure --if errorlevel 1 goto sed_error -- --Rem Make sure they have a config.site file --set CONFIG_SITE=%XSRC%/djgpp/config.site --if not "%CONFIG_SITE%" == "%XSRC%/djgpp/config.site" goto small_env -- --Rem Make sure crucial file names are not munged by unpacking --test -f %XSRC%/po/Makefile.in.in --if not errorlevel 1 mv -f %XSRC%/po/Makefile.in.in %XSRC%/po/Makefile.in-in --test -f %XSRC%/po/Makefile.am.in --if not errorlevel 1 mv -f %XSRC%/po/Makefile.am.in %XSRC%/po/Makefile.am-in -- --Rem This is required because DOS/Windows are case-insensitive --Rem to file names, and "make install" will do nothing if Make --Rem finds a file called `install'. --if exist INSTALL ren INSTALL INSTALL.txt -- --Rem Set HOME to a sane default so configure stops complaining. --if not "%HOME%" == "" goto host_name --set HOME=%XSRC%/djgpp --if not "%HOME%" == "%XSRC%/djgpp" goto small_env --echo No HOME found in the environment, using default value -- --:host_name --Rem Set HOSTNAME so it shows in config.status --if not "%HOSTNAME%" == "" goto hostdone --if "%windir%" == "" goto msdos --set OS=MS-Windows --if not "%OS%" == "MS-Windows" goto small_env --goto haveos --:msdos --set OS=MS-DOS --if not "%OS%" == "MS-DOS" goto small_env --:haveos --if not "%USERNAME%" == "" goto haveuname --if not "%USER%" == "" goto haveuser --echo No USERNAME and no USER found in the environment, using default values --set HOSTNAME=Unknown PC --if not "%HOSTNAME%" == "Unknown PC" goto small_env --goto userdone --:haveuser --set HOSTNAME=%USER%'s PC --if not "%HOSTNAME%" == "%USER%'s PC" goto small_env --goto userdone --:haveuname --set HOSTNAME=%USERNAME%'s PC --if not "%HOSTNAME%" == "%USERNAME%'s PC" goto small_env --:userdone --set _HOSTNAME=%HOSTNAME%, %OS% --if not "%_HOSTNAME%" == "%HOSTNAME%, %OS%" goto small_env --set HOSTNAME=%_HOSTNAME% --:hostdone --set _HOSTNAME= --set OS= -- --Rem install-sh is required by the configure script but clashes with the --Rem various Makefile install-foo targets, so we MUST have it before the --Rem script runs and rename it afterwards --test -f %XSRC%/install-sh --if not errorlevel 1 goto no_ren0 --test -f %XSRC%/install-sh.sh --if not errorlevel 1 mv -f %XSRC%/install-sh.sh %XSRC%/install-sh --:no_ren0 -- --if "%NLS%" == "disabled" goto without_NLS -- --:with_NLS --Rem Check for the needed libraries and binaries. --test -x /dev/env/DJDIR/bin/msgfmt.exe --if not errorlevel 0 goto missing_NLS_tools --test -x /dev/env/DJDIR/bin/xgettext.exe --if not errorlevel 0 goto missing_NLS_tools --test -f /dev/env/DJDIR/include/libcharset.h --if not errorlevel 0 goto missing_NLS_tools --test -f /dev/env/DJDIR/lib/libcharset.a --if not errorlevel 0 goto missing_NLS_tools --test -f /dev/env/DJDIR/include/iconv.h --if not errorlevel 0 goto missing_NLS_tools --test -f /dev/env/DJDIR/lib/libiconv.a --if not errorlevel 0 goto missing_NLS_tools --test -f /dev/env/DJDIR/include/libintl.h --if not errorlevel 0 goto missing_NLS_tools --test -f /dev/env/DJDIR/lib/libintl.a --if not errorlevel 0 goto missing_NLS_tools -- --Rem Recreate the files in the %XSRC%/po subdir with our ported tools. --redir -e /dev/null rm %XSRC%/po/*.gmo --redir -e /dev/null rm %XSRC%/po/diffutil*.pot --redir -e /dev/null rm %XSRC%/po/cat-id-tbl.c --redir -e /dev/null rm %XSRC%/po/stamp-cat-id -- --Rem Update the arguments file for the configure script. --Rem We prefer without-included-gettext because libintl.a from gettext package --Rem is the only one that is guaranteed to have been ported to DJGPP. --echo --enable-nls --without-included-gettext >> arguments --goto configure_package -- --:missing_NLS_tools --echo Needed libs/tools for NLS not found. Configuring without NLS. --:without_NLS --Rem Update the arguments file for the configure script. --echo --disable-nls >> arguments -- --:configure_package --echo Running the ./configure script... --sh ./configure @arguments --if errorlevel 1 goto cfg_error --rm arguments -- --Rem Remove files created by the gl_FUNC_MKSTEMP test. --rm co*.tmp --echo Done. --goto End -- --:sed_error --echo ./configure script editing failed! --goto End -- --:cfg_error --echo ./configure script exited abnormally! --goto End -- --:small_env --echo Your environment size is too small. Enlarge it and run me again. --echo Configuration NOT done! -- --:End --test -f %XSRC%/install-sh.sh --if not errorlevel 1 goto no_ren1 --test -f %XSRC%/install-sh --if not errorlevel 1 mv -f %XSRC%/install-sh %XSRC%/install-sh.sh --:no_ren1 --if "%HOME%" == "%XSRC%/djgpp" set HOME= --set ARGS= --set CONFIG_SITE= --set HOSTNAME= --set NLS= --set CACHE= --set DEPTRAK= --set XSRC= -diff -rNU3 texinfo.orig/djgpp/config.sed texinfo/djgpp/config.sed ---- texinfo.orig/djgpp/config.sed 2004-12-15 15:59:22.000000000 +0100 -+++ texinfo/djgpp/config.sed 1970-01-01 01:00:00.000000000 +0100 -@@ -1,67 +0,0 @@ --# Additional editing of configure and Makefiles for DJGPP -- --/(echo[ ]*':t/ a\ --# DJGPP specific Makefile changes.\ -- /^aliaspath * *=/s,:,";",g;t t\ -- /TEXINPUTS=/s,:,";",g;t t\ -- /PATH=/s,:,";",g;t t\ -- s,\\.deps,_deps,g;t t\ -- s,\\.new\\.,_new.,g;t t\ -- s,\\.old\\.,_old.,g;t t\ -- s,\\.tab\\.,_tab.,g;t t\ -- s,Makefile\\.in\\.in,Makefile.in-in,g;t t\ -- s,Makefile\\.am\\.in,Makefile.am-in,g;t t\ -- /^install-info-am:/,/^$/ {\ -- /@list=.\\\$(INFO_DEPS)\[^ \]/s,DEPS),& texinf- texin- info-stn.i info.inf,\ -- s,\\(\\\$\\\$d/\\\$\\\$file-\\[0-9\\]\\[0-9\\]\\)\\(\[^ \]\\),\\1 \\$\\$d/\\$\\$file[0-9] \\$\\$d/\\$\\$file[0-9][0-9]\\2,\ -- s,\\( \\\$\\\$file-\\[0-9\\]\\[0-9\\]\\)\\(\[^ \]\\),\\1 \\$\\$file[0-9] \\$\\$file[0-9][0-9]\\2,\ -- }\ -- /^uninstall-info-am:/,/^$/ {\ -- /@list=.\\\$(INFO_DEPS)\[^ \]/s,DEPS),& texinf- texin- info-stn.i info.inf,\ -- s,\\(file-\\[0-9\\]\\[0-9\\]\\)\\(\[^ \]\\),\\1 \\$\\$file[0-9] \\$\\$file[0-9][0-9]\\2,\ -- } -- --# Makefile.in.in is renamed to Makefile.in-in. --/ac_config_files=/,/_ACEOF/ { -- s|po/Makefile\.in|&:po/Makefile.in-in| --} --/CONFIG_FILES=/ s|po/Makefile\.in|&:po/Makefile.in-in|2 -- --# We always use _deps instead of .deps, because the latter is an --# invalid name on 8+3 MS-DOS filesystem. This makes the generated --# Makefiles good for every DJGPP installation, not only the one --# where the package was configured (which could happen to be a --# Windows box, where leading dots in file names are allowed). --s,\.deps,_deps,g -- --# The following two items are changes needed for configuring --# and compiling across partitions. --# The given srcdir value is always translated from the --# "x:" syntax into "/dev/x" syntax while we run configure. --/^[ ]*-srcdir=\*.*$/ a\ -- ac_optarg=`echo "$ac_optarg" | sed "s,^\\([A-Za-z]\\):,/dev/\\1,"` --/set X `ls -Lt \$srcdir/ i\ -- if `echo $srcdir | grep "^/dev/" - > /dev/null`; then\ -- srcdir=`echo "$srcdir" | sed -e "s%^/dev/%%" -e "s%/%:/%"`\ -- fi -- --# Autoconf 2.52e generated configure scripts --# write absolute paths into Makefiles making --# them useless for DJGPP installations for which --# the package has not been configured for. --/MISSING=/,/^$/ { -- /^fi$/ a\ --am_missing_run=`echo "$am_missing_run" | sed 's%/dev.*/texinfo-\\{0,1\\}4\\.[0-9][a-z]\\{0,1\\}%${top_srcdir}%;s%.:.*/texinfo-\\{0,1\\}4\\.[0-9][a-z]\\{0,1\\}%${top_srcdir}%'` --} --/^install_sh=/a\ --install_sh=`echo "$install_sh" | sed 's%/dev.*/texinfo-\\{0,1\\}4\\.[0-9][a-z]\\{0,1\\}%${top_srcdir}%;s%.:.*/texinfo-\\{0,1\\}4\\.[0-9][a-z]\\{0,1\\}%${top_srcdir}%'` -- --# The following makes sure we are not going to remove a directory --# which is the cwd on its drive (DOS doesn't allow to remove such --# a directory). The trick is to chdir to the root directory on --# temp directory's drive before removing $tmp. --/^ *trap 'exit_status=\$\?; rm -rf/s%rm -rf%cd $tmp; cd /; &% -- --# AC_CONFIG_LINKS fails if the source and destination are on --# different file systems and symlinks don't work. --/^ ln \$srcdir/s%||%|| cp -pf $srcdir/$ac_source $ac_dest ||% -diff -rNU3 texinfo.orig/djgpp/config.site texinfo/djgpp/config.site ---- texinfo.orig/djgpp/config.site 2002-09-27 00:01:10.000000000 +0200 -+++ texinfo/djgpp/config.site 1970-01-01 01:00:00.000000000 +0100 -@@ -1,53 +0,0 @@ --#! /bin/sh --# Site defaults for the DJGPP configuration -- --# These two variables are required, otherwise looking for --# programs along the PATH will not work. --PATH_SEPARATOR=: --PATH_EXPAND=y -- --# This is required in for "test -f foo" to find foo.exe. --export TEST_FINDS_EXE=y -- --# The root of the DJGPP tree serves as the default prefix --# for all paths that are hardcoded in the binaries. --# When installing the installation prefix must be supplied. --test "x$prefix" = xNONE && prefix='/dev/env/DJDIR' -- --# This is required for config.status script to be run, since --# ./configure runs it by invoking ${CONFIG_SHELL-/bin/sh} --# CONFIG_SHELL=${CONFIG_SHELL='sh'} -- --# These are set here so the generated Makefile's will be good --# for every DJGPP installation, not only the one where the --# package was configured. --# $INSTALL must be an absolute path name, otherwise config.status --# will try to prepend ./ and ../ to it when it goes into subdirs. --INSTALL=${INSTALL='/dev/env/DJDIR/bin/ginstall -c'} --RANLIB=${RANLIB='ranlib'} --GMSGFMT=${GMSGFMT='/dev/env/DJDIR/bin/msgfmt'} --MSGFMT=${MSGFMT='/dev/env/DJDIR/bin/msgfmt'} --XGETTEXT=${XGETTEXT='/dev/env/DJDIR/bin/xgettext'} -- --# Sane defaults for standard programs used by the build process. --# We force the values of these variables so that the resultant --# Makefile's will work on any DJGPP platform, not only on the --# machine where the package was configured. --ac_cv_prog_AWK=${AWK='gawk'} --ac_cv_prog_INTLBISON=${INTLBISON='bison'} --ac_cv_prog_CC=${CC='gcc'} -- --# These are set here so the generated libtool/Makefile's will --# be good for every DJGPP installation, not only the one where --# the package was configured. --NM=${NM='nm'} --LD=${LD='ld'} --MAKEINFO=${MAKEINFO='makeinfo'} -- --# Force the test for 'ln -s' to report 'cp -pf'. --ac_cv_prog_LN_S='cp -pf' -- --# We have `fork', but it always fails. Don't trust Autoconf to be --# smart enough to detect that... --ac_cv_func_fork=no --ac_cv_func_vfork=no -diff -rNU3 texinfo.orig/doc/Makefile.am texinfo/doc/Makefile.am ---- texinfo.orig/doc/Makefile.am 2004-11-18 02:10:59.000000000 +0100 -+++ texinfo/doc/Makefile.am 2015-10-18 11:13:23.000000000 +0200 -@@ -1,4 +1,4 @@ --# $Id: Makefile.am,v 1.20 2004/11/18 01:10:59 karl Exp $ -+# Id: Makefile.am,v 1.20 2004/11/18 01:10:59 karl Exp - # Makefile.am for texinfo/doc. - # Run automake in .. to produce Makefile.in from this. - # -diff -rNU3 texinfo.orig/doc/Makefile.in texinfo/doc/Makefile.in ---- texinfo.orig/doc/Makefile.in 2004-12-31 19:01:47.000000000 +0100 -+++ texinfo/doc/Makefile.in 2015-10-18 11:13:23.000000000 +0200 -@@ -14,7 +14,7 @@ - - @SET_MAKE@ - --# $Id: Makefile.am,v 1.20 2004/11/18 01:10:59 karl Exp $ -+# Id: Makefile.am,v 1.20 2004/11/18 01:10:59 karl Exp - # Makefile.am for texinfo/doc. - # Run automake in .. to produce Makefile.in from this. - # -diff -rNU3 texinfo.orig/doc/README texinfo/doc/README ---- texinfo.orig/doc/README 2004-04-11 19:56:45.000000000 +0200 -+++ texinfo/doc/README 2015-10-18 11:13:23.000000000 +0200 -@@ -1,4 +1,4 @@ --$Id: README,v 1.4 2004/04/11 17:56:45 karl Exp $ -+Id: README,v 1.4 2004/04/11 17:56:45 karl Exp - texinfo/doc/README - - Copyright (C) 2002 Free Software Foundation, Inc. -diff -rNU3 texinfo.orig/doc/fdl.texi texinfo/doc/fdl.texi ---- texinfo.orig/doc/fdl.texi 2003-03-19 02:29:34.000000000 +0100 -+++ texinfo/doc/fdl.texi 2015-10-18 11:13:23.000000000 +0200 -@@ -1,4 +1,5 @@ - -+@c $NetBSD: fdl.texi,v 1.1.1.3 2003/07/03 14:58:45 wiz Exp $ - @node GNU Free Documentation License - @appendixsec GNU Free Documentation License - -diff -rNU3 texinfo.orig/doc/info-stnd.texi texinfo/doc/info-stnd.texi ---- texinfo.orig/doc/info-stnd.texi 2004-12-14 17:58:15.000000000 +0100 -+++ texinfo/doc/info-stnd.texi 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,6 @@ - \input texinfo.tex @c -*-texinfo-*- --@comment $Id: info-stnd.texi,v 1.9 2004/12/14 16:58:15 karl Exp $ -+@c $NetBSD: info-stnd.texi,v 1.1.1.6 2008/09/02 07:51:41 christos Exp $ -+@comment Id: info-stnd.texi,v 1.9 2004/12/14 16:58:15 karl Exp - @c We must \input texinfo.tex instead of texinfo, otherwise make - @c distcheck in the Texinfo distribution fails, because the texinfo Info - @c file is made first, and texi2dvi must include . first in the path. -diff -rNU3 texinfo.orig/doc/info.1 texinfo/doc/info.1 ---- texinfo.orig/doc/info.1 2004-12-31 19:02:15.000000000 +0100 -+++ texinfo/doc/info.1 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+.\" $NetBSD: info.1,v 1.1.1.6 2008/09/02 07:51:56 christos Exp $ -+.\" - .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.34. - .TH INFO "1" "December 2004" "info 4.8" "User Commands" - .SH NAME -diff -rNU3 texinfo.orig/doc/info.5 texinfo/doc/info.5 ---- texinfo.orig/doc/info.5 2004-04-11 19:56:45.000000000 +0200 -+++ texinfo/doc/info.5 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+.\" $NetBSD: info.5,v 1.1.1.4 2008/09/02 07:51:56 christos Exp $ -+.\" - .\" info(5) --.\" $Id: info.5,v 1.2 2004/04/11 17:56:45 karl Exp $ -+.\" Id: info.5,v 1.2 2004/04/11 17:56:45 karl Exp - .\" - .\" Copyright (C) 1998 Free Software Foundation, Inc. - .\" -diff -rNU3 texinfo.orig/doc/info.texi texinfo/doc/info.texi ---- texinfo.orig/doc/info.texi 2004-10-06 23:29:48.000000000 +0200 -+++ texinfo/doc/info.texi 2015-10-18 11:13:23.000000000 +0200 -@@ -1,4 +1,5 @@ - \input texinfo.tex @c -*-texinfo-*- -+@c $NetBSD: info.texi,v 1.1.1.5 2008/09/02 07:51:43 christos Exp $ - @c We must \input texinfo.tex instead of texinfo, otherwise make - @c distcheck in the Texinfo distribution fails, because the texinfo Info - @c file is made first, and texi2dvi must include . first in the path. -diff -rNU3 texinfo.orig/doc/infokey.1 texinfo/doc/infokey.1 ---- texinfo.orig/doc/infokey.1 2004-12-31 19:02:16.000000000 +0100 -+++ texinfo/doc/infokey.1 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+.\" $NetBSD: infokey.1,v 1.1.1.2 2008/09/02 07:51:56 christos Exp $ -+.\" - .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.34. - .TH INFOKEY "1" "December 2004" "infokey 4.8" "User Commands" - .SH NAME -diff -rNU3 texinfo.orig/doc/install-info.1 texinfo/doc/install-info.1 ---- texinfo.orig/doc/install-info.1 2004-12-31 19:02:16.000000000 +0100 -+++ texinfo/doc/install-info.1 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+.\" $NetBSD: install-info.1,v 1.1.1.6 2008/09/02 07:51:46 christos Exp $ -+.\" - .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.34. - .TH INSTALL-INFO "1" "December 2004" "install-info 4.8" "User Commands" - .SH NAME -diff -rNU3 texinfo.orig/doc/makeinfo.1 texinfo/doc/makeinfo.1 ---- texinfo.orig/doc/makeinfo.1 2004-12-31 19:02:16.000000000 +0100 -+++ texinfo/doc/makeinfo.1 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+.\" $NetBSD: makeinfo.1,v 1.2 2009/02/28 19:14:15 joerg Exp $ -+.\" - .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.34. - .TH MAKEINFO "1" "December 2004" "makeinfo 4.8" "User Commands" - .SH NAME -@@ -62,6 +64,9 @@ - suppress splitting of Info or HTML output, - generate only one output file. - .TP -+\fB\-\-no\-version\-header\fR -+suppress header with makeinfo version and source path. -+.TP - \fB\-\-number\-sections\fR - output chapter and sectioning numbers. - .TP -diff -rNU3 texinfo.orig/doc/texi2dvi.1 texinfo/doc/texi2dvi.1 ---- texinfo.orig/doc/texi2dvi.1 2004-12-31 19:03:11.000000000 +0100 -+++ texinfo/doc/texi2dvi.1 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+.\" $NetBSD: texi2dvi.1,v 1.1.1.6 2008/09/02 07:51:56 christos Exp $ -+.\" - .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.34. - .TH TEXI2DVI "1" "December 2004" "texi2dvi 1.34" "User Commands" - .SH NAME -diff -rNU3 texinfo.orig/doc/texindex.1 texinfo/doc/texindex.1 ---- texinfo.orig/doc/texindex.1 2004-12-31 19:02:16.000000000 +0100 -+++ texinfo/doc/texindex.1 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+.\" $NetBSD: texindex.1,v 1.3 2008/09/02 08:00:24 christos Exp $ -+.\" - .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.34. - .TH TEXINDEX "1" "December 2004" "texindex 4.8" "User Commands" - .SH NAME -@@ -13,12 +15,6 @@ - \fB\-h\fR, \fB\-\-help\fR - display this help and exit - .TP --\fB\-k\fR, \fB\-\-keep\fR --keep temporary files around after processing --.TP --\fB\-\-no\-keep\fR --do not keep temporary files around after processing (default) --.TP - \fB\-o\fR, \fB\-\-output\fR FILE - send output to FILE - .TP -diff -rNU3 texinfo.orig/doc/texinfo.5 texinfo/doc/texinfo.5 ---- texinfo.orig/doc/texinfo.5 2004-04-11 19:56:45.000000000 +0200 -+++ texinfo/doc/texinfo.5 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+.\" $NetBSD: texinfo.5,v 1.1.1.4 2008/09/02 07:51:56 christos Exp $ -+.\" - .\" texinfo(5) --.\" $Id: texinfo.5,v 1.2 2004/04/11 17:56:45 karl Exp $ -+.\" Id: texinfo.5,v 1.2 2004/04/11 17:56:45 karl Exp - .\" - .\" Copyright (C) 1998, 1999, 2002 Free Software Foundation, Inc. - .\" -diff -rNU3 texinfo.orig/doc/texinfo.txi texinfo/doc/texinfo.txi ---- texinfo.orig/doc/texinfo.txi 2004-12-29 16:06:41.000000000 +0100 -+++ texinfo/doc/texinfo.txi 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,5 @@ - \input texinfo.tex @c -*-texinfo-*- --@c $Id: texinfo.txi,v 1.128 2004/12/29 15:06:41 karl Exp $ -+@c Id: texinfo.txi,v 1.128 2004/12/29 15:06:41 karl Exp - @c Ordinarily, Texinfo files have the extension .texi. But texinfo.texi - @c clashes with texinfo.tex on 8.3 filesystems, so we use texinfo.txi. - -@@ -12782,7 +12782,7 @@ - - @table @code - @item @@set @var{flag} [@var{value}] --Set the variable @var{flag}, to the optional @var{value} if specifed. -+Set the variable @var{flag}, to the optional @var{value} if specified. - - @item @@clear @var{flag} - Undefine the variable @var{flag}, whether or not it was previously defined. -@@ -18451,7 +18451,7 @@ - Concurrent Versions System}) or RCS (see rcsintro(1)) version control - systems, which expand it into a string such as: - @example --$Id: texinfo.txi,v 1.128 2004/12/29 15:06:41 karl Exp $ -+Id: texinfo.txi,v 1.128 2004/12/29 15:06:41 karl Exp - @end example - (This is useful in all sources that use version control, not just manuals.) - You may wish to include the @samp{$Id:} comment in the @code{@@copying} -@@ -18517,7 +18517,7 @@ - - @verbatim - \input texinfo @c -*-texinfo-*- --@comment $Id: texinfo.txi,v 1.128 2004/12/29 15:06:41 karl Exp $ -+@comment Id: texinfo.txi,v 1.128 2004/12/29 15:06:41 karl Exp - @comment %**start of header - @setfilename sample.info - @include version.texi -diff -rNU3 texinfo.orig/doc/txi-cs.tex texinfo/doc/txi-cs.tex ---- texinfo.orig/doc/txi-cs.tex 2004-04-11 19:56:45.000000000 +0200 -+++ texinfo/doc/txi-cs.tex 2015-10-18 11:13:23.000000000 +0200 -@@ -1,4 +1,4 @@ --% $Id: txi-cs.tex,v 1.3 2004/04/11 17:56:45 karl Exp $ -+% Id: txi-cs.tex,v 1.3 2004/04/11 17:56:45 karl Exp - % Czech translation for texinfo.tex. - % - % Copyright (C) 1999, 2000 Free Software Foundation. -diff -rNU3 texinfo.orig/doc/txi-de.tex texinfo/doc/txi-de.tex ---- texinfo.orig/doc/txi-de.tex 2004-04-11 19:56:45.000000000 +0200 -+++ texinfo/doc/txi-de.tex 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,5 @@ - % txi-de.tex -- adaptation to German for texinfo.tex. --% $Id: txi-de.tex,v 1.3 2004/04/11 17:56:45 karl Exp $ -+% Id: txi-de.tex,v 1.3 2004/04/11 17:56:45 karl Exp - % - % Copyright (C) 1999 Free Software Foundation, Inc. - % -diff -rNU3 texinfo.orig/doc/txi-en.tex texinfo/doc/txi-en.tex ---- texinfo.orig/doc/txi-en.tex 2004-04-11 19:56:45.000000000 +0200 -+++ texinfo/doc/txi-en.tex 2015-10-18 11:13:23.000000000 +0200 -@@ -1,7 +1,7 @@ - % English non-translation for texinfo.tex. This is read when a source - % document says @documentlanguage en (which might happen after another - % @documentlanguage). The actual values are the same as defaults. --% $Id: txi-en.tex,v 1.3 2004/04/11 17:56:45 karl Exp $ -+% Id: txi-en.tex,v 1.3 2004/04/11 17:56:45 karl Exp - % - % Copyright (C) 1999 Free Software Foundation. - % -diff -rNU3 texinfo.orig/doc/txi-fr.tex texinfo/doc/txi-fr.tex ---- texinfo.orig/doc/txi-fr.tex 2004-04-11 19:56:45.000000000 +0200 -+++ texinfo/doc/txi-fr.tex 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,5 @@ - % txi-fr.tex -- TeX macros to handle French language for texinfo.tex documents. --% $Id: txi-fr.tex,v 1.3 2004/04/11 17:56:45 karl Exp $ -+% Id: txi-fr.tex,v 1.3 2004/04/11 17:56:45 karl Exp - % - % Copyright (C) 1999 Free Software Foundation. - % -diff -rNU3 texinfo.orig/doc/txi-it.tex texinfo/doc/txi-it.tex ---- texinfo.orig/doc/txi-it.tex 2004-04-11 19:56:45.000000000 +0200 -+++ texinfo/doc/txi-it.tex 2015-10-18 11:13:23.000000000 +0200 -@@ -1,7 +1,7 @@ - % English non-translation for texinfo.tex. This is read when a source - % document says @documentlanguage en (which might happen after another - % @documentlanguage). The actual values are the same as defaults. --% $Id: txi-it.tex,v 1.3 2004/04/11 17:56:45 karl Exp $ -+% Id: txi-it.tex,v 1.3 2004/04/11 17:56:45 karl Exp - % - % Copyright (C) 1999 Free Software Foundation. - % -diff -rNU3 texinfo.orig/doc/txi-nl.tex texinfo/doc/txi-nl.tex ---- texinfo.orig/doc/txi-nl.tex 2004-04-11 19:56:45.000000000 +0200 -+++ texinfo/doc/txi-nl.tex 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,5 @@ - % Dutch translation for texinfo.tex. --% $Id: txi-nl.tex,v 1.3 2004/04/11 17:56:45 karl Exp $ -+% Id: txi-nl.tex,v 1.3 2004/04/11 17:56:45 karl Exp - % - % Copyright (C) 1999 Free Software Foundation. - % -diff -rNU3 texinfo.orig/doc/txi-pl.tex texinfo/doc/txi-pl.tex ---- texinfo.orig/doc/txi-pl.tex 2004-04-11 19:56:45.000000000 +0200 -+++ texinfo/doc/txi-pl.tex 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,5 @@ - % txi-pl.tex -- adaptation to Polish for texinfo.tex. --% $Id: txi-pl.tex,v 1.3 2004/04/11 17:56:45 karl Exp $ -+% Id: txi-pl.tex,v 1.3 2004/04/11 17:56:45 karl Exp - % - % Copyright (C) 2003 Free Software Foundation. - % -diff -rNU3 texinfo.orig/doc/txi-tr.tex texinfo/doc/txi-tr.tex ---- texinfo.orig/doc/txi-tr.tex 2004-04-11 19:56:45.000000000 +0200 -+++ texinfo/doc/txi-tr.tex 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,5 @@ - % txi-en.tex -- adaptation to Turkish for texinfo.tex. --% $Id: txi-tr.tex,v 1.3 2004/04/11 17:56:45 karl Exp $ -+% Id: txi-tr.tex,v 1.3 2004/04/11 17:56:45 karl Exp - % - % Copyright (C) 2003 Free Software Foundation, Inc. - % -diff -rNU3 texinfo.orig/doc/version-stnd.texi texinfo/doc/version-stnd.texi ---- texinfo.orig/doc/version-stnd.texi 2004-12-31 19:02:15.000000000 +0100 -+++ texinfo/doc/version-stnd.texi 2015-10-18 11:13:23.000000000 +0200 -@@ -1,4 +1,5 @@ - @set UPDATED 14 December 2004 -+@c $NetBSD: version-stnd.texi,v 1.1.1.5 2008/09/02 07:51:36 christos Exp $ - @set UPDATED-MONTH December 2004 - @set EDITION 4.8 - @set VERSION 4.8 -diff -rNU3 texinfo.orig/doc/version.texi texinfo/doc/version.texi ---- texinfo.orig/doc/version.texi 2004-12-31 19:02:15.000000000 +0100 -+++ texinfo/doc/version.texi 2015-10-18 11:13:23.000000000 +0200 -@@ -1,4 +1,5 @@ - @set UPDATED 29 December 2004 -+@c $NetBSD: version.texi,v 1.1.1.6 2008/09/02 07:51:46 christos Exp $ - @set UPDATED-MONTH December 2004 - @set EDITION 4.8 - @set VERSION 4.8 -diff -rNU3 texinfo.orig/info/Makefile.am texinfo/info/Makefile.am ---- texinfo.orig/info/Makefile.am 2004-10-28 16:03:27.000000000 +0200 -+++ texinfo/info/Makefile.am 2015-10-18 11:13:23.000000000 +0200 -@@ -1,4 +1,4 @@ --# $Id: Makefile.am,v 1.8 2004/10/28 14:03:27 karl Exp $ -+# Id: Makefile.am,v 1.8 2004/10/28 14:03:27 karl Exp - # Makefile.am for texinfo/info. - # Run automake in .. to produce Makefile.in from this. - # -diff -rNU3 texinfo.orig/info/Makefile.in texinfo/info/Makefile.in ---- texinfo.orig/info/Makefile.in 2004-12-31 19:01:48.000000000 +0100 -+++ texinfo/info/Makefile.in 2015-10-18 11:13:23.000000000 +0200 -@@ -14,7 +14,7 @@ - - @SET_MAKE@ - --# $Id: Makefile.am,v 1.8 2004/10/28 14:03:27 karl Exp $ -+# Id: Makefile.am,v 1.8 2004/10/28 14:03:27 karl Exp - # Makefile.am for texinfo/info. - # Run automake in .. to produce Makefile.in from this. - # -diff -rNU3 texinfo.orig/info/README texinfo/info/README ---- texinfo.orig/info/README 2004-04-11 19:56:45.000000000 +0200 -+++ texinfo/info/README 2015-10-18 11:13:23.000000000 +0200 -@@ -1,4 +1,4 @@ --$Id: README,v 1.3 2004/04/11 17:56:45 karl Exp $ -+Id: README,v 1.3 2004/04/11 17:56:45 karl Exp - texinfo/info/README - - Copyright (C) 2002 Free Software Foundation, Inc. -diff -rNU3 texinfo.orig/info/dir.c texinfo/info/dir.c ---- texinfo.orig/info/dir.c 2004-04-11 19:56:45.000000000 +0200 -+++ texinfo/info/dir.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: dir.c,v 1.1.1.5 2008/09/02 07:49:33 christos Exp $ */ -+ - /* dir.c -- how to build a special "dir" node from "localdir" files. -- $Id: dir.c,v 1.3 2004/04/11 17:56:45 karl Exp $ -+ Id: dir.c,v 1.3 2004/04/11 17:56:45 karl Exp - - Copyright (C) 1993, 1997, 1998, 2004 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/info/display.c texinfo/info/display.c ---- texinfo.orig/info/display.c 2004-04-11 19:56:45.000000000 +0200 -+++ texinfo/info/display.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: display.c,v 1.1.1.5 2008/09/02 07:49:34 christos Exp $ */ -+ - /* display.c -- How to display Info windows. -- $Id: display.c,v 1.7 2004/04/11 17:56:45 karl Exp $ -+ Id: display.c,v 1.7 2004/04/11 17:56:45 karl Exp - - Copyright (C) 1993, 1997, 2003, 2004 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/info/display.h texinfo/info/display.h ---- texinfo.orig/info/display.h 2004-04-11 19:56:45.000000000 +0200 -+++ texinfo/info/display.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: display.h,v 1.1.1.4 2008/09/02 07:49:34 christos Exp $ */ -+ - /* display.h -- How the display in Info is done. -- $Id: display.h,v 1.3 2004/04/11 17:56:45 karl Exp $ -+ Id: display.h,v 1.3 2004/04/11 17:56:45 karl Exp - - This file is part of GNU Info, a program for reading online documentation - stored in Info format. -diff -rNU3 texinfo.orig/info/doc.h texinfo/info/doc.h ---- texinfo.orig/info/doc.h 2004-04-11 19:56:45.000000000 +0200 -+++ texinfo/info/doc.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: doc.h,v 1.1.1.4 2008/09/02 07:49:34 christos Exp $ */ -+ - /* doc.h -- Structures associating function pointers with documentation. -- $Id: doc.h,v 1.3 2004/04/11 17:56:45 karl Exp $ -+ Id: doc.h,v 1.3 2004/04/11 17:56:45 karl Exp - - Copyright (C) 1993, 2001, 2004 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/info/dribble.c texinfo/info/dribble.c ---- texinfo.orig/info/dribble.c 2004-04-11 19:56:45.000000000 +0200 -+++ texinfo/info/dribble.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: dribble.c,v 1.1.1.5 2008/09/02 07:49:34 christos Exp $ */ -+ - /* dribble.c -- dribble files for Info. -- $Id: dribble.c,v 1.3 2004/04/11 17:56:45 karl Exp $ -+ Id: dribble.c,v 1.3 2004/04/11 17:56:45 karl Exp - - Copyright (C) 1993, 1998, 2004 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/info/dribble.h texinfo/info/dribble.h ---- texinfo.orig/info/dribble.h 2004-04-11 19:56:45.000000000 +0200 -+++ texinfo/info/dribble.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: dribble.h,v 1.1.1.3 2004/07/12 23:26:56 wiz Exp $ */ -+ - /* dribble.h -- Functions and vars declared in dribble.c. */ - - /* This file is part of GNU Info, a program for reading online documentation -diff -rNU3 texinfo.orig/info/echo-area.c texinfo/info/echo-area.c ---- texinfo.orig/info/echo-area.c 2004-12-14 01:15:36.000000000 +0100 -+++ texinfo/info/echo-area.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: echo-area.c,v 1.4 2008/09/02 08:41:51 christos Exp $ */ -+ - /* echo-area.c -- how to read a line in the echo area. -- $Id: echo-area.c,v 1.7 2004/12/14 00:15:36 karl Exp $ -+ Id: echo-area.c,v 1.7 2004/12/14 00:15:36 karl Exp - - Copyright (C) 1993, 1997, 1998, 1999, 2001, 2004 Free Software - Foundation, Inc. -@@ -936,7 +938,7 @@ - printf_to_message_buffer (completions_found_index == 1 - ? (char *) _("One completion:\n") - : (char *) _("%d completions:\n"), -- (void *) (long) completions_found_index, -+ (void*)((intptr_t)completions_found_index), - NULL, NULL); - - /* Find the maximum length of a label. */ -diff -rNU3 texinfo.orig/info/echo-area.h texinfo/info/echo-area.h ---- texinfo.orig/info/echo-area.h 2004-08-08 00:03:08.000000000 +0200 -+++ texinfo/info/echo-area.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: echo-area.h,v 1.1.1.4 2008/09/02 07:49:37 christos Exp $ */ -+ - /* echo-area.h -- Functions used in reading information from the echo area. -- $Id: echo-area.h,v 1.4 2004/08/07 22:03:08 karl Exp $ -+ Id: echo-area.h,v 1.4 2004/08/07 22:03:08 karl Exp - - This file is part of GNU Info, a program for reading online documentation - stored in Info format. -diff -rNU3 texinfo.orig/info/filesys.c texinfo/info/filesys.c ---- texinfo.orig/info/filesys.c 2004-07-30 19:17:40.000000000 +0200 -+++ texinfo/info/filesys.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: filesys.c,v 1.1.1.6 2008/09/02 07:49:37 christos Exp $ */ -+ - /* filesys.c -- filesystem specific functions. -- $Id: filesys.c,v 1.6 2004/07/30 17:17:40 karl Exp $ -+ Id: filesys.c,v 1.6 2004/07/30 17:17:40 karl Exp - - Copyright (C) 1993, 1997, 1998, 2000, 2002, 2003, 2004 Free Software - Foundation, Inc. -diff -rNU3 texinfo.orig/info/filesys.h texinfo/info/filesys.h ---- texinfo.orig/info/filesys.h 2004-04-11 19:56:45.000000000 +0200 -+++ texinfo/info/filesys.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: filesys.h,v 1.1.1.5 2008/09/02 07:49:38 christos Exp $ */ -+ - /* filesys.h -- external declarations for filesys.c. -- $Id: filesys.h,v 1.3 2004/04/11 17:56:45 karl Exp $ -+ Id: filesys.h,v 1.3 2004/04/11 17:56:45 karl Exp - - Copyright (C) 1993, 1997, 1998, 2002, 2004 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/info/footnotes.c texinfo/info/footnotes.c ---- texinfo.orig/info/footnotes.c 2004-04-11 19:56:45.000000000 +0200 -+++ texinfo/info/footnotes.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: footnotes.c,v 1.1.1.5 2008/09/02 07:49:38 christos Exp $ */ -+ - /* footnotes.c -- Some functions for manipulating footnotes. -- $Id: footnotes.c,v 1.4 2004/04/11 17:56:45 karl Exp $ -+ Id: footnotes.c,v 1.4 2004/04/11 17:56:45 karl Exp - - Copyright (C) 1993, 1997, 1998, 1999, 2002, 2004 Free Software - Foundation, Inc. -diff -rNU3 texinfo.orig/info/footnotes.h texinfo/info/footnotes.h ---- texinfo.orig/info/footnotes.h 2004-04-11 19:56:45.000000000 +0200 -+++ texinfo/info/footnotes.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: footnotes.h,v 1.1.1.5 2008/09/02 07:49:38 christos Exp $ */ -+ - /* footnotes.h -- Some functions for manipulating footnotes. -- $Id: footnotes.h,v 1.3 2004/04/11 17:56:45 karl Exp $ -+ Id: footnotes.h,v 1.3 2004/04/11 17:56:45 karl Exp - - Copyright (C) 1993, 1997, 1998, 2002, 2004 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/info/gc.c texinfo/info/gc.c ---- texinfo.orig/info/gc.c 2004-04-11 19:56:45.000000000 +0200 -+++ texinfo/info/gc.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: gc.c,v 1.1.1.4 2008/09/02 07:49:38 christos Exp $ */ -+ - /* gc.c -- Functions to remember and garbage collect unused node contents. -- $Id: gc.c,v 1.3 2004/04/11 17:56:45 karl Exp $ -+ Id: gc.c,v 1.3 2004/04/11 17:56:45 karl Exp - - Copyright (C) 1993, 2004 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/info/gc.h texinfo/info/gc.h ---- texinfo.orig/info/gc.h 2004-04-11 19:56:45.000000000 +0200 -+++ texinfo/info/gc.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: gc.h,v 1.1.1.4 2008/09/02 07:49:38 christos Exp $ */ -+ - /* gc.h -- Functions for garbage collecting unused node contents. -- $Id: gc.h,v 1.3 2004/04/11 17:56:45 karl Exp $ -+ Id: gc.h,v 1.3 2004/04/11 17:56:45 karl Exp - - This file is part of GNU Info, a program for reading online documentation - stored in Info format. -diff -rNU3 texinfo.orig/info/indices.c texinfo/info/indices.c ---- texinfo.orig/info/indices.c 2004-04-11 19:56:45.000000000 +0200 -+++ texinfo/info/indices.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: indices.c,v 1.1.1.6 2008/09/02 07:49:40 christos Exp $ */ -+ - /* indices.c -- deal with an Info file index. -- $Id: indices.c,v 1.5 2004/04/11 17:56:45 karl Exp $ -+ Id: indices.c,v 1.5 2004/04/11 17:56:45 karl Exp - - Copyright (C) 1993, 1997, 1998, 1999, 2002, 2003, 2004 Free Software - Foundation, Inc. -diff -rNU3 texinfo.orig/info/indices.h texinfo/info/indices.h ---- texinfo.orig/info/indices.h 2004-04-11 19:56:45.000000000 +0200 -+++ texinfo/info/indices.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: indices.h,v 1.1.1.4 2008/09/02 07:49:40 christos Exp $ */ -+ - /* indices.h -- Functions defined in indices.c. -- $Id: indices.h,v 1.3 2004/04/11 17:56:45 karl Exp $ -+ Id: indices.h,v 1.3 2004/04/11 17:56:45 karl Exp - - This file is part of GNU Info, a program for reading online documentation - stored in Info format. -diff -rNU3 texinfo.orig/info/info-utils.c texinfo/info/info-utils.c ---- texinfo.orig/info/info-utils.c 2004-04-11 19:56:45.000000000 +0200 -+++ texinfo/info/info-utils.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: info-utils.c,v 1.1.1.6 2008/09/02 07:49:40 christos Exp $ */ -+ - /* info-utils.c -- miscellanous. -- $Id: info-utils.c,v 1.4 2004/04/11 17:56:45 karl Exp $ -+ Id: info-utils.c,v 1.4 2004/04/11 17:56:45 karl Exp - - Copyright (C) 1993, 1998, 2003, 2004 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/info/info-utils.h texinfo/info/info-utils.h ---- texinfo.orig/info/info-utils.h 2004-04-11 19:56:45.000000000 +0200 -+++ texinfo/info/info-utils.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: info-utils.h,v 1.1.1.6 2008/09/02 07:49:40 christos Exp $ */ -+ - /* info-utils.h -- Exported functions and variables from info-utils.c. -- $Id: info-utils.h,v 1.4 2004/04/11 17:56:45 karl Exp $ -+ Id: info-utils.h,v 1.4 2004/04/11 17:56:45 karl Exp - - Copyright (C) 1993, 1996, 1998, 2002, 2003, 2004 Free Software - Foundation, Inc. -diff -rNU3 texinfo.orig/info/info.c texinfo/info/info.c ---- texinfo.orig/info/info.c 2004-04-11 19:56:45.000000000 +0200 -+++ texinfo/info/info.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: info.c,v 1.12 2010/02/18 14:00:39 wiz Exp $ */ -+ - /* info.c -- Display nodes of Info files in multiple windows. -- $Id: info.c,v 1.11 2004/04/11 17:56:45 karl Exp $ -+ Id: info.c,v 1.11 2004/04/11 17:56:45 karl Exp - - Copyright (C) 1993, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, - 2004 Free Software Foundation, Inc. -@@ -356,7 +358,7 @@ - } - - /* Get the initial Info node. It is either "(dir)Top", or what the user -- specifed with values in user_filename and user_nodenames. */ -+ specified with values in user_filename and user_nodenames. */ - initial_node = info_get_node (user_filename, - user_nodenames ? user_nodenames[0] : 0); - -diff -rNU3 texinfo.orig/info/info.h texinfo/info/info.h ---- texinfo.orig/info/info.h 2004-04-11 19:56:45.000000000 +0200 -+++ texinfo/info/info.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: info.h,v 1.1.1.6 2008/09/02 07:49:43 christos Exp $ */ -+ - /* info.h -- Header file which includes all of the other headers. -- $Id: info.h,v 1.4 2004/04/11 17:56:45 karl Exp $ -+ Id: info.h,v 1.4 2004/04/11 17:56:45 karl Exp - - Copyright (C) 1993, 1997, 1998, 1999, 2001, 2002, 2003, 2004 Free Software - Foundation, Inc. -diff -rNU3 texinfo.orig/info/infodoc.c texinfo/info/infodoc.c ---- texinfo.orig/info/infodoc.c 2004-04-11 19:56:45.000000000 +0200 -+++ texinfo/info/infodoc.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: infodoc.c,v 1.1.1.6 2008/09/02 07:49:44 christos Exp $ */ -+ - /* infodoc.c -- functions which build documentation nodes. -- $Id: infodoc.c,v 1.8 2004/04/11 17:56:45 karl Exp $ -+ Id: infodoc.c,v 1.8 2004/04/11 17:56:45 karl Exp - - Copyright (C) 1993, 1997, 1998, 1999, 2001, 2002, 2003, 2004 Free Software - Foundation, Inc. -diff -rNU3 texinfo.orig/info/infokey.c texinfo/info/infokey.c ---- texinfo.orig/info/infokey.c 2004-12-14 01:15:36.000000000 +0100 -+++ texinfo/info/infokey.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: infokey.c,v 1.4 2008/09/02 08:41:51 christos Exp $ */ -+ - /* infokey.c -- compile ~/.infokey to ~/.info. -- $Id: infokey.c,v 1.9 2004/12/14 00:15:36 karl Exp $ -+ Id: infokey.c,v 1.9 2004/12/14 00:15:36 karl Exp - - Copyright (C) 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. - -@@ -639,7 +641,7 @@ - { - syntax_error (filename, lnum, - (char *) _("NUL character (^%c) not permitted"), -- (void *) (long) c, NULL, NULL, NULL); -+ (void *)((intptr_t)c), NULL, NULL, NULL); - error = 1; - } - seqstate = normal; -@@ -663,7 +665,7 @@ - if (alen == 0) - { - syntax_error (filename, lnum, (char *) _("missing action name"), -- (void *) (long) c, NULL, NULL, NULL); -+ (void *)((intptr_t)c), NULL, NULL, NULL); - error = 1; - } - else -diff -rNU3 texinfo.orig/info/infokey.h texinfo/info/infokey.h ---- texinfo.orig/info/infokey.h 2004-04-11 19:56:45.000000000 +0200 -+++ texinfo/info/infokey.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: infokey.h,v 1.1.1.3 2008/09/02 07:50:15 christos Exp $ */ -+ - /* infokey.h -- Custom keystroke definition support. -- $Id: infokey.h,v 1.2 2004/04/11 17:56:45 karl Exp $ -+ Id: infokey.h,v 1.2 2004/04/11 17:56:45 karl Exp - - Copyright (C) 1999, 2002 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/info/infomap.c texinfo/info/infomap.c ---- texinfo.orig/info/infomap.c 2004-07-30 22:43:40.000000000 +0200 -+++ texinfo/info/infomap.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: infomap.c,v 1.1.1.7 2008/09/02 07:49:47 christos Exp $ */ -+ - /* infomap.c -- keymaps for Info. -- $Id: infomap.c,v 1.10 2004/07/30 20:43:40 karl Exp $ -+ Id: infomap.c,v 1.10 2004/07/30 20:43:40 karl Exp - - Copyright (C) 1993, 1997, 1998, 1999, 2001, 2002, 2003, 2004 Free Software - Foundation, Inc. -diff -rNU3 texinfo.orig/info/infomap.h texinfo/info/infomap.h ---- texinfo.orig/info/infomap.h 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/info/infomap.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: infomap.h,v 1.1.1.4 2008/09/02 07:49:47 christos Exp $ */ -+ - /* infomap.h -- description of a keymap in Info and related functions. -- $Id: infomap.h,v 1.3 2004/04/11 17:56:46 karl Exp $ -+ Id: infomap.h,v 1.3 2004/04/11 17:56:46 karl Exp - - Copyright (C) 1993, 2001, 2004 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/info/key.h texinfo/info/key.h ---- texinfo.orig/info/key.h 2002-08-26 01:38:38.000000000 +0200 -+++ texinfo/info/key.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: key.h,v 1.1.1.1 2003/01/17 14:54:34 wiz Exp $ */ -+ - /* key.h -- Structure associating function names with numeric codes. */ - - /* This file is part of GNU Info, a program for reading online documentation -diff -rNU3 texinfo.orig/info/m-x.c texinfo/info/m-x.c ---- texinfo.orig/info/m-x.c 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/info/m-x.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: m-x.c,v 1.1.1.5 2008/09/02 07:49:47 christos Exp $ */ -+ - /* m-x.c -- Meta-x minibuffer reader. -- $Id: m-x.c,v 1.3 2004/04/11 17:56:46 karl Exp $ -+ Id: m-x.c,v 1.3 2004/04/11 17:56:46 karl Exp - - Copyright (C) 1993, 1997, 1998, 2001, 2002, 2004 Free Software - Foundation, Inc. -diff -rNU3 texinfo.orig/info/makedoc.c texinfo/info/makedoc.c ---- texinfo.orig/info/makedoc.c 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/info/makedoc.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: makedoc.c,v 1.1.1.6 2008/09/02 07:50:15 christos Exp $ */ -+ - /* makedoc.c -- make doc.c and funs.h from input files. -- $Id: makedoc.c,v 1.4 2004/04/11 17:56:46 karl Exp $ -+ Id: makedoc.c,v 1.4 2004/04/11 17:56:46 karl Exp - - Copyright (C) 1993, 1997, 1998, 1999, 2001, 2002, 2003, 2004 Free Software - Foundation, Inc. -diff -rNU3 texinfo.orig/info/man.c texinfo/info/man.c ---- texinfo.orig/info/man.c 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/info/man.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: man.c,v 1.1.1.6 2008/09/02 07:49:49 christos Exp $ */ -+ - /* man.c: How to read and format man files. -- $Id: man.c,v 1.4 2004/04/11 17:56:46 karl Exp $ -+ Id: man.c,v 1.4 2004/04/11 17:56:46 karl Exp - - Copyright (C) 1995, 1997, 1998, 1999, 2000, 2002, 2003, 2004 Free Software - Foundation, Inc. -diff -rNU3 texinfo.orig/info/man.h texinfo/info/man.h ---- texinfo.orig/info/man.h 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/info/man.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: man.h,v 1.1.1.4 2008/09/02 07:49:49 christos Exp $ */ -+ - /* man.h: Defines and external function declarations for man.c. -- $Id: man.h,v 1.3 2004/04/11 17:56:46 karl Exp $ -+ Id: man.h,v 1.3 2004/04/11 17:56:46 karl Exp - - This file is part of GNU Info, a program for reading online documentation - stored in Info format. -diff -rNU3 texinfo.orig/info/nodemenu.c texinfo/info/nodemenu.c ---- texinfo.orig/info/nodemenu.c 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/info/nodemenu.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: nodemenu.c,v 1.1.1.6 2008/09/02 07:49:49 christos Exp $ */ -+ - /* nodemenu.c -- produce a menu of all visited nodes. -- $Id: nodemenu.c,v 1.5 2004/04/11 17:56:46 karl Exp $ -+ Id: nodemenu.c,v 1.5 2004/04/11 17:56:46 karl Exp - - Copyright (C) 1993, 1997, 1998, 2002, 2003, 2004 Free Software - Foundation, Inc. -diff -rNU3 texinfo.orig/info/nodes.c texinfo/info/nodes.c ---- texinfo.orig/info/nodes.c 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/info/nodes.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: nodes.c,v 1.7 2008/09/02 08:00:24 christos Exp $ */ -+ - /* nodes.c -- how to get an Info file and node. -- $Id: nodes.c,v 1.4 2004/04/11 17:56:46 karl Exp $ -+ Id: nodes.c,v 1.4 2004/04/11 17:56:46 karl Exp - - Copyright (C) 1993, 1998, 1999, 2000, 2002, 2003, 2004 Free Software - Foundation, Inc. -diff -rNU3 texinfo.orig/info/nodes.h texinfo/info/nodes.h ---- texinfo.orig/info/nodes.h 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/info/nodes.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: nodes.h,v 1.1.1.5 2008/09/02 07:49:51 christos Exp $ */ -+ - /* nodes.h -- How we represent nodes internally. -- $Id: nodes.h,v 1.3 2004/04/11 17:56:46 karl Exp $ -+ Id: nodes.h,v 1.3 2004/04/11 17:56:46 karl Exp - - Copyright (C) 1993, 1997, 1998, 2002, 2004 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/info/pcterm.c texinfo/info/pcterm.c ---- texinfo.orig/info/pcterm.c 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/info/pcterm.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: pcterm.c,v 1.1.1.5 2008/09/02 07:50:19 christos Exp $ */ -+ - /* pcterm.c -- How to handle the PC terminal for Info under MS-DOS/MS-Windows. -- $Id: pcterm.c,v 1.4 2004/04/11 17:56:46 karl Exp $ -+ Id: pcterm.c,v 1.4 2004/04/11 17:56:46 karl Exp - - Copyright (C) 1998, 1999, 2003, 2004 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/info/search.c texinfo/info/search.c ---- texinfo.orig/info/search.c 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/info/search.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: search.c,v 1.1.1.5 2008/09/02 07:49:51 christos Exp $ */ -+ - /* search.c -- searching large bodies of text. -- $Id: search.c,v 1.3 2004/04/11 17:56:46 karl Exp $ -+ Id: search.c,v 1.3 2004/04/11 17:56:46 karl Exp - - Copyright (C) 1993, 1997, 1998, 2002, 2004 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/info/search.h texinfo/info/search.h ---- texinfo.orig/info/search.h 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/info/search.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: search.h,v 1.1.1.5 2008/09/02 07:49:53 christos Exp $ */ -+ - /* search.h -- Structure used to search large bodies of text, with bounds. -- $Id: search.h,v 1.3 2004/04/11 17:56:46 karl Exp $ -+ Id: search.h,v 1.3 2004/04/11 17:56:46 karl Exp - - Copyright (C) 1993, 1997, 1998, 2002, 2004 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/info/session.c texinfo/info/session.c ---- texinfo.orig/info/session.c 2004-12-14 01:15:36.000000000 +0100 -+++ texinfo/info/session.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: session.c,v 1.6 2014/02/27 18:09:18 joerg Exp $ */ -+ - /* session.c -- user windowing interface to Info. -- $Id: session.c,v 1.16 2004/12/14 00:15:36 karl Exp $ -+ Id: session.c,v 1.16 2004/12/14 00:15:36 karl Exp - - Copyright (C) 1993, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 - Free Software Foundation, Inc. -@@ -962,7 +964,7 @@ - same as the first menu item found in this node. */ - window_message_in_echo_area - ((char *) _("Moving Up %d time(s), then Next."), -- (void *) (long) up_counter, NULL); -+ (void *)((intptr_t)up_counter), NULL); - - info_handle_pointer ("Next", window); - return; -@@ -1959,7 +1961,7 @@ - - /* Special case. Item "0" is the last item in this menu. */ - if (item == 0) -- for (i = 0; menu[i + 1]; i++); -+ for (i = 0; menu[i] && menu[i + 1]; i++); - else - { - for (i = 0; menu[i]; i++) -@@ -1975,7 +1977,7 @@ - } - else - info_error ((char *) _("There aren't %d items in this menu."), -- (void *) (long) item, NULL); -+ (void *)((intptr_t)item), NULL); - - info_free_references (menu); - return; -@@ -2018,7 +2020,7 @@ - /* See how far POS is from this xref. Take into account the - `*Note' that begins the xref, since as far as the user is - concerned, that's where it starts. */ -- delta = MIN (labs (pos - (xref->start - strlen (INFO_XREF_LABEL))), -+ delta = MIN (labs (pos - (xref->start - (long)strlen (INFO_XREF_LABEL))), - labs (pos - xref->end)); - - /* It's the <= instead of < that makes us choose the forward xref -@@ -2245,7 +2247,7 @@ - { - /* ref->end is more accurate estimate of position - for menus than ref->start. Go figure. */ -- int dist = abs (window->point - ref->end); -+ int dist = labs (window->point - ref->end); - - if (dist < min_dist) - { -diff -rNU3 texinfo.orig/info/session.h texinfo/info/session.h ---- texinfo.orig/info/session.h 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/info/session.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: session.h,v 1.1.1.5 2008/09/02 07:50:07 christos Exp $ */ -+ - /* session.h -- Functions found in session.c. -- $Id: session.h,v 1.3 2004/04/11 17:56:46 karl Exp $ -+ Id: session.h,v 1.3 2004/04/11 17:56:46 karl Exp - - Copyright (C) 1993, 1998, 1999, 2001, 2002, 2004 Free Software - Foundation, Inc. -diff -rNU3 texinfo.orig/info/signals.c texinfo/info/signals.c ---- texinfo.orig/info/signals.c 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/info/signals.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: signals.c,v 1.1.1.6 2008/09/02 07:50:08 christos Exp $ */ -+ - /* signals.c -- install and maintain signal handlers. -- $Id: signals.c,v 1.7 2004/04/11 17:56:46 karl Exp $ -+ Id: signals.c,v 1.7 2004/04/11 17:56:46 karl Exp - - Copyright (C) 1993, 1994, 1995, 1998, 2002, 2003, 2004 Free Software - Foundation, Inc. -diff -rNU3 texinfo.orig/info/signals.h texinfo/info/signals.h ---- texinfo.orig/info/signals.h 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/info/signals.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: signals.h,v 1.1.1.4 2008/09/02 07:50:08 christos Exp $ */ -+ - /* signals.h -- header to include system dependent signal definitions. -- $Id: signals.h,v 1.2 2004/04/11 17:56:46 karl Exp $ -+ Id: signals.h,v 1.2 2004/04/11 17:56:46 karl Exp - - Copyright (C) 1993, 1994, 1995, 1997, 2002, 2004 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/info/termdep.h texinfo/info/termdep.h ---- texinfo.orig/info/termdep.h 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/info/termdep.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: termdep.h,v 1.1.1.5 2008/09/02 07:50:08 christos Exp $ */ -+ - /* termdep.h -- system things that terminal.c depends on. -- $Id: termdep.h,v 1.2 2004/04/11 17:56:46 karl Exp $ -+ Id: termdep.h,v 1.2 2004/04/11 17:56:46 karl Exp - - Copyright (C) 1993, 1996, 1997, 1998, 2001, 2002 Free Software - Foundation, Inc. -diff -rNU3 texinfo.orig/info/terminal.c texinfo/info/terminal.c ---- texinfo.orig/info/terminal.c 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/info/terminal.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: terminal.c,v 1.11 2011/05/15 14:35:47 christos Exp $ */ -+ - /* terminal.c -- how to handle the physical terminal for Info. -- $Id: terminal.c,v 1.3 2004/04/11 17:56:46 karl Exp $ -+ Id: terminal.c,v 1.3 2004/04/11 17:56:46 karl Exp - - Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1996, 1997, 1998, - 1999, 2001, 2002, 2004 Free Software Foundation, Inc. -@@ -25,6 +27,7 @@ - #include "termdep.h" - - #include -+#include - #include - - /* The Unix termcap interface code. */ -diff -rNU3 texinfo.orig/info/terminal.h texinfo/info/terminal.h ---- texinfo.orig/info/terminal.h 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/info/terminal.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: terminal.h,v 1.1.1.4 2008/09/02 07:50:09 christos Exp $ */ -+ - /* terminal.h -- The external interface to terminal I/O. -- $Id: terminal.h,v 1.3 2004/04/11 17:56:46 karl Exp $ -+ Id: terminal.h,v 1.3 2004/04/11 17:56:46 karl Exp - - Copyright (C) 1993, 1996, 1997, 2001, 2002, 2004 Free Software - Foundation, Inc. -diff -rNU3 texinfo.orig/info/tilde.c texinfo/info/tilde.c ---- texinfo.orig/info/tilde.c 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/info/tilde.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: tilde.c,v 1.1.1.5 2008/09/02 07:50:09 christos Exp $ */ -+ - /* tilde.c -- tilde expansion code (~/foo := $HOME/foo). -- $Id: tilde.c,v 1.3 2004/04/11 17:56:46 karl Exp $ -+ Id: tilde.c,v 1.3 2004/04/11 17:56:46 karl Exp - - Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1996, 1998, 1999, - 2002, 2004 Free Software Foundation, Inc. -diff -rNU3 texinfo.orig/info/tilde.h texinfo/info/tilde.h ---- texinfo.orig/info/tilde.h 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/info/tilde.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: tilde.h,v 1.1.1.4 2008/09/02 07:50:10 christos Exp $ */ -+ - /* tilde.h: Externally available variables and function in libtilde.a. -- $Id: tilde.h,v 1.3 2004/04/11 17:56:46 karl Exp $ -+ Id: tilde.h,v 1.3 2004/04/11 17:56:46 karl Exp - - This file has appeared in prior works by the Free Software Foundation; - thus it carries copyright dates from 1988 through 1993. -diff -rNU3 texinfo.orig/info/variables.c texinfo/info/variables.c ---- texinfo.orig/info/variables.c 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/info/variables.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: variables.c,v 1.1.1.5 2008/09/02 07:50:10 christos Exp $ */ -+ - /* variables.c -- how to manipulate user visible variables in Info. -- $Id: variables.c,v 1.3 2004/04/11 17:56:46 karl Exp $ -+ Id: variables.c,v 1.3 2004/04/11 17:56:46 karl Exp - - Copyright (C) 1993, 1997, 2001, 2002, 2004 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/info/variables.h texinfo/info/variables.h ---- texinfo.orig/info/variables.h 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/info/variables.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: variables.h,v 1.1.1.4 2008/09/02 07:50:10 christos Exp $ */ -+ - /* variables.h -- Description of user visible variables in Info. -- $Id: variables.h,v 1.3 2004/04/11 17:56:46 karl Exp $ -+ Id: variables.h,v 1.3 2004/04/11 17:56:46 karl Exp - - This file is part of GNU Info, a program for reading online documentation - stored in Info format. -diff -rNU3 texinfo.orig/info/window.c texinfo/info/window.c ---- texinfo.orig/info/window.c 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/info/window.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: window.c,v 1.1.1.6 2008/09/02 07:50:14 christos Exp $ */ -+ - /* window.c -- windows in Info. -- $Id: window.c,v 1.4 2004/04/11 17:56:46 karl Exp $ -+ Id: window.c,v 1.4 2004/04/11 17:56:46 karl Exp - - Copyright (C) 1993, 1997, 1998, 2001, 2002, 2003, 2004 Free Software - Foundation, Inc. -diff -rNU3 texinfo.orig/info/window.h texinfo/info/window.h ---- texinfo.orig/info/window.h 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/info/window.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: window.h,v 1.1.1.4 2008/09/02 07:50:14 christos Exp $ */ -+ - /* window.h -- Structure and flags used in manipulating Info windows. -- $Id: window.h,v 1.3 2004/04/11 17:56:46 karl Exp $ -+ Id: window.h,v 1.3 2004/04/11 17:56:46 karl Exp - - This file is part of GNU Info, a program for reading online documentation - stored in Info format. -diff -rNU3 texinfo.orig/intl/Makefile.in texinfo/intl/Makefile.in ---- texinfo.orig/intl/Makefile.in 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/intl/Makefile.in 2015-10-18 11:13:23.000000000 +0200 -@@ -19,7 +19,7 @@ - PACKAGE = @PACKAGE@ - VERSION = @VERSION@ - --SHELL = /bin/sh -+SHELL = @SHELL@ - - srcdir = @srcdir@ - top_srcdir = @top_srcdir@ -diff -rNU3 texinfo.orig/intl/bindtextdom.c texinfo/intl/bindtextdom.c ---- texinfo.orig/intl/bindtextdom.c 2003-12-24 16:12:48.000000000 +0100 -+++ texinfo/intl/bindtextdom.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: bindtextdom.c,v 1.1.1.5 2004/07/12 23:27:17 wiz Exp $ */ -+ - /* Implementation of the bindtextdomain(3) function - Copyright (C) 1995-1998, 2000-2003 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/intl/dcgettext.c texinfo/intl/dcgettext.c ---- texinfo.orig/intl/dcgettext.c 2003-12-24 16:12:48.000000000 +0100 -+++ texinfo/intl/dcgettext.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: dcgettext.c,v 1.1.1.4 2004/07/12 23:27:16 wiz Exp $ */ -+ - /* Implementation of the dcgettext(3) function. - Copyright (C) 1995-1999, 2000-2003 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/intl/dcigettext.c texinfo/intl/dcigettext.c ---- texinfo.orig/intl/dcigettext.c 2003-12-24 16:12:48.000000000 +0100 -+++ texinfo/intl/dcigettext.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: dcigettext.c,v 1.1.1.3 2004/07/12 23:27:16 wiz Exp $ */ -+ - /* Implementation of the internal dcigettext function. - Copyright (C) 1995-1999, 2000-2003 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/intl/dcngettext.c texinfo/intl/dcngettext.c ---- texinfo.orig/intl/dcngettext.c 2003-12-24 16:12:48.000000000 +0100 -+++ texinfo/intl/dcngettext.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: dcngettext.c,v 1.1.1.3 2004/07/12 23:27:16 wiz Exp $ */ -+ - /* Implementation of the dcngettext(3) function. - Copyright (C) 1995-1999, 2000-2003 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/intl/dgettext.c texinfo/intl/dgettext.c ---- texinfo.orig/intl/dgettext.c 2003-12-24 16:12:48.000000000 +0100 -+++ texinfo/intl/dgettext.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: dgettext.c,v 1.1.1.4 2004/07/12 23:27:16 wiz Exp $ */ -+ - /* Implementation of the dgettext(3) function. - Copyright (C) 1995-1997, 2000-2003 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/intl/dngettext.c texinfo/intl/dngettext.c ---- texinfo.orig/intl/dngettext.c 2003-12-24 16:12:48.000000000 +0100 -+++ texinfo/intl/dngettext.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: dngettext.c,v 1.1.1.3 2004/07/12 23:27:16 wiz Exp $ */ -+ - /* Implementation of the dngettext(3) function. - Copyright (C) 1995-1997, 2000-2003 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/intl/eval-plural.h texinfo/intl/eval-plural.h ---- texinfo.orig/intl/eval-plural.h 2003-12-24 16:12:48.000000000 +0100 -+++ texinfo/intl/eval-plural.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: eval-plural.h,v 1.1.1.2 2004/07/12 23:27:17 wiz Exp $ */ -+ - /* Plural expression evaluation. - Copyright (C) 2000-2003 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/intl/explodename.c texinfo/intl/explodename.c ---- texinfo.orig/intl/explodename.c 2003-12-24 16:12:48.000000000 +0100 -+++ texinfo/intl/explodename.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: explodename.c,v 1.1.1.4 2004/07/12 23:27:16 wiz Exp $ */ -+ - /* Copyright (C) 1995-1998, 2000-2001, 2003 Free Software Foundation, Inc. - Contributed by Ulrich Drepper , 1995. - -diff -rNU3 texinfo.orig/intl/finddomain.c texinfo/intl/finddomain.c ---- texinfo.orig/intl/finddomain.c 2003-12-24 16:12:48.000000000 +0100 -+++ texinfo/intl/finddomain.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: finddomain.c,v 1.1.1.5 2004/07/12 23:27:16 wiz Exp $ */ -+ - /* Handle list of needed message catalogs - Copyright (C) 1995-1999, 2000-2001, 2003 Free Software Foundation, Inc. - Written by Ulrich Drepper , 1995. -diff -rNU3 texinfo.orig/intl/gettext.c texinfo/intl/gettext.c ---- texinfo.orig/intl/gettext.c 2003-12-24 16:12:48.000000000 +0100 -+++ texinfo/intl/gettext.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: gettext.c,v 1.1.1.4 2004/07/12 23:27:16 wiz Exp $ */ -+ - /* Implementation of gettext(3) function. - Copyright (C) 1995, 1997, 2000-2003 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/intl/gettextP.h texinfo/intl/gettextP.h ---- texinfo.orig/intl/gettextP.h 2003-12-24 16:12:48.000000000 +0100 -+++ texinfo/intl/gettextP.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: gettextP.h,v 1.1.1.5 2004/07/12 23:27:17 wiz Exp $ */ -+ - /* Header describing internals of libintl library. - Copyright (C) 1995-1999, 2000-2003 Free Software Foundation, Inc. - Written by Ulrich Drepper , 1995. -diff -rNU3 texinfo.orig/intl/gmo.h texinfo/intl/gmo.h ---- texinfo.orig/intl/gmo.h 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/intl/gmo.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: gmo.h,v 1.1.1.2 2004/07/12 23:27:17 wiz Exp $ */ -+ - /* Description of GNU message catalog format: general file layout. - Copyright (C) 1995, 1997, 2000-2002, 2004 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/intl/hash-string.h texinfo/intl/hash-string.h ---- texinfo.orig/intl/hash-string.h 2003-12-24 16:12:48.000000000 +0100 -+++ texinfo/intl/hash-string.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: hash-string.h,v 1.1.1.4 2004/07/12 23:27:17 wiz Exp $ */ -+ - /* Description of GNU message catalog format: string hashing function. - Copyright (C) 1995, 1997-1998, 2000-2003 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/intl/intl-compat.c texinfo/intl/intl-compat.c ---- texinfo.orig/intl/intl-compat.c 2003-12-24 16:12:48.000000000 +0100 -+++ texinfo/intl/intl-compat.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: intl-compat.c,v 1.1.1.4 2004/07/12 23:27:15 wiz Exp $ */ -+ - /* intl-compat.c - Stub functions to call gettext functions from GNU gettext - Library. - Copyright (C) 1995, 2000-2003 Software Foundation, Inc. -diff -rNU3 texinfo.orig/intl/l10nflist.c texinfo/intl/l10nflist.c ---- texinfo.orig/intl/l10nflist.c 2003-12-24 16:12:48.000000000 +0100 -+++ texinfo/intl/l10nflist.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: l10nflist.c,v 1.1.1.4 2004/07/12 23:27:16 wiz Exp $ */ -+ - /* Copyright (C) 1995-1999, 2000-2003 Free Software Foundation, Inc. - Contributed by Ulrich Drepper , 1995. - -diff -rNU3 texinfo.orig/intl/loadinfo.h texinfo/intl/loadinfo.h ---- texinfo.orig/intl/loadinfo.h 2003-12-24 16:12:48.000000000 +0100 -+++ texinfo/intl/loadinfo.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: loadinfo.h,v 1.1.1.4 2004/07/12 23:27:17 wiz Exp $ */ -+ - /* Copyright (C) 1996-1999, 2000-2003 Free Software Foundation, Inc. - This file is part of the GNU C Library. - Contributed by Ulrich Drepper , 1996. -diff -rNU3 texinfo.orig/intl/loadmsgcat.c texinfo/intl/loadmsgcat.c ---- texinfo.orig/intl/loadmsgcat.c 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/intl/loadmsgcat.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: loadmsgcat.c,v 1.1.1.5 2004/07/12 23:27:16 wiz Exp $ */ -+ - /* Load needed message catalogs. - Copyright (C) 1995-1999, 2000-2004 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/intl/localcharset.c texinfo/intl/localcharset.c ---- texinfo.orig/intl/localcharset.c 2003-12-24 16:12:48.000000000 +0100 -+++ texinfo/intl/localcharset.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: localcharset.c,v 1.1.1.3 2004/07/12 23:27:16 wiz Exp $ */ -+ - /* Determine a canonical name for the current locale's character encoding. - - Copyright (C) 2000-2003 Free Software Foundation, Inc. -diff -rNU3 texinfo.orig/intl/localcharset.h texinfo/intl/localcharset.h ---- texinfo.orig/intl/localcharset.h 2003-11-06 15:36:16.000000000 +0100 -+++ texinfo/intl/localcharset.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: localcharset.h,v 1.1.1.1 2003/07/03 14:59:13 wiz Exp $ */ -+ - /* Determine a canonical name for the current locale's character encoding. - Copyright (C) 2000-2003 Free Software Foundation, Inc. - This file is part of the GNU CHARSET Library. -diff -rNU3 texinfo.orig/intl/localealias.c texinfo/intl/localealias.c ---- texinfo.orig/intl/localealias.c 2003-12-24 16:12:48.000000000 +0100 -+++ texinfo/intl/localealias.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: localealias.c,v 1.1.1.5 2004/07/12 23:27:16 wiz Exp $ */ -+ - /* Handle aliases for locale names. - Copyright (C) 1995-1999, 2000-2001, 2003 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/intl/localename.c texinfo/intl/localename.c ---- texinfo.orig/intl/localename.c 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/intl/localename.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: localename.c,v 1.1.1.2 2004/07/12 23:27:16 wiz Exp $ */ -+ - /* Determine the current selected locale. - Copyright (C) 1995-1999, 2000-2004 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/intl/log.c texinfo/intl/log.c ---- texinfo.orig/intl/log.c 2003-12-24 16:12:48.000000000 +0100 -+++ texinfo/intl/log.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: log.c,v 1.1.1.2 2004/07/12 23:27:15 wiz Exp $ */ -+ - /* Log file output. - Copyright (C) 2003 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/intl/ngettext.c texinfo/intl/ngettext.c ---- texinfo.orig/intl/ngettext.c 2003-12-24 16:12:48.000000000 +0100 -+++ texinfo/intl/ngettext.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: ngettext.c,v 1.1.1.3 2004/07/12 23:27:16 wiz Exp $ */ -+ - /* Implementation of ngettext(3) function. - Copyright (C) 1995, 1997, 2000-2003 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/intl/os2compat.c texinfo/intl/os2compat.c ---- texinfo.orig/intl/os2compat.c 2002-09-21 02:41:16.000000000 +0200 -+++ texinfo/intl/os2compat.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: os2compat.c,v 1.1.1.1 2003/01/17 14:54:20 wiz Exp $ */ -+ - /* OS/2 compatibility functions. - Copyright (C) 2001-2002 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/intl/os2compat.h texinfo/intl/os2compat.h ---- texinfo.orig/intl/os2compat.h 2002-09-21 02:41:16.000000000 +0200 -+++ texinfo/intl/os2compat.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: os2compat.h,v 1.1.1.1 2003/01/17 14:54:19 wiz Exp $ */ -+ - /* OS/2 compatibility defines. - This file is intended to be included from config.h - Copyright (C) 2001-2002 Free Software Foundation, Inc. -diff -rNU3 texinfo.orig/intl/osdep.c texinfo/intl/osdep.c ---- texinfo.orig/intl/osdep.c 2002-09-03 17:51:40.000000000 +0200 -+++ texinfo/intl/osdep.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: osdep.c,v 1.1.1.1 2003/01/17 14:54:20 wiz Exp $ */ -+ - /* OS dependent parts of libintl. - Copyright (C) 2001-2002 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/intl/plural-exp.c texinfo/intl/plural-exp.c ---- texinfo.orig/intl/plural-exp.c 2003-12-24 16:12:48.000000000 +0100 -+++ texinfo/intl/plural-exp.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: plural-exp.c,v 1.1.1.2 2004/07/12 23:27:16 wiz Exp $ */ -+ - /* Expression parsing for plural form selection. - Copyright (C) 2000-2001, 2003 Free Software Foundation, Inc. - Written by Ulrich Drepper , 2000. -diff -rNU3 texinfo.orig/intl/plural-exp.h texinfo/intl/plural-exp.h ---- texinfo.orig/intl/plural-exp.h 2003-12-24 16:12:48.000000000 +0100 -+++ texinfo/intl/plural-exp.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: plural-exp.h,v 1.1.1.2 2004/07/12 23:27:17 wiz Exp $ */ -+ - /* Expression parsing and evaluation for plural form selection. - Copyright (C) 2000-2003 Free Software Foundation, Inc. - Written by Ulrich Drepper , 2000. -diff -rNU3 texinfo.orig/intl/plural.c texinfo/intl/plural.c ---- texinfo.orig/intl/plural.c 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/intl/plural.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: plural.c,v 1.1.1.3 2004/07/12 23:27:15 wiz Exp $ */ -+ - /* A Bison parser, made from plural.y - by GNU bison 1.35. */ - -diff -rNU3 texinfo.orig/intl/plural.y texinfo/intl/plural.y ---- texinfo.orig/intl/plural.y 2003-12-24 16:12:48.000000000 +0100 -+++ texinfo/intl/plural.y 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: plural.y,v 1.1.1.2 2004/07/12 23:27:16 wiz Exp $ */ -+ - %{ - /* Expression parsing for plural form selection. - Copyright (C) 2000-2001, 2003 Free Software Foundation, Inc. -diff -rNU3 texinfo.orig/intl/printf-args.c texinfo/intl/printf-args.c ---- texinfo.orig/intl/printf-args.c 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/intl/printf-args.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: printf-args.c,v 1.1.1.1 2004/07/12 23:27:17 wiz Exp $ */ -+ - /* Decomposed printf argument list. - Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/intl/printf-args.h texinfo/intl/printf-args.h ---- texinfo.orig/intl/printf-args.h 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/intl/printf-args.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: printf-args.h,v 1.1.1.1 2004/07/12 23:27:17 wiz Exp $ */ -+ - /* Decomposed printf argument list. - Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/intl/printf-parse.c texinfo/intl/printf-parse.c ---- texinfo.orig/intl/printf-parse.c 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/intl/printf-parse.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: printf-parse.c,v 1.1.1.1 2004/07/12 23:27:17 wiz Exp $ */ -+ - /* Formatted output to strings. - Copyright (C) 1999-2000, 2002-2003 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/intl/printf-parse.h texinfo/intl/printf-parse.h ---- texinfo.orig/intl/printf-parse.h 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/intl/printf-parse.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: printf-parse.h,v 1.1.1.1 2004/07/12 23:27:17 wiz Exp $ */ -+ - /* Parse printf format string. - Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/intl/printf.c texinfo/intl/printf.c ---- texinfo.orig/intl/printf.c 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/intl/printf.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: printf.c,v 1.1.1.1 2004/07/12 23:27:15 wiz Exp $ */ -+ - /* Formatted output to strings, using POSIX/XSI format strings with positions. - Copyright (C) 2003 Free Software Foundation, Inc. - Written by Bruno Haible , 2003. -diff -rNU3 texinfo.orig/intl/relocatable.c texinfo/intl/relocatable.c ---- texinfo.orig/intl/relocatable.c 2003-12-24 16:12:48.000000000 +0100 -+++ texinfo/intl/relocatable.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: relocatable.c,v 1.1.1.2 2004/07/12 23:27:15 wiz Exp $ */ -+ - /* Provide relocatable packages. - Copyright (C) 2003 Free Software Foundation, Inc. - Written by Bruno Haible , 2003. -diff -rNU3 texinfo.orig/intl/relocatable.h texinfo/intl/relocatable.h ---- texinfo.orig/intl/relocatable.h 2003-12-24 16:12:48.000000000 +0100 -+++ texinfo/intl/relocatable.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: relocatable.h,v 1.1.1.2 2004/07/12 23:27:17 wiz Exp $ */ -+ - /* Provide relocatable packages. - Copyright (C) 2003 Free Software Foundation, Inc. - Written by Bruno Haible , 2003. -diff -rNU3 texinfo.orig/intl/textdomain.c texinfo/intl/textdomain.c ---- texinfo.orig/intl/textdomain.c 2003-12-24 16:12:48.000000000 +0100 -+++ texinfo/intl/textdomain.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: textdomain.c,v 1.1.1.4 2004/07/12 23:27:16 wiz Exp $ */ -+ - /* Implementation of the textdomain(3) function. - Copyright (C) 1995-1998, 2000-2003 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/intl/vasnprintf.c texinfo/intl/vasnprintf.c ---- texinfo.orig/intl/vasnprintf.c 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/intl/vasnprintf.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: vasnprintf.c,v 1.1.1.1 2004/07/12 23:27:17 wiz Exp $ */ -+ - /* vsprintf with automatic memory allocation. - Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/intl/vasnprintf.h texinfo/intl/vasnprintf.h ---- texinfo.orig/intl/vasnprintf.h 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/intl/vasnprintf.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: vasnprintf.h,v 1.1.1.1 2004/07/12 23:27:17 wiz Exp $ */ -+ - /* vsprintf with automatic memory allocation. - Copyright (C) 2002-2003 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/intl/vasnwprintf.h texinfo/intl/vasnwprintf.h ---- texinfo.orig/intl/vasnwprintf.h 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/intl/vasnwprintf.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: vasnwprintf.h,v 1.1.1.1 2004/07/12 23:27:17 wiz Exp $ */ -+ - /* vswprintf with automatic memory allocation. - Copyright (C) 2002-2003 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/intl/wprintf-parse.h texinfo/intl/wprintf-parse.h ---- texinfo.orig/intl/wprintf-parse.h 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/intl/wprintf-parse.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: wprintf-parse.h,v 1.1.1.1 2004/07/12 23:27:17 wiz Exp $ */ -+ - /* Parse printf format string. - Copyright (C) 1999, 2002-2003 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/intl/xsize.h texinfo/intl/xsize.h ---- texinfo.orig/intl/xsize.h 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/intl/xsize.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: xsize.h,v 1.1.1.1 2004/07/12 23:27:17 wiz Exp $ */ -+ - /* xsize.h -- Checked size_t computations. - - Copyright (C) 2003 Free Software Foundation, Inc. -diff -rNU3 texinfo.orig/lib/Makefile.am texinfo/lib/Makefile.am ---- texinfo.orig/lib/Makefile.am 2004-11-06 23:05:59.000000000 +0100 -+++ texinfo/lib/Makefile.am 2015-10-18 11:13:23.000000000 +0200 -@@ -1,4 +1,4 @@ --# $Id: Makefile.am,v 1.7 2004/11/06 22:05:59 karl Exp $ -+# Id: Makefile.am,v 1.7 2004/11/06 22:05:59 karl Exp - # Makefile.am for texinfo/lib. - # Run automake in .. to produce Makefile.in from this. - # -diff -rNU3 texinfo.orig/lib/Makefile.in texinfo/lib/Makefile.in ---- texinfo.orig/lib/Makefile.in 2004-12-31 19:01:48.000000000 +0100 -+++ texinfo/lib/Makefile.in 2015-10-18 11:13:23.000000000 +0200 -@@ -14,7 +14,7 @@ - - @SET_MAKE@ - --# $Id: Makefile.am,v 1.7 2004/11/06 22:05:59 karl Exp $ -+# Id: Makefile.am,v 1.7 2004/11/06 22:05:59 karl Exp - # Makefile.am for texinfo/lib. - # Run automake in .. to produce Makefile.in from this. - # -diff -rNU3 texinfo.orig/lib/README texinfo/lib/README ---- texinfo.orig/lib/README 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/lib/README 2015-10-18 11:13:23.000000000 +0200 -@@ -1,4 +1,4 @@ --$Id: README,v 1.3 2004/04/11 17:56:46 karl Exp $ -+Id: README,v 1.3 2004/04/11 17:56:46 karl Exp - texinfo/lib/README - - Copyright (C) 2002 Free Software Foundation, Inc. -diff -rNU3 texinfo.orig/lib/alloca.c texinfo/lib/alloca.c ---- texinfo.orig/lib/alloca.c 2004-05-17 14:59:20.000000000 +0200 -+++ texinfo/lib/alloca.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: alloca.c,v 1.1.1.5 2008/09/02 07:49:28 christos Exp $ */ -+ - /* alloca.c -- allocate automatically reclaimed memory - (Mostly) portable public-domain implementation -- D A Gwyn - -diff -rNU3 texinfo.orig/lib/getopt.c texinfo/lib/getopt.c ---- texinfo.orig/lib/getopt.c 2004-09-10 14:43:21.000000000 +0200 -+++ texinfo/lib/getopt.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: getopt.c,v 1.7 2008/09/02 08:00:24 christos Exp $ */ -+ - /* Getopt for GNU. - NOTE: getopt is now part of the C library, so if you don't know what - "Keep this file name-space clean" means, talk to drepper@gnu.org -diff -rNU3 texinfo.orig/lib/getopt.h texinfo/lib/getopt.h ---- texinfo.orig/lib/getopt.h 2004-09-14 14:36:00.000000000 +0200 -+++ texinfo/lib/getopt.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: getopt.h,v 1.1.1.6 2008/09/02 07:49:28 christos Exp $ */ -+ - /* getopt.h -- wrapper for gnulib getopt_.h. -- $Id: getopt.h,v 1.6 2004/09/14 12:36:00 karl Exp $ -+ Id: getopt.h,v 1.6 2004/09/14 12:36:00 karl Exp - Copyright (C) 2004 Free Software Foundation, Inc. - - Copying and distribution of this file, with or without modification, -diff -rNU3 texinfo.orig/lib/getopt1.c texinfo/lib/getopt1.c ---- texinfo.orig/lib/getopt1.c 2004-09-10 14:43:21.000000000 +0200 -+++ texinfo/lib/getopt1.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: getopt1.c,v 1.1.1.6 2008/09/02 07:49:29 christos Exp $ */ -+ - /* getopt_long and getopt_long_only entry points for GNU getopt. - Copyright (C) 1987,88,89,90,91,92,93,94,96,97,98,2004 - Free Software Foundation, Inc. -diff -rNU3 texinfo.orig/lib/getopt_.h texinfo/lib/getopt_.h ---- texinfo.orig/lib/getopt_.h 2004-09-14 14:36:00.000000000 +0200 -+++ texinfo/lib/getopt_.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: getopt_.h,v 1.1.1.1 2008/09/02 07:49:31 christos Exp $ */ -+ - /* Declarations for getopt. - Copyright (C) 1989-1994,1996-1999,2001,2003,2004 - Free Software Foundation, Inc. -diff -rNU3 texinfo.orig/lib/getopt_int.h texinfo/lib/getopt_int.h ---- texinfo.orig/lib/getopt_int.h 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/lib/getopt_int.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: getopt_int.h,v 1.1.1.1 2004/07/12 23:26:57 wiz Exp $ */ -+ - /* Internal declarations for getopt. - Copyright (C) 1989-1994,1996-1999,2001,2003,2004 - Free Software Foundation, Inc. -diff -rNU3 texinfo.orig/lib/gettext.h texinfo/lib/gettext.h ---- texinfo.orig/lib/gettext.h 2003-07-17 15:11:25.000000000 +0200 -+++ texinfo/lib/gettext.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: gettext.h,v 1.1.1.2 2004/07/12 23:26:56 wiz Exp $ */ -+ - /* Convenience header for conditional use of GNU . - Copyright (C) 1995-1998, 2000-2002 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/lib/memcpy.c texinfo/lib/memcpy.c ---- texinfo.orig/lib/memcpy.c 2003-09-10 15:17:12.000000000 +0200 -+++ texinfo/lib/memcpy.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: memcpy.c,v 1.1.1.3 2004/07/12 23:26:57 wiz Exp $ */ -+ - /* Copyright (C) 1995, 1997, 2000, 2003 Free Software Foundation, Inc. - - This program is free software; you can redistribute it and/or modify -diff -rNU3 texinfo.orig/lib/memmove.c texinfo/lib/memmove.c ---- texinfo.orig/lib/memmove.c 2003-09-10 15:17:12.000000000 +0200 -+++ texinfo/lib/memmove.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: memmove.c,v 1.1.1.3 2004/07/12 23:26:57 wiz Exp $ */ -+ - /* memmove.c -- copy memory. - Copy LENGTH bytes from SOURCE to DEST. Does not null-terminate. - In the public domain. -diff -rNU3 texinfo.orig/lib/mkstemp.c texinfo/lib/mkstemp.c ---- texinfo.orig/lib/mkstemp.c 2003-07-17 15:11:25.000000000 +0200 -+++ texinfo/lib/mkstemp.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: mkstemp.c,v 1.1.1.2 2004/07/12 23:26:57 wiz Exp $ */ -+ - /* Copyright (C) 1998, 1999, 2001 Free Software Foundation, Inc. - This file is derived from the one in the GNU C Library. - -diff -rNU3 texinfo.orig/lib/strcase.h texinfo/lib/strcase.h ---- texinfo.orig/lib/strcase.h 2004-04-11 20:13:34.000000000 +0200 -+++ texinfo/lib/strcase.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: strcase.h,v 1.1.1.1 2008/09/02 07:49:31 christos Exp $ */ -+ - /* Case-insensitive string comparison functions. - Copyright (C) 1995-1996, 2001, 2003 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/lib/strcasecmp.c texinfo/lib/strcasecmp.c ---- texinfo.orig/lib/strcasecmp.c 2003-06-06 14:19:59.000000000 +0200 -+++ texinfo/lib/strcasecmp.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: strcasecmp.c,v 1.1.1.3 2003/07/03 14:58:58 wiz Exp $ */ -+ - /* strcasecmp.c -- case insensitive string comparator - Copyright (C) 1998, 1999 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/lib/strdup.c texinfo/lib/strdup.c ---- texinfo.orig/lib/strdup.c 2004-09-14 14:36:50.000000000 +0200 -+++ texinfo/lib/strdup.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: strdup.c,v 1.1.1.5 2008/09/02 07:49:28 christos Exp $ */ -+ - /* Copyright (C) 1991, 1996, 1997, 1998, 2002, 2003, 2004 Free Software - Foundation, Inc. - -diff -rNU3 texinfo.orig/lib/strdup.h texinfo/lib/strdup.h ---- texinfo.orig/lib/strdup.h 2004-04-11 20:13:34.000000000 +0200 -+++ texinfo/lib/strdup.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: strdup.h,v 1.1.1.1 2008/09/02 07:49:31 christos Exp $ */ -+ - /* strdup.h -- duplicate a string - Copyright (C) 2004 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/lib/strerror.c texinfo/lib/strerror.c ---- texinfo.orig/lib/strerror.c 2003-08-03 15:09:35.000000000 +0200 -+++ texinfo/lib/strerror.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: strerror.c,v 1.1.1.3 2004/07/12 23:26:57 wiz Exp $ */ -+ - /* strerror.c --- ANSI C compatible system error routine - - Copyright (C) 1986, 1988, 1989, 1991, 2002, 2003 Free Software -diff -rNU3 texinfo.orig/lib/strncasecmp.c texinfo/lib/strncasecmp.c ---- texinfo.orig/lib/strncasecmp.c 2002-09-03 17:51:40.000000000 +0200 -+++ texinfo/lib/strncasecmp.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,2 +1,4 @@ -+/* $NetBSD: strncasecmp.c,v 1.1.1.2 2003/01/17 14:54:30 wiz Exp $ */ -+ - #define LENGTH_LIMIT - #include "strcasecmp.c" -diff -rNU3 texinfo.orig/lib/substring.c texinfo/lib/substring.c ---- texinfo.orig/lib/substring.c 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/lib/substring.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: substring.c,v 1.1.1.4 2008/09/02 07:49:29 christos Exp $ */ -+ - /* substring.c -- extract substring. -- $Id: substring.c,v 1.2 2004/04/11 17:56:46 karl Exp $ -+ Id: substring.c,v 1.2 2004/04/11 17:56:46 karl Exp - - Copyright (C) 1999, 2004 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/lib/system.h texinfo/lib/system.h ---- texinfo.orig/lib/system.h 2004-04-26 15:56:57.000000000 +0200 -+++ texinfo/lib/system.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: system.h,v 1.11 2009/03/06 17:03:48 apb Exp $ */ -+ - /* system.h: system-dependent declarations; include this first. -- $Id: system.h,v 1.12 2004/04/26 13:56:57 karl Exp $ -+ Id: system.h,v 1.12 2004/04/26 13:56:57 karl Exp - - Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software - Foundation, Inc. -@@ -267,6 +269,10 @@ - /* Some systems don't declare this function in pwd.h. */ - struct passwd *getpwnam (const char *name); - -+#ifdef HAVE_STDINT_H -+#include -+#endif -+ - /* Our library routines not included in any system library. */ - extern void *xmalloc (size_t), *xrealloc (void *, size_t); - extern char *xstrdup (const char *); -diff -rNU3 texinfo.orig/lib/tempname.c texinfo/lib/tempname.c ---- texinfo.orig/lib/tempname.c 2003-09-15 15:25:45.000000000 +0200 -+++ texinfo/lib/tempname.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: tempname.c,v 1.1.1.4 2004/07/12 23:26:57 wiz Exp $ */ -+ - /* tempname.c - generate the name of a temporary file. - - Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -diff -rNU3 texinfo.orig/lib/xalloc.h texinfo/lib/xalloc.h ---- texinfo.orig/lib/xalloc.h 2004-09-10 14:43:21.000000000 +0200 -+++ texinfo/lib/xalloc.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: xalloc.h,v 1.1.1.4 2008/09/02 07:49:31 christos Exp $ */ -+ - /* xalloc.h -- malloc with out-of-memory checking - - Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, -diff -rNU3 texinfo.orig/lib/xexit.c texinfo/lib/xexit.c ---- texinfo.orig/lib/xexit.c 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/lib/xexit.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: xexit.c,v 1.1.1.5 2008/09/02 07:49:31 christos Exp $ */ -+ - /* xexit.c -- exit with attention to return values and closing stdout. -- $Id: xexit.c,v 1.5 2004/04/11 17:56:46 karl Exp $ -+ Id: xexit.c,v 1.5 2004/04/11 17:56:46 karl Exp - - Copyright (C) 1999, 2003, 2004 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/lib/xmalloc.c texinfo/lib/xmalloc.c ---- texinfo.orig/lib/xmalloc.c 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/lib/xmalloc.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: xmalloc.c,v 1.1.1.3 2004/07/12 23:26:56 wiz Exp $ */ -+ - /* xmalloc.c -- safe versions of malloc and realloc. - - Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 2004 Free Software -diff -rNU3 texinfo.orig/lib/xstrdup.c texinfo/lib/xstrdup.c ---- texinfo.orig/lib/xstrdup.c 2003-10-14 20:22:07.000000000 +0200 -+++ texinfo/lib/xstrdup.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: xstrdup.c,v 1.1.1.3 2004/07/12 23:26:56 wiz Exp $ */ -+ - /* xstrdup.c -- copy a string with out of memory checking - Copyright (C) 1990, 1996, 1998, 2001, 2003 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/makeinfo/Makefile.am texinfo/makeinfo/Makefile.am ---- texinfo.orig/makeinfo/Makefile.am 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/makeinfo/Makefile.am 2015-10-18 11:13:23.000000000 +0200 -@@ -1,4 +1,4 @@ --# $Id: Makefile.am,v 1.5 2004/04/11 17:56:46 karl Exp $ -+# Id: Makefile.am,v 1.5 2004/04/11 17:56:46 karl Exp - # Makefile.am for texinfo/makeinfo. - # Run automake in .. to produce Makefile.in from this. - # -diff -rNU3 texinfo.orig/makeinfo/Makefile.in texinfo/makeinfo/Makefile.in ---- texinfo.orig/makeinfo/Makefile.in 2004-12-31 19:01:48.000000000 +0100 -+++ texinfo/makeinfo/Makefile.in 2015-10-18 11:13:23.000000000 +0200 -@@ -14,7 +14,7 @@ - - @SET_MAKE@ - --# $Id: Makefile.am,v 1.5 2004/04/11 17:56:46 karl Exp $ -+# Id: Makefile.am,v 1.5 2004/04/11 17:56:46 karl Exp - # Makefile.am for texinfo/makeinfo. - # Run automake in .. to produce Makefile.in from this. - # -diff -rNU3 texinfo.orig/makeinfo/README texinfo/makeinfo/README ---- texinfo.orig/makeinfo/README 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/makeinfo/README 2015-10-18 11:13:23.000000000 +0200 -@@ -1,4 +1,4 @@ --$Id: README,v 1.3 2004/04/11 17:56:46 karl Exp $ -+Id: README,v 1.3 2004/04/11 17:56:46 karl Exp - texinfo/makeinfo/README - - Copyright (C) 2002 Free Software Foundation, Inc. -diff -rNU3 texinfo.orig/makeinfo/cmds.c texinfo/makeinfo/cmds.c ---- texinfo.orig/makeinfo/cmds.c 2004-12-14 01:15:36.000000000 +0100 -+++ texinfo/makeinfo/cmds.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: cmds.c,v 1.3 2008/09/02 08:00:24 christos Exp $ */ -+ - /* cmds.c -- Texinfo commands. -- $Id: cmds.c,v 1.55 2004/12/14 00:15:36 karl Exp $ -+ Id: cmds.c,v 1.55 2004/12/14 00:15:36 karl Exp - - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software - Foundation, Inc. -diff -rNU3 texinfo.orig/makeinfo/cmds.h texinfo/makeinfo/cmds.h ---- texinfo.orig/makeinfo/cmds.h 2004-11-26 01:48:35.000000000 +0100 -+++ texinfo/makeinfo/cmds.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: cmds.h,v 1.1.1.4 2008/09/02 07:50:24 christos Exp $ */ -+ - /* cmds.h -- declarations for cmds.c. -- $Id: cmds.h,v 1.9 2004/11/26 00:48:35 karl Exp $ -+ Id: cmds.h,v 1.9 2004/11/26 00:48:35 karl Exp - - Copyright (C) 1998, 1999, 2002, 2003, 2004 Free Software Foundation, - Inc. -diff -rNU3 texinfo.orig/makeinfo/defun.c texinfo/makeinfo/defun.c ---- texinfo.orig/makeinfo/defun.c 2004-04-11 19:56:46.000000000 +0200 -+++ texinfo/makeinfo/defun.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: defun.c,v 1.1.1.5 2008/09/02 07:50:24 christos Exp $ */ -+ - /* defun.c -- @defun and friends. -- $Id: defun.c,v 1.11 2004/04/11 17:56:46 karl Exp $ -+ Id: defun.c,v 1.11 2004/04/11 17:56:46 karl Exp - - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software - Foundation, Inc. -diff -rNU3 texinfo.orig/makeinfo/defun.h texinfo/makeinfo/defun.h ---- texinfo.orig/makeinfo/defun.h 2004-04-11 19:56:47.000000000 +0200 -+++ texinfo/makeinfo/defun.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: defun.h,v 1.1.1.4 2008/09/02 07:50:26 christos Exp $ */ -+ - /* defun.h -- declaration for defuns. -- $Id: defun.h,v 1.2 2004/04/11 17:56:47 karl Exp $ -+ Id: defun.h,v 1.2 2004/04/11 17:56:47 karl Exp - - Copyright (C) 1999 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/makeinfo/files.c texinfo/makeinfo/files.c ---- texinfo.orig/makeinfo/files.c 2004-07-27 02:06:31.000000000 +0200 -+++ texinfo/makeinfo/files.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: files.c,v 1.10 2015/06/05 16:44:56 joerg Exp $ */ -+ - /* files.c -- file-related functions for makeinfo. -- $Id: files.c,v 1.5 2004/07/27 00:06:31 karl Exp $ -+ Id: files.c,v 1.5 2004/07/27 00:06:31 karl Exp - - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software - Foundation, Inc. -@@ -456,8 +458,7 @@ - temp_home = (char *) getenv ("HOME"); - result = xmalloc (strlen (&filename[1]) - + 1 -- + temp_home ? strlen (temp_home) -- : 0); -+ + (temp_home ? strlen (temp_home) : 0)); - *result = 0; - - if (temp_home) -diff -rNU3 texinfo.orig/makeinfo/files.h texinfo/makeinfo/files.h ---- texinfo.orig/makeinfo/files.h 2004-07-27 02:06:31.000000000 +0200 -+++ texinfo/makeinfo/files.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: files.h,v 1.3 2008/09/02 08:00:24 christos Exp $ */ -+ - /* files.h -- declarations for files.c. -- $Id: files.h,v 1.4 2004/07/27 00:06:31 karl Exp $ -+ Id: files.h,v 1.4 2004/07/27 00:06:31 karl Exp - - Copyright (C) 1998, 2002, 2004 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/makeinfo/float.c texinfo/makeinfo/float.c ---- texinfo.orig/makeinfo/float.c 2004-07-06 00:23:22.000000000 +0200 -+++ texinfo/makeinfo/float.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: float.c,v 1.1.1.2 2008/09/02 07:50:28 christos Exp $ */ -+ - /* float.c -- float environment functions. -- $Id: float.c,v 1.8 2004/07/05 22:23:22 karl Exp $ -+ Id: float.c,v 1.8 2004/07/05 22:23:22 karl Exp - - Copyright (C) 2003, 2004 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/makeinfo/float.h texinfo/makeinfo/float.h ---- texinfo.orig/makeinfo/float.h 2004-04-11 19:56:47.000000000 +0200 -+++ texinfo/makeinfo/float.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: float.h,v 1.1.1.2 2008/09/02 07:50:28 christos Exp $ */ -+ - /* float.h -- declarations for the float environment. -- $Id: float.h,v 1.5 2004/04/11 17:56:47 karl Exp $ -+ Id: float.h,v 1.5 2004/04/11 17:56:47 karl Exp - - Copyright (C) 2003, 2004 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/makeinfo/footnote.c texinfo/makeinfo/footnote.c ---- texinfo.orig/makeinfo/footnote.c 2004-04-11 19:56:47.000000000 +0200 -+++ texinfo/makeinfo/footnote.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: footnote.c,v 1.1.1.4 2008/09/02 07:50:28 christos Exp $ */ -+ - /* footnote.c -- footnotes for Texinfo. -- $Id: footnote.c,v 1.7 2004/04/11 17:56:47 karl Exp $ -+ Id: footnote.c,v 1.7 2004/04/11 17:56:47 karl Exp - - Copyright (C) 1998, 1999, 2002 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/makeinfo/footnote.h texinfo/makeinfo/footnote.h ---- texinfo.orig/makeinfo/footnote.h 2004-04-11 19:56:47.000000000 +0200 -+++ texinfo/makeinfo/footnote.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: footnote.h,v 1.1.1.4 2008/09/02 07:50:28 christos Exp $ */ -+ - /* footnote.h -- declarations for footnote.c. -- $Id: footnote.h,v 1.2 2004/04/11 17:56:47 karl Exp $ -+ Id: footnote.h,v 1.2 2004/04/11 17:56:47 karl Exp - - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software - Foundation, Inc. -diff -rNU3 texinfo.orig/makeinfo/html.c texinfo/makeinfo/html.c ---- texinfo.orig/makeinfo/html.c 2004-12-06 02:13:06.000000000 +0100 -+++ texinfo/makeinfo/html.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: html.c,v 1.1.1.5 2008/09/02 07:50:29 christos Exp $ */ -+ - /* html.c -- html-related utilities. -- $Id: html.c,v 1.28 2004/12/06 01:13:06 karl Exp $ -+ Id: html.c,v 1.28 2004/12/06 01:13:06 karl Exp - - Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Free Software - Foundation, Inc. -diff -rNU3 texinfo.orig/makeinfo/html.h texinfo/makeinfo/html.h ---- texinfo.orig/makeinfo/html.h 2004-11-30 03:03:23.000000000 +0100 -+++ texinfo/makeinfo/html.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: html.h,v 1.1.1.4 2008/09/02 07:50:29 christos Exp $ */ -+ - /* html.h -- declarations for html-related utilities. -- $Id: html.h,v 1.6 2004/11/30 02:03:23 karl Exp $ -+ Id: html.h,v 1.6 2004/11/30 02:03:23 karl Exp - - Copyright (C) 1999, 2000, 2002, 2004 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/makeinfo/index.c texinfo/makeinfo/index.c ---- texinfo.orig/makeinfo/index.c 2004-11-30 03:03:23.000000000 +0100 -+++ texinfo/makeinfo/index.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: index.c,v 1.1.1.6 2008/09/02 07:50:31 christos Exp $ */ -+ - /* index.c -- indexing for Texinfo. -- $Id: index.c,v 1.17 2004/11/30 02:03:23 karl Exp $ -+ Id: index.c,v 1.17 2004/11/30 02:03:23 karl Exp - - Copyright (C) 1998, 1999, 2002, 2003, 2004 Free Software Foundation, - Inc. -diff -rNU3 texinfo.orig/makeinfo/index.h texinfo/makeinfo/index.h ---- texinfo.orig/makeinfo/index.h 2004-04-11 19:56:47.000000000 +0200 -+++ texinfo/makeinfo/index.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: index.h,v 1.1.1.4 2008/09/02 07:50:31 christos Exp $ */ -+ - /* index.h -- declarations for index.c. -- $Id: index.h,v 1.2 2004/04/11 17:56:47 karl Exp $ -+ Id: index.h,v 1.2 2004/04/11 17:56:47 karl Exp - - Copyright (C) 1998, 99 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/makeinfo/insertion.c texinfo/makeinfo/insertion.c ---- texinfo.orig/makeinfo/insertion.c 2004-11-11 19:34:28.000000000 +0100 -+++ texinfo/makeinfo/insertion.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: insertion.c,v 1.1.1.6 2008/09/02 07:50:34 christos Exp $ */ -+ - /* insertion.c -- insertions for Texinfo. -- $Id: insertion.c,v 1.55 2004/11/11 18:34:28 karl Exp $ -+ Id: insertion.c,v 1.55 2004/11/11 18:34:28 karl Exp - - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software - Foundation, Inc. -diff -rNU3 texinfo.orig/makeinfo/insertion.h texinfo/makeinfo/insertion.h ---- texinfo.orig/makeinfo/insertion.h 2004-04-11 19:56:47.000000000 +0200 -+++ texinfo/makeinfo/insertion.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: insertion.h,v 1.1.1.4 2008/09/02 07:50:34 christos Exp $ */ -+ - /* insertion.h -- declarations for insertion.c. -- $Id: insertion.h,v 1.10 2004/04/11 17:56:47 karl Exp $ -+ Id: insertion.h,v 1.10 2004/04/11 17:56:47 karl Exp - - Copyright (C) 1998, 1999, 2001, 2002, 2003 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/makeinfo/lang.c texinfo/makeinfo/lang.c ---- texinfo.orig/makeinfo/lang.c 2004-11-23 00:57:33.000000000 +0100 -+++ texinfo/makeinfo/lang.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: lang.c,v 1.1.1.5 2008/09/02 07:50:36 christos Exp $ */ -+ - /* lang.c -- language-dependent support. -- $Id: lang.c,v 1.14 2004/11/22 23:57:33 karl Exp $ -+ Id: lang.c,v 1.14 2004/11/22 23:57:33 karl Exp - - Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Free Software - Foundation, Inc. -diff -rNU3 texinfo.orig/makeinfo/lang.h texinfo/makeinfo/lang.h ---- texinfo.orig/makeinfo/lang.h 2004-04-11 19:56:47.000000000 +0200 -+++ texinfo/makeinfo/lang.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: lang.h,v 1.1.1.5 2008/09/02 07:50:36 christos Exp $ */ -+ - /* lang.h -- declarations for language codes etc. -- $Id: lang.h,v 1.6 2004/04/11 17:56:47 karl Exp $ -+ Id: lang.h,v 1.6 2004/04/11 17:56:47 karl Exp - - Copyright (C) 1999, 2001, 2002, 2003 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/makeinfo/macro.c texinfo/makeinfo/macro.c ---- texinfo.orig/makeinfo/macro.c 2004-04-11 19:56:47.000000000 +0200 -+++ texinfo/makeinfo/macro.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: macro.c,v 1.1.1.5 2008/09/02 07:50:37 christos Exp $ */ -+ - /* macro.c -- user-defined macros for Texinfo. -- $Id: macro.c,v 1.6 2004/04/11 17:56:47 karl Exp $ -+ Id: macro.c,v 1.6 2004/04/11 17:56:47 karl Exp - - Copyright (C) 1998, 1999, 2002, 2003 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/makeinfo/macro.h texinfo/makeinfo/macro.h ---- texinfo.orig/makeinfo/macro.h 2004-04-11 19:56:47.000000000 +0200 -+++ texinfo/makeinfo/macro.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: macro.h,v 1.1.1.4 2008/09/02 07:50:37 christos Exp $ */ -+ - /* macro.h -- declarations for macro.c. -- $Id: macro.h,v 1.2 2004/04/11 17:56:47 karl Exp $ -+ Id: macro.h,v 1.2 2004/04/11 17:56:47 karl Exp - - Copyright (C) 1998, 99 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/makeinfo/makeinfo.c texinfo/makeinfo/makeinfo.c ---- texinfo.orig/makeinfo/makeinfo.c 2004-12-19 18:15:42.000000000 +0100 -+++ texinfo/makeinfo/makeinfo.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: makeinfo.c,v 1.16 2009/02/28 19:51:13 joerg Exp $ */ -+ - /* makeinfo -- convert Texinfo source into other formats. -- $Id: makeinfo.c,v 1.74 2004/12/19 17:15:42 karl Exp $ -+ Id: makeinfo.c,v 1.74 2004/12/19 17:15:42 karl Exp - - Copyright (C) 1987, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, - 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. -@@ -379,6 +381,8 @@ - also, write to standard output by default.\n\ - --no-split suppress splitting of Info or HTML output,\n\ - generate only one output file.\n\ -+ --no-version-headers suppress header with makeinfo version and\n\ -+ source path.\n\ - --number-sections output chapter and sectioning numbers.\n\ - -o, --output=FILE output to FILE (directory if split HTML),\n\ - ")); -@@ -503,6 +507,7 @@ - { "no-pointer-validate", 0, &validating, 0 }, - { "no-split", 0, &splitting, 0 }, - { "no-validate", 0, &validating, 0 }, -+ { "no-version-header", 0, &no_version_header, 1 }, - { "no-warn", 0, &print_warnings, 0 }, - { "number-footnotes", 0, &number_footnotes, 1 }, - { "number-sections", 0, &number_sections, 1 }, -@@ -1669,7 +1674,7 @@ - } - - /* html fixxme: should output this as trailer on first page. */ -- if (!no_headers && !html && !xml) -+ if (!no_headers && !html && !xml && !no_version_header) - add_word_args (_("This is %s, produced by makeinfo version %s from %s.\n"), - output_filename, VERSION, input_filename); - -diff -rNU3 texinfo.orig/makeinfo/makeinfo.h texinfo/makeinfo/makeinfo.h ---- texinfo.orig/makeinfo/makeinfo.h 2004-11-30 03:03:23.000000000 +0100 -+++ texinfo/makeinfo/makeinfo.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: makeinfo.h,v 1.2 2009/02/28 19:14:15 joerg Exp $ */ -+ - /* makeinfo.h -- declarations for Makeinfo. -- $Id: makeinfo.h,v 1.17 2004/11/30 02:03:23 karl Exp $ -+ Id: makeinfo.h,v 1.17 2004/11/30 02:03:23 karl Exp - - Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free - Software Foundation, Inc. -@@ -190,6 +192,10 @@ - is, generate plain text. (--no-headers) */ - DECLARE (int, no_headers, 0); - -+/* Nonzero means do not output makeinfo version and source file. -+ (--no-version-header) */ -+DECLARE (int, no_version_header, 0); -+ - /* Nonzero means that we process @docbook and @ifdocbook. (--ifdocbook) */ - DECLARE (int, process_docbook, 0); - -diff -rNU3 texinfo.orig/makeinfo/multi.c texinfo/makeinfo/multi.c ---- texinfo.orig/makeinfo/multi.c 2004-04-11 19:56:47.000000000 +0200 -+++ texinfo/makeinfo/multi.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: multi.c,v 1.1.1.5 2008/09/02 07:50:44 christos Exp $ */ -+ - /* multi.c -- multiple-column tables (@multitable) for makeinfo. -- $Id: multi.c,v 1.8 2004/04/11 17:56:47 karl Exp $ -+ Id: multi.c,v 1.8 2004/04/11 17:56:47 karl Exp - - Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2004 Free Software - Foundation, Inc. -diff -rNU3 texinfo.orig/makeinfo/multi.h texinfo/makeinfo/multi.h ---- texinfo.orig/makeinfo/multi.h 2004-04-11 19:56:47.000000000 +0200 -+++ texinfo/makeinfo/multi.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: multi.h,v 1.1.1.2 2008/09/02 07:50:44 christos Exp $ */ -+ - /* multi.h -- declarations for multi.c. -- $Id: multi.h,v 1.1 2004/04/11 17:56:47 karl Exp $ -+ Id: multi.h,v 1.1 2004/04/11 17:56:47 karl Exp - - Copyright (C) 2004 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/makeinfo/node.c texinfo/makeinfo/node.c ---- texinfo.orig/makeinfo/node.c 2004-12-21 00:56:07.000000000 +0100 -+++ texinfo/makeinfo/node.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: node.c,v 1.4 2008/09/02 08:00:24 christos Exp $ */ -+ - /* node.c -- nodes for Texinfo. -- $Id: node.c,v 1.27 2004/12/20 23:56:07 karl Exp $ -+ Id: node.c,v 1.27 2004/12/20 23:56:07 karl Exp - - Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software - Foundation, Inc. -diff -rNU3 texinfo.orig/makeinfo/node.h texinfo/makeinfo/node.h ---- texinfo.orig/makeinfo/node.h 2004-04-11 19:56:47.000000000 +0200 -+++ texinfo/makeinfo/node.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: node.h,v 1.1.1.4 2008/09/02 07:50:47 christos Exp $ */ -+ - /* node.h -- declarations for Node. -- $Id: node.h,v 1.2 2004/04/11 17:56:47 karl Exp $ -+ Id: node.h,v 1.2 2004/04/11 17:56:47 karl Exp - - Copyright (C) 1996, 1997, 1998, 1999, 2002 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/makeinfo/sectioning.c texinfo/makeinfo/sectioning.c ---- texinfo.orig/makeinfo/sectioning.c 2004-07-06 00:23:23.000000000 +0200 -+++ texinfo/makeinfo/sectioning.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: sectioning.c,v 1.2 2011/05/11 23:20:46 joerg Exp $ */ -+ - /* sectioning.c -- for @chapter, @section, ..., @contents ... -- $Id: sectioning.c,v 1.25 2004/07/05 22:23:23 karl Exp $ -+ Id: sectioning.c,v 1.25 2004/07/05 22:23:23 karl Exp - - Copyright (C) 1999, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. - -@@ -256,14 +258,13 @@ - return xstrdup (""); - else if (enum_marker == APPENDIX_MAGIC) - { -- char s[1]; -- sprintf (s, "%c", numbers[0] + 64); -+ char s[2] = { numbers[0] + 64, '\0' }; - return xstrdup (s); - } - else - { -- char s[5]; -- sprintf (s, "%d", numbers[0]); -+ char s[11]; -+ snprintf (s, sizeof(s), "%d", numbers[0]); - return xstrdup (s); - } - } -diff -rNU3 texinfo.orig/makeinfo/sectioning.h texinfo/makeinfo/sectioning.h ---- texinfo.orig/makeinfo/sectioning.h 2004-04-11 19:56:47.000000000 +0200 -+++ texinfo/makeinfo/sectioning.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: sectioning.h,v 1.1.1.4 2008/09/02 07:50:47 christos Exp $ */ -+ - /* sectioning.h -- all related stuff @chapter, @section... @contents -- $Id: sectioning.h,v 1.5 2004/04/11 17:56:47 karl Exp $ -+ Id: sectioning.h,v 1.5 2004/04/11 17:56:47 karl Exp - - Copyright (C) 1999, 2003 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/makeinfo/tests/Makefile.am texinfo/makeinfo/tests/Makefile.am ---- texinfo.orig/makeinfo/tests/Makefile.am 2004-04-11 19:56:47.000000000 +0200 -+++ texinfo/makeinfo/tests/Makefile.am 2015-10-18 11:13:23.000000000 +0200 -@@ -1,4 +1,4 @@ --# $Id: Makefile.am,v 1.5 2004/04/11 17:56:47 karl Exp $ -+# Id: Makefile.am,v 1.5 2004/04/11 17:56:47 karl Exp - # Makefile.am for texinfo/tests/makeinfo. - # - # This file is free software; as a special exception the author gives -diff -rNU3 texinfo.orig/makeinfo/tests/Makefile.in texinfo/makeinfo/tests/Makefile.in ---- texinfo.orig/makeinfo/tests/Makefile.in 2004-12-31 19:01:48.000000000 +0100 -+++ texinfo/makeinfo/tests/Makefile.in 2015-10-18 11:13:23.000000000 +0200 -@@ -14,7 +14,7 @@ - - @SET_MAKE@ - --# $Id: Makefile.am,v 1.5 2004/04/11 17:56:47 karl Exp $ -+# Id: Makefile.am,v 1.5 2004/04/11 17:56:47 karl Exp - # Makefile.am for texinfo/tests/makeinfo. - # - # This file is free software; as a special exception the author gives -diff -rNU3 texinfo.orig/makeinfo/tests/copying texinfo/makeinfo/tests/copying ---- texinfo.orig/makeinfo/tests/copying 2004-04-20 15:26:00.000000000 +0200 -+++ texinfo/makeinfo/tests/copying 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,5 @@ - #!/bin/sh --# $Id: copying,v 1.2 2004/04/20 13:26:00 karl Exp $ -+# Id: copying,v 1.2 2004/04/20 13:26:00 karl Exp - # Test @copying. The configure script for tramp uses this to make sure - # the makeinfo that is present supports @copying. - -diff -rNU3 texinfo.orig/makeinfo/tests/html-manuals texinfo/makeinfo/tests/html-manuals ---- texinfo.orig/makeinfo/tests/html-manuals 2004-04-11 19:56:47.000000000 +0200 -+++ texinfo/makeinfo/tests/html-manuals 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,5 @@ - #!/bin/sh --# $Id: html-manuals,v 1.3 2004/04/11 17:56:47 karl Exp $ -+# Id: html-manuals,v 1.3 2004/04/11 17:56:47 karl Exp - # Test that all the distribution manuals can be converted to HTML. - - : ${srcdir=.} -diff -rNU3 texinfo.orig/makeinfo/tests/include-value texinfo/makeinfo/tests/include-value ---- texinfo.orig/makeinfo/tests/include-value 2004-04-11 19:56:47.000000000 +0200 -+++ texinfo/makeinfo/tests/include-value 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,5 @@ - #!/bin/sh --# $Id: include-value,v 1.3 2004/04/11 17:56:47 karl Exp $ -+# Id: include-value,v 1.3 2004/04/11 17:56:47 karl Exp - # Test @value expansion in @include and @verbatiminclude names. - - unset TEXINFO_OUTPUT -diff -rNU3 texinfo.orig/makeinfo/tests/include-value.txi texinfo/makeinfo/tests/include-value.txi ---- texinfo.orig/makeinfo/tests/include-value.txi 2004-04-11 19:56:47.000000000 +0200 -+++ texinfo/makeinfo/tests/include-value.txi 2015-10-18 11:13:23.000000000 +0200 -@@ -1,6 +1,6 @@ - \input texinfo - @setfilename include-value.info --@c $Id: include-value.txi,v 1.2 2004/04/11 17:56:47 karl Exp $ -+@c Id: include-value.txi,v 1.2 2004/04/11 17:56:47 karl Exp - - @set testvar incl-incl.txi - -diff -rNU3 texinfo.orig/makeinfo/tests/twofiles texinfo/makeinfo/tests/twofiles ---- texinfo.orig/makeinfo/tests/twofiles 2004-04-11 19:56:47.000000000 +0200 -+++ texinfo/makeinfo/tests/twofiles 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,5 @@ - #!/bin/sh --# $Id: twofiles,v 1.3 2004/04/11 17:56:47 karl Exp $ -+# Id: twofiles,v 1.3 2004/04/11 17:56:47 karl Exp - # Test that an existing and nonexisting file doesn't cause a - # segmentation fault. - # From: Arkadiusz Miskiewicz , 15 Feb 2003 13:22:49 +0100. -diff -rNU3 texinfo.orig/makeinfo/toc.c texinfo/makeinfo/toc.c ---- texinfo.orig/makeinfo/toc.c 2004-04-11 19:56:47.000000000 +0200 -+++ texinfo/makeinfo/toc.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: toc.c,v 1.1.1.4 2008/09/02 07:50:47 christos Exp $ */ -+ - /* toc.c -- table of contents handling. -- $Id: toc.c,v 1.6 2004/04/11 17:56:47 karl Exp $ -+ Id: toc.c,v 1.6 2004/04/11 17:56:47 karl Exp - - Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/makeinfo/toc.h texinfo/makeinfo/toc.h ---- texinfo.orig/makeinfo/toc.h 2004-04-11 19:56:47.000000000 +0200 -+++ texinfo/makeinfo/toc.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: toc.h,v 1.1.1.4 2008/09/02 07:50:47 christos Exp $ */ -+ - /* toc.h -- table of contents handling. -- $Id: toc.h,v 1.2 2004/04/11 17:56:47 karl Exp $ -+ Id: toc.h,v 1.2 2004/04/11 17:56:47 karl Exp - - Copyright (C) 1999 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/makeinfo/xml.c texinfo/makeinfo/xml.c ---- texinfo.orig/makeinfo/xml.c 2004-12-19 18:02:23.000000000 +0100 -+++ texinfo/makeinfo/xml.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: xml.c,v 1.2 2014/11/15 02:01:27 joerg Exp $ */ -+ - /* xml.c -- xml output. -- $Id: xml.c,v 1.52 2004/12/19 17:02:23 karl Exp $ -+ Id: xml.c,v 1.52 2004/12/19 17:02:23 karl Exp - - Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. - -@@ -868,7 +870,7 @@ - return; - } - -- if (!xml_element_list[elt].name || !strlen (xml_element_list[elt].name)) -+ if (!strlen (xml_element_list[elt].name)) - { - /*printf ("Warning: Inserting empty element %d\n", elt);*/ - return; -diff -rNU3 texinfo.orig/makeinfo/xml.h texinfo/makeinfo/xml.h ---- texinfo.orig/makeinfo/xml.h 2004-11-26 01:48:35.000000000 +0100 -+++ texinfo/makeinfo/xml.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: xml.h,v 1.1.1.3 2008/09/02 07:50:51 christos Exp $ */ -+ - /* xml.h -- xml output declarations. -- $Id: xml.h,v 1.24 2004/11/26 00:48:35 karl Exp $ -+ Id: xml.h,v 1.24 2004/11/26 00:48:35 karl Exp - - Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/makeinfo/xref.c texinfo/makeinfo/xref.c ---- texinfo.orig/makeinfo/xref.c 2004-12-21 18:28:35.000000000 +0100 -+++ texinfo/makeinfo/xref.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: xref.c,v 1.1.1.2 2008/09/02 07:50:51 christos Exp $ */ -+ - /* xref.c -- cross references for Texinfo. -- $Id: xref.c,v 1.4 2004/12/21 17:28:35 karl Exp $ -+ Id: xref.c,v 1.4 2004/12/21 17:28:35 karl Exp - - Copyright (C) 2004 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/makeinfo/xref.h texinfo/makeinfo/xref.h ---- texinfo.orig/makeinfo/xref.h 2004-04-11 19:56:47.000000000 +0200 -+++ texinfo/makeinfo/xref.h 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: xref.h,v 1.1.1.2 2008/09/02 07:50:51 christos Exp $ */ -+ - /* xref.h -- declarations for the cross references. -- $Id: xref.h,v 1.1 2004/04/11 17:56:47 karl Exp $ -+ Id: xref.h,v 1.1 2004/04/11 17:56:47 karl Exp - - Copyright (C) 2004 Free Software Foundation, Inc. - -diff -rNU3 texinfo.orig/po/Makefile.in.in texinfo/po/Makefile.in.in ---- texinfo.orig/po/Makefile.in.in 2004-04-11 19:56:47.000000000 +0200 -+++ texinfo/po/Makefile.in.in 2015-10-18 11:13:23.000000000 +0200 -@@ -13,7 +13,7 @@ - PACKAGE = @PACKAGE@ - VERSION = @VERSION@ - --SHELL = /bin/sh -+SHELL = @SHELL@ - @SET_MAKE@ - - srcdir = @srcdir@ -diff -rNU3 texinfo.orig/texinfo2netbsd texinfo/texinfo2netbsd ---- texinfo.orig/texinfo2netbsd 1970-01-01 01:00:00.000000000 +0100 -+++ texinfo/texinfo2netbsd 2015-10-18 11:13:23.000000000 +0200 -@@ -0,0 +1,86 @@ -+#! /bin/sh -+# -+# $NetBSD: texinfo2netbsd,v 1.4 2008/04/30 13:10:50 martin Exp $ -+# -+# Copyright (c) 2003, 2004 The NetBSD Foundation, Inc. -+# All rights reserved. -+# -+# Redistribution and use in source and binary forms, with or without -+# modification, are permitted provided that the following conditions -+# are met: -+# 1. Redistributions of source code must retain the above copyright -+# notice, this list of conditions and the following disclaimer. -+# 2. Redistributions in binary form must reproduce the above copyright -+# notice, this list of conditions and the following disclaimer in the -+# documentation and/or other materials provided with the distribution. -+# -+# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -+# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -+# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -+# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -+# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -+# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -+# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -+# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -+# POSSIBILITY OF SUCH DAMAGE. -+# -+# texinfo2netbsd: convert an texinfo source tree into a -+# format suitable for commit. Works on current dir. -+# -+ -+# delete some superfluous files -+echo deleting some superfluous files -+rm -rf djgpp -+ -+echo done -+ -+### Remove the $'s around RCS tags -+find . -type f -print | xargs egrep -l '\$(Id|Created|Header|NetBSD|Revision)' | while read f; do -+ sed -e 's/\$\(Id.*\) \$/\1/' \ -+ -e 's/\$\(Created.*\) \$/\1/' \ -+ -e 's/\$\(Header.*\) \$/\1/' \ -+ -e 's/\$\(NetBSD.*\) \$/\1/' \ -+ -e 's/\$\(Revision.*\) \$/\1/' \ -+ $f > /tmp/texinfo2$$ && mv /tmp/texinfo2$$ $f && \ -+ echo removed RCS tag from $f -+done -+ -+### Add our NetBSD RCS Id -+find . -type f -name '*.[chly]' -print | while read c; do -+ sed 1q < $c | grep -q '\$NetBSD' || ( -+echo "/* \$NetBSD\$ */" >/tmp/texinfo3$$ -+echo "" >>/tmp/texinfo3$$ -+cat $c >> /tmp/texinfo3$$ -+mv /tmp/texinfo3$$ $c && echo added NetBSD RCS tag to $c -+ ) -+done -+ -+find . -type f -name '*.[0-9]' -print | while read m; do -+ sed 1q < $m | grep -q '\$NetBSD' || ( -+echo ".\\\" \$NetBSD\$" >/tmp/texinfo4$$ -+echo ".\\\"" >>/tmp/texinfo4$$ -+cat $m >> /tmp/texinfo4$$ -+mv /tmp/texinfo4$$ $m && echo added NetBSD RCS tag to $m -+ ) -+done -+ -+find . -type f -name '*.texi' -print | while read t; do -+ sed "2 s/^/@c \$NetBSD\$\\ -+/" < $t > /tmp/texinfo5$$ -+ mv /tmp/texinfo5$$ $t && echo added NetBSD RCS tag to $t -+done -+ -+echo done -+ -+echo You can import now. -+ -+echo Path: src/gnu/dist/texinfo -+echo Vendor: FSF -+echo Versiontag: texinfo-X-Y -+ -+echo -+echo Do not forget to update src/gnu/usr.bin/texinfo/common/config.h -+echo and src/gnu/dist/texinfo/util/texinfo.cat! -+exit 0 -diff -rNU3 texinfo.orig/util/Makefile.am texinfo/util/Makefile.am ---- texinfo.orig/util/Makefile.am 2004-08-26 13:43:18.000000000 +0200 -+++ texinfo/util/Makefile.am 2015-10-18 11:13:23.000000000 +0200 -@@ -1,4 +1,4 @@ --# $Id: Makefile.am,v 1.14 2004/08/26 11:43:18 karl Exp $ -+# Id: Makefile.am,v 1.14 2004/08/26 11:43:18 karl Exp - # Makefile.am for texinfo/util. - # Run automake in .. to produce Makefile.in from this. - # -diff -rNU3 texinfo.orig/util/Makefile.in texinfo/util/Makefile.in ---- texinfo.orig/util/Makefile.in 2004-12-31 19:01:49.000000000 +0100 -+++ texinfo/util/Makefile.in 2015-10-18 11:13:23.000000000 +0200 -@@ -14,7 +14,7 @@ - - @SET_MAKE@ - --# $Id: Makefile.am,v 1.14 2004/08/26 11:43:18 karl Exp $ -+# Id: Makefile.am,v 1.14 2004/08/26 11:43:18 karl Exp - # Makefile.am for texinfo/util. - # Run automake in .. to produce Makefile.in from this. - # -diff -rNU3 texinfo.orig/util/README texinfo/util/README ---- texinfo.orig/util/README 2004-04-11 19:56:47.000000000 +0200 -+++ texinfo/util/README 2015-10-18 11:13:23.000000000 +0200 -@@ -1,4 +1,4 @@ --$Id: README,v 1.5 2004/04/11 17:56:47 karl Exp $ -+Id: README,v 1.5 2004/04/11 17:56:47 karl Exp - texinfo/util/README - - Copyright (C) 2002 Free Software Foundation, Inc. -diff -rNU3 texinfo.orig/util/deref.c texinfo/util/deref.c ---- texinfo.orig/util/deref.c 2002-08-26 01:38:39.000000000 +0200 -+++ texinfo/util/deref.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,3 +1,5 @@ -+/* $NetBSD: deref.c,v 1.1.1.3 2003/01/17 14:54:37 wiz Exp $ */ -+ - /* - * deref.c - * -diff -rNU3 texinfo.orig/util/dir-example texinfo/util/dir-example ---- texinfo.orig/util/dir-example 2004-12-30 14:42:54.000000000 +0100 -+++ texinfo/util/dir-example 2015-10-18 11:13:23.000000000 +0200 -@@ -10,7 +10,7 @@ - If you have dir entries for Texinfo manuals you'd like to be added here, - please send them to karl@gnu.org. - --$Id: dir-example,v 1.51 2004/12/18 02:11:43 karl Exp $ -+Id: dir-example,v 1.51 2004/12/18 02:11:43 karl Exp -  - File: dir, Node: Top, This is the top of the INFO tree. - -diff -rNU3 texinfo.orig/util/gen-dir-node texinfo/util/gen-dir-node ---- texinfo.orig/util/gen-dir-node 2004-04-11 19:56:47.000000000 +0200 -+++ texinfo/util/gen-dir-node 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,5 @@ - #!/bin/sh --# $Id: gen-dir-node,v 1.3 2004/04/11 17:56:47 karl Exp $ -+# Id: gen-dir-node,v 1.3 2004/04/11 17:56:47 karl Exp - # Generate the top-level Info node, given a directory of Info files - # and (optionally) a skeleton file. The output will be suitable for a - # top-level dir file. The skeleton file contains info topic names in the -@@ -51,7 +51,7 @@ - echo "by `whoami`@`hostname` for `(cd ${INFODIR}; pwd)`" - - cat << moobler --\$Id: gen-dir-node,v 1.3 2004/04/11 17:56:47 karl Exp $ -+\Id: gen-dir-node,v 1.3 2004/04/11 17:56:47 karl Exp - This is the file .../info/dir, which contains the topmost node of the - Info hierarchy. The first time you invoke Info you start off - looking at that node, which is (dir)Top. -diff -rNU3 texinfo.orig/util/gendocs.sh texinfo/util/gendocs.sh ---- texinfo.orig/util/gendocs.sh 2004-09-01 13:40:20.000000000 +0200 -+++ texinfo/util/gendocs.sh 2015-10-18 11:13:23.000000000 +0200 -@@ -1,7 +1,7 @@ - #!/bin/sh - # gendocs.sh -- generate a GNU manual in many formats. This script is - # mentioned in maintain.texi. See the help message below for usage details. --# $Id: gendocs.sh,v 1.13 2004/09/01 11:40:20 karl Exp $ -+# Id: gendocs.sh,v 1.13 2004/09/01 11:40:20 karl Exp - # - # Copyright (C) 2003, 2004 Free Software Foundation, Inc. - # -@@ -39,7 +39,7 @@ - : ${GENDOCS_TEMPLATE_DIR="."} - unset CDPATH - --rcs_revision='$Revision: 1.13 $' -+rcs_revision='Revision: 1.13' - rcs_version=`set - $rcs_revision; echo $2` - program=`echo $0 | sed -e 's!.*/!!'` - version="gendocs.sh $rcs_version -diff -rNU3 texinfo.orig/util/gendocs_template texinfo/util/gendocs_template ---- texinfo.orig/util/gendocs_template 2004-09-23 15:16:19.000000000 +0200 -+++ texinfo/util/gendocs_template 2015-10-18 11:13:23.000000000 +0200 -@@ -1,7 +1,7 @@ - - -- -+ - - - -@@ -91,7 +91,7 @@ -

- Updated: - --$Date: 2004/09/23 13:16:19 $ $Author: karl $ -+$Date: 2008/09/02 07:50:57 $ $Author: christos $ - -

- -diff -rNU3 texinfo.orig/util/infosrch texinfo/util/infosrch ---- texinfo.orig/util/infosrch 2004-04-11 19:56:47.000000000 +0200 -+++ texinfo/util/infosrch 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,5 @@ - #!/usr/local/bin/perl -w --# $Id: infosrch,v 1.2 2004/04/11 17:56:47 karl Exp $ -+# Id: infosrch,v 1.2 2004/04/11 17:56:47 karl Exp - # infosrch does a regex search on an info manual. - # By Harry Putnam . - -diff -rNU3 texinfo.orig/util/install-info-html texinfo/util/install-info-html ---- texinfo.orig/util/install-info-html 2004-04-11 19:56:47.000000000 +0200 -+++ texinfo/util/install-info-html 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,5 @@ - #!@BASH@ --# $Id: install-info-html,v 1.3 2004/04/11 17:56:47 karl Exp $ -+# Id: install-info-html,v 1.3 2004/04/11 17:56:47 karl Exp - - name=install-info-html - version=1.0 -diff -rNU3 texinfo.orig/util/install-info.c texinfo/util/install-info.c ---- texinfo.orig/util/install-info.c 2004-04-11 19:56:47.000000000 +0200 -+++ texinfo/util/install-info.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: install-info.c,v 1.9 2008/09/02 08:00:24 christos Exp $ */ -+ - /* install-info -- create Info directory entry(ies) for an Info file. -- $Id: install-info.c,v 1.12 2004/04/11 17:56:47 karl Exp $ -+ Id: install-info.c,v 1.12 2004/04/11 17:56:47 karl Exp - - Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software - Foundation, Inc. -diff -rNU3 texinfo.orig/util/texi-docstring-magic.el texinfo/util/texi-docstring-magic.el ---- texinfo.orig/util/texi-docstring-magic.el 2004-04-11 19:56:47.000000000 +0200 -+++ texinfo/util/texi-docstring-magic.el 2015-10-18 11:13:23.000000000 +0200 -@@ -5,7 +5,7 @@ - ;; Copyright (C) 1998 David Aspinall - ;; Maintainer: David Aspinall - ;; --;; $Id: texi-docstring-magic.el,v 1.2 2004/04/11 17:56:47 karl Exp $ -+;; Id: texi-docstring-magic.el,v 1.2 2004/04/11 17:56:47 karl Exp - ;; - ;; This package is distributed under the terms of the - ;; GNU General Public License, Version 2. -diff -rNU3 texinfo.orig/util/texi2dvi texinfo/util/texi2dvi ---- texinfo.orig/util/texi2dvi 2004-12-31 19:03:05.000000000 +0100 -+++ texinfo/util/texi2dvi 2015-10-18 11:13:23.000000000 +0200 -@@ -1,6 +1,6 @@ - #! /bin/sh - # texi2dvi --- produce DVI (or PDF) files from Texinfo (or LaTeX) sources. --# $Id: texi2dvi,v 1.34 2004/12/01 18:35:36 karl Exp $ -+# Id: texi2dvi,v 1.34 2004/12/01 18:35:36 karl Exp - # - # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2001, - # 2002, 2003, 2004 Free Software Foundation, Inc. -@@ -27,7 +27,7 @@ - # the `--debug' option when making a bug report. - - # This string is expanded by rcs automatically when this file is checked out. --rcs_revision='$Revision: 1.34 $' -+rcs_revision='Revision: 1.34' - rcs_version=`set - $rcs_revision; echo $2` - program=`echo $0 | sed -e 's!.*/!!'` - version="texi2dvi (GNU Texinfo 4.8) $rcs_version -@@ -605,10 +605,10 @@ - # If this is a Texinfo file with a specified input encoding, and - # recode is available, then recode to plain 7 bit Texinfo. - if test $language = texinfo; then -- pgm='s/\(^\|.* \)@documentencoding *\([^ ][^ ]*\)\( .*\|$\)/\2/ -- t found -- d -- :found -+ pgm='s/\(^\|.* \)@documentencoding *\([^ ][^ ]*\)\( .*\|$\)/\2/ -+ t found -+ d -+ :found - q' - encoding=`sed -e "$pgm" "$filename_input"` - if $recode && test -n "$encoding" && findprog recode; then -@@ -691,8 +691,13 @@ - - # Finally, run TeX. - cmd="$tex $tex_args" -- $verbose "Running $cmd $filename_input ..." -+ $verbose "Running $cmd ..." - if $cmd "$filename_input" >&5; then :; else -+ echo "$0: TeX failed. If the above said 'tex: not found', " >&2 -+ echo "$0: you may need to install TeX;" >&2 -+ echo "$0: it is available from the pkgsrc system in print/teTeX." >&2 -+ echo "$0: If TeX is installed, make sure it is in your $PATH, or" >&2 -+ echo "$0: set the environment variable $TEX to its location." >&2 - echo "$0: $tex exited with bad status, quitting." >&2 - echo "$0: see $filename_noext.log for errors." >&2 - test "$clean" = t \ -diff -rNU3 texinfo.orig/util/texi2pdf texinfo/util/texi2pdf ---- texinfo.orig/util/texi2pdf 2004-07-11 03:02:35.000000000 +0200 -+++ texinfo/util/texi2pdf 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,5 @@ - #!/bin/sh --# $Id: texi2pdf,v 1.1 2004/07/11 01:02:35 karl Exp $ -+# Id: texi2pdf,v 1.1 2004/07/11 01:02:35 karl Exp - # Written by Thomas Esser. Public domain. - # Execute texi2dvi --pdf. - -diff -rNU3 texinfo.orig/util/texindex.c texinfo/util/texindex.c ---- texinfo.orig/util/texindex.c 2004-04-11 19:56:47.000000000 +0200 -+++ texinfo/util/texindex.c 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,7 @@ -+/* $NetBSD: texindex.c,v 1.11 2008/09/02 08:00:24 christos Exp $ */ -+ - /* texindex -- sort TeX index dribble output into an actual index. -- $Id: texindex.c,v 1.11 2004/04/11 17:56:47 karl Exp $ -+ Id: texindex.c,v 1.11 2004/04/11 17:56:47 karl Exp - - Copyright (C) 1987, 1991, 1992, 1996, 1997, 1998, 1999, 2000, 2001, - 2002, 2003, 2004 Free Software Foundation, Inc. -@@ -37,16 +39,12 @@ - #define memset(ptr, ignore, count) bzero (ptr, count) - #endif - --char *mktemp (char *); -- - #if !defined (SEEK_SET) - # define SEEK_SET 0 - # define SEEK_CUR 1 - # define SEEK_END 2 - #endif /* !SEEK_SET */ - --struct linebuffer; -- - /* When sorting in core, this structure describes one line - and the position and length of its first keyfield. */ - struct lineinfo -@@ -96,16 +94,6 @@ - /* The allocated length of `linearray'. */ - long nlines; - --/* Directory to use for temporary files. On Unix, it ends with a slash. */ --char *tempdir; -- --/* Number of last temporary file. */ --int tempcount; -- --/* Number of last temporary file already deleted. -- Temporary files are deleted by `flush_tempfiles' in order of creation. */ --int last_deleted_tempcount; -- - /* During in-core sort, this points to the base of the data block - which contains all the lines of data. */ - char *text_base; -@@ -117,15 +105,9 @@ - determine whether we need initials in the sorted form. */ - char first_initial; - --/* Additional command switches .*/ -- --/* Nonzero means do not delete tempfiles -- for debugging. */ --int keep_tempfiles; -- - /* Forward declarations of functions in this file. */ - void decode_command (int argc, char **argv); - void sort_in_core (char *infile, int total, char *outfile); --void sort_offline (char *infile, off_t total, char *outfile); - char **parsefile (char *filename, char **nextline, char *data, long int size); - char *find_field (struct keyfield *keyfield, char *str, long int *lengthptr); - char *find_pos (char *str, int words, int chars, int ignore_blanks); -@@ -137,26 +119,17 @@ - long int length1, long int pos1, char *start2, - long int length2, long int pos2); - int compare_full (const void *, const void *); --long readline (struct linebuffer *linebuffer, FILE *stream); --int merge_files (char **infiles, int nfiles, char *outfile); --int merge_direct (char **infiles, int nfiles, char *outfile); - void pfatal_with_name (const char *name); - void fatal (const char *format, const char *arg); - void error (const char *format, const char *arg); - void *xmalloc (), *xrealloc (); --char *concat (char *s1, char *s2); --void flush_tempfiles (int to_count); -+static char *concat3 (const char *, const char *, const char *); - --#define MAX_IN_CORE_SORT 500000 -- - int - main (int argc, char **argv) - { - int i; - -- tempcount = 0; -- last_deleted_tempcount = 0; -- - #ifdef HAVE_SETLOCALE - /* Set locale via LC_ALL. */ - setlocale (LC_ALL, ""); -@@ -220,19 +193,20 @@ - - outfile = outfiles[i]; - if (!outfile) -- outfile = concat (infiles[i], "s"); -+ outfile = concat3 (infiles[i], "s", ""); - - need_initials = 0; - first_initial = '\0'; - -- if (ptr < MAX_IN_CORE_SORT) -- /* Sort a small amount of data. */ -- sort_in_core (infiles[i], (int)ptr, outfile); -- else -- sort_offline (infiles[i], ptr, outfile); -+ if (ptr != (int)ptr) -+ { -+ fprintf (stderr, "%s: %s: file too large\n", program_name, -+ infiles[i]); -+ xexit (1); -+ } -+ sort_in_core (infiles[i], (int)ptr, outfile); - } - -- flush_tempfiles (tempcount); - xexit (0); - return 0; /* Avoid bogus warnings. */ - } -@@ -250,10 +224,6 @@ - TEXINDEX_OPTION texindex_options[] = { - { "--help", "-h", (int *)NULL, 0, (char *)NULL, - N_("display this help and exit") }, -- { "--keep", "-k", &keep_tempfiles, 1, (char *)NULL, -- N_("keep temporary files around after processing") }, -- { "--no-keep", 0, &keep_tempfiles, 0, (char *)NULL, -- N_("do not keep temporary files around after processing (default)") }, - { "--output", "-o", (int *)NULL, 0, "FILE", - N_("send output to FILE") }, - { "--version", (char *)NULL, (int *)NULL, 0, (char *)NULL, -@@ -308,20 +278,6 @@ - char **ip; - char **op; - -- /* Store default values into parameter variables. */ -- -- tempdir = getenv ("TMPDIR"); -- if (tempdir == NULL) -- tempdir = getenv ("TEMP"); -- if (tempdir == NULL) -- tempdir = getenv ("TMP"); -- if (tempdir == NULL) -- tempdir = DEFAULT_TMPDIR; -- else -- tempdir = concat (tempdir, "/"); -- -- keep_tempfiles = 0; -- - /* Allocate ARGC input files, which must be enough. */ - - infiles = (char **) xmalloc (argc * sizeof (char *)); -@@ -348,7 +304,7 @@ - else if ((strcmp (arg, "--keep") == 0) || - (strcmp (arg, "-k") == 0)) - { -- keep_tempfiles = 1; -+ /* Ignore, for backward compatibility */ - } - else if ((strcmp (arg, "--help") == 0) || - (strcmp (arg, "-h") == 0)) -@@ -384,41 +340,6 @@ - usage (1); - } - --/* Return a name for temporary file COUNT. */ -- --static char * --maketempname (int count) --{ -- static char *tempbase = NULL; -- char tempsuffix[10]; -- -- if (!tempbase) -- { -- int fd; -- tempbase = concat (tempdir, "txidxXXXXXX"); -- -- fd = mkstemp (tempbase); -- if (fd == -1) -- pfatal_with_name (tempbase); -- } -- -- sprintf (tempsuffix, ".%d", count); -- return concat (tempbase, tempsuffix); --} -- -- --/* Delete all temporary files up to TO_COUNT. */ -- --void --flush_tempfiles (int to_count) --{ -- if (keep_tempfiles) -- return; -- while (last_deleted_tempcount < to_count) -- unlink (maketempname (++last_deleted_tempcount)); --} -- -- - /* Compare LINE1 and LINE2 according to the specified set of keyfields. */ - - int -@@ -801,150 +722,6 @@ - } - } - --/* A `struct linebuffer' is a structure which holds a line of text. -- `readline' reads a line from a stream into a linebuffer -- and works regardless of the length of the line. */ -- --struct linebuffer --{ -- long size; -- char *buffer; --}; -- --/* Initialize LINEBUFFER for use. */ -- --void --initbuffer (struct linebuffer *linebuffer) --{ -- linebuffer->size = 200; -- linebuffer->buffer = (char *) xmalloc (200); --} -- --/* Read a line of text from STREAM into LINEBUFFER. -- Return the length of the line. */ -- --long --readline (struct linebuffer *linebuffer, FILE *stream) --{ -- char *buffer = linebuffer->buffer; -- char *p = linebuffer->buffer; -- char *end = p + linebuffer->size; -- -- while (1) -- { -- int c = getc (stream); -- if (p == end) -- { -- buffer = (char *) xrealloc (buffer, linebuffer->size *= 2); -- p += buffer - linebuffer->buffer; -- end += buffer - linebuffer->buffer; -- linebuffer->buffer = buffer; -- } -- if (c < 0 || c == '\n') -- { -- *p = 0; -- break; -- } -- *p++ = c; -- } -- -- return p - buffer; --} -- --/* Sort an input file too big to sort in core. */ -- --void --sort_offline (char *infile, off_t total, char *outfile) --{ -- /* More than enough. */ -- int ntemps = 2 * (total + MAX_IN_CORE_SORT - 1) / MAX_IN_CORE_SORT; -- char **tempfiles = (char **) xmalloc (ntemps * sizeof (char *)); -- FILE *istream = fopen (infile, "r"); -- int i; -- struct linebuffer lb; -- long linelength; -- int failure = 0; -- -- initbuffer (&lb); -- -- /* Read in one line of input data. */ -- -- linelength = readline (&lb, istream); -- -- if (lb.buffer[0] != '\\' && lb.buffer[0] != '@') -- { -- error (_("%s: not a texinfo index file"), infile); -- return; -- } -- -- /* Split up the input into `ntemps' temporary files, or maybe fewer, -- and put the new files' names into `tempfiles' */ -- -- for (i = 0; i < ntemps; i++) -- { -- char *outname = maketempname (++tempcount); -- FILE *ostream = fopen (outname, "w"); -- long tempsize = 0; -- -- if (!ostream) -- pfatal_with_name (outname); -- tempfiles[i] = outname; -- -- /* Copy lines into this temp file as long as it does not make file -- "too big" or until there are no more lines. */ -- -- while (tempsize + linelength + 1 <= MAX_IN_CORE_SORT) -- { -- tempsize += linelength + 1; -- fputs (lb.buffer, ostream); -- putc ('\n', ostream); -- -- /* Read another line of input data. */ -- -- linelength = readline (&lb, istream); -- if (!linelength && feof (istream)) -- break; -- -- if (lb.buffer[0] != '\\' && lb.buffer[0] != '@') -- { -- error (_("%s: not a texinfo index file"), infile); -- failure = 1; -- goto fail; -- } -- } -- fclose (ostream); -- if (feof (istream)) -- break; -- } -- -- free (lb.buffer); -- --fail: -- /* Record number of temp files we actually needed. */ -- -- ntemps = i; -- -- /* Sort each tempfile into another tempfile. -- Delete the first set of tempfiles and put the names of the second -- into `tempfiles'. */ -- -- for (i = 0; i < ntemps; i++) -- { -- char *newtemp = maketempname (++tempcount); -- sort_in_core (tempfiles[i], MAX_IN_CORE_SORT, newtemp); -- if (!keep_tempfiles) -- unlink (tempfiles[i]); -- tempfiles[i] = newtemp; -- } -- -- if (failure) -- return; -- -- /* Merge the tempfiles together and indexify. */ -- -- merge_files (tempfiles, ntemps, outfile); --} -- - /* Sort INFILE, whose size is TOTAL, - assuming that is small enough to be done in-core, - then indexify it and send the output to OUTFILE (or to stdout). */ -@@ -1348,8 +1125,7 @@ - - for (next_line = linearray; next_line != stop_line; next_line++) - { -- /* If -u was specified, output the line only if distinct from -- previous one. */ -+ /* Output the line only if distinct from previous one. */ - if (next_line == linearray - /* Compare previous line with this one, using only the - explicitly specd keyfields. */ -@@ -1369,215 +1145,6 @@ - finish_index (ostream); - } - --/* Assume (and optionally verify) that each input file is sorted; -- merge them and output the result. -- Returns nonzero if any input file fails to be sorted. -- -- This is the high-level interface that can handle an unlimited -- number of files. */ -- --#define MAX_DIRECT_MERGE 10 -- --int --merge_files (char **infiles, int nfiles, char *outfile) --{ -- char **tempfiles; -- int ntemps; -- int i; -- int value = 0; -- int start_tempcount = tempcount; -- -- if (nfiles <= MAX_DIRECT_MERGE) -- return merge_direct (infiles, nfiles, outfile); -- -- /* Merge groups of MAX_DIRECT_MERGE input files at a time, -- making a temporary file to hold each group's result. */ -- -- ntemps = (nfiles + MAX_DIRECT_MERGE - 1) / MAX_DIRECT_MERGE; -- tempfiles = (char **) xmalloc (ntemps * sizeof (char *)); -- for (i = 0; i < ntemps; i++) -- { -- int nf = MAX_DIRECT_MERGE; -- if (i + 1 == ntemps) -- nf = nfiles - i * MAX_DIRECT_MERGE; -- tempfiles[i] = maketempname (++tempcount); -- value |= merge_direct (&infiles[i * MAX_DIRECT_MERGE], nf, tempfiles[i]); -- } -- -- /* All temporary files that existed before are no longer needed -- since their contents have been merged into our new tempfiles. -- So delete them. */ -- flush_tempfiles (start_tempcount); -- -- /* Now merge the temporary files we created. */ -- -- merge_files (tempfiles, ntemps, outfile); -- -- free (tempfiles); -- -- return value; --} -- --/* Assume (and optionally verify) that each input file is sorted; -- merge them and output the result. -- Returns nonzero if any input file fails to be sorted. -- -- This version of merging will not work if the number of -- input files gets too high. Higher level functions -- use it only with a bounded number of input files. */ -- --int --merge_direct (char **infiles, int nfiles, char *outfile) --{ -- struct linebuffer *lb1, *lb2; -- struct linebuffer **thisline, **prevline; -- FILE **streams; -- int i; -- int nleft; -- int lossage = 0; -- int *file_lossage; -- struct linebuffer *prev_out = 0; -- FILE *ostream = stdout; -- -- if (outfile) -- { -- ostream = fopen (outfile, "w"); -- } -- if (!ostream) -- pfatal_with_name (outfile); -- -- init_index (); -- -- if (nfiles == 0) -- { -- if (outfile) -- fclose (ostream); -- return 0; -- } -- -- /* For each file, make two line buffers. Also, for each file, there -- is an element of `thisline' which points at any time to one of the -- file's two buffers, and an element of `prevline' which points to -- the other buffer. `thisline' is supposed to point to the next -- available line from the file, while `prevline' holds the last file -- line used, which is remembered so that we can verify that the file -- is properly sorted. */ -- -- /* lb1 and lb2 contain one buffer each per file. */ -- lb1 = (struct linebuffer *) xmalloc (nfiles * sizeof (struct linebuffer)); -- lb2 = (struct linebuffer *) xmalloc (nfiles * sizeof (struct linebuffer)); -- -- /* thisline[i] points to the linebuffer holding the next available -- line in file i, or is zero if there are no lines left in that file. */ -- thisline = (struct linebuffer **) -- xmalloc (nfiles * sizeof (struct linebuffer *)); -- /* prevline[i] points to the linebuffer holding the last used line -- from file i. This is just for verifying that file i is properly -- sorted. */ -- prevline = (struct linebuffer **) -- xmalloc (nfiles * sizeof (struct linebuffer *)); -- /* streams[i] holds the input stream for file i. */ -- streams = (FILE **) xmalloc (nfiles * sizeof (FILE *)); -- /* file_lossage[i] is nonzero if we already know file i is not -- properly sorted. */ -- file_lossage = (int *) xmalloc (nfiles * sizeof (int)); -- -- /* Allocate and initialize all that storage. */ -- -- for (i = 0; i < nfiles; i++) -- { -- initbuffer (&lb1[i]); -- initbuffer (&lb2[i]); -- thisline[i] = &lb1[i]; -- prevline[i] = &lb2[i]; -- file_lossage[i] = 0; -- streams[i] = fopen (infiles[i], "r"); -- if (!streams[i]) -- pfatal_with_name (infiles[i]); -- -- readline (thisline[i], streams[i]); -- } -- -- /* Keep count of number of files not at eof. */ -- nleft = nfiles; -- -- while (nleft) -- { -- struct linebuffer *best = 0; -- struct linebuffer *exch; -- int bestfile = -1; -- int i; -- -- /* Look at the next avail line of each file; choose the least one. */ -- -- for (i = 0; i < nfiles; i++) -- { -- if (thisline[i] && -- (!best || -- 0 < compare_general (best->buffer, thisline[i]->buffer, -- (long) bestfile, (long) i, num_keyfields))) -- { -- best = thisline[i]; -- bestfile = i; -- } -- } -- -- /* Output that line, unless it matches the previous one and we -- don't want duplicates. */ -- -- if (!(prev_out && -- !compare_general (prev_out->buffer, -- best->buffer, 0L, 1L, num_keyfields - 1))) -- indexify (best->buffer, ostream); -- prev_out = best; -- -- /* Now make the line the previous of its file, and fetch a new -- line from that file. */ -- -- exch = prevline[bestfile]; -- prevline[bestfile] = thisline[bestfile]; -- thisline[bestfile] = exch; -- -- while (1) -- { -- /* If the file has no more, mark it empty. */ -- -- if (feof (streams[bestfile])) -- { -- thisline[bestfile] = 0; -- /* Update the number of files still not empty. */ -- nleft--; -- break; -- } -- readline (thisline[bestfile], streams[bestfile]); -- if (thisline[bestfile]->buffer[0] || !feof (streams[bestfile])) -- break; -- } -- } -- -- finish_index (ostream); -- -- /* Free all storage and close all input streams. */ -- -- for (i = 0; i < nfiles; i++) -- { -- fclose (streams[i]); -- free (lb1[i].buffer); -- free (lb2[i].buffer); -- } -- free (file_lossage); -- free (lb1); -- free (lb2); -- free (thisline); -- free (prevline); -- free (streams); -- -- if (outfile) -- fclose (ostream); -- -- return lossage; --} -- - /* Print error message and exit. */ - - void -@@ -1612,17 +1179,18 @@ - } - - --/* Return a newly-allocated string concatenating S1 and S2. */ -+/* Return a newly-allocated string concatenating S1, S2, and S3. */ - --char * --concat (char *s1, char *s2) -+static char * -+concat3 (const char *s1, const char *s2, const char *s3) - { -- int len1 = strlen (s1), len2 = strlen (s2); -- char *result = (char *) xmalloc (len1 + len2 + 1); -+ int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3); -+ char *result = (char *) xmalloc (len1 + len2 + len3 + 1); - - strcpy (result, s1); - strcpy (result + len1, s2); -- *(result + len1 + len2) = 0; -+ strcpy (result + len1 + len2, s3); -+ *(result + len1 + len2 + len3) = 0; - - return result; - } -diff -rNU3 texinfo.orig/util/texinfo.dtd texinfo/util/texinfo.dtd ---- texinfo.orig/util/texinfo.dtd 2004-12-19 16:08:55.000000000 +0100 -+++ texinfo/util/texinfo.dtd 2015-10-18 11:13:23.000000000 +0200 -@@ -1,4 +1,4 @@ -- -+ - - -diff -rNU3 texinfo.orig/util/txitextest texinfo/util/txitextest ---- texinfo.orig/util/txitextest 2004-04-11 19:56:47.000000000 +0200 -+++ texinfo/util/txitextest 2015-10-18 11:13:23.000000000 +0200 -@@ -1,5 +1,5 @@ - #!/bin/sh --# $Id: txitextest,v 1.5 2004/04/11 17:56:47 karl Exp $ -+# Id: txitextest,v 1.5 2004/04/11 17:56:47 karl Exp - # Test texinfo.tex changes by running various manuals through with an - # old version, saving the .ps result from dvips, doing the same with a - # new version, and comparing. Idea from Stepan Kasal. diff --git a/usr.sbin/installboot/installboot_nbsd.8 b/usr.sbin/installboot/installboot_nbsd.8 deleted file mode 100644 index ec0b6d1cd..000000000 --- a/usr.sbin/installboot/installboot_nbsd.8 +++ /dev/null @@ -1,863 +0,0 @@ -.\" $NetBSD: installboot_nbsd.8,v 1.79 2011/11/03 20:09:18 martin Exp $ -.\" -.\" Copyright (c) 2002-2009 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Luke Mewburn of Wasabi Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd August 3, 2011 -.Dt INSTALLBOOT 8 -.Os -.Sh NAME -.Nm installboot_nbsd -.Nd install disk bootstrap software -. -.Sh SYNOPSIS -.Nm -.Op Fl fnv -.Op Fl B Ar s2bno -.Op Fl b Ar s1bno -.Op Fl o Ar options -.Op Fl t Ar fstype -.Ar filesystem -.Ar primary -.Op Ar secondary -.Nm -.Fl c -.Op Fl fnv -.Op Fl o Ar options -.Op Fl t Ar fstype -.Ar filesystem -.Nm -.Fl e -.Op Fl fnv -.Op Fl o Ar options -.Ar bootstrap -.Nm -.Fl m(aster) -.Ar device -.Ar masterboot -. -.Sh DESCRIPTION -The -.Nm -utility installs and removes -.Nx -disk bootstrap software into a file system. -.Nm -can install -.Ar primary -into -.Ar filesystem , -or disable an existing bootstrap in -.Ar filesystem . -.Pp -On some architectures the options of an existing installed bootstrap, -or those of a bootstrap file can be changed. -Installing a new primary bootstrap will reset those options to default -values. -.Pp -Generally, -.Nx -disk bootstrap software consists of two parts: a -.Dq primary -bootstrap program usually written into the disklabel area of the -file system by -.Nm , -and a -.Dq secondary -bootstrap program that usually resides as an ordinary file in the file system. -.Pp -When booting, the primary bootstrap program is loaded and invoked by -the machine's PROM or BIOS. -After receiving control of the system it loads and runs the secondary -bootstrap program, which in turn loads and runs the kernel. -The secondary bootstrap may allow control over various boot parameters -passed to the kernel. -.Pp -Perform the following steps to make a file system bootable: -.Bl -enum -.It -Copy the secondary bootstrap (usually -.Pa /usr/mdec/boot. Ns Sy MACHINE -or -.Pa /usr/mdec/boot ) -to the root directory of the target file system. -.Pp -. -.It -Use -.Nm -to install the primary bootstrap program -(usually -.Pa /usr/mdec/bootxx_ Ns Sy FSTYPE ) -into -.Ar filesystem . -.Pp -The following platforms do not require this step if the primary bootstrap -already exists and the secondary bootstrap file is just being updated: -.Sy alpha , -.Sy amd64 , -.Sy amiga , -.Sy i386 , -.Sy pmax , -.Sy sparc64 , -and -.Sy vax . -.Pp -The following platform does not require the first step since a -single bootstrap file is used. -The single bootstrap is installed like the primary bootstrap on -other platforms: -.Sy next68k . -.Pp -.El -.Pp -The options and arguments recognized by -.Nm -are as follows: -. -.Bl -tag -width "optionsxxx" -. -.It Fl B Ar s2bno -When hard-coding the blocks of -.Ar secondary -into -.Ar primary , -start from block -.Ar s2bno -instead of trying to determine the block numbers occupied by -.Ar secondary -by examining -.Ar filesystem . -If this option is supplied, -.Ar secondary -should refer to an actual secondary bootstrap (rather than the -file name of the one present in -.Ar filesystem ) -so that its size can be determined. -. -.It Fl b Ar s1bno -Install -.Ar primary -at block number -.Ar s1bno -instead of the default location for the machine and file system type. -.Sy [ alpha , -.Sy pmax , -.Sy vax ] -. -.It Fl c -Clear (remove) any existing bootstrap instead of installing one. -. -.It Fl e -Edit the options of an existing bootstrap. -This can be use to change the options in bootxx_xxxfs files, -raw disk partitions, and the -.Pa pxeboot_ia32.bin -file. -With -.Fl v -and without -.Fl o , -show the current options. -.Sy [ amd64 , i386 ] -. -.It Fl f -Forces -.Nm -to ignore some errors. -. -.It Fl n -Do not write to -.Ar filesystem . -. -.It Fl o Ar options -Machine specific -.Nm -options, comma separated. -.Pp -Supported options are (with the machines for they are valid in brackets): -. -.Bl -tag -offset indent -width alphasum -. -.It Sy alphasum -.Sy [ alpha ] -Recalculate and restore the Alpha checksum. -This is the default for -.Nx Ns Tn /alpha . -. -.It Sy append -.Sy [ alpha , -.Sy pmax , -.Sy vax ] -Append -.Ar primary -to the end of -.Ar filesystem , -which must be a regular file in this case. -. -.It Sy bootconf -.Sy [ amd64 , -.Sy i386 ] -(Don't) read a -.Dq boot.cfg -file. -. -.It Sy command=\*[Lt]boot command\*[Gt] -.Sy [ amiga ] -Modify the default boot command line. -. -.It Sy console=\*[Lt]console name\*[Gt] -.Sy [ amd64 , -.Sy i386 ] -Set the console device, \*[Lt]console name\*[Gt] must be one of: -pc, com0, com1, com2, com3, com0kbd, com1kbd, com2kbd or com3kbd. -. -.It Sy ioaddr=\*[Lt]ioaddr\*[Gt] -.Sy [ amd64 , -.Sy i386 ] -Set the IO address to be used for the console serial port. -Defaults to the IO address used by the system BIOS for the specified port. -. -.It Sy keymap=\*[Lt]keymap\*[Gt] -.Sy [ amd64 , -.Sy i386 ] -Set a boot time keyboard translation map. -Each character in \*[Lt]keymap\*[Gt] will be replaced by the one following it. -For example, an argument of -.Dq zyz -would swap the lowercase letters -.Sq y -and -.Sq z . -. -.It Sy modules -.Sy [ amd64 , -.Sy i386 ] -(Don't) load kernel modules. -. -.It Sy password=\*[Lt]password\*[Gt] -.Sy [ amd64 , -.Sy i386 ] -Set the password which must be entered before the boot menu can be accessed. -. -.It Sy resetvideo -.Sy [ amd64 , -.Sy i386 ] -Reset the video before booting. -. -.It Sy speed=\*[Lt]baud rate\*[Gt] -.Sy [ amd64 , -.Sy i386 ] -Set the baud rate for the serial console. -If a value of zero is specified, then the current baud rate (set by the -BIOS) will be used. -. -.It Sy sunsum -.Sy [ alpha , -.Sy pmax , -.Sy vax ] -Recalculate and restore the Sun and -.Nx Ns Tn /sparc -compatible checksum. -.Em Note : -The existing -.Nx Ns Tn /sparc -disklabel should use no more than 4 partitions. -. -.It Sy timeout=\*[Lt]seconds\*[Gt] -.Sy [ amd64 , -.Sy i386 ] -Set the timeout before the automatic boot begins to the given number of seconds. -.El -. -.It Fl t Ar fstype -Use -.Ar fstype -as the type of -.Ar filesystem . -The default operation is to attempt to auto-detect this setting. -The following file system types are currently supported by -.Nm : -. -.Bl -tag -offset indent -width raid -. -.It Sy ffs -.Bx -Fast File System. -. -.It Sy raid -Mirrored RAIDframe File System. -. -.It Sy raw -.Sq Raw -image. -Note: if a platform needs to hard-code the block offset of the secondary -bootstrap, it cannot be searched for on this file system type, and must -be provided with -.Fl B Ar s2bno . -.El -. -.It Fl v -Verbose operation. -. -.It Ar filesystem -The path name of the device or file system image that -.Nm -is to operate on. -It is not necessary for -.Ar filesystem -to be a currently mounted file system. -. -.It Ar primary -The path name of the -.Dq primary -boot block to install. -The path name must refer to a file in a file system that is currently -mounted. -. -.It Ar secondary -The path name of the -.Dq secondary -boot block, relative to the root of -the file system in the device or image specified by the -.Ar filesystem -argument. -Note that this may refer to a file in a file system that is not mounted. -Most systems require -.Ar secondary -to be in the -.Dq root -directory of the file system, so the leading -.Dq Pa / -is not necessary on -.Ar secondary . -.Pp -Only certain combinations of -platform -.Pq Fl m Ar machine -and file system type -.Pq Fl t Ar fstype -require that the name of the secondary bootstrap is -supplied as -.Ar secondary , -so that information such as the disk block numbers occupied -by the secondary bootstrap can be stored in the primary bootstrap. -These are: -.Bl -column "Platform" "File systems" -offset indent -.It Sy "Platform" Ta Sy "File systems" -.It macppc Ta ffs, raw -.It news68k Ta ffs, raw -.It newsmips Ta ffs, raw -.It sparc Ta ffs, raid, raw -.It sun2 Ta ffs, raw -.It sun3 Ta ffs, raw -.El -.El -.Pp -.Nm -exits 0 on success, and \*[Gt]0 if an error occurs. -. -.Sh ENVIRONMENT -.Nm -uses the following environment variables: -. -.Bl -tag -width "MACHINE" -. -.It Ev MACHINE -Default value for -.Ar machine , -overriding the result from -.Xr uname 3 . -. -.El -. -.Sh FILES -Most -.Nx -ports will contain variations of the following files: -.Pp -.Bl -tag -width /usr/mdec/bootxx_ustarfs -. -.It Pa /usr/mdec/bootxx_ Ns Sy FSTYPE -Primary bootstrap for file system type -.Sy FSTYPE . -Installed into the bootstrap area of the file system by -.Nm . -. -.It Pa /usr/mdec/bootxx_fat16 -Primary bootstrap for -.Tn MS-DOS -.Sy FAT16 -file systems. -This differs from -.Nm bootxx_msdos -in that it doesn't require the filesystem to have been initialised with -any -.Ql reserved sectors . -It also uses the information in the -.Ql Boot Parameter Block -to get the media and filesytem properties. -. -.It Pa /usr/mdec/bootxx_ffsv1 -Primary bootstrap for -.Sy FFSv1 -file systems -(the "traditional" -.Nx -file system). -Use -.Xr dumpfs 8 -to confirm the file system format is -.Sy FFSv1 . -. -.It Pa /usr/mdec/bootxx_ffsv2 -Primary bootstrap for -.Sy FFSv2 -file systems. -Use -.Xr dumpfs 8 -to confirm the file system format is -.Sy FFSv2 . -. -.It Pa /usr/mdec/bootxx_lfsv1 -Primary bootstrap for -.Sy LFSv1 -file systems. -. -.It Pa /usr/mdec/bootxx_lfsv2 -Primary bootstrap for -.Sy LFSv2 -file systems -(the default LFS version). -. -.It Pa /usr/mdec/bootxx_msdos -Primary bootstrap for -.Tn MS-DOS -.Sy FAT -file systems. -. -.It Pa /usr/mdec/bootxx_ustarfs -Primary bootstrap for -.Sy TARFS -boot images. -This is used by various install media. -. -.It Pa /usr/mdec/boot. Ns Sy MACHINE -Secondary bootstrap for machine type -.Sy MACHINE . -This should be installed into the file system before -.Nm -is run. -. -.It Pa /usr/mdec/boot -Synonym for -.Pa /usr/mdec/boot. Ns Sy MACHINE -. -.It Pa /boot. Ns Sy MACHINE -Installed copy of secondary bootstrap for machine type -.Sy MACHINE . -. -.It Pa /boot -Installed copy of secondary bootstrap. -Searched for by the primary bootstrap if -.Pa /boot. Ns Sy MACHINE -is not found. -. -.El -. -.Ss Nx Ns Tn /macppc files -. -.Bl -tag -width /usr/mdec/bootxx_ustarfs -. -.It Pa /usr/mdec/bootxx -.Nx Ns Tn /macppc -primary bootstrap. -. -.It Pa /usr/mdec/ofwboot -.Nx Ns Tn /macppc -secondary bootstrap. -. -.It Pa /ofwboot -Installed copy of -.Nx Ns Tn /macppc -secondary bootstrap. -. -.El -. -.Ss Nx Ns Tn /next68k files -. -.Bl -tag -width /usr/mdec/bootxx_ustarfs -. -.It Pa /usr/mdec/boot -.Nx Ns Tn /next68k -bootstrap. -. -.El -. -.Ss Nx Ns Tn /sparc64 files -. -.Bl -tag -width /usr/mdec/bootxx_ustarfs -. -.It Pa /usr/mdec/bootblk -.Nx Ns Tn /sparc64 -primary bootstrap. -. -.It Pa /usr/mdec/ofwboot -.Nx Ns Tn /sparc64 -secondary bootstrap. -. -.It Pa /ofwboot -Installed copy of -.Nx Ns Tn /sparc64 -secondary bootstrap. -. -.El -. -.Sh EXAMPLES -. -.Ss common -Verbosely install the Berkeley Fast File System primary bootstrap on to disk -.Sq sd0 : -.Dl Ic installboot_nbsd -v /dev/rsd0c /usr/mdec/bootxx_ffs -Note: the -.Dq whole disk -partition (c on some ports, d on others) is used here, since the a partition -probably is already opened (mounted as -.Pa / ) , -so -.Nm -would not be able to access it. -.Pp -Remove the primary bootstrap from disk -.Sq sd1 : -.Dl Ic installboot_nbsd -c /dev/rsd1c -. -.Ss Nx Ns Tn /amiga -Modify the command line to change the default from "netbsd -ASn2" to -"netbsd -S": -.Dl Ic installboot_nbsd -m amiga -o command="netbsd -S" /dev/rsd0a /usr/mdec/bootxx_ffs -. -.Ss Nx Ns Tn /ews4800mips -Install the System V Boot File System primary bootstrap on to disk -.Sq sd0 , -with the secondary bootstrap -.Sq Pa /boot -already present in the SysVBFS partition on the disk: -.Dl Ic installboot_nbsd /dev/rsd0c /usr/mdec/bootxx_bfs -. -.Ss Nx Ns Tn /i386 and Nx Ns Tn /amd64 -Install new boot blocks on an existing mounted root file system on -.Sq wd0 , -setting the timeout to five seconds, after copying a new secondary -bootstrap: -.Dl Ic cp /usr/mdec/boot /boot -.Dl Ic installboot_nbsd -v -o timeout=5 /dev/rwd0a /usr/mdec/bootxx_ffsv1 -. -.Pp -Create a bootable CD-ROM with an ISO9660 -file system for an i386 system with a serial console: -.Dl Ic mkdir cdrom -.Dl Ic cp sys/arch/i386/compile/mykernel/netbsd cdrom/netbsd -.Dl Ic cp /usr/mdec/boot cdrom/boot -.Dl Ic cp /usr/mdec/bootxx_cd9660 bootxx -.Dl Ic installboot_nbsd -o console=com0,speed=19200 -m i386 -e bootxx -.Dl Ic makefs -t cd9660 -o 'bootimage=i386;bootxx,no-emul-boot' boot.iso \ - cdrom -. -.Pp -Create a bootable floppy disk with an FFSv1 -file system for a small custom kernel (note: bigger kernels needing -multiple disks are handled with the ustarfs file system): -.Dl Ic newfs -s 1440k /dev/rfd0a -.Bd -ragged -offset indent-two -compact -.Em Note : -Ignore the warnings that -.Xr newfs 8 -displays; it can not write a disklabel, -which is not a problem for a floppy disk. -.Ed -.Dl Ic mount /dev/fd0a /mnt -.Dl Ic cp /usr/mdec/boot /mnt/boot -.Dl Ic gzip -9 \*[Lt] sys/arch/i386/compile/mykernel/netbsd \*[Gt] /mnt/netbsd.gz -.Dl Ic umount /mnt -.Dl Ic installboot_nbsd -v /dev/rfd0a /usr/mdec/bootxx_ffsv1 -. -.Pp -Create a bootable FAT file system on -.Sq wd1a , -which should have the same offset and size as a FAT primary partition -in the Master Boot Record (MBR): -.Dl Ic newfs_msdos -r 16 /dev/rwd1a -.Bd -ragged -offset indent-two -compact -.Em Notes : -The -.Fl r Ar 16 -is to reserve space for the primary bootstrap. -.Xr newfs_msdos 8 -will display an -.Dq MBR type -such as -.Ql 1 , -.Ql 4 , -or -.Ql 6 ; -the MBR partition type of the appropriate primary partition should be -changed to this value. -.Ed -.Dl Ic mount -t msdos /dev/wd1a /mnt -.Dl Ic cp /usr/mdec/boot /mnt/boot -.Dl Ic cp path/to/kernel /mnt/netbsd -.Dl Ic umount /mnt -.Dl Ic installboot_nbsd -t raw /dev/rwd1a /usr/mdec/bootxx_msdos -.Pp -Make the existing FAT16 filesystem on -.Sq sd0e -bootable. -This can be used to make USB memory bootable provided it has 512 byte -sectors and that the manufacturer correctly initialised the file system. -.Dl Ic mount -t msdos /dev/sd0e /mnt -.Dl Ic cp /usr/mdec/boot /mnt/boot -.Dl Ic cp path/to/kernel /mnt/netbsd -.Dl Ic umount /mnt -.Dl Ic installboot_nbsd /dev/rsd0e /usr/mdec/bootxx_fat16 -It may also be necessary to use -.Nm fdisk -to make the device itself bootable. -. -.Pp -Switch the existing installed bootstrap to use a serial console without -reinstalling or altering other options such as timeout. -.Dl Ic installboot_nbsd -e -o console=com0 /dev/rwd0a -.Ss Nx Ns Tn /macppc -Note the -.Nm -utility is only required for macppc machines with OpenFirmware version 2 -to boot. -OpenFirmware 3 cannot load bootblocks specified in the Apple partition -map. -.Pp -Install the Berkeley Fast File System primary bootstrap on to disk -.Sq wd0 : -.Dl Ic installboot_nbsd /dev/rwd0c /usr/mdec/bootxx /ofwboot -.Pp -The secondary -.Nx Ns Tn /macppc -bootstrap is located in -.Pa /usr/mdec/ofwboot . -.Pp -The primary bootstrap requires the raw -.Pa ofwboot -for the secondary bootstrap, not -.Pa ofwboot.xcf , -which is used for the OpenFirmware to load kernels. -.Ss Nx Ns Tn /next68k -Install the bootstrap on to disk -.Sq sd0 : -.Dl Ic installboot_nbsd /dev/rsd0c /usr/mdec/boot -.Pp -. -.Ss Nx Ns Tn /pmax -Install the Berkeley Fast File System primary bootstrap on to disk -.Sq sd0 : -.Dl Ic installboot_nbsd /dev/rsd0c /usr/mdec/bootxx_ffs -.Pp -.Nx Ns Tn /pmax -requires that this file system starts at block 0 of the disk. -.Pp -Install the ISO 9660 primary bootstrap in the file -.Pa /tmp/cd-image : -.Dl Ic installboot_nbsd -m pmax /tmp/cd-image /usr/mdec/bootxx_cd9660 -.Pp -Make an ISO 9660 filesystem in the file -.Pa /tmp/cd-image -and install the ISO 9660 primary bootstrap in the filesystem, where the -source directory for the ISO 9660 filesystem contains a kernel, the -primary bootstrap -.Pa bootxx_cd9660 -and the secondary bootstrap -.Pa boot.pmax : -.Dl Ic mkisofs -o /tmp/cd-image -a -l -v iso-source-dir -.Dl ... -.Dl 48 51 iso-source-dir/bootxx_cd9660 -.Dl ... -.Dl Ic installboot_nbsd -b `expr 48 \e* 4` /tmp/cd-image /usr/mdec/bootxx_cd9660 -. -.Ss Nx Ns Tn /sparc -Install the Berkeley Fast File System primary bootstrap on to disk -.Sq sd0 , -with the secondary bootstrap -.Sq Pa /boot -already present: -.Dl Ic installboot_nbsd /dev/rsd0c /usr/mdec/bootxx /boot -. -.Ss Nx Ns Tn /sparc64 -Install the primary bootstrap on to disk -.Sq sd0 : -.Dl Ic installboot_nbsd /dev/rsd0c /usr/mdec/bootblk -.Pp -The secondary -.Nx Ns Tn /sparc64 -bootstrap is located in -.Pa /usr/mdec/ofwboot . -. -.Ss Nx Ns Tn /sun2 and Nx Ns Tn /sun3 -Install the Berkeley Fast File System primary bootstrap on to disk -.Sq sd0 , -with the secondary bootstrap -.Sq Pa /boot -already present: -.Dl Ic installboot_nbsd /dev/rsd0c /usr/mdec/bootxx /boot -. -.Sh SEE ALSO -.Xr uname 3 , -.Xr boot 8 , -.Xr disklabel 8 , -.Xr dumpfs 8 , -.Xr fdisk 8 , -.Xr pxeboot 8 -. -.Sh HISTORY -This implementation of -.Nm -appeared in -.Nx 1.6 . -. -.Sh AUTHORS -The machine independent portion of this implementation of -.Nm -was written by Luke Mewburn. -The following people contributed to the various machine dependent -back-ends: -Simon Burge (pmax), -Chris Demetriou (alpha), -Matthew Fredette (sun2, sun3), -Matthew Green (sparc64), -Ross Harvey (alpha), -Michael Hitch (amiga), -Paul Kranenburg (sparc), -David Laight (i386), -Christian Limpach (next68k), -Luke Mewburn (macppc), -Matt Thomas (vax), -Izumi Tsutsui (news68k, newsmips), -and -UCHIYAMA Yasushi (ews4800mips). -. -.Sh BUGS -There are not currently primary bootstraps to support all file systems -types which are capable of being the root file system. -.Pp -If a disk has been converted from -.Sy FFS -to -.Sy RAID -without the contents of the disk erased, then the original -.Sy FFS -installation may be auto-detected instead of the -.Sy RAID -installation. -In this case, the -.Fl t Ar raid -option must be provided. -. -.Ss Nx Ns Tn /alpha -The -.Nx Ns Tn /alpha -primary bootstrap program can only load the secondary bootstrap program -from file systems starting at the beginning (block 0) of disks. -Similarly, the secondary bootstrap program can only load kernels from -file systems starting at the beginning of disks. -.Pp -The size of primary bootstrap programs is restricted to 7.5KB, even -though some file systems (e.g., ISO 9660) are able to accommodate larger -ones. -. -.Ss Nx Ns Tn /hp300 -The disk must have a boot partition large enough to hold the bootstrap code. -Currently the primary bootstrap must be a LIF format file. -. -.Ss Nx Ns Tn /i386 and Nx Ns Tn /amd64 -The bootstrap must be installed in the -.Nx -partition that starts at the beginning of the mbr partition. -If that is a valid filesystem and contains the -.Pa /boot -program then it will be used as the root filesystem, otherwise the -.Sq a -partition will be booted. -.Pp -The size of primary bootstrap programs is restricted to 8KB, even -though some file systems (e.g., ISO 9660) are able to accommodate larger -ones. -. -.Ss Nx Ns Tn /macppc -Due to restrictions in -.Nm -and the secondary bootstrap implementation, file systems where kernels exist -must start at the beginning of disks. -.Pp -Currently, -.Nm -doesn't recognize an existing Apple partition map on the disk -and always writes a faked map to make disks bootable. -.Pp -The -.Nx Ns Tn /macppc -bootstrap program can't load kernels from -.Sy FFSv2 -partitions. -.Ss Nx Ns Tn /next68k -The size of bootstrap programs is restricted to the free space before -the file system at the beginning of the disk minus 8KB. -. -.Ss Nx Ns Tn /pmax -The -.Nx Ns Tn /pmax -secondary bootstrap program can only load kernels from file -systems starting at the beginning of disks. -.Pp -The size of primary bootstrap programs is restricted to 7.5KB, even -though some file systems (e.g., ISO 9660) are able to accommodate larger -ones. -. -.Ss Nx Ns Tn /sun2 and Nx Ns Tn /sun3 -The -.Nx Ns Tn /sun2 -and -.Nx Ns Tn /sun3 -secondary bootstrap program can only load kernels from file -systems starting at the beginning of disks. -. -.Ss Nx Ns Tn /vax -The -.Nx Ns Tn /vax -secondary bootstrap program can only load kernels from file systems -starting at the beginning of disks. -.Pp -The size of primary bootstrap programs is restricted to 7.5KB, even -though some file systems (e.g., ISO 9660) are able to accommodate larger -ones.