Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Side by Side Diff: src/IceTargetLoweringARM32.cpp

Issue 1213593002: Implement ARM32 switch lowering. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Add TODOs for jvoung suggested in review Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceTargetLoweringARM32.h ('k') | tests_lit/llvm2ice_tests/switch-opt.ll » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceTargetLoweringARM32.cpp - ARM32 lowering ------------===// 1 //===- subzero/src/IceTargetLoweringARM32.cpp - ARM32 lowering ------------===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This file implements the TargetLoweringARM32 class, which consists almost 10 // This file implements the TargetLoweringARM32 class, which consists almost
(...skipping 1907 matching lines...) Expand 10 before | Expand all | Expand 10 after
1918 Variable *ValueR = legalizeToVar(Value); 1918 Variable *ValueR = legalizeToVar(Value);
1919 _str(ValueR, NewAddr); 1919 _str(ValueR, NewAddr);
1920 } 1920 }
1921 } 1921 }
1922 1922
1923 void TargetARM32::doAddressOptStore() { 1923 void TargetARM32::doAddressOptStore() {
1924 UnimplementedError(Func->getContext()->getFlags()); 1924 UnimplementedError(Func->getContext()->getFlags());
1925 } 1925 }
1926 1926
1927 void TargetARM32::lowerSwitch(const InstSwitch *Inst) { 1927 void TargetARM32::lowerSwitch(const InstSwitch *Inst) {
1928 (void)Inst; 1928 // This implements the most naive possible lowering.
1929 UnimplementedError(Func->getContext()->getFlags()); 1929 // cmp a,val[0]; jeq label[0]; cmp a,val[1]; jeq label[1]; ... jmp default
1930 Operand *Src0 = Inst->getComparison();
1931 SizeT NumCases = Inst->getNumCases();
1932 if (Src0->getType() == IceType_i64) {
1933 // TODO(jvoung): handle and test undef for Src0
1934 Variable *Src0Lo = legalizeToVar(loOperand(Src0));
1935 Variable *Src0Hi = legalizeToVar(hiOperand(Src0));
1936 for (SizeT I = 0; I < NumCases; ++I) {
1937 Operand *ValueLo = Ctx->getConstantInt32(Inst->getValue(I));
1938 Operand *ValueHi = Ctx->getConstantInt32(Inst->getValue(I) >> 32);
1939 ValueLo = legalize(ValueLo, Legal_Reg | Legal_Flex);
1940 ValueHi = legalize(ValueHi, Legal_Reg | Legal_Flex);
1941 _cmp(Src0Lo, ValueLo);
1942 _cmp(Src0Hi, ValueHi, CondARM32::EQ);
1943 _br(Inst->getLabel(I), CondARM32::EQ);
1944 }
1945 _br(Inst->getLabelDefault());
1946 return;
1947 }
1948
1949 // 32 bit integer
1950 Variable *Src0Var = legalizeToVar(Src0);
1951 for (SizeT I = 0; I < NumCases; ++I) {
1952 Operand *Value = Ctx->getConstantInt32(Inst->getValue(I));
1953 Value = legalize(Value, Legal_Reg | Legal_Flex);
1954 _cmp(Src0Var, Value);
1955 _br(Inst->getLabel(I), CondARM32::EQ);
1956 }
1957 _br(Inst->getLabelDefault());
1930 } 1958 }
1931 1959
1932 void TargetARM32::lowerUnreachable(const InstUnreachable * /*Inst*/) { 1960 void TargetARM32::lowerUnreachable(const InstUnreachable * /*Inst*/) {
1933 UnimplementedError(Func->getContext()->getFlags()); 1961 UnimplementedError(Func->getContext()->getFlags());
1934 } 1962 }
1935 1963
1936 // Turn an i64 Phi instruction into a pair of i32 Phi instructions, to 1964 // Turn an i64 Phi instruction into a pair of i32 Phi instructions, to
1937 // preserve integrity of liveness analysis. Undef values are also 1965 // preserve integrity of liveness analysis. Undef values are also
1938 // turned into zeroes, since loOperand() and hiOperand() don't expect 1966 // turned into zeroes, since loOperand() and hiOperand() don't expect
1939 // Undef input. 1967 // Undef input.
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
2266 << ".eabi_attribute 36, 1 @ Tag_FP_HP_extension\n" 2294 << ".eabi_attribute 36, 1 @ Tag_FP_HP_extension\n"
2267 << ".eabi_attribute 38, 1 @ Tag_ABI_FP_16bit_format\n" 2295 << ".eabi_attribute 38, 1 @ Tag_ABI_FP_16bit_format\n"
2268 << ".eabi_attribute 42, 1 @ Tag_MPextension_use\n" 2296 << ".eabi_attribute 42, 1 @ Tag_MPextension_use\n"
2269 << ".eabi_attribute 68, 1 @ Tag_Virtualization_use\n"; 2297 << ".eabi_attribute 68, 1 @ Tag_Virtualization_use\n";
2270 // Technically R9 is used for TLS with Sandboxing, and we reserve it. 2298 // Technically R9 is used for TLS with Sandboxing, and we reserve it.
2271 // However, for compatibility with current NaCl LLVM, don't claim that. 2299 // However, for compatibility with current NaCl LLVM, don't claim that.
2272 Str << ".eabi_attribute 14, 3 @ Tag_ABI_PCS_R9_use: Not used\n"; 2300 Str << ".eabi_attribute 14, 3 @ Tag_ABI_PCS_R9_use: Not used\n";
2273 } 2301 }
2274 2302
2275 } // end of namespace Ice 2303 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceTargetLoweringARM32.h ('k') | tests_lit/llvm2ice_tests/switch-opt.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698