Skip to content
This repository has been archived by the owner on Apr 11, 2024. It is now read-only.

Commit

Permalink
Fix toolchain conventions and psABI document.
Browse files Browse the repository at this point in the history
  • Loading branch information
scylaac committed Nov 4, 2021
1 parent 19e3e88 commit f8952d6
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 76 deletions.
40 changes: 16 additions & 24 deletions docs/LoongArch-ELF-ABI-CN.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ v1.00

== C 语言数据类型规格

.lp64 数据模型 (对应基础 ABI 类型:`lp64d` `lp64f` `lp64s`)
.LP64 数据模型 (对应基础 ABI 类型:`lp64d` `lp64f` `lp64s`)
[%header,cols="3,^1,^1"]
|===
|标量类型
Expand Down Expand Up @@ -139,7 +139,7 @@ v1.00
|8
|===

.ilp32 数据模型 (对应基础 ABI 类型:`ilp32d` `ilp32f` `ilp32s`)
.ILP32 数据模型 (对应基础 ABI 类型:`ilp32d` `ilp32f` `ilp32s`)
[%header,cols="3,^1,^1"]
|===
|标量类型
Expand Down Expand Up @@ -226,32 +226,32 @@ v1.00
|lp64d
|`0x3`
|使用 64 位通用寄存器,64位浮点寄存器和栈传参,
数据模型为 "lp64"(`long` 和指针类型宽度为64位,`int` 为32位)
数据模型为 LP64(`long` 和指针类型宽度为64位,`int` 为32位)

|lp64f
|`0x2`
|使用 64 位通用寄存器,32位浮点寄存器和栈传参,
数据模型为 "lp64"(`long` 和指针类型宽度为64位,`int` 为32位)
数据模型为 LP64(`long` 和指针类型宽度为64位,`int` 为32位)

|lp64s
|`0x1`
|使用 64 位通用寄存器和栈传参,
数据模型为 "lp64"(`long` 和指针类型宽度为64位,`int` 为32位)
数据模型为 LP64(`long` 和指针类型宽度为64位,`int` 为32位)

|ilp32d
|`0x7`
|使用 32 位通用寄存器,64位浮点寄存器和栈传参,
数据模型为 "ilp32"(`int`,`long` 和指针类型宽度为32位)
数据模型为 ILP32(`int`,`long` 和指针类型宽度为32位)

|ilp32f
|`0x6`
|使用 32 位通用寄存器,32位浮点寄存器和栈传参,
数据模型为 "ilp32"(`int`,`long` 和指针类型宽度为32位)
数据模型为 ILP32(`int`,`long` 和指针类型宽度为32位)

|ilp32s
|`0x5`
|使用 32 位通用寄存器和栈传参,
数据模型为 "ilp32"(`int`,`long` 和指针类型宽度为32位)
数据模型为 ILP32(`int`,`long` 和指针类型宽度为32位)

|
|`0x4` `0x0`
Expand All @@ -275,31 +275,26 @@ v1.00
|===

[[abi-versioning]]
`e_flags[7:6]` 标记了 ELF 目标文件使用的 ABI 版本,
它和动态链接器标准文件名 (`ld-*.so`) 的版本后缀一一对应。
`e_flags[7:6]` 标记了 ELF 目标文件使用的 ABI 版本。

.ABI 版本标记
[%header,cols="2,^1,^5,^1"]
[%header,cols="2,^1,^5"]
|===
|ABI 版本
|枚举值
|描述
|动态链接器版本后缀

|`v0`
|`0x0`
|支持具有栈操作语义的重定位类型
|`.0`

|`v1`
|`0x1`
|按需保留
|`.1`

|
|`0x2` `0x3`
|保留值
|`.2` `.3`
|===


Expand Down Expand Up @@ -610,28 +605,25 @@ v1.00

|lp64d |default
|Linux, Glibc
|/lib64/ld-linux-loongarch-lp64d.so.<abiversion>
|/lib64/ld-linux-loongarch-lp64d.so.1

|lp64f |default
|Linux, Glibc
|/lib64/ld-linux-loongarch-lp64f.so.<abiversion>
|/lib64/ld-linux-loongarch-lp64f.so.1

|lp64s |default
|Linux, Glibc
|/lib64/ld-linux-loongarch-lp64s.so.<abiversion>
|/lib64/ld-linux-loongarch-lp64s.so.1

|ilp32d |default
|Linux, Glibc
|/lib32/ld-linux-loongarch-ilp32d.so.<abiversion>
|/lib32/ld-linux-loongarch-ilp32d.so.1

