Created
September 22, 2010 12:13
-
-
Save christianparpart/591569 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
llvm::Value *Runner::emitToLower(llvm::Value *value) | |
{ | |
#if 1 == 0 // {{{ C equivalent | |
return value >= 'A' && value <= 'Z' | |
? value + 32 | |
: value; | |
#endif // }}} | |
// IR: | |
// %off = add %ch, -65 | |
// %lwr = add %ch, 32 | |
// %cnd = icmp ult %off, 26 | |
// %result = select %cnd, %off, %lwr | |
llvm::Value *offset = builder_.CreateAdd(value, llvm::ConstantInt::get(value->getType(), -65)); | |
llvm::Value *lwr = builder_.CreateAdd(value, llvm::ConstantInt::get(value->getType(), 32)); | |
llvm::Value *cnd = builder_.CreateICmpULT(offset, llvm::ConstantInt::get(value->getType(), 26)); | |
llvm::Value *result = builder_.CreateSelect(cnd, offset, lwr); | |
return result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment