⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 notes

📁 Mac OS X 10.4.9 for x86 Source Code gcc 实现源代码
💻
字号:
Copyright (C) 2002Free Software Foundation, Inc.			 Implementation Notes			 ====================IEEE floating point comparisonsIan Dall <ian@beware.dropbear.id.au>------------------------------------The ns32x81 fpu handles most operands in hardware, but traps on NaN,Inf and Denormalized numbers. The correct behavior can be handled bythe trap handler. This is mostly transparent to the compiler, but inthe case of floating point comparisons, the trap handler and thecompiler must co-operate.Comparing a Nan with anything (including another Nan) is an unorderedcomparison and a NE test should be true and any other test should befalse. There is nothing the trap handler can do to the condition codesto make, for example ble and bgt (the machine instructions, not thegcc insn's) both fail.The L flag (normally used for unsigned comparisons) is cleared by a floatingpoint compare. So, it is possible for the trap handler to communicate thatit has seen a NaN by setting this flag.This can get confusing so the following documents the reasoning. Thereare only 3 flags of significance, N, Z and L. In what follows AB isthe conjunction of A and B ("and") A+B is the disjunction of A and B("or"), upper case represents true and lower case represents false. So"Zl" is "Z AND (NOT L)".Also, we can require that the trap handler clears N and Z, whenever itsets L. This means that in many cases, we do not need to test if L isset or clear. The operations we require are:	Operator	Expression	Check L	GT		Nl		No	LT		znl		Yes	GE		(Z+N)l		No	LE		nl		Yes	EQ		Zl		No	NE		z+L		NoFor example, the emitted code for the case of LT is	  bhi 0f	  blt %0	0:which is, in effect, "branch if ordered and less than."We also need insns for the reverse branches. These have the PC andthe label ref operands reversed. Thus the reverse bgt has a pattern: (set (pc)	(if_then_else (gt (cc0)			  (const_int 0))		      (pc)		      (label_ref (match_operand 0 "" ""))))This is identical to a normal branch with the test complimented: (set (pc)	(if_then_else (not (gt (cc0)			  (const_int 0)))		      (label_ref (match_operand 0 "" "")		      (pc))))Thus we need a family of (NOT cond) tests. For integers this is easy,a reverse blt becomes bge. However, the possibility of unorderedcomparison complicates the floating point case. So, we need tocompliment the above expressions, using deMorgan's theorem, for the reversebranch:	Operator	Expression	Check L	RGT		n+L		Yes	RLT		Z+N+L		Yes	RGE		zn+L		Yes	RLE		N+L		Yes	REQ		z+L		No	RNE		Zl		NoFor example the emitted code for the case of RLT is   bge %0   bhi %0which is, in effect "branch if not less than and not unordered."These extra comparisons are safe if the trap handler doesn't set theL flag, since in that case the additional "bhi" instructions are nevertaken. Also, these extra branch instructions are controlled by the"-mieee-compare" option.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -