-
Notifications
You must be signed in to change notification settings - Fork 392
/
OMRILOps.hpp
1463 lines (1341 loc) · 57.7 KB
/
OMRILOps.hpp
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
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*******************************************************************************
* Copyright (c) 2000, 2021 IBM Corp. and others
*
* This program and the accompanying materials are made available under
* the terms of the Eclipse Public License 2.0 which accompanies this
* distribution and is available at http://eclipse.org/legal/epl-2.0
* or the Apache License, Version 2.0 which accompanies this distribution
* and is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License, v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception [1] and GNU General Public
* License, version 2 with the OpenJDK Assembly Exception [2].
*
* [1] https://www.gnu.org/software/classpath/license.html
* [2] http://openjdk.java.net/legal/assembly-exception.html
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception
*******************************************************************************/
#ifndef OMR_ILOPS_INCL
#define OMR_ILOPS_INCL
#include <stdint.h>
#include "il/DataTypes.hpp"
#include "il/ILHelpers.hpp"
#include "il/ILOpCodes.hpp"
#include "il/ILProps.hpp"
#include "infra/Assert.hpp"
#include "infra/Flags.hpp"
namespace TR { class SymbolReference; }
namespace OMR
{
/**
* Opcode properties.
*/
struct OpCodeProperties
{
TR::ILOpCodes opcode; ///< Enum value. In the _opCodeProperties table, every entry
///< must be in the same position as its enum entry value.
char const * name; ///< Opcode Name
/**
* Opcode properties
*/
uint32_t properties1; // These should be flags32_t, but gcc becomes too slow
uint32_t properties2; // at compiling the big table in IlOps.cpp trying to inline
uint32_t properties3; // all those trivial flags32_t constructor calls
uint32_t properties4;
TR::DataType dataType;
uint32_t typeProperties;
TR::ILChildPropType childTypes;
TR::ILOpCodes swapChildrenOpCode;
TR::ILOpCodes reverseBranchOpCode;
TR::ILOpCodes booleanCompareOpCode;
TR::ILOpCodes ifCompareOpCode;
};
/**
* ILOpCode largely consists of a query interface to
* ask questions about TR IL Opcodes.
*/
class ILOpCode
{
public:
// Deprecate?
ILOpCode()
: _opCode(TR::BadILOp)
{}
ILOpCode(TR::ILOpCodes opCode)
: _opCode(opCode)
{
TR_ASSERT(opCode <= TR::LastTROp, "assertion failure");
}
TR::ILOpCodes getOpCodeValue() const { return (TR::ILOpCodes)_opCode; }
TR::ILOpCodes setOpCodeValue(TR::ILOpCodes op) { TR_ASSERT(op <= TR::LastTROp, "assertion failure"); return (TR::ILOpCodes) (_opCode = op); }
/// Get the opcode to be used if the children of this opcode are swapped.
/// e.g. ificmplt --> ificmpgt
TR::ILOpCodes getOpCodeForSwapChildren() const
{ return _opCodeProperties[_opCode].swapChildrenOpCode; }
/// Get the opcode to be used if the sense of this (compare) opcode is reversed.
/// e.g. ificmplt --> ificmpge
TR::ILOpCodes getOpCodeForReverseBranch() const
{ return _opCodeProperties[_opCode].reverseBranchOpCode; }
/// Get the boolean compare opcode that corresponds to this compare-and-branch
/// opcode.
/// e.g. ificmplt --> icmplt
TR::ILOpCodes convertIfCmpToCmp()
{ return _opCodeProperties[_opCode].booleanCompareOpCode; }
/// Get the compare-and-branch opcode that corresponds to this boolean compare
///e.g. icmplt --> ificmplt
TR::ILOpCodes convertCmpToIfCmp()
{ return _opCodeProperties[_opCode].ifCompareOpCode; }
TR::DataType getDataType() const { return _opCodeProperties[_opCode].dataType; }
static TR::DataType getDataType(TR::ILOpCodes op) { return _opCodeProperties[op].dataType; }
TR::DataType getType() const { return _opCodeProperties[_opCode].dataType; }
static TR::DataType getType(TR::ILOpCodes op) { return _opCodeProperties[op].dataType; }
const char *getName() const { return _opCodeProperties[_opCode].name; }
// Query Functions
uint32_t getSize() const { return typeProperties().getValue(ILTypeProp::Size_Mask); }
static uint32_t getSize(TR::ILOpCodes op) { return ILOpCode(op).getSize(); }
/**
* ILTypeProp
*/
bool isVoid() const { return typeProperties().getValue() == 0; }
bool isByte() const { return (typeProperties().testAny(ILTypeProp::Integer | ILTypeProp::Unsigned) && typeProperties().testAll(ILTypeProp::Size_1)); }
bool isShort() const { return (typeProperties().testAny(ILTypeProp::Integer | ILTypeProp::Unsigned) && typeProperties().testAll(ILTypeProp::Size_2)); }
bool isInt() const { return (typeProperties().testAny(ILTypeProp::Integer | ILTypeProp::Unsigned) && typeProperties().testAll(ILTypeProp::Size_4)); }
bool isLong() const { return (typeProperties().testAny(ILTypeProp::Integer | ILTypeProp::Unsigned) && typeProperties().testAll(ILTypeProp::Size_8)); }
bool isRef() const { return typeProperties().testAny(ILTypeProp::Address); }
bool isFloat() const { return typeProperties().testAll(ILTypeProp::Floating_Point | ILTypeProp::Size_4); }
bool isDouble() const { return typeProperties().testAll(ILTypeProp::Floating_Point | ILTypeProp::Size_8); }
bool isInteger() const { return typeProperties().testAny(ILTypeProp::Integer); }
bool isUnsigned() const { return typeProperties().testAny(ILTypeProp::Unsigned); }
bool isUnsignedConversion() const { return isUnsigned() && isConversion(); }
bool isFloatingPoint() const { return typeProperties().testAny(ILTypeProp::Floating_Point); }
bool isVector() const { return typeProperties().testAny(ILTypeProp::Vector); }
bool isIntegerOrAddress() const { return typeProperties().testAny(ILTypeProp::Integer | ILTypeProp::Address); }
bool is1Byte() const { return typeProperties().testAny(ILTypeProp::Size_1); }
bool is2Byte() const { return typeProperties().testAny(ILTypeProp::Size_2); }
bool is4Byte() const { return typeProperties().testAny(ILTypeProp::Size_4); }
bool is8Byte() const { return typeProperties().testAny(ILTypeProp::Size_8); }
bool is16Byte() const { return typeProperties().testAny(ILTypeProp::Size_16); }
bool is32Byte() const { return typeProperties().testAny(ILTypeProp::Size_32); }
/**
* Opcode does not explicitly encode datatype in the property. Nodes with
* this flag must determine datatype from other means such as children,
* symrefs, etc.
*/
bool hasNoDataType() const { return typeProperties().testAny(ILTypeProp::HasNoDataType); }
/**
* ILChildProp
*/
uint32_t expectedChildCount() const { return GET_CHILD_COUNT(childProperties()); }
TR::DataTypes expectedChildType(uint32_t childIndex) const { return GET_CHILD_TYPE(childIndex, childProperties()); }
bool canHaveGlRegDeps() const { return getOpCodeValue() == TR::BBStart || getOpCodeValue() == TR::BBEnd || isCall() || isBranch(); }
/**
* ILProp1
*/
bool isCommutative() const { return properties1().testAny(ILProp1::Commutative); }
bool isAssociative() const { return properties1().testAny(ILProp1::Associative); }
bool isConversion() const { return properties1().testAny(ILProp1::Conversion); }
bool isAdd() const { return properties1().testAny(ILProp1::Add); }
bool isSub() const { return properties1().testAny(ILProp1::Sub); }
bool isMul() const { return properties1().testAny(ILProp1::Mul); }
bool isDiv() const { return properties1().testAny(ILProp1::Div); }
bool isRem() const { return properties1().testAny(ILProp1::Rem); }
bool isLeftShift() const { return properties1().testAny(ILProp1::LeftShift); }
bool isRightShift() const { return properties1().testAny(ILProp1::RightShift); }
bool isShift() const { return properties1().testAny(ILProp1::LeftShift | ILProp1::RightShift); }
bool isShiftLogical() const { return properties1().testAny(ILProp1::ShiftLogical); }
bool isBooleanCompare() const { return properties1().testAny(ILProp1::BooleanCompare); }
bool isBranch() const { return properties1().testAny(ILProp1::Branch); }
bool isCompBranchOnly() const { return properties1().testAny(ILProp1::CompBranchOnly); }
bool isIf() const { return properties1().testAll(ILProp1::BooleanCompare | ILProp1::Branch) && !isCompBranchOnly(); }
bool isGoto() const { return properties1().testAll(ILProp1::Branch | ILProp1::TreeTop) && !isCompBranchOnly() && !isIf(); }
bool isIndirect() const { return properties1().testAny(ILProp1::Indirect); }
bool isLoadVar() const { return properties1().testAny(ILProp1::LoadVar); }
bool isLoadConst() const { return properties1().testAny(ILProp1::LoadConst); }
bool isLoad() const { return properties1().testAny(ILProp1::Load); }
bool isLoadVarDirect() const { return properties1().testValue(ILProp1::Indirect | ILProp1::LoadVar, ILProp1::LoadVar); }
bool isLoadDirect() const { return isLoad() && !isIndirect(); }
bool isLoadIndirect() const { return properties1().testAll(ILProp1::Indirect | ILProp1::LoadVar); }
bool isStore() const { return properties1().testAny(ILProp1::Store); }
bool isStoreDirect() const { return properties1().testValue(ILProp1::Indirect | ILProp1::Store, ILProp1::Store); }
bool isStoreIndirect() const { return properties1().testAll(ILProp1::Indirect | ILProp1::Store); }
bool isLoadVarOrStore() const { return properties1().testAny((ILProp1::Store | ILProp1::LoadVar)); }
bool isLoadReg() const { return properties1().testAny(ILProp1::LoadReg); }
bool isStoreReg() const { return properties1().testAny(ILProp1::StoreReg); }
bool isLoadDirectOrReg() const { return isLoadDirect() || isLoadReg(); }
bool isStoreDirectOrReg() const { return isStoreDirect() || isStoreReg(); }
bool isIntegralLoadVar() const { return isLoadVar() && getType().isIntegral(); }
bool isIntegralConst() const { return isLoadConst() && getType().isIntegral(); }
bool isAnd() const { return properties1().testAny(ILProp1::And); }
bool isOr() const { return properties1().testAny(ILProp1::Or); }
bool isXor() const { return properties1().testAny(ILProp1::Xor); }
bool isNeg() const { return properties1().testAny(ILProp1::Neg); }
bool isBitwiseLogical() const { return isAnd() || isXor() || isOr(); }
bool isReturn() const { return properties1().testAny(ILProp1::Return); }
bool isCall() const { return properties1().testAny(ILProp1::Call); }
bool isCallDirect() const { return properties1().testValue(ILProp1::Indirect | ILProp1::Call, ILProp1::Call); }
bool isCallIndirect() const { return properties1().testAll(ILProp1::Call | ILProp1::Indirect); }
/**
* @brief This query must return true for any opcode that may appear at the
* top of a tree (i.e., any node that a `TR::TreeTop` points to). For
* example, a store opcode would return true because it may appear under
* a TR::TreeTop, even though it might also appear as a child of a NULLCHK
* node in another circumstance.
*/
bool isTreeTop() const { return properties1().testAny(ILProp1::TreeTop); }
bool hasSymbolReference() const { return properties1().testAny(ILProp1::HasSymbolRef); }
bool isMemoryReference() const { return properties1().testAll(ILProp1::HasSymbolRef | ILProp1::LoadVar); }
bool isSwitch() const { return properties1().testAny(ILProp1::Switch); }
/**
* ILProp2
*/
bool mustBeLowered() const { return properties2().testAny(ILProp2::MustBeLowered); }
bool canShareValueNumber() const { return properties2().testAny(ILProp2::ValueNumberShare); }
bool isWrtBar() const { return properties2().testAny(ILProp2::WriteBarrierStore); }
bool isReadBar() const { return properties2().testAny(ILProp2::ReadBarrierLoad); }
bool canRaiseException() const { return properties2().testAny(ILProp2::CanRaiseException); }
bool isCheck() const { return properties2().testAny(ILProp2::Check); }
bool isNullCheck() const { return properties2().testAny(ILProp2::NullCheck); }
bool isResolveCheck() const { return properties2().testAny(ILProp2::ResolveCheck); }
bool isResolveOrNullCheck() const { return properties2().testAny(ILProp2::ResolveCheck | ILProp2::NullCheck); }
bool isBndCheck() const { return properties2().testAny(ILProp2::BndCheck); }
bool isCheckCast() const { return properties2().testAny(ILProp2::CheckCast); }
bool isCheckCastOrNullCheck() const { return properties2().testAny(ILProp2::CheckCast | ILProp2::NullCheck); }
bool mayUseSystemStack() const { return properties2().testAny(ILProp2::MayUseSystemStack); }
bool isSupportedForPRE() const { return properties2().testAny(ILProp2::SupportedForPRE); }
bool isLeftRotate() const { return properties2().testAny(ILProp2::LeftRotate); }
bool isRotate() const { return properties2().testAny(ILProp2::LeftRotate); }
bool isUnsignedCompare() const { return properties2().testAny(ILProp2::UnsignedCompare); }
bool isOverflowCompare() const { return properties2().testAny(ILProp2::OverflowCompare); }
bool isSelect() const { return properties2().testAny(ILProp2::Select); }
bool isSelectAdd() const { return properties2().testAny(ILProp2::SelectAdd); }
bool isSelectSub() const { return properties2().testAny(ILProp2::SelectSub); }
bool isArithmetic() const { return isAdd() || isSub() || isMul() || isDiv() || isRem() || isLeftShift() || isRightShift() || isShiftLogical() || isAnd() || isXor() || isOr() || isNeg() || isSelectAdd() || isSelectSub(); }
bool isCondCodeComputation() const { return properties2().testAny(ILProp2::CondCodeComputation); }
bool isJumpWithMultipleTargets() const { return properties2().testAny(ILProp2::JumpWithMultipleTargets); } // Transactional Memory uses this
bool isLoadAddr() const { return properties2().testAny(ILProp2::LoadAddress); }
bool isMax() const { return properties2().testAny(ILProp2::Max); }
bool isMin() const { return properties2().testAny(ILProp2::Min); }
bool isNew() const { return properties2().testAny(ILProp2::New); }
bool isZeroExtension() const { return properties2().testAny(ILProp2::ZeroExtension); }
bool isSignExtension() const { return properties2().testAny(ILProp2::SignExtension); }
/**
* ILProp3
*/
bool isFence() const { return properties3().testAny(ILProp3::Fence); }
bool isExceptionRangeFence() const { return properties3().testAny(ILProp3::ExceptionRangeFence); }
bool isLikeUse() const { return properties3().testAny(ILProp3::LikeUse); }
bool isLikeDef() const { return properties3().testAny(ILProp3::LikeDef); }
bool isSpineCheck() const { return properties3().testAny(ILProp3::SpineCheck); }
bool isArrayLength() const { return properties3().testAny(ILProp3::ArrayLength); }
bool isSignedExponentiation() const { return properties3().testAny(ILProp3::SignedExponentiation); } // denotes the power (not the base) is signed
bool isUnsignedExponentiation() const { return properties3().testAny(ILProp3::UnsignedExponentiation); } // denotes the power (not the base) is unsigned
bool isExponentiation() const { return isSignedExponentiation() || isUnsignedExponentiation(); }
bool isCompareTrueIfLess() const { return properties3().testAny(ILProp3::CompareTrueIfLess); }
bool isCompareTrueIfGreater() const { return properties3().testAny(ILProp3::CompareTrueIfGreater); }
bool isCompareTrueIfEqual() const { return properties3().testAny(ILProp3::CompareTrueIfEqual); }
bool isCompareTrueIfUnordered() const { return properties3().testAny(ILProp3::CompareTrueIfUnordered); }
bool isCompareForEquality() const { return isBooleanCompare() && (isCompareTrueIfLess() == isCompareTrueIfGreater()); }
bool isCompareForOrder() const { return isBooleanCompare() && (isCompareTrueIfLess() != isCompareTrueIfGreater()); }
bool hasBranchChildren() const { return properties3().testAny(ILProp3::HasBranchChild); }
bool skipDynamicLitPoolOnInts() const { return properties3().testAny(ILProp3::SkipDynamicLitPoolOnInts); }
bool isAbs() const { return properties3().testAny(ILProp3::Abs); }
bool isVectorReduction() const { return properties3().testAny(ILProp3::VectorReduction); }
bool isSignum() const { return properties3().testAny(ILProp3::Signum); }
bool isArrayRef() const { return (isAdd() && isCommutative() && isAssociative() && isRef()); } // returns true if TR::aiadd or TR::aladd
bool isTwoChildrenAddress() const { return isArrayRef(); }
bool isCase() const { return getOpCodeValue() == TR::Case; }
bool isAnchor() const { return getOpCodeValue() == TR::compressedRefs; }
bool isOverflowCheck() const { return (getOpCodeValue() == TR::OverflowCHK) ||
(getOpCodeValue() == TR::UnsignedOverflowCHK);
}
bool hasPinningArrayPointer()
{
return (getOpCodeValue() == TR::aiadd) ||
(getOpCodeValue() == TR::aladd);
}
bool isLongCompare() const
{
return (getOpCodeValue() == TR::lcmp) ||
(getOpCodeValue() == TR::lcmpeq) ||
(getOpCodeValue() == TR::lcmpne) ||
(getOpCodeValue() == TR::lcmplt) ||
(getOpCodeValue() == TR::lcmpge) ||
(getOpCodeValue() == TR::lcmpgt) ||
(getOpCodeValue() == TR::lcmple) ||
(getOpCodeValue() == TR::lucmp) ||
(getOpCodeValue() == TR::lucmplt) ||
(getOpCodeValue() == TR::lucmpge) ||
(getOpCodeValue() == TR::lucmpgt) ||
(getOpCodeValue() == TR::lucmple);
}
bool isFunctionCall() const
{
return isCall() &&
getOpCodeValue() != TR::arraycopy &&
getOpCodeValue() != TR::arrayset &&
getOpCodeValue() != TR::bitOpMem &&
getOpCodeValue() != TR::arraycmp;
}
bool isCompareDouble()
{
switch (_opCode)
{
case TR::ifdcmpeq:
case TR::ifdcmpne:
case TR::ifdcmpge:
case TR::ifdcmpgt:
case TR::ifdcmple:
case TR::ifdcmplt:
case TR::ifdcmpequ:
case TR::ifdcmpneu:
case TR::ifdcmpgeu:
case TR::ifdcmpleu:
case TR::ifdcmpgtu:
case TR::ifdcmpltu:
case TR::dcmpeq:
case TR::dcmpne:
case TR::dcmpge:
case TR::dcmpgt:
case TR::dcmple:
case TR::dcmplt:
case TR::dcmpequ:
case TR::dcmpneu:
case TR::dcmpgeu:
case TR::dcmpleu:
case TR::dcmpgtu:
case TR::dcmpltu:
return true;
default:
return false;
}
return false;
}
bool canUseBranchOnCount()
{
return getOpCodeValue() == TR::ificmpgt ||
getOpCodeValue() == TR::iflcmpgt ||
getOpCodeValue() == TR::ifiucmpgt ||
getOpCodeValue() == TR::ifacmpgt ||
getOpCodeValue() == TR::iflucmpgt ||
getOpCodeValue() == TR::iadd ||
getOpCodeValue() == TR::ladd ||
getOpCodeValue() == TR::iuaddc ||
getOpCodeValue() == TR::aiadd ||
getOpCodeValue() == TR::luaddc ||
getOpCodeValue() == TR::aladd ||
getOpCodeValue() == TR::isub ||
getOpCodeValue() == TR::lsub ||
getOpCodeValue() == TR::iusubb ||
getOpCodeValue() == TR::asub ||
getOpCodeValue() == TR::lusubb;
}
bool isStrictWidenConversion()
{
return getOpCodeValue() == TR::f2d ||
getOpCodeValue() == TR::b2i ||
getOpCodeValue() == TR::s2i ||
getOpCodeValue() == TR::b2l ||
getOpCodeValue() == TR::bu2i ||
getOpCodeValue() == TR::bu2l ||
getOpCodeValue() == TR::s2l ||
getOpCodeValue() == TR::su2i ||
getOpCodeValue() == TR::su2l ||
getOpCodeValue() == TR::i2l;
}
bool isMemToMemOp()
{
return getOpCodeValue() == TR::bitOpMem ||
getOpCodeValue() == TR::arrayset ||
getOpCodeValue() == TR::arraycmp ||
getOpCodeValue() == TR::arraycopy;
}
static TR::ILOpCodes getProperConversion(TR::DataType sourceDataType, TR::DataType targetDataType, bool needUnsignedConversion)
{
TR::ILOpCodes op = TR::DataType::getDataTypeConversion(sourceDataType, targetDataType);
if (!needUnsignedConversion) return op;
//FIXME: maybe its better to come up with two conversionMap tables rather
// than having a big switch here
switch (op)
{
case TR::b2s: return TR::bu2s;
case TR::b2i: return TR::bu2i;
case TR::b2l: return TR::bu2l;
case TR::b2a: return TR::bu2a;// do we care about this?
case TR::b2f: return TR::bu2f;
case TR::b2d: return TR::bu2d;
case TR::s2i: return TR::su2i;
case TR::s2l: return TR::su2l;
case TR::s2a: return TR::su2a;
case TR::s2f: return TR::su2f;
case TR::s2d: return TR::su2d;
case TR::i2l: return TR::iu2l;
case TR::i2a: return TR::iu2a;
case TR::i2f: return TR::iu2f;
case TR::i2d: return TR::iu2d;
case TR::l2a: return TR::lu2a;
case TR::l2f: return TR::lu2f;
case TR::l2d: return TR::lu2d;
case TR::f2i: return TR::f2iu;
case TR::f2l: return TR::f2lu;
case TR::f2b: return TR::f2bu;
case TR::f2s: return TR::f2s;
case TR::d2i: return TR::d2iu;
case TR::d2l: return TR::d2lu;
case TR::d2b: return TR::d2bu;
case TR::d2s: return TR::d2s;
default: return op;
}
}
static TR::ILOpCodes convertSignedCmpToUnsignedCmp(TR::ILOpCodes op)
{
switch (op)
{
case TR::icmpeq:
return TR::icmpeq;
case TR::icmpne:
return TR::icmpne;
case TR::icmplt:
return TR::iucmplt;
case TR::icmpge:
return TR::iucmpge;
case TR::icmpgt:
return TR::iucmpgt;
case TR::icmple:
return TR::iucmple;
case TR::ificmpeq:
return TR::ificmpeq;
case TR::ificmpne:
return TR::ificmpne;
case TR::ificmplt:
return TR::ifiucmplt;
case TR::ificmpge:
return TR::ifiucmpge;
case TR::ificmpgt:
return TR::ifiucmpgt;
case TR::ificmple:
return TR::ifiucmple;
case TR::lcmpeq:
return TR::lcmpeq;
case TR::lcmpne:
return TR::lcmpne;
case TR::lcmplt:
return TR::lucmplt;
case TR::lcmpge:
return TR::lucmpge;
case TR::lcmpgt:
return TR::lucmpgt;
case TR::lcmple:
return TR::lucmple;
case TR::iflcmpeq:
return TR::iflcmpeq;
case TR::iflcmpne:
return TR::iflcmpne;
case TR::iflcmplt:
return TR::iflucmplt;
case TR::iflcmpge:
return TR::iflucmpge;
case TR::iflcmpgt:
return TR::iflucmpgt;
case TR::iflcmple:
return TR::iflucmple;
default:
return TR::BadILOp;
}
}
static TR::ILOpCodes compareOpCode(TR::DataType dt, enum TR_ComparisonTypes ct, bool unsignedCompare = false);
static TR_ComparisonTypes getCompareType(TR::ILOpCodes op);
static bool isStrictlyLessThanCmp(TR::ILOpCodes op)
{
switch (op)
{
case TR::ificmplt:
case TR::ifiucmplt:
case TR::iflcmplt:
case TR::iflucmplt:
case TR::ifbcmplt:
case TR::ifscmplt:
case TR::ifsucmplt:
case TR::iffcmplt:
case TR::iffcmpltu:
case TR::ifdcmplt:
case TR::ifdcmpltu:
return true;
default:
return false;
}
}
static bool isStrictlyGreaterThanCmp(TR::ILOpCodes op)
{
switch (op)
{
case TR::ificmpgt:
case TR::ifiucmpgt:
case TR::iflcmpgt:
case TR::iflucmpgt:
case TR::ifbcmpgt:
case TR::ifscmpgt:
case TR::ifsucmpgt:
case TR::iffcmpgt:
case TR::iffcmpgtu:
case TR::ifdcmpgt:
case TR::ifdcmpgtu:
return true;
default:
return false;
}
}
static bool isLessCmp(TR::ILOpCodes op)
{
switch (op)
{
case TR::ificmplt:
case TR::ifiucmplt:
case TR::iflcmplt:
case TR::iflucmplt:
case TR::ifbcmplt:
case TR::ifscmplt:
case TR::ifsucmplt:
case TR::iffcmplt:
case TR::iffcmpltu:
case TR::ifdcmplt:
case TR::ifdcmpltu:
case TR::ificmple:
case TR::ifiucmple:
case TR::iflcmple:
case TR::iflucmple:
case TR::ifbcmple:
case TR::ifscmple:
case TR::ifsucmple:
case TR::iffcmple:
case TR::iffcmpleu:
case TR::ifdcmple:
case TR::ifdcmpleu:
return true;
default:
return false;
}
}
static bool isGreaterCmp(TR::ILOpCodes op)
{
switch (op)
{
case TR::ificmpgt:
case TR::ifiucmpgt:
case TR::iflcmpgt:
case TR::iflucmpgt:
case TR::ifbcmpgt:
case TR::ifscmpgt:
case TR::ifsucmpgt:
case TR::iffcmpgt:
case TR::iffcmpgtu:
case TR::ifdcmpgt:
case TR::ifdcmpgtu:
case TR::ificmpge:
case TR::ifiucmpge:
case TR::iflcmpge:
case TR::iflucmpge:
case TR::ifbcmpge:
case TR::ifscmpge:
case TR::ifsucmpge:
case TR::iffcmpge:
case TR::iffcmpgeu:
case TR::ifdcmpge:
case TR::ifdcmpgeu:
return true;
default:
return false;
}
}
static bool isEqualCmp(TR::ILOpCodes op)
{
switch (op)
{
case TR::ificmpeq:
case TR::iflcmpeq:
case TR::ifacmpeq:
case TR::ifbcmpeq:
case TR::ifscmpeq:
case TR::iffcmpeq:
case TR::ifdcmpeq:
return true;
default:
return false;
}
}
static bool isNotEqualCmp(TR::ILOpCodes op)
{
switch (op)
{
case TR::ificmpne:
case TR::iflcmpne:
case TR::ifacmpne:
case TR::ifbcmpne:
case TR::ifscmpne:
case TR::iffcmpne:
case TR::ifdcmpne:
return true;
default:
return false;
}
}
static TR::ILOpCodes indirectLoadOpCode(TR::DataType type)
{
switch(type)
{
case TR::Int8: return TR::bloadi;
case TR::Int16: return TR::sloadi;
case TR::Int32: return TR::iloadi;
case TR::Int64: return TR::lloadi;
case TR::Address: return TR::aloadi;
case TR::Float: return TR::floadi;
case TR::Double: return TR::dloadi;
default: TR_ASSERT(0, "no load opcode for this datatype");
}
return TR::BadILOp;
}
static TR::ILOpCodes absOpCode(TR::DataType type)
{
switch(type)
{
case TR::Int32: return TR::iabs;
case TR::Int64: return TR::labs;
case TR::Float: return TR::fabs;
case TR::Double: return TR::dabs;
default: TR_ASSERT(false, "no abs opcode for this datatype %s",type.toString());
}
return TR::BadILOp;
}
static TR::ILOpCodes addOpCode(TR::DataType type, bool is64Bit)
{
switch(type)
{
case TR::Int8: return TR::badd;
case TR::Int16: return TR::sadd;
case TR::Int32: return TR::iadd;
case TR::Int64: return TR::ladd;
case TR::Address: return (is64Bit) ? TR::aladd : TR::aiadd;
case TR::Float: return TR::fadd;
case TR::Double: return TR::dadd;
case TR::VectorInt8: return TR::vadd;
case TR::VectorInt16: return TR::vadd;
case TR::VectorInt32: return TR::vadd;
case TR::VectorInt64: return TR::vadd;
case TR::VectorFloat: return TR::vadd;
case TR::VectorDouble: return TR::vadd;
default: TR_ASSERT(0, "no add opcode for this datatype");
}
return TR::BadILOp;
}
static TR::ILOpCodes unsignedAddOpCode(TR::DataType type, bool is64Bit)
{
switch(type)
{
case TR::Int8: return TR::badd;
case TR::Int16: return TR::sadd;
case TR::Int32: return TR::iadd;
case TR::Int64: return TR::ladd;
case TR::Address: return (is64Bit) ? TR::aladd : TR::aiadd;
default: TR_ASSERT(0, "no add opcode for this datatype");
}
return TR::BadILOp;
}
static TR::ILOpCodes subtractOpCode(TR::DataType type)
{
switch(type)
{
case TR::Int8: return TR::bsub;
case TR::Int16: return TR::ssub;
case TR::Int32: return TR::isub;
case TR::Int64: return TR::lsub;
case TR::Float: return TR::fsub;
case TR::Double: return TR::dsub;
case TR::VectorInt8: return TR::vsub;
case TR::VectorInt16: return TR::vsub;
case TR::VectorInt32: return TR::vsub;
case TR::VectorInt64: return TR::vsub;
case TR::VectorFloat: return TR::vsub;
case TR::VectorDouble: return TR::vsub;
default: TR_ASSERT(0, "no sub opcode for this datatype");
}
return TR::BadILOp;
}
static TR::ILOpCodes unsignedSubtractOpCode(TR::DataType type)
{
switch(type)
{
default: TR_ASSERT(0, "no unsigned sub opcode for this datatype");
}
TR_ASSERT_FATAL(0, "all unsigned subtract opcode has been deprecated. (eclipse/omr#2657)");
return TR::BadILOp;
}
static TR::ILOpCodes multiplyOpCode(TR::DataType type)
{
switch(type)
{
case TR::Int8: return TR::bmul;
case TR::Int16: return TR::smul;
case TR::Int32: return TR::imul;
case TR::Int64: return TR::lmul;
case TR::Float: return TR::fmul;
case TR::Double: return TR::dmul;
case TR::VectorInt8: return TR::vmul;
case TR::VectorInt16: return TR::vmul;
case TR::VectorInt32: return TR::vmul;
case TR::VectorInt64: return TR::vmul;
case TR::VectorFloat: return TR::vmul;
case TR::VectorDouble: return TR::vmul;
default: TR_ASSERT(0, "no mul opcode for this datatype");
}
return TR::BadILOp;
}
static TR::ILOpCodes divideOpCode(TR::DataType type)
{
switch(type)
{
case TR::Int8: return TR::bdiv;
case TR::Int16: return TR::sdiv;
case TR::Int32: return TR::idiv;
case TR::Int64: return TR::ldiv;
case TR::Float: return TR::fdiv;
case TR::Double: return TR::ddiv;
case TR::VectorInt8: return TR::vdiv;
case TR::VectorInt16: return TR::vdiv;
case TR::VectorInt32: return TR::vdiv;
case TR::VectorInt64: return TR::vdiv;
case TR::VectorFloat: return TR::vdiv;
case TR::VectorDouble: return TR::vdiv;
default: TR_ASSERT(0, "no div opcode for this datatype");
}
return TR::BadILOp;
}
static TR::ILOpCodes unsignedDivideOpCode(TR::DataType type)
{
switch (type)
{
case TR::Int32: return TR::iudiv;
case TR::Int64: return TR::ludiv;
default: TR_ASSERT(0, "no unsigned div opcode for this datatype");
}
return TR::BadILOp;
}
static TR::ILOpCodes remainderOpCode(TR::DataType type)
{
switch(type)
{
case TR::Int8: return TR::brem;
case TR::Int16: return TR::srem;
case TR::Int32: return TR::irem;
case TR::Int64: return TR::lrem;
case TR::Float: return TR::frem;
case TR::Double: return TR::drem;
default: TR_ASSERT(0, "no div opcode for this datatype");
}
return TR::BadILOp;
}
static TR::ILOpCodes andOpCode(TR::DataType type)
{
switch(type)
{
case TR::Int8: return TR::band;
case TR::Int16: return TR::sand;
case TR::Int32: return TR::iand;
case TR::Int64: return TR::land;
default: TR_ASSERT(false, "no and opcode for datatype %s",type.toString());
}
return TR::BadILOp;
}
static TR::ILOpCodes orOpCode(TR::DataType type)
{
switch(type)
{
case TR::Int8: return TR::bor;
case TR::Int16: return TR::sor;
case TR::Int32: return TR::ior;
case TR::Int64: return TR::lor;
default: TR_ASSERT(false, "no or opcode for datatype %s",type.toString());
}
return TR::BadILOp;
}
static TR::ILOpCodes xorOpCode(TR::DataType type)
{
switch(type)
{
case TR::Int8: return TR::bxor;
case TR::Int16: return TR::sxor;
case TR::Int32: return TR::ixor;
case TR::Int64: return TR::lxor;
default: TR_ASSERT(false, "no xor opcode for datatype %s",type.toString());
}
return TR::BadILOp;
}
static TR::ILOpCodes shiftLeftOpCode(TR::DataType type)
{
switch(type)
{
case TR::Int8: return TR::bshl;
case TR::Int16: return TR::sshl;
case TR::Int32: return TR::ishl;
case TR::Int64: return TR::lshl;
default: TR_ASSERT(false, "no shl opcode for datatype %s",type.toString());
}
return TR::BadILOp;
}
static TR::ILOpCodes shiftRightOpCode(TR::DataType type)
{
switch(type)
{
case TR::Int8: return TR::bshr;
case TR::Int16: return TR::sshr;
case TR::Int32: return TR::ishr;
case TR::Int64: return TR::lshr;
default: TR_ASSERT(false, "no shr opcode for datatype %s",type.toString());
}
return TR::BadILOp;
}
static TR::ILOpCodes unsignedShiftRightOpCode(TR::DataType type)
{
switch(type)
{
case TR::Int32: return TR::iushr;
case TR::Int64: return TR::lushr;
default: TR_ASSERT(false, "no ushr opcode for datatype %s",type.toString());
}
return TR::BadILOp;
}
static TR::ILOpCodes negateOpCode(TR::DataType type)
{
switch(type)
{
case TR::Int8: return TR::bneg;
case TR::Int16: return TR::sneg;
case TR::Int32: return TR::ineg;
case TR::Int64: return TR::lneg;
case TR::Float: return TR::fneg;
case TR::Double: return TR::dneg;
default: TR_ASSERT(0, "no negate opcode for this datatype");
}
return TR::BadILOp;
}
static TR::ILOpCodes integerOpForLongOp(TR::ILOpCodes longOp)
{
switch (longOp)
{
case TR::ladd: return TR::iadd;
case TR::lsub: return TR::isub;
case TR::lmul: return TR::imul;
case TR::ldiv: return TR::idiv;
case TR::lrem: return TR::irem;
case TR::labs: return TR::iabs;
case TR::lneg: return TR::ineg;
case TR::lshr: return TR::ishr;
case TR::lushr: return TR::iushr;
case TR::lshl: return TR::ishl;
default: TR_ASSERT(0,"unexpected long arithmetic op\n");
}
return TR::BadILOp;
}
static bool isOpCodeAnImplicitNoOp(ILOpCode &opCode)
{
if (opCode.isConversion())
{
TR::ILOpCodes opCodeValue = opCode.getOpCodeValue();
switch (opCodeValue)
{
case TR::i2l:
case TR::i2f:
case TR::i2d:
case TR::l2f:
case TR::l2d:
case TR::f2i:
case TR::f2l:
case TR::f2b:
case TR::f2s:
case TR::f2c:
case TR::d2i:
case TR::d2l:
case TR::d2b:
case TR::d2s:
case TR::d2c:
case TR::b2l:
case TR::b2f:
case TR::b2d:
case TR::s2l:
case TR::s2f:
case TR::s2d:
case TR::su2l:
case TR::su2f:
case TR::su2d:
return false;
default:
{
return true;
}
}
}
return false;
}
static TR::ILOpCodes ifcmpgeOpCode(TR::DataType type, bool isUnsigned)
{
switch(type)
{
case TR::Int8: return isUnsigned ? TR::ifbucmpge : TR::ifbcmpge;
case TR::Int16: return isUnsigned ? TR::ifsucmpge : TR::ifscmpge;
case TR::Int32: return isUnsigned ? TR::ifiucmpge : TR::ificmpge;
case TR::Int64: return isUnsigned ? TR::iflucmpge : TR::iflcmpge;
case TR::Address: return TR::ifacmpge;
case TR::Float: return TR::iffcmpge;
case TR::Double: return TR::ifdcmpge;
default: TR_ASSERT(0, "no ifcmpge opcode for this datatype");
}
return TR::BadILOp;
}
static TR::ILOpCodes ifcmpleOpCode(TR::DataType type, bool isUnsigned)
{
switch(type)
{
case TR::Int8: return isUnsigned ? TR::ifbucmple : TR::ifbcmple;
case TR::Int16: return isUnsigned ? TR::ifsucmple : TR::ifscmple;
case TR::Int32: return isUnsigned ? TR::ifiucmple : TR::ificmple;
case TR::Int64: return isUnsigned ? TR::iflucmple : TR::iflcmple;
case TR::Address: return TR::ifacmple;
case TR::Float: return TR::iffcmple;
case TR::Double: return TR::ifdcmple;
default: TR_ASSERT(0, "no ifcmple opcode for this datatype");
}
return TR::BadILOp;
}
static TR::ILOpCodes ifcmpgtOpCode(TR::DataType type, bool isUnsigned)
{
switch(type)
{
case TR::Int8: return isUnsigned ? TR::ifbucmpgt : TR::ifbcmpgt;
case TR::Int16: return isUnsigned ? TR::ifsucmpgt : TR::ifscmpgt;