summaryrefslogtreecommitdiff
path: root/ghc/compiler/prelude/AbsPrel.lhs
blob: dffc16301e952951df8a7289338ca10bbf8ceaf8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
%
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1995
%
\section[AbsPrel]{The @AbsPrel@ interface to the compiler's prelude knowledge}

\begin{code}
#include "HsVersions.h"

module AbsPrel (

-- unlike most export lists, this one is actually interesting :-)

	-- re-export some PrimOp stuff:
	PrimOp(..), typeOfPrimOp, primOpNameInfo,
	HeapRequirement(..), primOpHeapReq, primOpCanTriggerGC, 
	primOpNeedsWrapper, primOpOkForSpeculation, primOpIsCheap,
	fragilePrimOp,
	PrimOpResultInfo(..), getPrimOpResultInfo,
	pprPrimOp, showPrimOp, isCompareOp,
	readUnfoldingPrimOp,  -- actually, defined herein

	pRELUDE, pRELUDE_BUILTIN, pRELUDE_CORE, pRELUDE_RATIO,
	pRELUDE_LIST, pRELUDE_TEXT, --OLD: pRELUDE_ARRAY, pRELUDE_COMPLEX,
	pRELUDE_PRIMIO, pRELUDE_IO, pRELUDE_PS,
	gLASGOW_ST, {-gLASGOW_IO,-} gLASGOW_MISC,

	-- lookup functions for built-in names, for the renamer:
	builtinNameInfo,

	-- *odd* values that need to be reached out and grabbed:
	eRROR_ID, pAT_ERROR_ID, aBSENT_ERROR_ID,
	unpackCStringId, packStringForCId, unpackCStringAppendId,
	integerZeroId, integerPlusOneId, integerMinusOneId,

#ifdef DPH
	-- ProcessorClass
	toPodId,

	-- Pid Class
	fromDomainId, toDomainId,
#endif {- Data Parallel Haskell -}

	-----------------------------------------------------
	-- the rest of the export list is organised by *type*
	-----------------------------------------------------

	-- "type": functions ("arrow" type constructor)
	mkFunTy,

	-- type: Bool
	boolTyCon, boolTy, falseDataCon, trueDataCon,

	-- types: Char#, Char, String (= [Char])
	charPrimTy, charTy, stringTy,
	charPrimTyCon, charTyCon, charDataCon,

	-- type: CMP_TAG (used in deriving)
	cmpTagTy, ltPrimDataCon, eqPrimDataCon, gtPrimDataCon,

	-- types: Double#, Double
	doublePrimTy, doubleTy,
	doublePrimTyCon, doubleTyCon, doubleDataCon,

	-- types: Float#, Float
	floatPrimTy, floatTy,
	floatPrimTyCon, floatTyCon, floatDataCon,

	-- types: Glasgow *primitive* arrays, sequencing and I/O
	mkPrimIoTy, -- to typecheck "mainIO", "mainPrimIO" & for _ccall_s
	realWorldStatePrimTy, realWorldStateTy{-boxed-},
	realWorldTy, realWorldTyCon, realWorldPrimId,
	stateDataCon, getStatePairingConInfo,

	-- types: Void# (only used within the compiler)
	voidPrimTy, voidPrimId,

	-- types: Addr#, Int#, Word#, Int
	intPrimTy, intTy, intPrimTyCon, intTyCon, intDataCon,
	wordPrimTyCon, wordPrimTy, wordTy, wordDataCon,
	addrPrimTyCon, addrPrimTy, addrTy, addrDataCon,

	-- types: Integer, Rational (= Ratio Integer)
	integerTy, rationalTy,
	integerTyCon, rationalTyCon, ratioDataCon,

	-- type: Lift
	liftTyCon, liftDataCon, mkLiftTy,

	-- type: List
	listTyCon, mkListTy, nilDataCon, consDataCon,
	-- NOT USED: buildDataCon,

	-- type: tuples
	mkTupleTy, unitTy,

	-- packed Strings
--	packedStringTyCon, packedStringTy, psDataCon, cpsDataCon,

	-- for compilation of List Comprehensions and foldr
	foldlId, foldrId, mkFoldl, mkFoldr, mkBuild, buildId,

#ifdef DPH
	mkProcessorTy,
        mkPodTy, mkPodNTy, podTyCon,			     -- user model
	mkPodizedPodNTy, 		     		     -- podized model
	mkInterfacePodNTy, interfacePodTyCon, mKINTERPOD_ID, -- interface model

        -- Misc used during podization
        primIfromPodNSelectorId,
#endif {- Data Parallel Haskell -}

	-- and, finally, we must put in some (abstract) data types,
	-- to make the interface self-sufficient
	GlobalSwitch, Id, Maybe, Name, PprStyle, PrimKind, HeapOffset,
	TyCon, UniType, TauType(..), Unique, CoreExpr, PlainCoreExpr(..)

	IF_ATTACK_PRAGMAS(COMMA tagOf_PrimOp)
	IF_ATTACK_PRAGMAS(COMMA mkStatePrimTy)

#ifndef __GLASGOW_HASKELL__
	,TAG_
#endif
    ) where

