52#if SIZEOF_INT_P==4 && !defined(USE_LOW32_TAGS)
54#define TAGS_FAST_OPS 1
56#define SHIFT_HIGH_TAG 29
58#define MKTAG(HI,LO) ((((UInt) (HI))<<SHIFT_HIGH_TAG)|(LO))
60#define TagBits MKTAG(0x5,3)
61#define LowTagBits MKTAG(0x0,3)
62#define LowBit MKTAG(0x0,1)
63#define HighTagBits MKTAG(0x7,0)
64#define AdrHiBit (((UInt)1) << (SHIFT_HIGH_TAG-1))
65#define MaskAdr ((((UInt)1) << (SHIFT_HIGH_TAG))-4)
66#define MaskPrim ((((UInt)1) << (SHIFT_HIGH_TAG))-4)
67#define NumberTag MKTAG(0x5,2)
68#define AtomTag MKTAG(0x4,2)
69#define MAX_ABS_INT ((Int)0x04000000L)
72#define YAP_PROTECTED_MASK 0xe0000000L
83#if defined(i386) || defined(sparc) || defined(_POWER) || defined(__POWERPC__) || defined(__sparc)
84#define UNIQUE_TAG_FOR_PAIRS 1
87#if UNIQUE_TAG_FOR_PAIRS
95#define TagOf(t) (Unsigned(t)&TagBits)
96#define LowTagOf(t) (Unsigned(t)&TagBits)
97#define NonTagPart(X) (Signed(X) & MaskPrim)
98#define TAGGEDA(TAG,V) (TAG | Unsigned(V))
99#define TAGGED(TAG,V) (TAG | NonTagPart(Unsigned(V)<<2))
100#define NONTAGGED(TAG,V) NonTagPart(Unsigned(V)<<2)
101#define BitOn(Bit,V) (Bit & Unsigned(V))
102#define CHKTAG(t,Tag) ((Unsigned(t)&TagBits)==Tag)
106#include "inline-only.h"
107INLINE_ONLY EXTERN
int IsVarTerm (Term);
109INLINE_ONLY EXTERN
int
112 return (
int) (Signed (t) >= 0);
117INLINE_ONLY EXTERN
int IsNonVarTerm (Term);
119INLINE_ONLY EXTERN
int
122 return (
int) (Signed (t) < 0);
126#if UNIQUE_TAG_FOR_PAIRS
128INLINE_ONLY EXTERN Term *RepPair (Term);
130INLINE_ONLY EXTERN Term *
133 return (Term *) ((~(t)));
138INLINE_ONLY EXTERN Term AbsPair (Term *);
140INLINE_ONLY EXTERN Term
143 return (Term) ((~Unsigned (p)));
148INLINE_ONLY EXTERN Int IsPairTerm (Term);
150INLINE_ONLY EXTERN Int
153 return (Int) (((t) & PairBit));
158INLINE_ONLY EXTERN Term *RepAppl (Term);
160INLINE_ONLY EXTERN Term *
163 return (Term *) ((-Signed (t)));
168INLINE_ONLY EXTERN Term AbsAppl (Term *);
170INLINE_ONLY EXTERN Term
173 return (Term) ((-Signed (p)));
178INLINE_ONLY EXTERN Int IsApplTerm (Term);
180INLINE_ONLY EXTERN Int
183 return (Int) ((!((t) & LowTagBits)));
189INLINE_ONLY EXTERN Term *RepPair (Term);
191INLINE_ONLY EXTERN Term *
194 return (Term *) ((-Signed (t)));
199INLINE_ONLY EXTERN Term AbsPair (Term *);
201INLINE_ONLY EXTERN Term
204 return (Term) (((CELL) (-Signed (p))));
209INLINE_ONLY EXTERN Int IsPairTerm (Term);
211INLINE_ONLY EXTERN Int
214 return (Int) ((!((t) & LowTagBits)));
219INLINE_ONLY EXTERN Term *RepAppl (Term);
221INLINE_ONLY EXTERN Term *
224 return (Term *) ((~(t)));
229INLINE_ONLY EXTERN Term AbsAppl (Term *);
231INLINE_ONLY EXTERN Term
234 return (Term) ((~Unsigned (p)));
239INLINE_ONLY EXTERN Int IsApplTerm (Term);
241INLINE_ONLY EXTERN Int
244 return (Int) (((t) & ApplBit));
250INLINE_ONLY EXTERN Int IsAtomOrIntTerm (Term);
252INLINE_ONLY EXTERN Int
253IsAtomOrIntTerm (Term t)
255 return (Int) (((Unsigned (t) & LowTagBits) == 0x2));
261INLINE_ONLY EXTERN Int IntOfTerm (Term);
263INLINE_ONLY EXTERN Int
266 return (Int) ((Int) (Unsigned (t) << 3) >> 5);
271#if UNIQUE_TAG_FOR_PAIRS
273INLINE_ONLY EXTERN Term AdjustPtr (Term t, Term off);
275INLINE_ONLY EXTERN Term
276AdjustPtr (Term t, Term off)
278 return (Term) (((IsVarTerm (t)
279 || IsAtomOrIntTerm (t)) ? (t) +
280 (off) : (IsPairTerm (t) ? (CELL)
281 AbsPair ((CELL *) ((CELL) RepPair (t) +
282 (off))) : (t) - (off))));
287INLINE_ONLY EXTERN Term AdjustIDBPtr (Term t, Term off);
289INLINE_ONLY EXTERN Term
290AdjustIDBPtr (Term t, Term off)
292 return (Term) (IsVarTerm (t) ? (t) + (off) : (t) - (off));
298INLINE_ONLY EXTERN Term AdjustPtr (Term t, Term off);
300INLINE_ONLY EXTERN Term
301AdjustPtr (Term t, Term off)
303 return (Term) (((IsVarTerm (t)
304 || IsAtomOrIntTerm (t)) ? (t) +
305 (off) : (IsApplTerm (t) ? (CELL)
306 AbsAppl ((CELL *) ((CELL) RepAppl (t) +
307 (off))) : (t) - (off))));
312INLINE_ONLY EXTERN Term AdjustIDBPtr (Term t, Term off);
314INLINE_ONLY EXTERN Term
315AdjustIDBPtr (Term t, Term off)
317 return (Term) (IsVarTerm (t) ? (t) +
318 (off) : (IsApplTerm (t) ? (CELL)
319 AbsAppl ((CELL *) ((CELL) RepAppl (t) +
320 (off))) : (t) - (off)));