Share via


ARM 內建函式

Microsoft C++ 編譯程式 (MSVC) 可在 ARM 架構上使用下列內部函數。 如需 ARM 的詳細資訊,請參閱 ARM 開發人員文件網站的架構和軟體開發工具章節

霓虹燈

ARM 的 NEON 向量指令集延伸模組提供與 x86 和 x64 架構處理器通用之 MMX 和 SSE 向量指令集中的單一指令多重數據 (SIMD) 功能。

支援 NEON 內建函式,並提供於標頭檔 arm_neon.h 中。 NEON 內部函數的 MSVC 支援類似於 ARM 編譯程式,如 ARM Infocenter 網站上的 ARM 編譯程式工具鏈附錄 G 中所述。

MSVC 與 ARM 編譯程式之間的主要差異在於 MSVC 會新增 _exvstX 向量載入的vldX變體,並儲存指示。 _ex 變異採取額外的參數,以指定指標引數的對齊,除此之外,與非 _ex 對應項目均相同。

ARM 特定的內部函數清單

函數名稱 指示 函式原型
_arm_smlal SMLAL __int64 _arm_smlal(__int64 _RdHiLo,int _Rn,int _Rm)
_arm_umlal UMLAL unsigned __int64 _arm_umlal(unsigned __int64 _RdHiLo、unsigned int _Rn、unsigned int _Rm)
_arm_clz CLZ unsigned int _arm_clz(unsigned int _Rm)
_arm_qadd QADD int _arm_qadd(int _Rm, int _Rn)
_arm_qdadd QDADD int _arm_qdadd(int _Rm, int _Rn)
_arm_qdsub QDSUB int _arm_qdsub(int _Rm, int _Rn)
_arm_qsub QSUB int _arm_qsub(int _Rm, int _Rn)
_arm_smlabb SMLABB int _arm_smlabb(int _Rn, int _Rm, int _Ra)
_arm_smlabt SMLABT int _arm_smlabt(int _Rn, int _Rm, int _Ra)
_arm_smlatb SMLATB int _arm_smlatb(int _Rn, int _Rm, int _Ra)
_arm_smlatt SMLATT int _arm_smlatt(int _Rn, int _Rm, int _Ra)
_arm_smlalbb SMLALBB __int64 _arm_smlalbb(__int64 _RdHiLo,int _Rn,int _Rm)
_arm_smlalbt SMLALBT __int64 _arm_smlalbt(__int64 _RdHiLo,int _Rn,int _Rm)
_arm_smlaltb SMLALTB __int64 _arm_smlaltb(__int64 _RdHiLo,int _Rn,int _Rm)
_arm_smlaltt SMLALTT __int64 _arm_smlaltt(__int64 _RdHiLo,int _Rn,int _Rm)
_arm_smlawb SMLAWB int _arm_smlawb(int _Rn, int _Rm, int _Ra)
_arm_smlawt SMLAWT int _arm_smlawt(int _Rn, int _Rm, int _Ra)
_arm_smulbb SMULBB int _arm_smulbb(int _Rn, int _Rm)
_arm_smulbt SMULBT int _arm_smulbt(int _Rn, int _Rm)
_arm_smultb SMULTB int _arm_smultb(int _Rn, int _Rm)
_arm_smultt SMULTT int _arm_smultt(int _Rn, int _Rm)
_arm_smulwb SMULWB int _arm_smulwb(int _Rn, int _Rm)
_arm_smulwt SMULWT int _arm_smulwt(int _Rn, int _Rm)
_arm_sadd16 SADD16 int _arm_sadd16(int _Rn, int _Rm)
_arm_sadd8 SADD8 int _arm_sadd8(int _Rn, int _Rm)
_arm_sasx SASX int _arm_sasx(int _Rn, int _Rm)
_arm_ssax SSAX int _arm_ssax(int _Rn, int _Rm)
_arm_ssub16 SSUB16 int _arm_ssub16(int _Rn, int _Rm)
_arm_ssub8 SSUB8 int _arm_ssub8(int _Rn, int _Rm)
_arm_shadd16 SHADD16 int _arm_shadd16(int _Rn, int _Rm)
_arm_shadd8 SHADD8 int _arm_shadd8(int _Rn, int _Rm)
_arm_shasx SHASX int _arm_shasx(int _Rn, int _Rm)
_arm_shsax SHSAX int _arm_shsax(int _Rn, int _Rm)
_arm_shsub16 SHSUB16 int _arm_shsub16(int _Rn, int _Rm)
_arm_shsub8 SHSUB8 int _arm_shsub8(int _Rn, int _Rm)
_arm_qadd16 QADD16 int _arm_qadd16(int _Rn, int _Rm)
_arm_qadd8 QADD8 int _arm_qadd8(int _Rn, int _Rm)
_arm_qasx QASX int _arm_qasx(int _Rn, int _Rm)
_arm_qsax QSAX int _arm_qsax(int _Rn, int _Rm)
_arm_qsub16 QSUB16 int _arm_qsub16(int _Rn, int _Rm)
_arm_qsub8 QSUB8 int _arm_qsub8(int _Rn, int _Rm)
_arm_uadd16 UADD16 unsigned int _arm_uadd16(unsigned int _Rn, unsigned int _Rm)
_arm_uadd8 UADD8 unsigned int _arm_uadd8(unsigned int _Rn, unsigned int _Rm)
_arm_uasx UASX unsigned int _arm_uasx(unsigned int _Rn, unsigned int _Rm)
_arm_usax USAX unsigned int _arm_usax(unsigned int _Rn, unsigned int _Rm)
_arm_usub16 USUB16 unsigned int _arm_usub16(unsigned int _Rn, unsigned int _Rm)
_arm_usub8 USUB8 unsigned int _arm_usub8(unsigned int _Rn, unsigned int _Rm)
_arm_uhadd16 UHADD16 unsigned int _arm_uhadd16(unsigned int _Rn, unsigned int _Rm)
_arm_uhadd8 UHADD8 unsigned int _arm_uhadd8(unsigned int _Rn, unsigned int _Rm)
_arm_uhasx UHASX unsigned int _arm_uhasx(unsigned int _Rn, unsigned int _Rm)
_arm_uhsax UHSAX unsigned int _arm_uhsax(unsigned int _Rn, unsigned int _Rm)
_arm_uhsub16 UHSUB16 unsigned int _arm_uhsub16(unsigned int _Rn, unsigned int _Rm)
_arm_uhsub8 UHSUB8 unsigned int _arm_uhsub8(unsigned int _Rn, unsigned int _Rm)
_arm_uqadd16 UQADD16 unsigned int _arm_uqadd16(unsigned int _Rn, unsigned int _Rm)
_arm_uqadd8 UQADD8 unsigned int _arm_uqadd8(unsigned int _Rn, unsigned int _Rm)
_arm_uqasx UQASX unsigned int _arm_uqasx(unsigned int _Rn, unsigned int _Rm)
_arm_uqsax UQSAX unsigned int _arm_uqsax(unsigned int _Rn, unsigned int _Rm)
_arm_uqsub16 UQSUB16 unsigned int _arm_uqsub16(unsigned int _Rn, unsigned int _Rm)
_arm_uqsub8 UQSUB8 unsigned int _arm_uqsub8(unsigned int _Rn, unsigned int _Rm)
_arm_sxtab SXTAB int _arm_sxtab(int _Rn, int _Rm, unsigned int _Rotation)
_arm_sxtab16 SXTAB16 int _arm_sxtab16(int _Rn, int _Rm, unsigned int _Rotation)
_arm_sxtah SXTAH int _arm_sxtah(int _Rn, int _Rm, unsigned int _Rotation)
_arm_uxtab UXTAB unsigned int _arm_uxtab(unsigned int _Rn, unsigned int _Rm, unsigned int _Rotation)
_arm_uxtab16 UXTAB16 unsigned int _arm_uxta16b(unsigned int _Rn, unsigned int _Rm, unsigned int _Rotation)
_arm_uxtah UXTAH unsigned int _arm_uxtah(unsigned int _Rn, unsigned int _Rm, unsigned int _Rotation)
_arm_sxtb SXTB int _arm_sxtb(int _Rn, unsigned int _Rotation)
_arm_sxtb16 SXTB16 int _arm_sxtb16(int _Rn, unsigned int _Rotation)
_arm_sxth SXTH int _arm_sxth(int _Rn, unsigned int _Rotation)
_arm_uxtb UXTB unsigned int _arm_uxtb(unsigned int _Rn, unsigned int _Rotation)
_arm_uxtb16 UXTB16 unsigned int _arm_uxtb16(unsigned int _Rn, unsigned int _Rotation)
_arm_uxth UXTH unsigned int _arm_uxth(unsigned int _Rn, unsigned int _Rotation)
_arm_pkhbt PKHBT int _arm_pkhbt(int _Rn, int _Rm, unsigned int _Lsl_imm)
_arm_pkhtb PKHTB int _arm_pkhtb(int _Rn, int _Rm, unsigned int _Asr_imm)
_arm_usad8 USAD8 unsigned int _arm_usad8(unsigned int _Rn, unsigned int _Rm)
_arm_usada8 USADA8 unsigned int _arm_usada8(unsigned int _Rn, unsigned int _Rm, unsigned int _Ra)
_arm_ssat SSAT int _arm_ssat(unsigned int _Sat_imm, _int _Rn, _ARMINTR_SHIFT_T _Shift_type, unsigned int _Shift_imm)
_arm_usat USAT int _arm_usat(unsigned int _Sat_imm, _int _Rn, _ARMINTR_SHIFT_T _Shift_type, unsigned int _Shift_imm)
_arm_ssat16 SSAT16 int _arm_ssat16(unsigned int _Sat_imm, _int _Rn)
_arm_usat16 USAT16 int _arm_usat16(unsigned int _Sat_imm, _int _Rn)
_arm_rev REV unsigned int _arm_rev(unsigned int _Rm)
_arm_rev16 REV16 unsigned int _arm_rev16(unsigned int _Rm)
_arm_revsh REVSH unsigned int _arm_revsh(unsigned int _Rm)
_arm_smlad SMLAD int _arm_smlad(int _Rn, int _Rm, int _Ra)
_arm_smladx SMLADX int _arm_smladx(int _Rn, int _Rm, int _Ra)
_arm_smlsd SMLSD int _arm_smlsd(int _Rn, int _Rm, int _Ra)
_arm_smlsdx SMLSDX int _arm_smlsdx(int _Rn, int _Rm, int _Ra)
_arm_smmla SMMLA int _arm_smmla(int _Rn, int _Rm, int _Ra)
_arm_smmlar SMMLAR int _arm_smmlar(int _Rn, int _Rm, int _Ra)
_arm_smmls SMMLS int _arm_smmls(int _Rn, int _Rm, int _Ra)
_arm_smmlsr SMMLSR int _arm_smmlsr(int _Rn, int _Rm, int _Ra)
_arm_smmul SMMUL int _arm_smmul(int _Rn, int _Rm)
_arm_smmulr SMMULR int _arm_smmulr(int _Rn, int _Rm)
_arm_smlald SMLALD __int64 _arm_smlald(__int64 _RdHiLo,int _Rn,int _Rm)
_arm_smlaldx SMLALDX __int64 _arm_smlaldx(__int64 _RdHiLo,int _Rn,int _Rm)
_arm_smlsld SMLSLD __int64 _arm_smlsld(__int64 _RdHiLo,int _Rn,int _Rm)
_arm_smlsldx SMLSLDX __int64 _arm_smlsldx(__int64 _RdHiLo,int _Rn,int _Rm)
_arm_smuad SMUAD int _arm_smuad(int _Rn, int _Rm)
_arm_smuadx SMUADX int _arm_muadxs(int _Rn, int _Rm)
_arm_smusd SMUSD int _arm_smusd(int _Rn, int _Rm)
_arm_smusdx SMUSDX int _arm_smusdx(int _Rn, int _Rm)
_arm_smull SMULL __int64 _arm_smull(int _Rn, int _Rm)
_arm_umull UMULL unsigned __int64 _arm_umull(unsigned int _Rn, unsigned int _Rm)
_arm_umaal UMAAL unsigned __int64 _arm_umaal(unsigned int _RdLo, unsigned int _RdHi, unsigned int _Rn, unsigned int _Rm)
_arm_bfc BFC unsigned int _arm_bfc(unsigned int _Rd, unsigned int _Lsb, unsigned int _Width)
_arm_bfi BFI unsigned int _arm_bfi(unsigned int _Rd, unsigned int _Rn, unsigned int _Lsb, unsigned int _Width)
_arm_rbit RBIT unsigned int _arm_rbit(unsigned int _Rm)
_arm_sbfx SBFX int _arm_sbfx(int _Rn, unsigned int _Lsb, unsigned int _Width)
_arm_ubfx UBFX unsigned int _arm_ubfx(unsigned int _Rn, unsigned int _Lsb, unsigned int _Width)
_arm_sdiv SDIV int _arm_sdiv(int _Rn, int _Rm)
_arm_udiv UDIV unsigned int _arm_udiv(unsigned int _Rn, unsigned int _Rm)
__cps CPS void __cps(unsigned int _Ops, unsigned int _Flags, unsigned int _Mode)
__dmb DMB void __dmb(unsigned int _Type)

