Shares of Taiwan Semiconductor (NYSE:TSM), the world's leading semiconductor contract manufacturer, have been on a veritable tear over the last several months and are currently trading just shy of 52-week and all-time highs. While the stock has made a big move, here's why the shares could have further potential upside in this rather frothy market.

A fundamental shift in semiconductors -- technological barriers
While many believe that manufacturing semiconductors is simply a matter of having the deep pockets to afford to build the factories themselves, this couldn't be further from the truth. There is a very large amount of research and development that goes into developing the manufacturing process -- which is like a "recipe" -- to build these chips. Only a few companies can afford to consistently spend the kind of money that it takes to stay on the leading edge (it's currently about $1.5 billion-$2 billion to do so).

As a result, it seems that the general purpose foundry industry has consolidated to Taiwan Semiconductor, Samsung (NASDAQOTH:SSNLF) and -- to the extent to which it can license the manufacturing recipes from others -- GlobalFoundries. TSMC commands the lion's share of the revenue, turning in over $20 billion in sales last year and on track to do about $23.5 billion this year (per sell-side consensus) -- far in excess of the roughly $4 billion each that Samsung and GlobalFoundries did last year.

With only a few players remaining on the leading edge, and with Taiwan Semiconductor out in front among the general purpose foundries, it will likely command pretty significant pricing power, driving increased revenue and gross margin dollars per wafer as customers find themselves with very few options.

TSMC has a de facto monopoly at 20-nanometer
Next year should be rather good for TSMC. Later this year, the upcoming Apple iPhone 6 is rumored to use a chip built on TSMC's 20-nanometer manufacturing process -- taking that business away from rival Samsung (note that most of Samsung's foundry revenues are from Apple).

While Samsung has been trying its hardest to grab new clients in order to support its foundry business, it remains to be seen just how many fabless semiconductor companies wish to build their chips at a company that also plans to compete with them. If Samsung fails to grab high volume foundry customers (think Qualcomm and MediaTek) to support its leading-edge business, then even it may not be willing to continue to invest in this market long-term.

At any rate, at 20-nanometer it looks like TSMC has a de facto monopoly as it has likely won Apple's A8 chip as well as Qualcomm's next generation modem/apps processor business throughout 2015.

Foolish bottom line
Taiwan Semiconductor captured the lion's share of the 28-nanometer foundry business and it looks like its share at 20-nanometer will be even higher if it has indeed scored Apple. While Samsung is taking a rather large game about its 14-nanometer plans, it is important to be careful in using its claims to assume that TSMC will lose significant share at that generation, particularly as it is in Samsung's best interests to appear to the rest of the fabless players that it will be ahead of TSMC.

Next year should be very good for TSMC, and the current run-up is likely due to the fact that the company will not only have leadership at 20-nanometer, but it will probably have a very good cost structure on the now-mature prior generation 28-nanometer technology (which will serve as the technology of choice for most high volume mobile parts).