1. 程式人生 > >RISC-V 開發工具鏈使用手冊及引數說明

RISC-V 開發工具鏈使用手冊及引數說明

RISC-V Toolchain Conventions

This document is authored by: 
* Alex Bradbury [email protected].

Licensed under the Creative Commons Attribution 4.0 International License (CC-BY 4.0). The full license text is available at https://creativecommons.org/licenses/by/4.0/.

Aims

This effort aims to document the expected behaviour and command-line interface of RISC-V toolchains. In doing so, we can provide an avenue for members of the GNU and LLVM communities to collaborate on standardising and extending these conventions. A diverse range of RISC-V implementations and custom extensions will inevitably result in vendor-specific toolchains being created and distributed. By describing a clear preferred path for exposing vendor-specific 
extensions or modifications, we can try to increase the likelihood that these vendor toolchain distributions have a common interface and aren’t gratuitously different.

Status and roadmap

This document is a work-in-progress, and contains many sections that serve mainly to enumerate current gaps or oddities. The plan is to seek feedback and further develop the proposal with the help of the RISC-V community, then to seek input from the wider GCC and Clang developer communities for extensions or changes beyond the current set of command-line options supported by GCC.

See the issues list to discuss any of the problems or TODO items described in this document.

This document is currently targeted at toolchain implementers and developers, but over time we hope it will also become a useful reference for RISC-V toolchain users.

See also

Specifying the target ISA with -march

The compiler and assembler both accept the -march flag to specify the target ISA, e.g. “rv32imafd”. The abbreviation “g” can be used to represent the IMAFD base and extensions, e.g. -march=rv64g. A target -march which includes floating point instructions implies a hardfloat calling convention, but can be overridden using the -mabi flag (see the next section).

The ISA subset naming conventions are described in Chapter 22 of the RISC-V user-level ISA specification. However, tools do not currently follow this specification (no support for parsing version specifiers, input is case 
sensitive, …).

If the ‘C’ (compressed) instruction set extension is targeted, the compiler will generate compressed instructions where possible.

Issues for consideration

  • Whether riscv32 and riscv64 should be accepted as synonyms for rv32 and rv64.
  • Whether the -march string should be parsed case insensitively.
  • Exposing the ability to specify version numbers for a target extension.
  • Specifying non-standard extensions. The ISA specification suggests naming such as rv32gXfirstext_Xsecondext. In GCC or Clang it would be more conventional to give a string such as rv32g+firstext+secondext.
  • How to specify more fine-grained information about a target. e.g. an RV32I target that implements only M-mode and doesn’t support the rdcycle instruction, or an RV32IM target that doesn’t support the division instructions.
  • Whether ordering should be enforced on the ISA string (e.g. currently rv32imafd is accepted by GCC but rv32iamfd is not).

Specifying the target ABI with -mabi

RISC-V compilers support the following ABIs, which can be specified using -mabi:

  • ilp32: int, long, pointers are 32-bit. GPRs and the stack are used for parameter passing.
  • ilp32f: int, long, pointers are 32-bit. GPRs, 32-bit FPRs, and the stack are used for parameter passing.
  • ilp32d: int, long, pointers are 32-bit. GPRs, 64-bit FPRs and the stack are used for parameter passing.
  • lp64: long, pointers are 64-bit. GPRs and the the stack are used for parameter passing.
  • lp64f: long, pointers are 64-bit. GPRs, 32-bit FPRs, and the stack are used for parameter passing.
  • lp64d: long, pointers are 64-bit. GPRs, 64-bit FPRs, and the stack are used for parameter passing.

See the RISC-V ELF psABI for more information on these ABIs.

The default value for -mabi is system dependent. For cross-compilation, both-march and -mabi should be specified. An error will be produced for impossible combinations of -march and -mabi such as -march=rv32i and -mabi=ilp32f.

Issues for consideration

  • Should the -mabi string be parsed case insensitively?
  • How should the RV32E ABI be specified? ilp32e?

Specifying the target code model with -mcmodel

The target code model indicates constraints on symbols which the compiler can exploit these constraints to generate more efficient code. Two code models are currently defined for RISC-V:

  • -mcmodel=medlow. The program and its statically defined symbols must lie within a single 2GiB address range, between the absolute addresses -2GiB and +2GiB. lui and addi pairs are used to generate addresses.
  • -mcmodel=medany. The program and its statically defined symbols must lie within a single 4GiB address range. auipc and addi pairs are used to generate addresses.

TODO: interaction with PIC.

Issues for consideration

  • It has been proposed to deprecate the medlow code model and rename medany to medium.

Disassembler (objdump) behaviour

A RISC-V ELF binary is not currently self-describing, in the sense that it doesn’t contain enough information to determine which variant of the RISC-V architecture is being targeted. GNU objdump will currently attempt disassemble any instruction whose encoding matches one of the standard RV32/RV64 IMAFDC extensions.

objdump will default to showing pseudoinstructions and ABI register names. The numeric disassembler argument can be used to use architectural register names such as x10, while the no-aliases disassembler argument will ensure only canonical instructions rather than pseudoinstructions or aliases are printed. These arguments are specified using -M, e.g. -M numeric or -M numeric,no-aliases.

