gccのソースにハードコード化されているのか、何らかの形でプログラマチックにフェッチされていますか?gccは特定のプラットフォーム上の各タイプの配置をどのように取得しますか?
3
A
答えて
5
アーチ専用のフォルダにハードコードされていると思います。 http://www.google.com/codesearch#Yj7Hz1ZInUg/trunk/gcc-4.2.1/gcc/config/sparc/sparc.h
SPARC
/* No data type wants to be aligned rounder than this. */
#define BIGGEST_ALIGNMENT (TARGET_ARCH64 ? 128 : 64)
/* The best alignment to use in cases where we have a choice. */
#define FASTEST_ALIGNMENT 64
...
/* Make strings word-aligned so strcpy from constants will be faster. */
#define CONSTANT_ALIGNMENT(EXP, ALIGN) \
((TREE_CODE (EXP) == STRING_CST \
&& (ALIGN) < FASTEST_ALIGNMENT) \
? FASTEST_ALIGNMENT : (ALIGN))
/* Make arrays of chars word-aligned for the same reasons. */
#define DATA_ALIGNMENT(TYPE, ALIGN) \
(TREE_CODE (TYPE) == ARRAY_TYPE \
&& TYPE_MODE (TREE_TYPE (TYPE)) == QImode \
&& (ALIGN) < FASTEST_ALIGNMENT ? FASTEST_ALIGNMENT : (ALIGN))
と同じフォルダにsparc.cため。
いくつかの基本的な配置ルールは、gcc/tree.cで定義されています。 voidの場合:
/* We are not going to have real types in C with less than byte alignment,
so we might as well not have any types that claim to have it. */
TYPE_ALIGN (void_type_node) = BITS_PER_UNIT;
TYPE_USER_ALIGN (void_type_node) = 0;
ビルドプロセスでgccにコンパイルされます。
したがって、デフォルトのアライメントはコンパイルされますが、gccコードからTREEタイプのオブジェクトを操作することで変更できます。
UPDATE:アーム、MIPS、SPARCについて
/* Minimum size in bits of the largest boundary to which any
and all fundamental data types supported by the hardware
might need to be aligned. No data type wants to be aligned
rounder than this.
Pentium+ prefers DFmode values to be aligned to 64 bit boundary
and Pentium Pro XFmode values at 128 bit boundaries. */
#define BIGGEST_ALIGNMENT 128
/* Decide whether a variable of mode MODE should be 128 bit aligned. */
#define ALIGN_MODE_128(MODE) \
((MODE) == XFmode || SSE_REG_MODE_P (MODE))
/* The published ABIs say that doubles should be aligned on word
boundaries, so lower the alignment for structure fields unless
-malign-double is set. */
/* ??? Blah -- this macro is used directly by libobjc. Since it
supports no vector modes, cut out the complexity and fall back
on BIGGEST_FIELD_ALIGNMENT. */
...
#define BIGGEST_FIELD_ALIGNMENT 32
...
/* If defined, a C expression to compute the alignment given to a
constant that is being placed in memory. EXP 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) ix86_constant_alignment ((EXP), (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. */
#define DATA_ALIGNMENT(TYPE, ALIGN) ix86_data_alignment ((TYPE), (ALIGN))
/* If defined, a C expression to compute the alignment for a local
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. */
#define LOCAL_ALIGNMENT(TYPE, ALIGN) ix86_local_alignment ((TYPE), (ALIGN))
...
/* Set this nonzero if move instructions will actually fail to work
when given unaligned data. */
#define STRICT_ALIGNMENT 0
、アライメントはアーチに記録することができる任意のマシン命令の必要(メモリへの非整列アクセスを制限する)他のarchsを:x86の設定ファイルは、より良いコメントを有します。 (例えば、sparc.md)
関連する問題
- 1. どのようにページ上の特定の位置にスクロールしますか?
- 2. 各サブ配列から特定の要素を取得する
- 3. スクロールビューの各要素の上にラベルを配置しますか?
- 4. 特定のリビジョンのコミットメッセージとファイルリストをどのように取得しますか?
- 5. gcc/cygwinはどのようにDNSサーバを取得しますか?
- 6. CSS:この特定の要素をページ上で水平にどのように配置するのですか?
- 7. 特定のタイプのCimInstanceプロパティを取得するにはどうすればよいですか?
- 8. 特定のタイプを知らずにジェネリックインターフェイスを取得するにはどうすればよいですか?
- 9. C#フォームの特定の位置にコントロールを取得します。
- 10. コードから位置を取得している他のビューの下にどのように配置するか
- 11. ウェブページの特定の位置に画像を配置するにはどうすればよいですか?
- 12. どのように特定のタグを取得できますか?
- 13. 特定の位置のカスタムリストビューでビューを取得するにはどうすればよいですか?アンドロイド?
- 14. どのようにExcelを自動化するときに特定のセルにテキストボックスオブジェクトを配置しますか?
- 15. どのように各画像ビューにTextviewを配置するのですか?
- 16. [Float]などの特定の配列タイプを拡張するにはどうすればよいですか?
- 17. データベース上の特定のテーブルをどのようにエコーしますか?
- 18. コレクションの各属性の「タイプ」を取得するにはどうすればよいですか?
- 19. 特定のメモリ位置から構造体を取得するにはどうすればよいですか?
- 20. Solrインデックスの各タイプの上位X結果を取得するには
- 21. GCCコードの手動再配置を指定するにはどうすればよいですか?
- 22. WikiData、特定のタイプまたはサブタイプのエンティティを特定の都市に配置する
- 23. 配列にajaxレスポンスを取得し、その配列に特定の値があるかどうかをチェック
- 24. どのようにミディノートの位置を取得するには?
- 25. Web配置プロジェクトを使用するにはどのようにWeb configトランスフォームを取得しますか?
- 26. 特定のアダプタ位置でRecyclerViewからビューを取得し、それらのビューから値を取得するにはどうすればよいですか?
- 27. 特定のタイプの親コンテナから子を取得する
- 28. カスタムクラスから特定のタイプのプロパティを取得する
- 29. 特定のインデックスに配列を配置するにはどうすればよいですか?
- 30. gccの-pgフラグはどのように機能しますか?
"何とかそれをフェッチする"ために、a)クロスコンパイルでは機能しません。b)いくつかのアーキテクチャではクラッシュします。 – Damon