將記憶體屏障作業插入指令資料流中。 參數 _Type 會指定屏障強制執行的限制類型。

如需可強制執行之限制類型的詳細資訊,請參閱 記憶體屏障限制
__dsb DSB void __dsb(unsigned int _Type)

將記憶體屏障作業插入指令資料流中。 參數 _Type 會指定屏障強制執行的限制類型。

如需可強制執行之限制類型的詳細資訊,請參閱 記憶體屏障限制
__isb ISB void __isb(unsigned int _Type)

將記憶體屏障作業插入指令資料流中。 參數 _Type 會指定屏障強制執行的限制類型。

如需可強制執行之限制類型的詳細資訊,請參閱 記憶體屏障限制
__emit void __emit(unsigned __int32 opcode)

將指定的指令,插入由編譯器輸出的指令資料流中。

opcode 的值,必須是在編譯時期已知的常數運算式。 指令字組的大小是 16 位元,而且最高有效的 16 位元 opcode 會被忽略。

編譯程式不會嘗試解譯 的內容 opcode ,而且在執行插入的指令之前,不保證 CPU 或記憶體狀態。

編譯器假設執行插入指令之後,CPU 和記憶體的狀態為不變。 因此,執行變更狀態的指示可能會對編譯程式所產生的一般程式代碼產生有害影響。