Perhaps surprisingly, the disassembler will default to hiding the difference between compressed (16-bit) instructions and their 32-bit equivalent. e.g.c.addi sp, -16 will be printed as addi sp, sp, -16.

Issues for consideration

  • The current GNU objdump behaviour will not provide useful results for cases where non-standard extensions are implemented which reuse some of the standard extension’s encoding space. Making RISC-V ELF files self-describing (as discussed here) would avoid this problem.
  • Would it be useful to have separate flags that control the printing of pseudoinstructions and whether compressed instructions are printed directly or not?

Assembler behaviour

See the RISC-V Assembly Programmer’s Manual for details on the syntax accepted by the assembler.

The assembler will produce compressed instructions whenever possible if the targeted RISC-V variant includes support for the ‘C’ compressed instruction set.

Issues for consideration

  • There is currently no way to enable support for the C ISA extension, but to disable the automatic ‘compression’ of instructions.

C/C++ preprocessor definitions

  • __riscv: defined for any RISC-V target. Older versions of the GCC toolchain defined __riscv__.
  • __riscv_xlen: 32 for RV32 and 64 for RV64.
  • __riscv_float_abi_soft__riscv_float_abi_single
    __riscv_float_abi_double: one of these three will be defined, depending on target ABI.
  • __riscv_cmodel_medlow__riscv_cmodel_medany: one of these two will be defined, depending on the target code model.
  • __riscv_mul: defined when targeting the ‘M’ ISA extension.
  • __riscv_muldiv: defined when targeting the ‘M’ ISA extension and -mno-div has not been used.
  • __riscv_div: defined when targeting the ‘M’ ISA extension and -mno-div has not been used.
  • __riscv_atomic: defined when targeting the ‘A’ ISA extension.
  • __riscv_flen: 32 when targeting the ‘F’ ISA extension (but not ‘D’) and 64 when targeting ‘FD’.
  • __riscv_fdiv: defined when targeting the ‘F’ or ‘D’ ISA extensions and -mno-fdiv has not been used.
  • __riscv_fsqrt: defined when targeting the ‘F’ or ‘D’ ISA extensions and -mno-fdiv has not been used.
  • __riscv_compressed: defined when targeting the ‘C’ ISA extension.

Issues for consideration

  • What should the naming convention be for defines that indicate support for non-standard extensions?
  • What additional information could/should be exposed via preprocessor defines?

Specifying stack alignment

The default stack alignment is 16 bytes in RV32I and RV64I, and 4 bytes on RV32E. There is not currently a way to specify an alternative stack alignment, but the -mpreferred-stack-boundary and -mincoming-stack-boundary flags supported by GCC on X86 could be adopted.

TODO

  • mdiv, mno-div, mfdiv, mno-fdiv, msave-restore, mno-save-restore, mstrict-align, mno-strict-align, -mexplicit-relocs, -mno-explicit-relocs

Appendix: Exposing a vendor-specific extension across the toolchain

TODO.

相關推薦

RISC-V 開發工具使用手冊引數說明

RISC-V Toolchain Conventions This document is authored by:  * Alex Bradbury [email protected]. Licensed under the Creative Comm

RISC-V 開發工具的使用

RISC-V Toolchain Conventions Copyright and license information This document is authored by: Licensed under the Creative Commons

開發工具--Eclipse使用常見問題解決

ack tor ogl data 都去 lib tom tar nbsp 怎麽查詢Eclipse版本號: 方法一: 方法二: Eclipse安裝目錄下面找到readme文件夾,裏邊有個網頁打開就可以看到當前版本; Eclipse漢化改為英文: Eclipse Mybat

基於RISC-V架構的開源處理器SoC研究綜述(二)

收錄 soc jxl gfs ldl ddx dtb ref ssl 5f吮撼墻l3窘簿夢l1承凸幹http://byzzjf.wikidot.com/zv壕握久v3毀誌喲7n霞煞已http://byzdsbbb.wikidot.com/4e諶蕉副2w奔略盜oe晌堵閡htt

初學C++——VS2013開發工具包下載破解

一、C++——VS2013開發工具包下載及破解 1、VS2013開發工具包下載連結(迅雷): ed2k://|file|cn_visual_studio_ultimate_2013_with_update_5_x86_dvd_6816649.iso|5567336448|

蜂鳥E203開源RISC-V開發板:蜂鳥FPGA開發板和JTAG偵錯程式介紹

隨著國內第一本RISC-V中文書籍《手把手教你設計CPU——RISC-V處理器篇》正式上市,越來越多的愛好者開始使用開源的蜂鳥E203 RISC-V處理核,很多初學者留言詢問有關RISC-V工具鏈使用的問題。 為了便於初學者能夠快速地學習RISC-V C

在Ubuntu 18.04 LTS構建RISC-V開發環境(SiFive E310開發環境建立)