#ifdef DPH
import TyPod
import TyProcs
#endif {- Data Parallel Haskell -}

import PrelFuns		-- help functions, types and things
import PrimKind

import TysPrim		-- TYPES
import TysWiredIn
import PrelVals		-- VALUES
import PrimOps		-- PRIMITIVE OPS

import AbsUniType	( getTyConDataCons, TyCon
			  IF_ATTACK_PRAGMAS(COMMA cmpTyCon)
			)
import CmdLineOpts	( GlobalSwitch(..) )
import FiniteMap
import Id		( Id )
--OLD:import NameEnv
import Maybes
import Unique		-- *Key stuff
import Util
\end{code}

This little devil is too small to merit its own ``TyFun'' module:

\begin{code}
mkFunTy = UniFun
\end{code}

%************************************************************************
%*									*
\subsection[builtinNameInfo]{Lookup built-in names}
%*									*
%************************************************************************

We have two ``builtin name funs,'' one to look up @TyCons@ and
@Classes@, the other to look up values.

\begin{code}
builtinNameInfo :: (GlobalSwitch -> Bool)	-- access to global cmd-line flags
		-> (FAST_STRING -> Maybe Name,	-- name lookup fn for values
		    FAST_STRING -> Maybe Name)	-- name lookup fn for tycons/classes

builtinNameInfo switch_is_on
  = (init_val_lookup_fn, init_tc_lookup_fn)
  where
    --
    -- values (including data constructors)
    --
    init_val_lookup_fn
      =	if	switch_is_on HideBuiltinNames then
		(\ x -> Nothing)
	else if switch_is_on HideMostBuiltinNames then
		lookupFM (listToFM min_val_assoc_list)
		-- OLD: mkStringLookupFn min_val_assoc_list False{-not pre-sorted-}
	else
		lookupFM (listToFM (concat list_of_val_assoc_lists))
		-- mkStringLookupFn (concat list_of_val_assoc_lists) False{-not pre-sorted-}

    min_val_assoc_list		-- this is an ad-hoc list; what "happens"
	=  totally_wired_in_Ids	-- to be needed (when compiling bits of
	++ unboxed_ops		-- Prelude).
	++ (concat (map pcDataConNameInfo min_nonprim_tycon_list))

    -- We let a lot of "non-standard" values be visible, so that we
    -- can make sense of them in interface pragmas.  It's cool, though
    -- -- they all have "non-standard" names, so they won't get past
    -- the parser in user code.
    list_of_val_assoc_lists
    	= [ -- each list is empty or all there

	    totally_wired_in_Ids,

	    concat (map pcDataConNameInfo data_tycons),

	    unboxed_ops,

	    if switch_is_on ForConcurrent then parallel_vals else []
	  ]

    --
    -- type constructors and classes
    --
    init_tc_lookup_fn
      =	if	switch_is_on HideBuiltinNames then
		(\ x -> Nothing)
	else if switch_is_on HideMostBuiltinNames then
		lookupFM (listToFM min_tc_assoc_list)
		--OLD: mkStringLookupFn min_tc_assoc_list False{-not pre-sorted-}
	else
		lookupFM (listToFM (
		-- OLD: mkStringLookupFn
		    map pcTyConNameInfo (data_tycons ++ synonym_tycons)
		    ++ std_tycon_list -- TyCons not quite so wired in
		    ++ std_class_list
		    ++ prim_tys))
		    -- The prim_tys,etc., are OK, because they all
		    -- have "non-standard" names (and we really
		    -- want them for interface pragmas).
		  --OLD: False{-not pre-sorted-}

    min_tc_assoc_list	-- again, pretty ad-hoc
	= prim_tys ++ (map pcTyConNameInfo min_nonprim_tycon_list)