基於這個理由,請只使用 emit 插入會影響編譯程式通常未處理之 CPU 狀態的指令,例如協處理器狀態,或實作使用 declspec(naked)宣告的函式。
__hvc HVC unsigned int __hvc(unsigned int, ...)
__iso_volatile_load16 __int16 __iso_volatile_load16(const volatile __int16 *)

如需詳細資訊,請參閱 __iso_volatile_load/存放內部函數
__iso_volatile_load32 __int32 __iso_volatile_load32(const volatile __int32 *)

如需詳細資訊,請參閱 __iso_volatile_load/存放內部函數
__iso_volatile_load64 __int64 __iso_volatile_load64(const volatile __int64 *)

如需詳細資訊,請參閱 __iso_volatile_load/存放內部函數
__iso_volatile_load8 __int8 __iso_volatile_load8(const volatile __int8 *)

如需詳細資訊,請參閱 __iso_volatile_load/存放內部函數
__iso_volatile_store16 void __iso_volatile_store16(volatile __int16 *, __int16)

如需詳細資訊,請參閱 __iso_volatile_load/存放內部函數
__iso_volatile_store32 void __iso_volatile_store32(volatile __int32 *, __int32)

如需詳細資訊,請參閱 __iso_volatile_load/存放內部函數
__iso_volatile_store64 void __iso_volatile_store64(volatile __int64 *, __int64)

如需詳細資訊,請參閱 __iso_volatile_load/存放內部函數
__iso_volatile_store8 void __iso_volatile_store8(volatile __int8 *, __int8)

如需詳細資訊,請參閱 __iso_volatile_load/存放內部函數
__ldrexd LDREXD __int64 __ldrexd(const volatile __int64 *)
__prefetch PLD void __cdecl __prefetch(const void *)

提供 PLD 記憶體提示給系統,通知可能很快就存取位於或接近指定位址的記憶體。 有些系統可能會選擇最佳化此記憶體存取模式,來增加執行階段效能。 不過,從 C++ 語言的觀點來看,函式沒有顯著的影響,而且可能根本不執行任何動作。
__rdpmccntr64 unsigned __int64 __rdpmccntr64(void)
__sev SEV void __sev(void)
__static_assert void __static_assert(int, const char *)
__swi SVC unsigned int __swi(unsigned int, ...)
__trap BKPT int __trap(int, ...)
__wfe WFE void __wfe(void)
__wfi WFI void __wfi(void)
_AddSatInt QADD int _AddSatInt(int, int)
_CopyDoubleFromInt64 雙_CopyDoubleFromInt64(__int64)
_CopyFloatFromInt32 float _CopyFloatFromInt32(__int32)
_CopyInt32FromFloat __int32 _CopyInt32FromFloat(float)
_CopyInt64FromDouble __int64 _CopyInt64FromDouble(double)
_CountLeadingOnes unsigned int _CountLeadingOnes(unsigned long)
_CountLeadingOnes64 unsigned int _CountLeadingOnes64(unsigned __int64)
_CountLeadingSigns unsigned int _CountLeadingSigns(long)
_CountLeadingSigns64 unsigned int _CountLeadingSigns64(__int64)
_CountLeadingZeros unsigned int _CountLeadingZeros(unsigned long)
_CountLeadingZeros64 unsigned int _CountLeadingZeros64(unsigned __int64)
_CountTrailingZeros unsigned _CountTrailingZeros(unsigned long)
_CountTrailingZeros64 unsigned _CountTrailingZeros64(unsigned __int64)
_CountOneBits unsigned int _CountOneBits(unsigned long)
_CountOneBits64 unsigned int _CountOneBits64(unsigned __int64)
_DAddSatInt QDADD int _DAddSatInt(int, int)
_DSubSatInt QDSUB int _DSubSatInt(int, int)
_isunordered int _isunordered(double, double)
_isunorderedf int _isunorderedf(float, float)
_MoveFromCoprocessor MRC unsigned int _MoveFromCoprocessor(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int)