|ilp32f |default
|Linux, Glibc
|/lib32/ld-linux-loongarch-ilp32f.so.<abiversion>
|/lib32/ld-linux-loongarch-ilp32f.so.1

|ilp32s |default
|Linux, Glibc
|/lib32/ld-linux-loongarch-ilp32s.so.<abiversion>
|/lib32/ld-linux-loongarch-ilp32s.so.1
|===

表中 `<abiversion>` 与 ELF文件编码的 `e_flags[7:6]` 一一对应,
参见 <<abi-versioning, ABI 版本>> 。
41 changes: 16 additions & 25 deletions docs/LoongArch-ELF-ABI-EN.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ Static registers are also known as callee-saved registers.

== Type Size and Alignment

.lp64 Data Model (base ABI types: `lp64d` `lp64f` `lp64s`)
.LP64 Data Model (base ABI types: `lp64d` `lp64f` `lp64s`)
[%header,cols="3,^1,^1"]
|===
|Scalar type
Expand Down Expand Up @@ -138,7 +138,7 @@ Static registers are also known as callee-saved registers.
|8
|===

.ilp32 Data Model (base ABI types: `ilp32d` `ilp32f` `ilp32s`)
.ILP32 Data Model (base ABI types: `ilp32d` `ilp32f` `ilp32s`)
[%header,cols="3,^1,^1"]
|===
|Scalar type
Expand Down Expand Up @@ -223,32 +223,32 @@ The ABI type of an ELF object is uniquely identified by `e_flags[7:0]` in its he
|lp64d
|`0x3`
|Uses 64-bit GPRs, 64-bit FPRs and the stack for parameter passing.
Data model is "lp64", where `long` and pointers are 64-bit while `int` is 32-bit.
Data model is LP64, where `long` and pointers are 64-bit while `int` is 32-bit.

|lp64f
|`0x2`
|Uses 64-bit GPRs, 32-bit FPRs and the stack for parameter passing.
Data model is "lp64", where `long` and pointers are 64-bit while `int` is 32-bit.
Data model is LP64, where `long` and pointers are 64-bit while `int` is 32-bit.

|lp64s
|`0x1`
|Uses 64-bit GPRs and the stack for parameter passing.
Data model is "lp64", where `long` and pointers are 64-bit while `int` is 32-bit.
Data model is LP64, where `long` and pointers are 64-bit while `int` is 32-bit.

|ilp32d
|`0x7`
|Uses 32-bit GPRs, 64-bit FPRs and the stack for parameter passing.
Data model is "ilp32", where `int`, `long` and pointers are 32-bit.
Data model is ILP32, where `int`, `long` and pointers are 32-bit.

|ilp32f
|`0x6`
|Uses 32-bit GPRs, 32-bit FPRs and the stack for parameter passing.
Data model is "ilp32", where `int`, `long` and pointers are 32-bit.
Data model is ILP32, where `int`, `long` and pointers are 32-bit.

|ilp32s
|`0x5`
|Uses 32-bit GPRs and the stack for parameter passing.
Data model is "ilp32", where `int`, `long` and pointers are 32-bit.
Data model is ILP32, where `int`, `long` and pointers are 32-bit.

|
|`0x4` `0x0`
Expand All @@ -272,32 +272,26 @@ Data model is "ilp32", where `int`, `long` and pointers are 32-bit.
|===

[[abi-versioning]]
`e_flags[7:6]` marks the ABI version of an ELF object,
it also corresponds to the version suffix of standard
program interpreters (`ld-*.so`).
`e_flags[7:6]` marks the ABI version of an ELF object.

.ABI Version
[%header,cols="2,^1,^5,^1"]
[%header,cols="2,^1,^5"]
|===
|ABI version
|Value
|Description
|Suffix of program interpreter filenames

|`v0`
|`0x0`
|Stack operands base relocation type.
|`.0`

|`v1`
|`0x1`
|Another relocation type IF needed.
|`.1`

|
|`0x2` `0x3`
|Reserved.
|`.2` `.3`
|===


Expand Down Expand Up @@ -608,28 +602,25 @@ with check 32-bit unsigned overflow

|lp64d |default
|Linux, Glibc
|/lib64/ld-linux-loongarch-lp64d.so.<abiversion>
|/lib64/ld-linux-loongarch-lp64d.so.1

|lp64f |default
|Linux, Glibc
|/lib64/ld-linux-loongarch-lp64f.so.<abiversion>
|/lib64/ld-linux-loongarch-lp64f.so.1

|lp64s |default
|Linux, Glibc
|/lib64/ld-linux-loongarch-lp64s.so.<abiversion>
|/lib64/ld-linux-loongarch-lp64s.so.1