--HA!	  ++ std_class_list -- no harm in this

min_nonprim_tycon_list -- used w/ HideMostBuiltinNames
  = [ boolTyCon,
      cmpTagTyCon,
      charTyCon,
      intTyCon,
      floatTyCon,
      doubleTyCon,
      integerTyCon,
      ratioTyCon,
      return2GMPsTyCon,	-- ADR asked for these last two (WDP 94/11)
      returnIntAndGMPTyCon ]

-- sigh: I (WDP) think these should be local defns
-- but you cannot imagine how bad it is for speed (w/ GHC)
prim_tys    = map pcTyConNameInfo prim_tycons

-- values

totally_wired_in_Ids
  = [(SLIT(":"),		WiredInVal consDataCon),
     (SLIT("error"),		WiredInVal eRROR_ID),
     (SLIT("patError#"),	WiredInVal pAT_ERROR_ID), -- occurs in i/faces
     (SLIT("parError#"),	WiredInVal pAR_ERROR_ID), -- ditto
     (SLIT("_trace"),		WiredInVal tRACE_ID),

     -- now the build  / foldr Id, which needs to be built in
     (SLIT("_build"),		WiredInVal buildId),
     (SLIT("foldl"),		WiredInVal foldlId),
     (SLIT("foldr"),		WiredInVal foldrId),
     (SLIT("_runST"),		WiredInVal runSTId),
     (SLIT("realWorld#"),	WiredInVal realWorldPrimId)
    ]

parallel_vals
  =[(SLIT("_seq_"),		WiredInVal seqId),
    (SLIT("_par_"),		WiredInVal parId),
    (SLIT("_fork_"),		WiredInVal forkId)
#ifdef GRAN
    ,
    (SLIT("_parLocal_"),	WiredInVal parLocalId),
    (SLIT("_parGlobal_"),	WiredInVal parGlobalId)
    -- Add later:
    -- (SLIT("_parAt_"),	WiredInVal parAtId)
    -- (SLIT("_parAtForNow_"),	WiredInVal parAtForNowId)
    -- (SLIT("_copyable_"),	WiredInVal copyableId)
    -- (SLIT("_noFollow_"),	WiredInVal noFollowId)
#endif {-GRAN-}
   ]