使用副處理器資料傳輸指令,讀取 ARM 副處理器的資料。 如需詳細資訊,請參閱 _MoveFromCoprocessor、_MoveFromCoprocessor2
_MoveFromCoprocessor2 MRC2 unsigned int _MoveFromCoprocessor2(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int)

使用副處理器資料傳輸指令,讀取 ARM 副處理器的資料。 如需詳細資訊,請參閱 _MoveFromCoprocessor、_MoveFromCoprocessor2
_MoveFromCoprocessor64 MRRC unsigned __int64 _MoveFromCoprocessor64(unsigned int, unsigned int, unsigned int)

使用副處理器資料傳輸指令,讀取 ARM 副處理器的資料。 如需詳細資訊,請參閱 _MoveFromCoprocessor64
_MoveToCoprocessor MCR void _MoveToCoprocessor(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int)

使用副處理器資料傳輸指令,讀取 ARM 副處理器的資料。 如需詳細資訊,請參閱 _MoveToCoprocessor、_MoveToCoprocessor2
_MoveToCoprocessor2 MCR2 void _MoveToCoprocessor2(unsigned int, unsigned int, unsigned int, unsigned int, unsigned int, unsigned int)

使用副處理器資料傳輸指令,讀取 ARM 副處理器的資料。 如需詳細資訊,請參閱 _MoveToCoprocessor、_MoveToCoprocessor2
_MoveToCoprocessor64 MCRR void _MoveToCoprocessor64(unsigned __int64, unsigned int, unsigned int, unsigned int)

使用副處理器資料傳輸指令,讀取 ARM 副處理器的資料。 如需詳細資訊,請參閱 _MoveToCoprocessor64
_MulHigh long _MulHigh(long, long)
_MulUnsignedHigh unsigned long _MulUnsignedHigh(unsigned long, unsigned long)
_ReadBankedReg MRS int _ReadBankedReg(int _Reg)
_ReadStatusReg MRS int _ReadStatusReg(int)
_SubSatInt QSUB int _SubSatInt(int, int)
_WriteBankedReg MSR void _WriteBankedReg(int _Value, int _Reg)
_WriteStatusReg MSR void _WriteStatusReg(int, int, int)

[返回頂端]

記憶體屏障限制

內部函 __dmb 式(數據記憶體屏障)、 __dsb (資料同步屏障)和 __isb (指令同步處理屏障)會使用下列預先定義的值來指定共用網域的記憶體屏障限制,以及受作業影響的存取類型。

限制值 描述
_ARM_BARRIER_SY 完整系統,讀取和寫入。
_ARM_BARRIER_ST 完整系統,只寫入。
_ARM_BARRIER_ISH 可內部共用,讀取和寫入。
_ARM_BARRIER_ISHST 可內部共用,只寫入。
_ARM_BARRIER_NSH 不可共用,讀取和寫入。
_ARM_BARRIER_NSHST 不可共用,只寫入。
_ARM_BARRIER_OSH 可外部共用,讀取和寫入。
_ARM_BARRIER_OSHST 可外部共用,只寫入。

對於 __isb 內建函式,目前唯一有效的限制是 _ARM_BARRIER_SY。架構保留其他所有值。

__iso_volatile_load/存放內部函數

這些內部函數會明確執行不受編譯程式優化影響的載入和存放區。

__int16 __iso_volatile_load16(const volatile __int16 * Location);
__int32 __iso_volatile_load32(const volatile __int32 * Location);
__int64 __iso_volatile_load64(const volatile __int64 * Location);
__int8 __iso_volatile_load8(const volatile __int8 * Location);

void __iso_volatile_store16(volatile __int16 * Location, __int16 Value);
void __iso_volatile_store32(volatile __int32 * Location, __int32 Value);
void __iso_volatile_store64(volatile __int64 * Location, __int64 Value);
void __iso_volatile_store8(volatile __int8 * Location, __int8 Value);

參數

地點
要讀取或寫入的記憶體位置的位址。


要寫入指定記憶體位置的值(僅儲存內部函數)。

傳回值(僅載入內部函數)

Location 所指定之記憶體位置的值。

備註

您可以使用 __iso_volatile_load8/16/32/64__iso_volatile_store8/16/32/64 內建來明確執行不受編譯程式優化影響的記憶體存取。 編譯程式無法移除、合成或變更這些作業的相對順序,但不會產生隱含的硬體記憶體屏障。 因此,硬體可能仍然重新排列跨多個執行緒中可觀察到的記憶體存取。 更精確地說,這些內部函數相當於在 /volatile:iso編譯的下列表達式。

int a = __iso_volatile_load32(p);    // equivalent to: int a = *(const volatile __int32*)p;
__iso_volatile_store32(p, a);        // equivalent to: *(volatile __int32*)p = a;

請注意,內建函式採取暫時性 (volatile) 指標以容納暫時性變數。 不過,不需要或建議使用揮發性指標作為自變數。 如果使用一般、非揮發性型別,這些作業的語意就完全相同。

如需 /volatile:iso 命令行自變數的詳細資訊,請參閱 /volatile (volatile 關鍵詞解譯)

_MoveFromCoprocessor,_MoveFromCoprocessor2

這些內建函式會使用副處理器資料傳輸指令,從 ARM 副處理器讀取資料。

int _MoveFromCoprocessor(
      unsigned int coproc,
      unsigned int opcode1,
      unsigned int crn,
      unsigned int crm,
      unsigned int opcode2
);

