This repository has been archived by the owner on Dec 19, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathhal.c
817 lines (705 loc) · 22.3 KB
/
hal.c
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
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
/****************************************************************************\
Copyright (c) 2002, NVIDIA Corporation.
NVIDIA Corporation("NVIDIA") supplies this software to you in
consideration of your agreement to the following terms, and your use,
installation, modification or redistribution of this NVIDIA software
constitutes acceptance of these terms. If you do not agree with these
terms, please do not use, install, modify or redistribute this NVIDIA
software.
In consideration of your agreement to abide by the following terms, and
subject to these terms, NVIDIA grants you a personal, non-exclusive
license, under NVIDIA's copyrights in this original NVIDIA software (the
"NVIDIA Software"), to use, reproduce, modify and redistribute the
NVIDIA Software, with or without modifications, in source and/or binary
forms; provided that if you redistribute the NVIDIA Software, you must
retain the copyright notice of NVIDIA, this notice and the following
text and disclaimers in all such redistributions of the NVIDIA Software.
Neither the name, trademarks, service marks nor logos of NVIDIA
Corporation may be used to endorse or promote products derived from the
NVIDIA Software without specific prior written permission from NVIDIA.
Except as expressly stated in this notice, no other rights or licenses
express or implied, are granted by NVIDIA herein, including but not
limited to any patent rights that may be infringed by your derivative
works or by other works in which the NVIDIA Software may be
incorporated. No hardware is licensed hereunder.
THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT
WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED,
INCLUDING WITHOUT LIMITATION, WARRANTIES OR CONDITIONS OF TITLE,
NON-INFRINGEMENT, MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
ITS USE AND OPERATION EITHER ALONE OR IN COMBINATION WITH OTHER
PRODUCTS.
IN NO EVENT SHALL NVIDIA BE LIABLE FOR ANY SPECIAL, INDIRECT,
INCIDENTAL, EXEMPLARY, CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
TO, LOST PROFITS; PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) OR ARISING IN ANY WAY
OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE
NVIDIA SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT,
TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF
NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\****************************************************************************/
//
// hal.c
//
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "slglobals.h"
static void InitHAL_HAL(slHAL *);
static int GetCapsBit_HAL(int bitNumber);
static int GetConnectorUses_HAL(int cid, int pid);
static int GetConnectorRegister_HAL(int cid, int ByIndex, int ratom, Binding *fBind);
static int GetFloatSuffixBase_HAL(SourceLoc *loc, int suffix);
static int GetSizeof_HAL(Type *fType);
static int GetAlignment_HAL(Type *fType);
static int CheckDeclarators_HAL(SourceLoc *loc, const dtype *fDtype);
static int CheckDefinition_HAL(SourceLoc *loc, int name, const Type *fType);
static int CheckStatement_HAL(SourceLoc *loc, stmt *fstmt);
static int CheckInternalFunction_HAL(Symbol *fSymb, int *group);
static int IsNumericBase_HAL(int fBase);
static int IsIntegralBase_HAL(int fBase);
static int IsTexobjBase_HAL(int fBase);
static int IsValidRuntimeBase_HAL(int fBase);
static int IsValidScalarCast_HAL(int toBase, int fromBase, int Explicit);
static int IsValidOperator_HAL(SourceLoc *loc, int name, int op, int suobp);
static int GetBinOpBase_HAL(int lop, int lbase, int rbase, int llen, int rlen);
static int ConvertConstant_HAL(const scalar_constant *fval, int fbase, int tbase,
expr **fexpr);
static int BindUniformUnbound_HAL(SourceLoc *loc, Symbol *fSymb, Binding *lBind);
static int BindUniformPragma_HAL(SourceLoc *loc, Symbol *fSymb, Binding *lBind,
const Binding *fBind);
static int BindVaryingSemantic_HAL(SourceLoc *loc, Symbol *fSymb, int semantic,
Binding *fBind, int IsOutVal);
static int BindVaryingPragma_HAL(SourceLoc *loc, Symbol *fSymb, Binding *lBind,
const Binding *fBind, int IsOutVal);
static int BindVaryingUnbound_HAL(SourceLoc *loc, Symbol *fSymb, int name, int connector,
Binding *fBind, int IsOutVal);
static int PrintCodeHeader_HAL(FILE *out);
static int GenerateCode_HAL(SourceLoc *loc, Scope *fScope, Symbol *program);
///////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////// Profile Manager: //////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
/*
* RegisterProfile() - Add a profile to the list of available profiles.
*
*/
slProfile *RegisterProfile(int (*InitHAL)(slHAL *), const char *name, int id)
{
slProfile *lProfile;
lProfile = (slProfile *) malloc(sizeof(slProfile));
lProfile->next = Cg->allProfiles;
lProfile->InitHAL = InitHAL;
lProfile->name = AddAtom(atable, name);
lProfile->id = id;
Cg->allProfiles = lProfile;
return lProfile;
} // RegisterProfile
/*
* EnumerateProfiles()
*
*/
slProfile *EnumerateProfiles(int index)
{
slProfile *lProfile;
lProfile = Cg->allProfiles;
while (index-- > 0 && lProfile)
lProfile = lProfile->next;
return lProfile;
} // EnumerateProfiles
///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////// Default Language HAL ////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////
/*
* InitHAL()
*
*/
int InitHAL(const char *profileName, const char *entryName)
{
slProfile *lProfile;
int result;
Cg->theHAL = (slHAL *) malloc(sizeof(slHAL));
InitHAL_HAL(Cg->theHAL);
Cg->theHAL->profileName = AddAtom(atable, profileName);
Cg->theHAL->entryName = AddAtom(atable, entryName);
lProfile = Cg->allProfiles;
while (lProfile) {
if (Cg->theHAL->profileName == lProfile->name) {
Cg->theHAL->InitHAL = lProfile->InitHAL;
Cg->theHAL->pid = lProfile->id;
result = Cg->theHAL->InitHAL(Cg->theHAL);
return result;
}
lProfile = lProfile->next;
}
printf(OPENSL_TAG ": unknown profile \"%s\".\n", profileName);
return 0;
} // InitHAL
/*
* InitHAL_HAL();
*
*/
static void InitHAL_HAL(slHAL *fHAL)
{
// Initialize default function members:
fHAL->InitHAL = NULL;
fHAL->FreeHAL = NULL;
fHAL->RegisterNames = NULL;
fHAL->GetCapsBit = GetCapsBit_HAL;
fHAL->GetConnectorID = NULL;
fHAL->GetConnectorAtom = NULL;
fHAL->GetConnectorUses = GetConnectorUses_HAL;
fHAL->GetConnectorRegister = GetConnectorRegister_HAL;
fHAL->GetFloatSuffixBase = GetFloatSuffixBase_HAL;
fHAL->GetSizeof = GetSizeof_HAL;
fHAL->GetAlignment = GetAlignment_HAL;
fHAL->CheckDeclarators = CheckDeclarators_HAL;
fHAL->CheckDefinition = CheckDefinition_HAL;
fHAL->CheckStatement = CheckStatement_HAL;
fHAL->CheckInternalFunction = CheckInternalFunction_HAL;
fHAL->IsNumericBase = IsNumericBase_HAL;
fHAL->IsTexobjBase = IsTexobjBase_HAL;
fHAL->IsIntegralBase = IsIntegralBase_HAL;
fHAL->IsValidRuntimeBase = IsValidRuntimeBase_HAL;
fHAL->IsValidScalarCast = IsValidScalarCast_HAL;
fHAL->IsValidOperator = IsValidOperator_HAL;
fHAL->GetBinOpBase = GetBinOpBase_HAL;
fHAL->ConvertConstant = ConvertConstant_HAL;
fHAL->BindUniformUnbound = BindUniformUnbound_HAL;
fHAL->BindUniformPragma = BindUniformPragma_HAL;
fHAL->BindVaryingSemantic = BindVaryingSemantic_HAL;
fHAL->BindVaryingPragma = BindVaryingPragma_HAL;
fHAL->BindVaryingUnbound = BindVaryingUnbound_HAL;
fHAL->PrintCodeHeader = PrintCodeHeader_HAL;
fHAL->GenerateCode = GenerateCode_HAL;
// Initialize default data members:
// Defined when profile is registered:
fHAL->vendor = "None";
fHAL->version = "0.0";
fHAL->profileName = 0;
fHAL->pid = 0;
fHAL->entryName = 0;
fHAL->semantics = NULL;
fHAL->numSemantics = 0;
fHAL->incid = CID_NONE_ID;
fHAL->inputCRegs = NULL;
fHAL->numInputCRegs = 0;
fHAL->nextUnboundVinReg = 0;
fHAL->lastUnboundVinReg = -1;
fHAL->outcid = CID_NONE_ID;
fHAL->outputCRegs = NULL;
fHAL->numOutputCRegs = 0;
fHAL->nextUnboundVoutReg = 0;
fHAL->lastUnboundVoutReg = -1;
// Defined by compiler front end:
fHAL->globalScope = NULL;
fHAL->varyingIn = NULL;
fHAL->varyingOut = NULL;
fHAL->uniformParam = NULL;
fHAL->uniformGlobal = NULL;
fHAL->uniforms = NULL;
fHAL->constantBindings = NULL;
fHAL->defaultBindings = NULL;
// Define default comment start string:
fHAL->comment = "#";
// Pointer to profile specific struct:
fHAL->localData = NULL;
} // InitHAL_HAL
/*
* AddConstantBinding() - Add a constant binding to the program.
*
*/
void AddConstantBinding(Binding *fBind)
{
BindingList *lBindList, *nBindList;
nBindList = (BindingList *) malloc(sizeof(BindingList));
nBindList->next = NULL;
nBindList->binding = fBind;
lBindList = Cg->theHAL->constantBindings;
if (lBindList) {
while (lBindList->next)
lBindList = lBindList->next;
lBindList->next = nBindList;
} else {
Cg->theHAL->constantBindings = nBindList;
}
} // AddConstantBinding
/*
* AddDefaultBinding() - Add a default binding to the program.
*
*/
void AddDefaultBinding(Binding *fBind)
{
BindingList *lBindList, *nBindList;
nBindList = (BindingList *) malloc(sizeof(BindingList));
nBindList->next = NULL;
nBindList->binding = fBind;
lBindList = Cg->theHAL->defaultBindings;
if (lBindList) {
while (lBindList->next)
lBindList = lBindList->next;
lBindList->next = nBindList;
} else {
Cg->theHAL->defaultBindings = nBindList;
}
} // AddDefaultBinding
/*
* LookupConnectorHAL() - Lookup a connector descriptor by cid.
*
*/
ConnectorDescriptor *LookupConnectorHAL(ConnectorDescriptor *connectors, int cid, int num)
{
int ii;
for (ii = 0; ii < num; ii++) {
if (cid == connectors[ii].cid)
return &connectors[ii];
}
return NULL;
} // LookupConnectorHAL
/*
* SetSymbolConnectorBindingHAL()
*
*/
void SetSymbolConnectorBindingHAL(Binding *fBind, ConnectorRegisters *fConn)
{
BindingConnector *tBind;
tBind = &fBind->conn;
tBind->properties = BIND_IS_BOUND;
tBind->kind = BK_CONNECTOR;
if (fConn->properties & REG_WRITE_REQUIRED)
tBind->properties |= BIND_WRITE_REQUIRED;
// tBind->gname set elsewhere
// tBind->lname set elsewhere
tBind->base = fConn->base;
tBind->size = fConn->size;
tBind->rname = fConn->name;
tBind->regno = fConn->regno;
} // SetSymbolConnectorBindingHAL
/*
* GetCapsBit_HAL() - Return an integer value representing the capabilities of this profile.
*
*/
static int GetCapsBit_HAL(int bitNumber)
{
return 0;
} // GetCapsBit_HAL
/*
* GetConnectorUses_HAL() - Return a connectors capabilities for this profile.
*
*/
static int GetConnectorUses_HAL(int cid, int pid)
{
return CONNECTOR_IS_USELESS;
} // GetConnectorUses_HAL
/*
* GetConnectorRegister_HAL() - Return the hw register number for "ratom" in connector "cid".
*
*/
static int GetConnectorRegister_HAL(int cid, int ByIndex, int ratom, Binding *fBind)
{
return 0;
} // GetConnectorRegister_HAL
/*
* GetFloatSuffixBase_HAL() - Check for profile-specific limitations of floating point
* suffixes and return the base for this suffix.
*
*/
static int GetFloatSuffixBase_HAL(SourceLoc *loc, int suffix)
{
switch (suffix) {
case ' ':
return TYPE_BASE_CFLOAT;
case 'f':
return TYPE_BASE_FLOAT;
default:
SemanticError(loc, ERROR_C_UNSUPPORTED_FP_SUFFIX, suffix);
return TYPE_BASE_UNDEFINED_TYPE;
}
} // GetFloatSuffixBase_HAL
/*
* GetSizeof_HAL() - Return a profile specific size for this scalar, vector, or matrix type.
* Used for defining struct member offsets for use by code generator.
*/
static int GetSizeof_HAL(Type *fType)
{
int category, size, alignment, len, len2;
if (fType) {
category = GetCategory(fType);
switch (category) {
case TYPE_CATEGORY_SCALAR:
case TYPE_CATEGORY_STRUCT:
case TYPE_CATEGORY_CONNECTOR:
size = fType->co.size;
break;
case TYPE_CATEGORY_ARRAY:
if (IsVector(fType, &len)) {
size = len;
} else if (IsMatrix(fType, &len, &len2)) {
if (len2 > len) {
size = len*4;
} else {
size = len2*4;
}
} else {
size = Cg->theHAL->GetSizeof(fType->arr.eltype);
alignment = Cg->theHAL->GetAlignment(fType->arr.eltype);
size = ((size + alignment - 1)/alignment)*alignment*fType->arr.numels;
}
break;
case TYPE_CATEGORY_FUNCTION:
default:
size = 0;
break;
}
} else {
size = 0;
}
return size;
} // GetSizeof_HAL
/*
* GetAlignment_HAL() - Return a profile specific alignment for this type.
* Used for defining struct member offsets for use by code generator.
*/
static int GetAlignment_HAL(Type *fType)
{
int category, alignment;
if (fType) {
if (Cg->theHAL->IsTexobjBase(GetBase(fType))) {
alignment = 4;
} else {
category = GetCategory(fType);
switch (category) {
case TYPE_CATEGORY_SCALAR:
alignment = 4;
break;
case TYPE_CATEGORY_STRUCT:
case TYPE_CATEGORY_ARRAY:
alignment = 4;
break;
case TYPE_CATEGORY_FUNCTION:
default:
alignment = 1;
break;
}
}
} else {
alignment = 1;
}
return alignment;
} // GetAlignment_HAL
/*
* CheckDeclarators_HAL() - Check for profile-specific limitations of declarators.
*
*/
static int CheckDeclarators_HAL(SourceLoc *loc, const dtype *fDtype)
{
int numdims = 0;
const Type *lType;
lType = &fDtype->type;
while (GetCategory(lType) == TYPE_CATEGORY_ARRAY) {
if (lType->arr.numels == 0 && numdims > 0) {
SemanticError(loc, ERROR___LOW_DIM_UNSPECIFIED);
return 0;
}
if (lType->arr.numels > 4 && IsPacked(lType)) {
SemanticError(loc, ERROR___PACKED_DIM_EXCEEDS_4);
return 0;
}
lType = lType->arr.eltype;
numdims++;
}
if (numdims > 3) {
SemanticError(loc, ERROR___NUM_DIMS_EXCEEDS_3);
return 0;
}
return 1;
} // CheckDeclarators_HAL
/*
* CheckDefinition_HAL() - Check for profile-specific statement limitations.
*
*/
static int CheckDefinition_HAL(SourceLoc *loc, int name, const Type *fType)
{
return 1;
} // CheckDefinition_HAL
/*
* CheckStatement_HAL() - Check for profile-specific limitations of statements.
*
*/
static int CheckStatement_HAL(SourceLoc *loc, stmt *fstmt)
{
return 1;
} // CheckStatement_HAL
/*
* CheckInternalFunction_HAL() - Check for profile-specific internally implemented function.
*
*/
static int CheckInternalFunction_HAL(Symbol *fSymb, int *group)
{
return 0;
} // CheckInternalFunction_HAL
/*
* IsValidScalarCast_HAL() - Is it valid to typecast a scalar from fromBase to toBase?.
*
*/
static int IsValidScalarCast_HAL(int toBase, int fromBase, int Explicit)
{
int answer;
switch (toBase) {
case TYPE_BASE_BOOLEAN:
case TYPE_BASE_FLOAT:
case TYPE_BASE_INT:
switch (fromBase) {
case TYPE_BASE_CFLOAT:
case TYPE_BASE_CINT:
case TYPE_BASE_FLOAT:
case TYPE_BASE_INT:
answer = 1;
break;
case TYPE_BASE_BOOLEAN:
answer = (toBase == TYPE_BASE_BOOLEAN) || Explicit;
break;
default:
answer = 0;
break;
}
break;
case TYPE_BASE_CFLOAT:
case TYPE_BASE_CINT:
default:
answer = 0;
break;
}
return answer;
} // IsValidScalarCast_HAL
/*
* IsValidOperator_HAL() - Is this operator supported in this profile? Print an error is not.
*
*/
static int IsValidOperator_HAL(SourceLoc *loc, int name, int op, int suobp)
{
switch (op) {
default:
return 1;
}
} // IsValidOperator_HAL
/*
* IsNumericBase_HAL() - Is fBase a numeric type?
*
*/
static int IsNumericBase_HAL(int fBase)
{
int answer;
switch (fBase) {
case TYPE_BASE_CFLOAT:
case TYPE_BASE_CINT:
case TYPE_BASE_FLOAT:
case TYPE_BASE_INT:
answer = 1;
break;
default:
answer = 0;
break;
}
return answer;
} // IsNumericBase_HAL
/*
* IsIntegralBase_HAL() - Is fBase an integral type?
*
*/
static int IsIntegralBase_HAL(int fBase)
{
int answer;
switch (fBase) {
case TYPE_BASE_CINT:
case TYPE_BASE_INT:
answer = 1;
break;
default:
answer = 0;
break;
}
return answer;
} // IsIntegralBase_HAL
/*
* IsTexobjBase_HAL() - Is fBase a texture object type?
*
*/
static int IsTexobjBase_HAL(int fBase)
{
return 0;
} // IsTexobjBase_HAL
/*
* IsValidRuntimeBase_HAL() - Are runtime variables with a base of fBase supported?
* In other words, can a non-const variable of this base be declared in this profile?
*
*/
static int IsValidRuntimeBase_HAL(int fBase)
{
int answer;
switch (fBase) {
case TYPE_BASE_FLOAT:
answer = 1;
break;
default:
answer = 0;
break;
}
return answer;
} // IsIntegralBase_HAL
/*
* GetBinOpBase_HAL() - Return the base type for this binary operation.
*
*/
static int GetBinOpBase_HAL(int lop, int lbase, int rbase, int llen, int rlen)
{
int result;
switch (lop) {
case VECTOR_V_OP:
case MUL_OP:
case DIV_OP:
case MOD_OP:
case ADD_OP:
case SUB_OP:
case SHL_OP:
case SHR_OP:
case LT_OP:
case GT_OP:
case LE_OP:
case GE_OP:
case EQ_OP:
case NE_OP:
case AND_OP:
case XOR_OP:
case OR_OP:
case COND_OP:
if (lbase == rbase) {
result = lbase;
} else if (lbase == TYPE_BASE_FLOAT || rbase == TYPE_BASE_FLOAT) {
result = TYPE_BASE_FLOAT;
} else if (lbase == TYPE_BASE_CFLOAT || rbase == TYPE_BASE_CFLOAT) {
if (lbase == TYPE_BASE_INT || rbase == TYPE_BASE_INT) {
result = TYPE_BASE_FLOAT;
} else {
result = TYPE_BASE_CFLOAT;
}
} else {
result = TYPE_BASE_INT;
}
break;
default:
result = TYPE_BASE_NO_TYPE;
break;
};
return result;
} // GetBinOpBase_HAL
/*
* ConvertConstant()_HAL - Convert a numeric scalar constant from one base type to another.
*
*/
static int ConvertConstant_HAL(const scalar_constant *fval, int fbase, int tbase, expr **fexpr)
{
expr *lexpr = NULL;
switch (fbase) {
case TYPE_BASE_CFLOAT:
case TYPE_BASE_FLOAT:
switch (tbase) {
case TYPE_BASE_CFLOAT:
case TYPE_BASE_FLOAT:
lexpr = (expr *) NewFConstNode(FCONST_OP, fval->f, tbase);
*fexpr = lexpr;
break;
case TYPE_BASE_CINT:
case TYPE_BASE_INT:
lexpr = (expr *) NewIConstNode(ICONST_OP, (int) fval->f, tbase);
*fexpr = lexpr;
break;
default:
return 0;
}
break;
case TYPE_BASE_CINT:
case TYPE_BASE_INT:
switch (tbase) {
case TYPE_BASE_CFLOAT:
case TYPE_BASE_FLOAT:
lexpr = (expr *) NewFConstNode(FCONST_OP, (float) fval->i, tbase);
*fexpr = lexpr;
break;
case TYPE_BASE_CINT:
case TYPE_BASE_INT:
lexpr = (expr *) NewIConstNode(ICONST_OP, fval->i, tbase);
*fexpr = lexpr;
break;
default:
return 0;
}
break;
default:
return 0;
}
return 1;
} // ConvertConstant_HAL
/*
* BindUniformUnbound_HAL() - Bind an unbound variable to a free uniform resource.
*
*/
static int BindUniformUnbound_HAL(SourceLoc *loc, Symbol *fSymb, Binding *lBind)
{
return 0;
} // BindUniformUnbound_HAL
/*
* BindUniformPragma_HAL() - Bind a variable to a uniform resource based on a #pragma bind.
*
*/
static int BindUniformPragma_HAL(SourceLoc *loc, Symbol *fSymb, Binding *lBind,
const Binding *fBind)
{
return 0;
} // BindUniformPragma_HAL
/*
* BindVaryingSemantic_HAL() - Bind a variable to a specific varying semantic.
*
*/
static int BindVaryingSemantic_HAL(SourceLoc *loc, Symbol *fSymb, int semantic,
Binding *fBind, int IsOutVal)
{
return 0;
} // BindVaryingSemantic_HAL
/*
* BindVaryingPragma_HAL() - Bind a variable to a varying resource based on a #pragma bind.
*
*/
static int BindVaryingPragma_HAL(SourceLoc *loc, Symbol *fSymb, Binding *lBind,
const Binding *fBind, int IsOutVal)
{
return 0;
} // BindVaryingPragma_HAL
/*
* BindVaryingUnbound_HAL() - Bind a variable with no binding information to a varying resource.
*
*/
static int BindVaryingUnbound_HAL(SourceLoc *loc, Symbol *fSymb, int name, int connector,
Binding *fBind, int IsOutVal)
{
return 0;
} // BindVaryingUnbound_HAL
/*
* PrintCodeHeader_HAL() - Dummy header output.
*
*/
static int PrintCodeHeader_HAL(FILE *out)
{
InternalError(Cg->tokenLoc, ERROR_S_NO_CODE_HEADER, GetAtomString(atable, Cg->theHAL->profileName));
return 1;
} // PrintCodeHeader_HAL
/*
* GenerateCode_HAL() - Dummy code generator.
*
*/
static int GenerateCode_HAL(SourceLoc *loc, Scope *fScope, Symbol *program)
{
InternalError(Cg->tokenLoc, ERROR_S_NO_CODE_GENERATOR, GetAtomString(atable, Cg->theHAL->profileName));
return 1;
} // GenerateCode_HAL
///////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////// End of hal.c ////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////