unboxed_ops
  = (map primOpNameInfo lots_of_primops)
   ++
    -- plus some of the same ones but w/ different names
   [case (primOpNameInfo IntAddOp) 	of (_,n) -> (SLIT("+#"),   n),
    case (primOpNameInfo IntSubOp) 	of (_,n) -> (SLIT("-#"),   n),
    case (primOpNameInfo IntMulOp) 	of (_,n) -> (SLIT("*#"),   n),
    case (primOpNameInfo IntGtOp)  	of (_,n) -> (SLIT(">#"),   n),
    case (primOpNameInfo IntGeOp)  	of (_,n) -> (SLIT(">=#"),  n),
    case (primOpNameInfo IntEqOp)  	of (_,n) -> (SLIT("==#"),  n),
    case (primOpNameInfo IntNeOp)  	of (_,n) -> (SLIT("/=#"),  n),
    case (primOpNameInfo IntLtOp)  	of (_,n) -> (SLIT("<#"),   n),
    case (primOpNameInfo IntLeOp)  	of (_,n) -> (SLIT("<=#"),  n),
    case (primOpNameInfo DoubleAddOp)   of (_,n) -> (SLIT("+##"),  n),
    case (primOpNameInfo DoubleSubOp)   of (_,n) -> (SLIT("-##"),  n),
    case (primOpNameInfo DoubleMulOp)   of (_,n) -> (SLIT("*##"),  n),
    case (primOpNameInfo DoubleDivOp)   of (_,n) -> (SLIT("/##"),  n),
    case (primOpNameInfo DoublePowerOp) of (_,n) -> (SLIT("**##"), n),
    case (primOpNameInfo DoubleGtOp)    of (_,n) -> (SLIT(">##"),  n),
    case (primOpNameInfo DoubleGeOp)    of (_,n) -> (SLIT(">=##"), n),
    case (primOpNameInfo DoubleEqOp)    of (_,n) -> (SLIT("==##"), n),
    case (primOpNameInfo DoubleNeOp)    of (_,n) -> (SLIT("/=##"), n),
    case (primOpNameInfo DoubleLtOp)    of (_,n) -> (SLIT("<##"),  n),
    case (primOpNameInfo DoubleLeOp)    of (_,n) -> (SLIT("<=##"), n)]

prim_tycons
  = [addrPrimTyCon,
     arrayPrimTyCon,
     byteArrayPrimTyCon,
     charPrimTyCon,
     doublePrimTyCon,
     floatPrimTyCon,
     intPrimTyCon,
     mallocPtrPrimTyCon,
     mutableArrayPrimTyCon,
     mutableByteArrayPrimTyCon,
     synchVarPrimTyCon,
     realWorldTyCon,
     stablePtrPrimTyCon,
     statePrimTyCon,
     wordPrimTyCon
    ]

std_tycon_list
  = let
	swizzle_over (mod, nm, key, arity, is_data)
	  = let
		fname = mkPreludeCoreName mod nm
	    in
	    (nm, PreludeTyCon key fname arity is_data)
    in
    map swizzle_over
	[--(pRELUDE_IO,	   SLIT("Request"),  requestTyConKey,  0, True),
--OLD:	 (pRELUDE_IO,	   SLIT("Response"), responseTyConKey, 0, True),
	 (pRELUDE_IO,	   SLIT("Dialogue"), dialogueTyConKey, 0, False),
	 (SLIT("PreludeMonadicIO"), SLIT("IO"), iOTyConKey,    1, False)
	]

-- Several of these are non-std, but they have non-std
-- names, so they won't get past the parser in user code
-- (but will be visible for interface-pragma purposes).

data_tycons
  = [addrTyCon,
     boolTyCon,
--   byteArrayTyCon,
     charTyCon,
     cmpTagTyCon,
     doubleTyCon,
     floatTyCon,
     intTyCon,
     integerTyCon,
     liftTyCon,
     mallocPtrTyCon,
--   mutableArrayTyCon,
--   mutableByteArrayTyCon,
     ratioTyCon,
     return2GMPsTyCon,
     returnIntAndGMPTyCon,
     stablePtrTyCon,
     stateAndAddrPrimTyCon,
     stateAndArrayPrimTyCon,
     stateAndByteArrayPrimTyCon,
     stateAndCharPrimTyCon,
     stateAndDoublePrimTyCon,
     stateAndFloatPrimTyCon,
     stateAndIntPrimTyCon,
     stateAndMallocPtrPrimTyCon,
     stateAndMutableArrayPrimTyCon,
     stateAndMutableByteArrayPrimTyCon,
     stateAndSynchVarPrimTyCon,
     stateAndPtrPrimTyCon,
     stateAndStablePtrPrimTyCon,
     stateAndWordPrimTyCon,
     stateTyCon,
     wordTyCon
#ifdef DPH
     ,podTyCon
#endif {- Data Parallel Haskell -}
    ]