int _MoveFromCoprocessor2(
      unsigned int coproc,
      unsigned int opcode1,
      unsigned int crn,
      unsigned int crm,
      unsigned int opcode2
);

參數

coproc
副處理器數目,範圍在 0 到 15 之間。

opcode1
範圍 0 到 7 的副處理器專用作業碼

crn
副處理器暫存器編號,範圍介於 0 到 15,指定第一個指令的運算元。

Crm
副處理器暫存器數目 (範圍在 0 到 15 之間),用以指定其他來源或目的地運算元。

opcode2
範圍 0 到 7 的其他副處理器專用作業碼。

傳回值

從副處理器讀取的值。

備註

內建所有五個參數的值必須是編譯時期已知的常數表達式。

_MoveFromCoprocessor 使用 MRC 指令;_MoveFromCoprocessor2 使用 MRC2。 對應到位元欄位的參數,這些參數會直接編碼到指令文字中。 參數的解譯會因副處理器而異。 如需詳細資訊,請參閱該副處理器的手冊。

_MoveFromCoprocessor64

使用副處理器資料傳輸指令,讀取 ARM 副處理器的資料。

unsigned __int64 _MoveFromCoprocessor64(
      unsigned int coproc,
      unsigned int opcode1,
      unsigned int crm,
);

參數

coproc
副處理器數目,範圍在 0 到 15 之間。

opcode1
範圍 0 到 15 的副處理器專用作業碼。

Crm
副處理器暫存器數目 (範圍在 0 到 15 之間),用以指定其他來源或目的地運算元。

傳回值

從副處理器讀取的值。

備註

內建這三個參數的值必須是編譯時期已知的常數表達式。

_MoveFromCoprocessor64 使用 MRRC 指令。 對應到位元欄位的參數,這些參數會直接編碼到指令文字中。 參數的解譯會因副處理器而異。 如需詳細資訊,請參閱該副處理器的手冊。

_MoveToCoprocessor,_MoveToCoprocessor2

這些內建函式會使用副處理器資料傳輸指令,將資料寫入 ARM 副處理器。

void _MoveToCoprocessor(
      unsigned int value,
      unsigned int coproc,
      unsigned int opcode1,
      unsigned int crn,
      unsigned int crm,
      unsigned int opcode2
);

void _MoveToCoprocessor2(
      unsigned int value,
      unsigned int coproc,
      unsigned int opcode1,
      unsigned int crn,
      unsigned int crm,
      unsigned int opcode2
);

參數

value
要寫入副處理器的值。

coproc
副處理器數目,範圍在 0 到 15 之間。

opcode1
範圍 0 到 7 的副處理器專用 opcode。

crn
副處理器暫存器編號,範圍介於 0 到 15,指定第一個指令的運算元。

Crm
副處理器暫存器數目 (範圍在 0 到 15 之間),用以指定其他來源或目的地運算元。

opcode2
範圍 0 到 7 的其他副處理器專用作業碼。

傳回值

無。

備註

內部函數的coprocopcode1、 、 crncrmopcode2 參數的值必須是編譯時期已知的常數表示式。

_MoveToCoprocessor 使用 MCR 指令;_MoveToCoprocessor2 使用 MCR2。 對應到位元欄位的參數,這些參數會直接編碼到指令文字中。 參數的解譯會因副處理器而異。 如需詳細資訊,請參閱該副處理器的手冊。

_MoveToCoprocessor64

這些內建函式會使用副處理器資料傳輸指令,將資料寫入 ARM 副處理器。

void _MoveFromCoprocessor64(
      unsigned __int64 value,
      unsigned int coproc,
      unsigned int opcode1,
      unsigned int crm,
);

參數

coproc
副處理器數目,範圍在 0 到 15 之間。

opcode1
範圍 0 到 15 的副處理器專用作業碼。

Crm
副處理器暫存器數目 (範圍在 0 到 15 之間),用以指定其他來源或目的地運算元。

傳回值

無。

備註

內部函數的 coprocopcode1crm 參數的值必須是編譯時期已知的常數表示式。

_MoveFromCoprocessor64 使用 MCRR 指令。 對應到位元欄位的參數,這些參數會直接編碼到指令文字中。 參數的解譯會因副處理器而異。 如需詳細資訊,請參閱該副處理器的手冊。

其他架構內部函數的ARM支援

下表列出 ARM 平台支援的其他架構的內建函式。 其中註明了內建函式的行為在 ARM 上與在其他硬體架構上有哪些不同的其他詳細資料。