|ilp64d |default
|Linux, Glibc
|/lib32/ld-linux-loongarch-ilp32d.so.<abiversion>
|/lib32/ld-linux-loongarch-ilp32d.so.1

|ilp64f |default
|Linux, Glibc
|/lib32/ld-linux-loongarch-ilp32f.so.<abiversion>
|/lib32/ld-linux-loongarch-ilp32f.so.1

|ilp64s |default
|Linux, Glibc
|/lib32/ld-linux-loongarch-ilp32s.so.<abiversion>
|/lib32/ld-linux-loongarch-ilp32s.so.1
|===

Note: Each ABI version listed in <<abi-versioning, ABI versions>> corresponds
to a unique `<abiversion>`.
27 changes: 14 additions & 13 deletions docs/LoongArch-toolchain-conventions-CN.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ v1.00
:docinfodir: ../themes
:docinfo: shared
:doctype: book
:imagesdir: ../images
:toc: left
:toc-title: 目录
:scripts: cjk
Expand Down Expand Up @@ -167,12 +168,12 @@ v1.00 定义的指令集架构
[%header,cols="^1,^1,^1"]
|===
|标准名称 |数据模型 |可用于传参、返回的通用/浮点寄存器宽度
|`lp64d` |lp64 |64 / 64
|`lp64f` |lp64 |64 / 32
|`lp64s` |lp64 |64 / (无)
|`ilp32d` |ilp32 |32 / 64
|`ilp32f` |ilp32 |32 / 32
|`ilp32s` |ilp32 |32 / (无)
|`lp64d` |LP64 |64 / 64
|`lp64f` |LP64 |64 / 32
|`lp64s` |LP64 |64 / (无)
|`ilp32d` |ILP32 |32 / 64
|`ilp32f` |ILP32 |32 / 32
|`ilp32s` |ILP32 |32 / (无)
|===

下表列举了全体 ABI 扩展特性类型及其相关命令行选项,除 `default` 必须实现之外,
Expand All @@ -199,7 +200,7 @@ v1.00 定义的指令集架构

原则上,实际配置的目标架构不应该对目标 ABI 的确定造成影响,
除非构建时配置或命令行选项对 ABI 的约束导致实现它所需的指令集特性
超出了编译选项对 ISA 配置的约束范围。此时编译器应报错退出
超出了编译选项对 ISA 配置的约束范围。此时编译器可选择报错退出

当编译选项不能唯一确定目标架构时,
在选择默认值之前,编译器应根据下表,从命令行显式给出的 ABI 配置
Expand Down Expand Up @@ -277,7 +278,7 @@ v1.00 定义的指令集架构
|`<fabi_suffix>` 字符串 |含义
|`f64` |基础 ABI 使用 64 位浮点寄存器传参 (`lp64d` `ilp32d`)
|`f32` |基础 ABI 使用 32 位浮点寄存器传参 (`lp64f` `ilp32f`)
|`sfp` |基础 ABI 不使用浮点寄存器传参 (`lp64s` `ilp32s`)
|`sf` |基础 ABI 不使用浮点寄存器传参 (`lp64s` `ilp32s`)
|===

.Multiarch `os` 字段,`<abiext_suffix>` 后缀标记及其对应的 ABI 扩展特性
Expand All @@ -304,7 +305,7 @@ v1.00 定义的指令集架构

|`lp64s` / `default`
|GNU/Linux
|`loongarch64-linux-gnusfp`
|`loongarch64-linux-gnusf`

|`ilp32d` / `default`
|GNU/Linux
Expand All @@ -316,7 +317,7 @@ v1.00 定义的指令集架构

|`ilp32s` / `default`
|GNU/Linux
|`loongarch32-linux-gnusfp`
|`loongarch32-linux-gnusf`
|===


Expand All @@ -343,15 +344,15 @@ v1.00 定义的指令集架构

|`_LOONGARCH_ARCH`
|`"loongarch64"` `"la464"`
|相当于 `--with-arch` / `-march` 指定的目标 CPU 名称
|`-march` 指定的目标 CPU 名称,若未指定则为默认值

|`_LOONGARCH_TUNE`
|`"loongarch64"` `"la464"`
|相当于 `-mtune` 指定的目标 CPU 名称
|`-mtune` 指定的目标 CPU 名称,若未指定则为默认值

|`__loongarch_lp64`
|(无)
|ABI 使用 64 位通用寄存器传参,采用 `lp64` 数据模型
|ABI 使用 64 位通用寄存器传参,采用 LP64 数据模型

|`__loongarch_hard_float`
|(无)
Expand Down
Loading

0 comments on commit f8952d6

Please sign in to comment.