早先的RISC-V環境是在Ubuntu 16.04上建立的,針對新的Ubuntu 18.04 LTS的釋出,我嘗試將原先的RISC-V的全部環境遷移到新的版本上,遇到了一些問題,如無法生成Verilog

基於RISC-V架構的開源處理器SoC研究綜述(三)

3 基於RISC-V的開源SoC研究現狀 3.1 Rocket-Chip   UCB為了方便使用者學習,同時也為了便於重複使用已設計好的硬體模組,在GitHub上建立了Rocket-Chip Generator的專案,其中包括了Chisel、GCC、Rocket處理器,以及

Hifive1(RISC-V)開發板在Arduino IDE中的配置方法

                                                   . 作業系統: 建議使用Ubuntu 16.04 LTS,據說這是設計Hifive1開發板的公司SiIive使用的作業系統版本。可以使用安裝在虛擬機器上Ubuntu。Sifi

【兆易創新RISC-V開發板評測】01.乾貨分享

  背景介紹:2019年12月19日在面板包偶然發可以免費申請測評GD32VF103開發板,欣喜萬分;在這之前各大技術論壇說是已經有國產兆易創新的RISCV指令集的MCU釋出的事情,一時間摩拳擦掌想購入一塊開發板回來,體驗一下我天朝自己產的MCU和外國貨的區別,期盼國產自強的那一天,不為別的只為看技術文件的時

微信小程式入門從這裡出發(登入註冊、開發工具、檔案結構介紹)

![](http://image.ideal-20.cn/weixin-mini/19-01-01-000.png) # (一) 準備工作 ## (1) 登入註冊 - 註冊賬號:這就不談了,只需要注意使用一個全新的郵箱,別之前註冊過公眾號小程式等就可以了 - `https://mp.weixin.q

以太坊智慧合約學習筆記:開發流程工具使用

本文主要介紹開發流程和工具鏈的使用,安裝過程百度上有好多,這裡就不贅述了 網上隨便找了一個智慧合約的例子,咱們來做一個投票系統,先用傳統的中心化方案去實現,然後在過度到區塊鏈1.0,最後再用區塊鏈2.0,感受一下開發思想的不同。 業務分析 傳統

最全面的Java字節byte操作,處理Java基本數據的轉換進制轉換操作工具,流媒體java底層開發項目常用工具

進制 string 常用工具類 cat i++ logs 指定位置 tput off 前言:用於處理Java基本數據的轉換及進制轉換操作工具 一、實現功能 1、int預byte互轉 2、int與byte[]互轉 3、short與byte互轉 4、short與byte[]互轉

JAVAEE開發工具環境配置過程

www system 環境 aries 文件 clip ppi env app 軟件152 盧仁順 一、準備開發環境 1. 安裝Tomcat 這裏使用Apache Tomcat作為Web容器,下載網址: http://tomcat.apache.org/download-7

c語言循環打印問題之A-FVC6++斷點開發工具的使用

images span 遞歸調用 for循環 開發 開發工具 ron pan def 1. 利用for循環輸出 ABCDEF 6個 1->6BCDEF 5個 2->6CDEF 4個 3->6DEF 3個 4->6EF

前端開發工具Brackets介紹,安裝安裝Emme插件時踩過的坑

module 文件 不想 現在 div 當前 user 沒有 -s   對於前端開發的園友來說有可能IDE工具有很多,層次不窮,還有每個人的喜好及習慣也不一樣,因為我是一名後端開發的.Net程序員,但是大家都知道,現在都提倡什麽全棧工程師,所以也得會點前端開發,所以我對於

區塊技術開發導向 聊應用正確發展方向

區塊鏈技術 process watermark 區塊鏈技術開發 p s mar 一次 image 自身 技術探索總能帶來一些新的商業發展思路,伴隨區塊鏈技術開發的逐年深入,不少企業都紛紛將目光聚焦到區塊鏈領域。雖然多數人試圖通過新技術實現企業轉型來謀求未來市場,也有部分投機

以太坊:Dapp相關開發工具介紹

去中心化應用 去中心化應用是可以使使用者和供應商之間直接互動的服務(例如,連線某些市場上的買方和賣方,檔案儲存裡的持有者和儲存者)。以太坊去中心化應用典型地通過HTML/Javascript網路應用與使用者互動,使用Javascript API與區塊鏈通訊。去中心化應用典型地在區塊

linuxC語言開發環境問題開發工具介紹

  1.VIM實踐  程式碼補全功能太難用了,不如VC,安裝了一堆的 VIM 外掛,可是還是那麼難用,命令倒還好,不過真的是不好用,格式自動對齊,亮度顯示都能實現,但是出錯檢查 啊,括號自動匹配啊,單詞補全功能啊,都不滿意,另外對C++的支援不好

RISC-V嵌入式開發準備篇1:編譯過程簡介

原文出處:https://mp.weixin.qq.com/s/-syKN0DibKGGPCllaeNqMg 隨著國內第一本RISC-V中文書籍《手把手教你設計CPU——RISC-V處理器篇》 正式上市,越來越多的愛好者開始使用開源的蜂鳥E203 RISC-V處理核,很多初學者留