函數名稱 函式原型
__assume void __assume(int)
__code_seg void __code_seg(const char *)
__debugbreak void __cdecl __debugbreak(void)
__fastfail __declspec(noreturn) void __fastfail(unsigned int)
__nop void __nop(void) 注意: 在 ARM 平臺上,如果在目標架構中實作 NOP 指令,則此函式會產生 NOP 指令;否則,不會產生不會變更程式狀態或 CPU 的替代指令, MOV r8, r8例如 。 其功能相當於其他硬體架構的__nop內建。 由於目標架構可能會忽略對程式或 CPU 狀態沒有任何影響的指令,因此指令不一定耗用 CPU 週期。 因此,除非您確定 CPU 的運作方式,否則請勿使用 __nop 內部函數來操作程式代碼序列的運行時間。 相反地,您可以使用 __nop 內部函數,將下一個指令對齊特定的 32 位界限位址。
__yield void __yield(void) 附注: 在 ARM 平臺上,此函式會產生 YIELD 指令,這表示線程正在執行可暫時暫停執行的工作,例如微調鎖定,而不會對程式造成負面影響。 它可讓 CPU 在執行週期期間執行其他工作,否則會浪費。
_AddressOfReturnAddress void * _AddressOfReturnAddress(void)
_BitScanForward unsigned char _BitScanForward(unsigned long * _Index,unsigned long _Mask)
_BitScanReverse unsigned char _BitScanReverse(unsigned long * _Index,unsigned long _Mask)
_bittest unsigned char _bittest(long const *, long)
_bittestandcomplement unsigned char _bittestandcomplement(long *, long)
_bittestandreset unsigned char _bittestandreset(long *, long)
_bittestandset unsigned char _bittestandset(long *, long)
_byteswap_uint64 unsigned __int64 __cdecl _byteswap_uint64(unsigned __int64)
_byteswap_ulong unsigned long __cdecl _byteswap_ulong(unsigned long)
_byteswap_ushort unsigned short __cdecl _byteswap_ushort(unsigned short)
_disable void __cdecl _disable(void) 注意: 在 ARM 平臺上,此函式會產生 CPSID 指令;它只能做為內建。
_enable void __cdecl _enable(void) 注意: 在 ARM 平臺上,此函式會產生 CPSIE 指令;它只能做為內建。
_lrotl unsigned long __cdecl _lrotl(unsigned long, int)
_lrotr unsigned long __cdecl _lrotr(unsigned long, int)
_ReadBarrier void _ReadBarrier(void)
_ReadWriteBarrier void _ReadWriteBarrier(void)
_ReturnAddress void * _ReturnAddress(void)
_rotl unsigned int __cdecl _rotl(unsigned int _Value, int _Shift)
_rotl16 unsigned short _rotl16(unsigned short _Value, unsigned char _Shift)
_rotl64 unsigned __int64 __cdecl _rotl64(unsigned __int64 _Value, int _Shift)
_rotl8 unsigned char _rotl8(unsigned char _Value, unsigned char _Shift)
_rotr unsigned int __cdecl _rotr(unsigned int _Value, int _Shift)
_rotr16 unsigned short _rotr16(unsigned short _Value, unsigned char _Shift)
_rotr64 unsigned __int64 __cdecl _rotr64(unsigned __int64 _Value, int _Shift)
_rotr8 unsigned char _rotr8(unsigned char _Value, unsigned char _Shift)
_setjmpex int __cdecl _setjmpex(jmp_buf)
_WriteBarrier void _WriteBarrier(void)

[返回頂端]

內建聯結

連鎖內建函式是一組內建函式,用來執行不可部分完成的讀取-修改-寫入作業。 其中有部分通用於所有平台。 它們會分別列在這裡,因為有大量的它們,但由於其定義大多是多餘的,所以一般情況下更容易思考它們。 它們的名稱可以用來得出確切的行為。

下表摘要說明非位元測試連鎖內建函式的 ARM 的支援。 在表中的每個儲存格對應的名稱,是將列的最左邊儲存格的作業名稱,和欄的最上方儲存格的類型名稱,附加至 _Interlocked 所衍生的名稱。 例如,數據列和數據行交集 Xor 處的 8 單元格會對應至 _InterlockedXor8 且完全支援。 大部分受支援的函式會提供這些選擇性的字尾:_acq_rel_nf_acq 字尾表示「取得」語意,_rel 字尾表示「釋放」語意。 _nf或 「無柵欄」後綴對 ARM 而言是唯一的,下一節會討論。

作業 8 16 32 64 P
完整 完整
完整 完整 完整 完整
CompareExchange 完整 完整 完整 完整 完整
遞減 完整 完整 完整
Exchange Partial Partial Partial Partial Partial
ExchangeAdd 完整 完整 完整 完整
[遞增] 完整 完整 完整
Or 完整 完整 完整 完整
Xor 完整 完整 完整 完整

索引鍵:

  • 完整:支援純文字、 _acq、、 _rel_nf 表單。

  • Partial:支援純文本、 _acq_nf 窗體。

  • :不支援

_nf (沒有柵欄) 後綴

_nf或「無柵欄」後綴表示作業不會作為任何種類的記憶體屏障,與其他三種形式(純文本、_acq_rel)相反,它們的行為都是某種障礙。 表單的 _nf 其中一個可能用法是維護由多個線程同時更新的統計數據計數器,但是其值不會在執行多個線程時使用。

內建聯結的清單