synonym_tycons
  = [primIoTyCon,
     rationalTyCon,
     stTyCon,
     stringTyCon]

std_class_list
  = let
	swizzle_over (str, key)
	  = (str, PreludeClass key (mkPreludeCoreName pRELUDE_CORE str))
    in
    map swizzle_over
	[(SLIT("Eq"),		eqClassKey),
	 (SLIT("Ord"),		ordClassKey),
	 (SLIT("Num"),		numClassKey),
	 (SLIT("Real"),		realClassKey),
	 (SLIT("Integral"),	integralClassKey),
	 (SLIT("Fractional"),	fractionalClassKey),
	 (SLIT("Floating"),	floatingClassKey),
	 (SLIT("RealFrac"),	realFracClassKey),
	 (SLIT("RealFloat"),	realFloatClassKey),
	 (SLIT("Ix"),		ixClassKey),
	 (SLIT("Enum"),		enumClassKey),
	 (SLIT("Text"),		textClassKey),
	 (SLIT("_CCallable"),	cCallableClassKey),
	 (SLIT("_CReturnable"), cReturnableClassKey),
	 (SLIT("Binary"),	binaryClassKey)
#ifdef DPH
	 , (SLIT("Pid"),	pidClassKey)
	 , (SLIT("Processor"),processorClassKey)
#endif {- Data Parallel Haskell -}
	]