函數名稱 函式原型
_InterlockedAdd long _InterlockedAdd(long _volatile *, long)
_InterlockedAdd64 __int64 _InterlockedAdd64(__int64揮發性 *, __int64)
_InterlockedAdd64_acq __int64 _InterlockedAdd64_acq(__int64揮發性 *, __int64)
_InterlockedAdd64_nf __int64 _InterlockedAdd64_nf(__int64揮發性 *, __int64)
_InterlockedAdd64_rel __int64 _InterlockedAdd64_rel(__int64揮發性 *, __int64)
_InterlockedAdd_acq long _InterlockedAdd_acq(long volatile *, long)
_InterlockedAdd_nf long _InterlockedAdd_nf(long volatile *, long)
_InterlockedAdd_rel long _InterlockedAdd_rel(long volatile *, long)
_InterlockedAnd long _InterlockedAnd(long volatile *, long)
_InterlockedAnd16 short _InterlockedAnd16(short volatile *, short)
_InterlockedAnd16_acq short _InterlockedAnd16_acq(short volatile *, short)
_InterlockedAnd16_nf short _InterlockedAnd16_nf(short volatile *, short)
_InterlockedAnd16_rel short _InterlockedAnd16_rel(short volatile *, short)
_InterlockedAnd64 __int64 _InterlockedAnd64(__int64揮發性 *, __int64)
_InterlockedAnd64_acq __int64 _InterlockedAnd64_acq(__int64揮發性 *, __int64)
_InterlockedAnd64_nf __int64 _InterlockedAnd64_nf(__int64揮發性 *, __int64)
_InterlockedAnd64_rel __int64 _InterlockedAnd64_rel(__int64揮發性 *, __int64)
_InterlockedAnd8 char _InterlockedAnd8(char volatile *, char)
_InterlockedAnd8_acq char _InterlockedAnd8_acq(char volatile *, char)
_InterlockedAnd8_nf char _InterlockedAnd8_nf(char volatile *, char)
_InterlockedAnd8_rel char _InterlockedAnd8_rel(char volatile *, char)
_InterlockedAnd_acq long _InterlockedAnd_acq(long volatile *, long)
_InterlockedAnd_nf long _InterlockedAnd_nf(long volatile *, long)
_InterlockedAnd_rel long _InterlockedAnd_rel(long volatile *, long)
_InterlockedCompareExchange long __cdecl _InterlockedCompareExchange(long volatile *, long, long)
_InterlockedCompareExchange16 short _InterlockedCompareExchange16(short volatile *, short, short)
_InterlockedCompareExchange16_acq short _InterlockedCompareExchange16_acq(short volatile *, short, short)
_InterlockedCompareExchange16_nf short _InterlockedCompareExchange16_nf(short volatile *, short, short)
_InterlockedCompareExchange16_rel short _InterlockedCompareExchange16_rel(short volatile *, short, short)
_InterlockedCompareExchange64 __int64 _InterlockedCompareExchange64(__int64揮發性 *、__int64、__int64)
_InterlockedCompareExchange64_acq __int64 _InterlockedCompareExchange64_acq(__int64揮發性 *、__int64、__int64)
_InterlockedCompareExchange64_nf __int64 _InterlockedCompareExchange64_nf(__int64揮發性 *、__int64、__int64)
_InterlockedCompareExchange64_rel __int64 _InterlockedCompareExchange64_rel(__int64揮發性 *、__int64、__int64)
_InterlockedCompareExchange8 char _InterlockedCompareExchange8(char volatile *, char, char)
_InterlockedCompareExchange8_acq char _InterlockedCompareExchange8_acq(char volatile *, char, char, char)
_InterlockedCompareExchange8_nf char _InterlockedCompareExchange8_nf(char volatile *, char, char)
_InterlockedCompareExchange8_rel char _InterlockedCompareExchange8_rel(char volatile *, char, char)
_InterlockedCompareExchangePointer void * _InterlockedCompareExchangePointer(void * volatile *, void *, void *)
_InterlockedCompareExchangePointer_acq void * _InterlockedCompareExchangePointer_acq(void * volatile *, void *, void *)
_InterlockedCompareExchangePointer_nf void * _InterlockedCompareExchangePointer_nf(void * volatile *, void *, void *)
_InterlockedCompareExchangePointer_rel void * _InterlockedCompareExchangePointer_rel(void * volatile *, void *, void *)
_InterlockedCompareExchange_acq long _InterlockedCompareExchange_acq(long volatile *, long, long)
_InterlockedCompareExchange_nf long _InterlockedCompareExchange_nf(long volatile *, long, long)
_InterlockedCompareExchange_rel long _InterlockedCompareExchange_rel(long volatile *, long, long)
_InterlockedDecrement long __cdecl _InterlockedDecrement(long volatile *)
_InterlockedDecrement16 short _InterlockedDecrement16(short volatile *)
_InterlockedDecrement16_acq short _InterlockedDecrement16_acq(short volatile *)
_InterlockedDecrement16_nf short _InterlockedDecrement16_nf(short volatile *)
_InterlockedDecrement16_rel short _InterlockedDecrement16_rel(short volatile *)
_InterlockedDecrement64 __int64 _InterlockedDecrement64(__int64揮發性 *)
_InterlockedDecrement64_acq __int64 _InterlockedDecrement64_acq(__int64揮發性 *)
_InterlockedDecrement64_nf __int64 _InterlockedDecrement64_nf(__int64揮發性 *)
_InterlockedDecrement64_rel __int64 _InterlockedDecrement64_rel(__int64揮發性 *)
_InterlockedDecrement_acq long _InterlockedDecrement_acq(long volatile *)
_InterlockedDecrement_nf long _InterlockedDecrement_nf(long volatile *)
_InterlockedDecrement_rel long _InterlockedDecrement_rel(long volatile *)
_InterlockedExchange long __cdecl _InterlockedExchange(long volatile * _Target, long)
_InterlockedExchange16 short _InterlockedExchange16(short volatile * _Target, short)
_InterlockedExchange16_acq short _InterlockedExchange16_acq(short volatile * _Target,short)
_InterlockedExchange16_nf short _InterlockedExchange16_nf(short volatile * _Target,short)
_InterlockedExchange64 __int64 _InterlockedExchange64(__int64揮發性 * _Target,__int64)
_InterlockedExchange64_acq __int64 _InterlockedExchange64_acq(__int64揮發性 * _Target,__int64)
_InterlockedExchange64_nf __int64 _InterlockedExchange64_nf(__int64揮發性 * _Target,__int64)
_InterlockedExchange8 char _InterlockedExchange8(char volatile * _Target, char)
_InterlockedExchange8_acq char _InterlockedExchange8_acq(char volatile * _Target,char)
_InterlockedExchange8_nf char _InterlockedExchange8_nf(char volatile * _Target, char)
_InterlockedExchangeAdd long __cdecl _InterlockedExchangeAdd(long volatile *, long)
_InterlockedExchangeAdd16 short _InterlockedExchangeAdd16(short volatile *, short)
_InterlockedExchangeAdd16_acq short _InterlockedExchangeAdd16_acq(short volatile *, short)
_InterlockedExchangeAdd16_nf short _InterlockedExchangeAdd16_nf(short volatile *, short)
_InterlockedExchangeAdd16_rel short _InterlockedExchangeAdd16_rel(short volatile *, short)
_InterlockedExchangeAdd64 __int64 _InterlockedExchangeAdd64(__int64揮發性 *, __int64)
_InterlockedExchangeAdd64_acq __int64 _InterlockedExchangeAdd64_acq(__int64揮發性 *, __int64)
_InterlockedExchangeAdd64_nf __int64 _InterlockedExchangeAdd64_nf(__int64揮發性 *, __int64)
_InterlockedExchangeAdd64_rel __int64 _InterlockedExchangeAdd64_rel(__int64揮發性 *, __int64)
_InterlockedExchangeAdd8 char _InterlockedExchangeAdd8(char volatile *, char)
_InterlockedExchangeAdd8_acq char _InterlockedExchangeAdd8_acq(char volatile *, char)
_InterlockedExchangeAdd8_nf char _InterlockedExchangeAdd8_nf(char volatile *, char)
_InterlockedExchangeAdd8_rel char _InterlockedExchangeAdd8_rel(char volatile *, char)
_InterlockedExchangeAdd_acq long _InterlockedExchangeAdd_acq(long volatile *, long)
_InterlockedExchangeAdd_nf long _InterlockedExchangeAdd_nf(long volatile *, long)
_InterlockedExchangeAdd_rel long _InterlockedExchangeAdd_rel(long volatile *, long)
_InterlockedExchangePointer void * _InterlockedExchangePointer(void * volatile * _Target, void *)
_InterlockedExchangePointer_acq void * _InterlockedExchangePointer_acq(void * volatile * _Target, void *)
_InterlockedExchangePointer_nf void * _InterlockedExchangePointer_nf(void * volatile * _Target, void *)
_InterlockedExchange_acq long _InterlockedExchange_acq(long volatile * _Target, long)
_InterlockedExchange_nf long _InterlockedExchange_nf(long volatile * _Target, long)
_InterlockedIncrement long __cdecl _InterlockedIncrement(long volatile *)
_InterlockedIncrement16 short _InterlockedIncrement16(short volatile *)
_InterlockedIncrement16_acq short _InterlockedIncrement16_acq(short volatile *)
_InterlockedIncrement16_nf short _InterlockedIncrement16_nf(short volatile *)
_InterlockedIncrement16_rel short _InterlockedIncrement16_rel(short volatile *)
_InterlockedIncrement64 __int64 _InterlockedIncrement64(__int64揮發性 *)
_InterlockedIncrement64_acq __int64 _InterlockedIncrement64_acq(__int64揮發性 *)
_InterlockedIncrement64_nf __int64 _InterlockedIncrement64_nf(__int64揮發性 *)
_InterlockedIncrement64_rel __int64 _InterlockedIncrement64_rel(__int64揮發性 *)
_InterlockedIncrement_acq long _InterlockedIncrement_acq(long volatile *)
_InterlockedIncrement_nf long _InterlockedIncrement_nf(long volatile *)
_InterlockedIncrement_rel long _InterlockedIncrement_rel(long volatile *)
_InterlockedOr long _InterlockedOr(long volatile *, long)
_InterlockedOr16 short _InterlockedOr16(short volatile *, short)
_InterlockedOr16_acq short _InterlockedOr16_acq(short volatile *, short)
_InterlockedOr16_nf short _InterlockedOr16_nf(short volatile *, short)
_InterlockedOr16_rel short _InterlockedOr16_rel(short volatile *, short)
_InterlockedOr64 __int64 _InterlockedOr64(__int64揮發性 *, __int64)
_InterlockedOr64_acq __int64 _InterlockedOr64_acq(__int64揮發性 *, __int64)
_InterlockedOr64_nf __int64 _InterlockedOr64_nf(__int64揮發性 *, __int64)
_InterlockedOr64_rel __int64 _InterlockedOr64_rel(__int64揮發性 *, __int64)
_InterlockedOr8 char _InterlockedOr8(char volatile *, char)
_InterlockedOr8_acq char _InterlockedOr8_acq(char volatile *, char)
_InterlockedOr8_nf char _InterlockedOr8_nf(char volatile *, char)
_InterlockedOr8_rel char _InterlockedOr8_rel(char volatile *, char)
_InterlockedOr_acq long _InterlockedOr_acq(long volatile *, long)
_InterlockedOr_nf long _InterlockedOr_nf(long volatile *, long)
_InterlockedOr_rel long _InterlockedOr_rel(long volatile *, long)
_InterlockedXor long _InterlockedXor(long volatile *, long)
_InterlockedXor16 short _InterlockedXor16(short volatile *, short)
_InterlockedXor16_acq short _InterlockedXor16_acq(short volatile *, short)
_InterlockedXor16_nf short _InterlockedXor16_nf(short volatile *, short)
_InterlockedXor16_rel short _InterlockedXor16_rel(short volatile *, short)
_InterlockedXor64 __int64 _InterlockedXor64(__int64揮發性 *, __int64)
_InterlockedXor64_acq __int64 _InterlockedXor64_acq(__int64揮發性 *, __int64)
_InterlockedXor64_nf __int64 _InterlockedXor64_nf(__int64揮發性 *, __int64)
_InterlockedXor64_rel __int64 _InterlockedXor64_rel(__int64揮發性 *, __int64)
_InterlockedXor8 char _InterlockedXor8(char volatile *, char)
_InterlockedXor8_acq char _InterlockedXor8_acq(char volatile *, char)
_InterlockedXor8_nf char _InterlockedXor8_nf(char volatile *, char)
_InterlockedXor8_rel char _InterlockedXor8_rel(char volatile *, char)
_InterlockedXor_acq long _InterlockedXor_acq(long volatile *, long)
_InterlockedXor_nf long _InterlockedXor_nf(long volatile *, long)
_InterlockedXor_rel long _InterlockedXor_rel(long volatile *, long)

[返回頂端]

_interlockedbittest內部函數

所有平臺通用的一般聯結位測試內部函數。 ARM 會新增 _acq_rel_nf 變體,其只會修改作業的屏障語意,如本文稍早_nf(無柵欄)後綴所述

函數名稱 函式原型
_interlockedbittestandreset unsigned char _interlockedbittestandreset(long volatile *, long)
_interlockedbittestandreset_acq unsigned char _interlockedbittestandreset_acq(long volatile *, long)
_interlockedbittestandreset_nf unsigned char _interlockedbittestandreset_nf(long volatile *, long)
_interlockedbittestandreset_rel unsigned char _interlockedbittestandreset_rel(long volatile *, long)
_interlockedbittestandset unsigned char _interlockedbittestandset(long volatile *, long)
_interlockedbittestandset_acq unsigned char _interlockedbittestandset_acq(long volatile *, long)
_interlockedbittestandset_nf unsigned char _interlockedbittestandset_nf(long volatile *, long)
_interlockedbittestandset_rel unsigned char _interlockedbittestandset_rel(long volatile *, long)

[返回頂端]

另請參閱

編譯程式內部函數
ARM64 內部函數
ARM 組合器參考
C++ 語言參考