lots_of_primops
  = [	CharGtOp,
	CharGeOp,
	CharEqOp,
	CharNeOp,
	CharLtOp,
	CharLeOp,
	IntGtOp,
	IntGeOp,
	IntEqOp,
	IntNeOp,
	IntLtOp,
	IntLeOp,
	WordGtOp,
	WordGeOp,
	WordEqOp,
	WordNeOp,
	WordLtOp,
	WordLeOp,
	AddrGtOp,
	AddrGeOp,
	AddrEqOp,
	AddrNeOp,
	AddrLtOp,
	AddrLeOp,
	FloatGtOp,
	FloatGeOp,
	FloatEqOp,
	FloatNeOp,
	FloatLtOp,
	FloatLeOp,
	DoubleGtOp,
	DoubleGeOp,
	DoubleEqOp,
	DoubleNeOp,
	DoubleLtOp,
	DoubleLeOp,
	OrdOp,
	ChrOp,
	IntAddOp,
	IntSubOp,
	IntMulOp,
	IntQuotOp,
	IntDivOp,
	IntRemOp,
	IntNegOp,
	AndOp,
	OrOp,
	NotOp,
    	SllOp,
    	SraOp,
    	SrlOp,
    	ISllOp,
    	ISraOp,
    	ISrlOp,
	Int2WordOp,
	Word2IntOp,
	Int2AddrOp,
	Addr2IntOp,
	FloatAddOp,
	FloatSubOp,
	FloatMulOp,
	FloatDivOp,
	FloatNegOp,
	Float2IntOp,
	Int2FloatOp,
	FloatExpOp,
	FloatLogOp,
	FloatSqrtOp,
	FloatSinOp,
	FloatCosOp,
	FloatTanOp,
	FloatAsinOp,
	FloatAcosOp,
	FloatAtanOp,
	FloatSinhOp,
	FloatCoshOp,
	FloatTanhOp,
	FloatPowerOp,
	DoubleAddOp,
	DoubleSubOp,
	DoubleMulOp,
	DoubleDivOp,
	DoubleNegOp,
	Double2IntOp,
	Int2DoubleOp,
	Double2FloatOp,
	Float2DoubleOp,
	DoubleExpOp,
	DoubleLogOp,
	DoubleSqrtOp,
	DoubleSinOp,
	DoubleCosOp,
	DoubleTanOp,
	DoubleAsinOp,
	DoubleAcosOp,
	DoubleAtanOp,
	DoubleSinhOp,
	DoubleCoshOp,
	DoubleTanhOp,
	DoublePowerOp,
	IntegerAddOp,
	IntegerSubOp,
	IntegerMulOp,
	IntegerQuotRemOp,
	IntegerDivModOp,
	IntegerNegOp,
	IntegerCmpOp,
	Integer2IntOp,
	Int2IntegerOp,
	Word2IntegerOp,
	Addr2IntegerOp,
	FloatEncodeOp,
	FloatDecodeOp,
	DoubleEncodeOp,
	DoubleDecodeOp,
	NewArrayOp,
	NewByteArrayOp CharKind,
	NewByteArrayOp IntKind,
	NewByteArrayOp AddrKind,
	NewByteArrayOp FloatKind,
	NewByteArrayOp DoubleKind,
	SameMutableArrayOp,
	SameMutableByteArrayOp,
	ReadArrayOp,
	WriteArrayOp,
	IndexArrayOp,
	ReadByteArrayOp CharKind,
	ReadByteArrayOp IntKind,
	ReadByteArrayOp AddrKind,
	ReadByteArrayOp FloatKind,
	ReadByteArrayOp DoubleKind,
	WriteByteArrayOp CharKind,
	WriteByteArrayOp IntKind,
	WriteByteArrayOp AddrKind,
	WriteByteArrayOp FloatKind,
	WriteByteArrayOp DoubleKind,
	IndexByteArrayOp CharKind,
	IndexByteArrayOp IntKind,
	IndexByteArrayOp AddrKind,
	IndexByteArrayOp FloatKind,
	IndexByteArrayOp DoubleKind,
	IndexOffAddrOp CharKind,
	IndexOffAddrOp IntKind,
	IndexOffAddrOp AddrKind,
	IndexOffAddrOp FloatKind,
	IndexOffAddrOp DoubleKind,
	UnsafeFreezeArrayOp,
	UnsafeFreezeByteArrayOp,
    	NewSynchVarOp,
	ReadArrayOp,
	TakeMVarOp,
	PutMVarOp,
	ReadIVarOp,
	WriteIVarOp,
	MakeStablePtrOp,
	DeRefStablePtrOp,
	ReallyUnsafePtrEqualityOp,
	ErrorIOPrimOp,
#ifdef GRAN
	ParGlobalOp,
	ParLocalOp,
#endif {-GRAN-}
	SeqOp,
    	ParOp,
    	ForkOp,
	DelayOp,
	WaitOp
    ]
\end{code}

\begin{code}
readUnfoldingPrimOp :: FAST_STRING -> PrimOp

readUnfoldingPrimOp
  = let
	-- "reverse" lookup table
	tbl = map (\ o -> let { (str,_) = primOpNameInfo o } in (str, o)) lots_of_primops
    in
    \ str -> case [ op | (s, op) <- tbl, s == str ] of
	       (op:_) -> op
#ifdef DEBUG
	       [] -> panic "readUnfoldingPrimOp" -- ++ _UNPK_ str ++"::"++show (map fst tbl))
#endif
\end{code}

Make table entries for various things:
\begin{code}
pcTyConNameInfo :: TyCon -> (FAST_STRING, Name)
pcTyConNameInfo tycon
  = (getOccurrenceName tycon, WiredInTyCon tycon)

pcDataConNameInfo :: TyCon -> [(FAST_STRING, Name)]
pcDataConNameInfo tycon
  = -- slurp out its data constructors...
    [(getOccurrenceName con, WiredInVal con) | con <- getTyConDataCons tycon]
\end{code}